# No. 470 (Brown 1868): "Steam hammer. Cylinder fixed above and hammer attached to lower end of piston-rod. Steam being alternately
# admitted below piston and allowed to escape, raises and lets fall the hammer."
# Model (cm, gravity on, the cylinder and valve chest cut away in half section, seen from in front). The cylinder (8 cm bore) is
# fixed on two standards over the anvil; the hammer (tup, piston rod and piston, 8 kg) slides in guides and rests on the work.
# The hammer-man's hand lever is the only drive (swung +-0.28 rad at 0.7 Hz); its rod works the slide valve in the chest
# beside the cylinder up and down: raised, it admits steam from the boiler (30 kPa gauge) under the piston; lowered, it lets that steam
# escape to the air. The space under the piston is a lumped gas vessel (src/fluid/vessels.c, isothermal steam) that the piston sweeps
# (50.2655 cm^2): its pressure lifts the hammer, and once the steam escapes the hammer falls by its weight on the work. The space over
# the piston is open to the air by vents in the top cover. The steam is drawn under the piston (src/fluid/vdraw.ts), shaded by
# its pressure. Generator: opencode-runs/water/gen470.py.
number: 470
slug: steam-hammer
name: Steam hammer
brown: "Steam hammer. Cylinder fixed above and hammer attached to lower end of piston-rod. Steam being alternately admitted below piston and allowed to escape, raises and lets fall the hammer."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 60
  duration_s: 14
  floor: false
