# No. 478 (Brown 1868): "Another steam trap (Ray’s patent). Valve, a, closes and opens by longitudinal expansion and contraction of waste-pipe, A, which terminates in the middle of an attached hollow sphere, C. A portion of the pipe is firmly secured to a fixed support, B. Valve consists of a plunger which works in a stuffing-box in the sphere, opposite the end of the pipe, and it is pressed toward the end of the pipe by a loaded elbow lever, D, as far as permitted by a stop-screw, b, and stop, c. When pipe is filled with water, its length is so reduced that valve remains open; but when filled with steam, it is expanded so that valve closes it. Screw, b, serves to adjust the action of valve."
# Model (cm, gravity on, seen from in front, C cut away in half section). The drive is the steam: a cock on the coil's end (left), swung open
# and shut by hand (+-0.8 rad at 1/8 Hz, the only drive). Open, steam fills the pipe A and its heat goes into the pipe, up to 800 W; shut,
# the condensed water stands in it and it cools. The pipe's temperature is the lumped heat store of its bore (openspec add-vessel-heat:
# C dT/dt = Q - H (T - 293 K), C 8 J/K, H 10 W/K), and the pipe grows with it (heat-to-length, the same change): from the clamp at B to
# its end in the middle of C it is 30 cm of brass (alpha 1.9e-05 /K), so it grows 0.46 mm at 80 K over the room, pushing its end
# (a slide) like a spring of 100000 N/m toward that length. The plunger a is on the elbow lever D, whose ball (80 g) presses it toward
# the pipe's end as far as the stop-screw b on c lets it (0.3 mm from the cold pipe's end). Cold, water runs from the pipe's end into C
# and out below; hot, the pipe's end meets the plunger (a contact) and shuts it, pushing the lever back off its stop a little.
# The water is lumped vessels: the coil's end a source at 2 kPa, the pipe's bore a chamber, the valve's opening a table on the pipe's end
# (the gap to the plunger, which stands on its stop until the pipe's end meets it), C an open chamber, the outlet a drain.
# Generator: opencode-runs/heat/gen478.py.
number: 478
slug: another-steam-trap
name: Another steam trap (Ray’s patent)
brown: "Another steam trap (Ray’s patent). Valve, a, closes and opens by longitudinal expansion and contraction of waste-pipe, A, which terminates in the middle of an attached hollow sphere, C. A portion of the pipe is firmly secured to a fixed support, B. Valve consists of a plunger which works in a stuffing-box in the sphere, opposite the end of the pipe, and it is pressed toward the end of the pipe by a loaded elbow lever, D, as far as permitted by a stop-screw, b, and stop, c. When pipe is filled with water, its length is so reduced that valve remains open; but when filled with steam, it is expanded so that valve closes it. Screw, b, serves to adjust the action of valve."
units: cm
sim:
  timestep: 0.0005
  integrator: implicitfast
  iterations: 60
  duration_s: 16
  floor: false