bodies:
  - id: hammer
    shape: part
    pos: [0, 0, 17.52]
    mass: 8
    color: "#4f4a43"
    pieces:
      - {kind: loft, a: [[-5, -3.5, 22.02], [5, -3.5, 22.02], [5, 3.5, 22.02], [-5, 3.5, 22.02]], b: [[-5, -3.5, 13.02], [5, -3.5, 13.02], [5, 3.5, 13.02], [-5, 3.5, 13.02]], collide: 1, color: "#4f4a43"}
      - {kind: rod, from: [0, 0, 22.02], to: [0, 0, 48], radius: 0.75, collide: 0}
      - {kind: loft, a: [[3.95, 0, 49], [3.6493, 1.5116, 49], [2.7931, 2.7931, 49], [1.5116, 3.6493, 49], [0, 3.95, 49], [-1.5116, 3.6493, 49], [-2.7931, 2.7931, 49], [-3.6493, 1.5116, 49], [-3.95, 0, 49], [-3.6493, -1.5116, 49], [-2.7931, -2.7931, 49], [-1.5116, -3.6493, 49], [-0, -3.95, 49], [1.5116, -3.6493, 49], [2.7931, -2.7931, 49], [3.6493, -1.5116, 49]], b: [[3.95, 0, 47], [3.6493, 1.5116, 47], [2.7931, 2.7931, 47], [1.5116, 3.6493, 47], [0, 3.95, 47], [-1.5116, 3.6493, 47], [-2.7931, 2.7931, 47], [-3.6493, 1.5116, 47], [-3.95, 0, 47], [-3.6493, -1.5116, 47], [-2.7931, -2.7931, 47], [-1.5116, -3.6493, 47], [-0, -3.95, 47], [1.5116, -3.6493, 47], [2.7931, -2.7931, 47], [3.6493, -1.5116, 47]], collide: 0, color: "#8a8478"}
  - id: valve
    shape: part
    pos: [7, 0, 48]
    mass: 0.01
    color: "#c8781e"
    pieces:
      - {kind: loft, a: [[5.8, 0.1, 49], [8.2, 0.1, 49], [8.2, 2.3, 49], [5.8, 2.3, 49]], b: [[5.8, 0.1, 46.4], [8.2, 0.1, 46.4], [8.2, 2.3, 46.4], [5.8, 2.3, 46.4]], collide: 0, color: "#c8781e"}
      - {kind: rod, from: [7, 0, 49], to: [7, 0, 57], radius: 0.3, collide: 0}
  - id: vrod
    shape: part
    mount: valve
    pos: [7, 0, 57]
    mass: 0.005
    color: "#6d675c"
    pieces:
      - {kind: rod, from: [7, 0, 57], to: [7, 0, 59], radius: 0.25, collide: 0}
      - {kind: rod, from: [7, -0.5, 59], to: [7, 0.5, 59], radius: 0.35, collide: 0}
  - id: lever
    shape: part
    pos: [9.9, 0, 59]
    mass: 0.2
    color: "#5f5a52"
    pieces:
      - {kind: rod, from: [6, 0, 59], to: [29.9, 0, 59], radius: 0.4, capsule: true, collide: 0}
      - {kind: rod, from: [9.9, -0.6, 59], to: [9.9, 0.6, 59], radius: 0.5, collide: 0}
      - {kind: rod, from: [29.9, -0.6, 59], to: [29.9, 0.6, 59], radius: 0.8, capsule: true, collide: 0}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#d6cdb8"
    pieces:
      - {kind: loft, a: [[-30, -6, 0], [30, -6, 0], [30, 10, 0], [-30, 10, 0]], b: [[-30, -6, -1.5], [30, -6, -1.5], [30, 10, -1.5], [-30, 10, -1.5]], collide: 0, color: "#8b7d66"}
      - {kind: loft, a: [[-9, -5, 3], [9, -5, 3], [9, 5, 3], [-9, 5, 3]], b: [[-9, -5, 0], [9, -5, 0], [9, 5, 0], [-9, 5, 0]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[-6.5, -4, 10], [6.5, -4, 10], [6.5, 4, 10], [-6.5, 4, 10]], b: [[-6.5, -4, 3], [6.5, -4, 3], [6.5, 4, 3], [-6.5, 4, 3]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[-7, -2.5, 13], [7, -2.5, 13], [7, 2.5, 13], [-7, 2.5, 13]], b: [[-7, -2.5, 10], [7, -2.5, 10], [7, 2.5, 10], [-7, 2.5, 10]], collide: 2, color: "#c0582c"}
      - {kind: loft, a: [[-15.5, -2, 43.5], [-12.5, -2, 43.5], [-12.5, 2, 43.5], [-15.5, 2, 43.5]], b: [[-15.5, -2, 0], [-12.5, -2, 0], [-12.5, 2, 0], [-15.5, 2, 0]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[-17, -3, 1.5], [-11, -3, 1.5], [-11, 3, 1.5], [-17, 3, 1.5]], b: [[-17, -3, 0], [-11, -3, 0], [-11, 3, 0], [-17, 3, 0]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[-5.3, -1, 43.5], [-6.3, -1, 43.5], [-6.3, 1, 43.5], [-5.3, 1, 43.5]], b: [[-5.3, -1, 15], [-6.3, -1, 15], [-6.3, 1, 15], [-5.3, 1, 15]], collide: 0, color: "#b9ae98"}
      - {kind: loft, a: [[12.5, -2, 43.5], [15.5, -2, 43.5], [15.5, 2, 43.5], [12.5, 2, 43.5]], b: [[12.5, -2, 0], [15.5, -2, 0], [15.5, 2, 0], [12.5, 2, 0]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[11, -3, 1.5], [17, -3, 1.5], [17, 3, 1.5], [11, 3, 1.5]], b: [[11, -3, 0], [17, -3, 0], [17, 3, 0], [11, 3, 0]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[5.3, -1, 43.5], [6.3, -1, 43.5], [6.3, 1, 43.5], [5.3, 1, 43.5]], b: [[5.3, -1, 15], [6.3, -1, 15], [6.3, 1, 15], [5.3, 1, 15]], collide: 0, color: "#b9ae98"}
      - {kind: loft, a: [[-15.5, -3, 45.2], [15.5, -3, 45.2], [15.5, 3, 45.2], [-15.5, 3, 45.2]], b: [[-15.5, -3, 43.5], [15.5, -3, 43.5], [15.5, 3, 43.5], [-15.5, 3, 43.5]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[4, 0, 66], [3.6955, 1.5307, 66], [4.4346, 1.8369, 66], [4.8, 0, 66]], b: [[4, 0, 46], [3.6955, 1.5307, 46], [4.4346, 1.8369, 46], [4.8, 0, 46]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[3.6955, 1.5307, 66], [2.8284, 2.8284, 66], [3.3941, 3.3941, 66], [4.4346, 1.8369, 66]], b: [[3.6955, 1.5307, 46], [2.8284, 2.8284, 46], [3.3941, 3.3941, 46], [4.4346, 1.8369, 46]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[2.8284, 2.8284, 66], [1.5307, 3.6955, 66], [1.8369, 4.4346, 66], [3.3941, 3.3941, 66]], b: [[2.8284, 2.8284, 46], [1.5307, 3.6955, 46], [1.8369, 4.4346, 46], [3.3941, 3.3941, 46]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[1.5307, 3.6955, 66], [0, 4, 66], [0, 4.8, 66], [1.8369, 4.4346, 66]], b: [[1.5307, 3.6955, 46], [0, 4, 46], [0, 4.8, 46], [1.8369, 4.4346, 46]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[0, 4, 66], [-1.5307, 3.6955, 66], [-1.8369, 4.4346, 66], [0, 4.8, 66]], b: [[0, 4, 46], [-1.5307, 3.6955, 46], [-1.8369, 4.4346, 46], [0, 4.8, 46]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[-1.5307, 3.6955, 66], [-2.8284, 2.8284, 66], [-3.3941, 3.3941, 66], [-1.8369, 4.4346, 66]], b: [[-1.5307, 3.6955, 46], [-2.8284, 2.8284, 46], [-3.3941, 3.3941, 46], [-1.8369, 4.4346, 46]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[-2.8284, 2.8284, 66], [-3.6955, 1.5307, 66], [-4.4346, 1.8369, 66], [-3.3941, 3.3941, 66]], b: [[-2.8284, 2.8284, 46], [-3.6955, 1.5307, 46], [-4.4346, 1.8369, 46], [-3.3941, 3.3941, 46]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[-3.6955, 1.5307, 66], [-4, 0, 66], [-4.8, 0, 66], [-4.4346, 1.8369, 66]], b: [[-3.6955, 1.5307, 46], [-4, 0, 46], [-4.8, 0, 46], [-4.4346, 1.8369, 46]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[-4.8, 0, 46], [4.8, 0, 46], [4.8, 4.8, 46], [-4.8, 4.8, 46]], b: [[-4.8, 0, 45.2], [4.8, 0, 45.2], [4.8, 4.8, 45.2], [-4.8, 4.8, 45.2]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[-4.8, 0, 66.8], [4.8, 0, 66.8], [4.8, 4.8, 66.8], [-4.8, 4.8, 66.8]], b: [[-4.8, 0, 66], [4.8, 0, 66], [4.8, 4.8, 66], [-4.8, 4.8, 66]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[0.75, 0, 45.2], [0.5303, 0.5303, 45.2], [1.1314, 1.1314, 45.2], [1.6, 0, 45.2]], b: [[0.75, 0, 43.6], [0.5303, 0.5303, 43.6], [1.1314, 1.1314, 43.6], [1.6, 0, 43.6]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[0.5303, 0.5303, 45.2], [0, 0.75, 45.2], [0, 1.6, 45.2], [1.1314, 1.1314, 45.2]], b: [[0.5303, 0.5303, 43.6], [0, 0.75, 43.6], [0, 1.6, 43.6], [1.1314, 1.1314, 43.6]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[0, 0.75, 45.2], [-0.5303, 0.5303, 45.2], [-1.1314, 1.1314, 45.2], [0, 1.6, 45.2]], b: [[0, 0.75, 43.6], [-0.5303, 0.5303, 43.6], [-1.1314, 1.1314, 43.6], [0, 1.6, 43.6]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[-0.5303, 0.5303, 45.2], [-0.75, 0, 45.2], [-1.6, 0, 45.2], [-1.1314, 1.1314, 45.2]], b: [[-0.5303, 0.5303, 43.6], [-0.75, 0, 43.6], [-1.6, 0, 43.6], [-1.1314, 1.1314, 43.6]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[-2.35, -0.1, 66.8], [-1.65, -0.1, 66.8], [-1.65, 0.1, 66.8], [-2.35, 0.1, 66.8]], b: [[-2.35, -0.1, 66], [-1.65, -0.1, 66], [-1.65, 0.1, 66], [-2.35, 0.1, 66]], collide: 0, color: "#2b2722"}
      - {kind: loft, a: [[1.65, -0.1, 66.8], [2.35, -0.1, 66.8], [2.35, 0.1, 66.8], [1.65, 0.1, 66.8]], b: [[1.65, -0.1, 66], [2.35, -0.1, 66], [2.35, 0.1, 66], [1.65, 0.1, 66]], collide: 0, color: "#2b2722"}
      - {kind: loft, a: [[5.4, 0, 52], [8.6, 0, 52], [8.6, 2.5, 52], [5.4, 2.5, 52]], b: [[5.4, 0, 45.2], [8.6, 0, 45.2], [8.6, 2.5, 45.2], [5.4, 2.5, 45.2]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[5.4, 0, 45.2], [8.6, 0, 45.2], [8.6, 2.5, 45.2], [5.4, 2.5, 45.2]], b: [[5.4, 0, 44.6], [8.6, 0, 44.6], [8.6, 2.5, 44.6], [5.4, 2.5, 44.6]], collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[4, 0, 45.2], [6, 0, 45.2], [6, 2.5, 45.2], [4, 2.5, 45.2]], b: [[4, 0, 44.6], [6, 0, 44.6], [6, 2.5, 44.6], [4, 2.5, 44.6]], collide: 0, color: "#6d675c"}
      - {kind: rod, from: [8.6, 1.2, 50], to: [19, 1.2, 50], radius: 0.9, collide: 0, color: "#5f5a52"}
      - {kind: rod, from: [8.6, 1.2, 46.6], to: [15, 1.2, 46.6], radius: 0.7, collide: 0, color: "#5f5a52"}
      - {kind: rod, from: [15, 1.2, 46.6], to: [15, 1.2, 40], radius: 0.7, collide: 0, color: "#5f5a52"}
      - {kind: rod, from: [7, 0, 52], to: [7, 0, 53.2], radius: 0.7, collide: 0, color: "#6d675c"}
      - {kind: loft, a: [[9.4, 1.2, 59], [10.4, 1.2, 59], [10.4, 2.2, 59], [9.4, 2.2, 59]], b: [[9.4, 1.2, 52], [10.4, 1.2, 52], [10.4, 2.2, 52], [9.4, 2.2, 52]], collide: 0, color: "#6d675c"}
      - {kind: rod, from: [9.9, 0, 59], to: [9.9, 2.4, 59], radius: 0.3, collide: 0, color: "#6d675c"}
joints:
  - {id: j_h, type: slide, body: hammer, axis: [0, 0, 1], range: [-0.5, 16.8], damping: 0.5}   # the hammer in its guides
  - {id: j_v, type: slide, body: valve, axis: [0, 0, 1], range: [-1.5, 1.5], damping: 0.01}   # the slide valve
  - {id: j_vr, type: hinge, body: vrod, axis: [0, 1, 0], damping: 0.0005}
  - {id: j_l, type: hinge, body: lever, axis: [0, 1, 0], damping: 0.002}   # the hammer-man's lever (the drive)
pins:
  - {id: p_v, a: lever, b: vrod, at: [7, 0, 59]}
vessels:
  substeps: 4
  nodes:
    - {id: boiler, kind: source, p: 30000, gas: true}
    - {id: air, kind: source, p: 0, gas: true}
    - {id: under, kind: gas, volume: 56.2655, p: 0,
       draw: {sections: [[[-3.95, 46], [3.95, 46], [3.95, 66], [-3.95, 66]], [[4, 44.7], [6, 44.7], [6, 45.9], [4, 45.9]]], y: [0, 3.7],
               face: {body: hammer, z: 47, side: below}, pref: 30000}}   # the steam under the piston (its clearance and the port)
  links:
    - {id: admit, from: boiler, to: under, area: 0.1, cd: 0.62, open: {joint: j_v, q: [0.15, 0.7], frac: [0, 1]}}
    - {id: exhaust, from: under, to: air, area: 1.2, cd: 0.62, open: {joint: j_v, q: [-0.7, -0.15], frac: [1, 0]}}
  pistons:
    - {node: under, joint: j_h, area: 50.2655, sign: 1}
driver: {joint: j_l, kind: velocity, rpm: 0, swing: {amplitude: 0.28, hz: 0.7}, kv: 3000, max_torque: 50}
checks:
  - {type: amplitude, joint: j_h, min: 0.045, max: 0.08, settle_s: 1.5, window_s: 12}
  - {type: penetration, max: 0.01}
camera: {target: [3, 0, 26.5], position: [3, -260, 30.5], fov: 21}
display:
  output: j_h
  labels: {j_h: "Hammer", j_v: "Slide valve", j_vr: "Valve rod", j_l: "Hand lever (driver)"}