bodies:
  - id: cock
    shape: part
    pos: [-37, 0, 8]
    mass: 0.2
    color: "#a8884a"
    pieces:
      - {kind: rod, from: [-37, -1, 8], to: [-37, 0, 8], radius: 1.05, collide: 0}
      - {kind: rod, from: [-37, -1.2, 8], to: [-43, -1.2, 11], radius: 0.35, collide: 0}
  - id: pipe
    shape: part
    pos: [0, 0, 8]
    mass: 0.3
    color: "#8a7a62"
    pieces:
      - {kind: rod, from: [-40, 0, 8], to: [0, 0, 8], radius: 0.8, collide: 0}   # the waste-pipe A, from the coil to the middle of C
      - {kind: poly, points: [[-0.12, 7.2], [0, 7.2], [0, 8.8], [-0.12, 8.8]], y: [-0.8, 0.8], collide: 1, color: "#7a6e5c"}   # its end (the valve's seat)
  - id: lever
    shape: part
    pos: [10.5, 0, 13.5]
    density: 1500
    color: "#7d7466"
    pieces:
      - {kind: rod, from: [0.03, 0, 8], to: [9, 0, 8], radius: 0.6, collide: 0, color: "#8f8a80"}   # the plunger a, through the stuffing-box
      - {kind: poly, points: [[0.03, 7.4], [0.15, 7.4], [0.15, 8.6], [0.03, 8.6]], y: [-0.6, 0.6], collide: 2, color: "#8f8a80"}   # its face
      - {kind: rod, from: [9, 0, 8], to: [10.5, 0, 13.5], radius: 0.45, collide: 0}   # the elbow lever D: its short arm down to the plunger
      - {kind: rod, from: [9, 0, 8], to: [10.7, 0, 4.2], radius: 0.4, collide: 0}   # its tail down to the stop
      - {kind: rod, from: [10.5, 0, 13.5], to: [16.5, 0, 14.5], radius: 0.4, collide: 0}   # its long arm
      - {kind: disc, center: [18.3, 14.8], radius: 2.2, inner: 0, y: [-1.2, 1.2], collide: 0, color: "#4f4a42"}   # the load (a ball)
      - {kind: rod, from: [10.5, -0.8, 13.5], to: [10.5, 0.8, 13.5], radius: 0.5, collide: 0, color: "#4f4a42"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#c9bfa9"
    pieces:
      - {kind: poly, points: [[-36, -1.2], [16, -1.2], [16, 0], [-30, 0]], y: [-3, 3], collide: 0, color: "#6d6252"}   # the bed
      - {kind: poly, points: [[-32, 0], [-28, 0], [-28, 7.2], [-32, 7.2]], y: [-1.5, 1.5], collide: 0, color: "#8b7d66"}   # the fixed support B
      - {kind: poly, points: [[-32, 8.8], [-28, 8.8], [-28, 9.6], [-32, 9.6]], y: [-1.5, 1.5], collide: 0, color: "#8b7d66"}   # its cap, clamping A
      - {kind: disc, center: [0, 8], radius: 4.8, inner: 4, y: [0, 3], collide: 0, color: "#9c8f78"}   # the hollow sphere C (cut away in half section)
      - {kind: poly, points: [[-1.2, -6], [1.2, -6], [1.2, 4.2], [-1.2, 4.2]], y: [0, 1.6], collide: 0, color: "#9c8f78"}   # its outlet down through the bed (cut away)
      - {kind: poly, points: [[-1.8, 3.2], [1.8, 3.2], [1.8, 0], [-1.8, 0]], y: [0, 2.2], collide: 0, color: "#9c8f78"}   # its foot
      - {kind: poly, points: [[-6.4, 6.6], [-3.8, 6.6], [-3.8, 9.4], [-6.4, 9.4]], y: [0, 1.6], collide: 0, color: "#7a6f5e"}   # the gland where A enters C
      - {kind: poly, points: [[3.8, 6.6], [6.6, 6.6], [6.6, 9.4], [3.8, 9.4]], y: [0, 1.6], collide: 0, color: "#7a6f5e"}   # the stuffing-box of the plunger
      - {kind: poly, points: [[9.9, 0], [11.1, 0], [11.1, 13.5], [9.9, 13.5]], y: [1, 1.8], collide: 0, color: "#8b7d66"}   # the lever's standard (behind)
      - {kind: poly, points: [[11.5, 0], [12.3, 0], [12.3, 4.6], [11.5, 4.6]], y: [-1, 1], collide: 0, color: "#8b7d66"}   # the stop c
      - {kind: rod, from: [11.5, 0, 4.2], to: [14.1, 0, 4.2], radius: 0.3, collide: 0, color: "#5d554a"}   # the stop-screw b in it
      - {kind: rod, from: [14.1, 0, 4.2], to: [14.7, 0, 4.2], radius: 0.55, collide: 0, color: "#5d554a"}
joints:
  - {id: j_k, type: hinge, body: cock, axis: [0, 1, 0], damping: 0.01}   # the steam cock (the drive): open from 0 to +0.3 rad and over
  - {id: j_e, type: slide, body: pipe, axis: [1, 0, 0], range: [-0.05, 0.12], damping: 200}   # the pipe's end (it grows + toward the plunger)
  - {id: j_d, type: hinge, body: lever, axis: [0, 1, 0], range: [-0.05, 0], damping: 0.02}   # the lever D: at 0 on its stop (b on c); - as the pipe pushes the plunger back
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0001], margin: 0}
vessels:
  substeps: 8
  nodes:
    - {id: coil, kind: source, p: 2000}   # the coil's end: its steam and water of condensation
    - {id: bore, kind: chamber, fixed: 7.5, sections: [[7.5, 40]], volume: 40, water: 28,
       heat: {C: 8, H: 10, T: 293, joint: j_k, q: [0.0, 0.3], Q: [0, 800]},
       draw: {sections: [[[-40, 7.5], [-0.5, 7.5], [-0.5, 8.5], [-40, 8.5]]], y: [-0.9, -0.82]}}   # the pipe's bore (cut away in front), and the pipe's temperature
    - {id: C, kind: chamber, open: true, fixed: 4, sections: [[4, 6], [5, 22], [6, 37.7], [7, 47]], volume: 134.04, water: 0,
       draw: {sections: [[[-4, 8], [-3.46, 6], [-2, 4.54], [0, 4], [2, 4.54], [3.46, 6], [4, 8]]], y: [0, 4]}}
    - {id: out, kind: source, p: 0}
  links:
    - {id: feed, from: coil, to: bore, area: 1.0, cd: 0.62, z: 8}
    - {id: valve, from: bore, to: C, area: 0.0942, cd: 0.62, z: 7.5, open: {joint: j_e, q: [0, 0.03], frac: [1, 0]},
       draw: {from: [0, 0.7, 7.7], to: [0.25, 0.7, 7.3], width: 0.5, flow: 0.015, fall: {dir: [0.15, 0, -1], floor: 4.3}}}   # the water past the valve a (the gap between the pipe's end and the plunger)
    - {id: drain, from: C, to: out, area: 0.3, cd: 0.62, z: 4,
       draw: {from: [0, 0.8, 4], to: [0, 0.8, -6], width: 0.6, flow: 0.015}}   # out below
  rods:
    - {id: A, node: bore, joint: j_e, length: 30, alpha: 1.9e-05, stiffness: 100000}   # the pipe grows with its temperature (heat-to-length)
driver: {joint: j_k, kind: velocity, rpm: 0, swing: {amplitude: 0.8, hz: 0.125}, kv: 5, max_torque: 2}
checks:
  - {type: amplitude, joint: j_k, min: 0.6, max: 1.0, settle_s: 0.5, window_s: 15}
camera: {target: [-8, 0, 4], position: [-8, -230, 8], fov: 20}
display:
  output: j_e
  labels: {j_k: "Steam cock (driver)", j_e: "Pipe A's end", j_d: "Lever D"}
