# No. 279 (Brown 1868): "Crank and slotted cross-head, with Clayton’s sliding journal-box applied to the crank-wrist. This box consists of two taper lining pieces and two taper gibs adjustable by screws, which serve at the same time to tighten the box on the wrist and to set it out to the slot in the cross-head as the box and wrist wear."
#
# Model (cm, gravity on, the cross-head horizontal): the crank (the one driven joint, 30 turns a minute) carries its wrist 4 cm out. On the wrist turns
# Clayton's box (3.2 x 3.6 cm): two taper lining pieces round the wrist, two taper gibs behind them, and the screws that set the gibs down, tightening the
# box on the wrist and spreading it to the slot. The box's two sides work by real contact in the upright slot of the cross-head (0.1 mm play a side),
# and the cross-head slides in its guides on two rods. The box rides up and down the slot and passes the crank's to-and-fro to the cross-head,
# x = r sin t, exactly harmonic. Generator: opencode-runs/batch12/gen279.py.
number: 279
slug: clayton-journal-box
name: Crank and slotted cross-head with Clayton's sliding journal-box
brown: "Crank and slotted cross-head, with Clayton’s sliding journal-box applied to the crank-wrist. This box consists of two taper lining pieces and two taper gibs adjustable by screws, which serve at the same time to tighten the box on the wrist and to set it out to the slot in the cross-head as the box and wrist wear."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 10
  floor: false
bodies:
  - id: crank
    shape: part
    pos: [0, 0, 0]
    mass: 1.5
    friction: 0.05
    color: "#d9cfb6"
    pieces:
      - {kind: rod, from: [0, 0.5, 0], to: [0, 3.0, 0], radius: 0.8, color: "#8f8a80"}   # the crank-shaft
      - {kind: disc, center: [0, 0], radius: 6.0, y: [0.0, 0.5]}   # the crank-disc, behind the cross-head
      - {kind: rod, from: [0, 0.0, 4.0], to: [0, -1.4, 4.0], radius: 0.7, color: "#8f8a80"}   # the crank-wrist
  - id: box
    shape: part
    pos: [0, 0, 4.0]
    mount: crank
    mass: 0.3
    friction: 0.05
    color: "#e4d9bf"
    pieces:
      - {kind: poly, points: [[-1.6, 2.2], [-1.25, 2.2], [-1.25, 5.8], [-1.6, 5.8]], y: [-1.3, -0.1], collide: 1, color: "#cbbf9f"}   # the box's left side, to the slot
      - {kind: poly, points: [[1.25, 2.2], [1.6, 2.2], [1.6, 5.8], [1.25, 5.8]], y: [-1.3, -0.1], collide: 1, color: "#cbbf9f"}   # its right side
      - {kind: poly, points: [[-1.25, 2.2], [-0.72, 2.2], [-0.72, 4.75], [-0.85, 4.75]], y: [-1.3, -0.1], collide: 0}   # the left taper lining piece
      - {kind: poly, points: [[0.72, 2.2], [1.25, 2.2], [0.85, 4.75], [0.72, 4.75]], y: [-1.3, -0.1], collide: 0}   # the right
      - {kind: poly, points: [[-1.25, 2.2], [-0.85, 4.75], [-1.25, 4.75]], y: [-1.3, -0.1], collide: 0, color: "#b8ad97"}   # the taper gibs
      - {kind: poly, points: [[1.25, 2.2], [1.25, 4.75], [0.85, 4.75]], y: [-1.3, -0.1], collide: 0, color: "#b8ad97"}
      - {kind: poly, points: [[-1.25, 4.75], [1.25, 4.75], [1.25, 5.8], [-1.25, 5.8]], y: [-1.3, -0.1], collide: 0, color: "#a39985"}   # the cap holding the screws
      - {kind: rod, from: [-0.8, -0.7, 4.6], to: [-0.8, -0.7, 6.15], radius: 0.16, color: "#5f5a52"}   # the screws
      - {kind: rod, from: [0.8, -0.7, 4.6], to: [0.8, -0.7, 6.15], radius: 0.16, color: "#5f5a52"}
  - id: crosshead
    shape: part
    pos: [0, 0, 0]
    mass: 1.2
    friction: 0.05
    color: "#b8ad97"
    pieces:
      - {kind: poly, points: [[-3.21, -6.4], [-1.61, -6.4], [-1.61, 6.4], [-3.21, 6.4]], y: [-1.4, 0.0], collide: 2}   # the slot's left side
      - {kind: poly, points: [[1.61, -6.4], [3.21, -6.4], [3.21, 6.4], [1.61, 6.4]], y: [-1.4, 0.0], collide: 2}   # its right side
      - {kind: poly, points: [[-3.21, 6.4], [3.21, 6.4], [3.21, 7.6], [-3.21, 7.6]], y: [-1.4, 0.0], collide: 0}   # its head
      - {kind: poly, points: [[-3.21, -7.6], [3.21, -7.6], [3.21, -6.4], [-3.21, -6.4]], y: [-1.4, 0.0], collide: 0}   # its foot
      - {kind: poly, points: [[-4.81, -2.2], [-3.21, -5.4], [-3.21, 5.4], [-4.81, 2.2]], y: [-1.4, 0.0], collide: 0}   # the bosses
      - {kind: poly, points: [[3.21, -5.4], [4.81, -2.2], [4.81, 2.2], [3.21, 5.4]], y: [-1.4, 0.0], collide: 0}
      - {kind: rod, from: [-4.81, -0.7, 0], to: [-19, -0.7, 0], radius: 0.9}   # the rods
      - {kind: rod, from: [4.81, -0.7, 0], to: [19, -0.7, 0], radius: 0.9}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-1.4, -9], [1.4, -9], [1.0, 0], [-1.0, 0]], y: [1.8, 2.8]}   # the shaft's standard, behind
      - {kind: poly, points: [[-16, -1.4], [-13, -1.4], [-13, 1.4], [-16, 1.4]], y: [-2.0, 0.6]}   # the guides
      - {kind: poly, points: [[13, -1.4], [16, -1.4], [16, 1.4], [13, 1.4]], y: [-2.0, 0.6]}
      - {kind: poly, points: [[-15.3, -9], [-13.7, -9], [-13.7, -1.4], [-15.3, -1.4]], y: [-1.0, 0.0]}   # their standards
      - {kind: poly, points: [[13.7, -9], [15.3, -9], [15.3, -1.4], [13.7, -1.4]], y: [-1.0, 0.0]}
      - {kind: poly, points: [[-18, -10], [18, -10], [18, -9], [-18, -9]], y: [-3, 3], color: "#b9b09c"}
joints:
  - {id: j_s, type: hinge, body: crank, axis: [0, 1, 0], damping: 0.002}   # the one driven joint; + : clockwise in the view
  - {id: j_w, type: hinge, body: box, axis: [0, 1, 0], damping: 0.0005}   # the box on the wrist (the lining pieces' bore)
  - {id: j_x, type: slide, body: crosshead, axis: [1, 0, 0], range: [-6, 6], damping: 2.0}   # the cross-head in its guides; + : right
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_s, kind: velocity, rpm: 30, kv: 20.0, max_torque: 20}
checks:
  - {type: follow, out: j_x, in: j_s, expect: 0.04, tol: 0.0008, min_r2: 0.995, settle_s: 1.9722, window_s: 0.0556}   # mid-stroke: r a radian
  - {type: follow, out: j_x, in: j_s, expect: 0.02828, tol: 0.00057, min_r2: 0.995, settle_s: 2.2222, window_s: 0.0556}   # at 45 deg ...
  - {type: follow, out: j_x, in: j_s, expect: -0.02828, tol: 0.00057, min_r2: 0.995, settle_s: 2.7222, window_s: 0.0556}   # ... and 135 deg alike: harmonic, no obliquity
  - {type: position, joint: j_x, min: -4.05, max: 4.05, settle_s: 0.5, window_s: 9}   # the stroke: twice the throw
  - {type: follow, out: j_w, in: j_s, expect: -1.0, tol: 0.01, min_r2: 0.999, settle_s: 0.5, window_s: 9}   # the slot keeps the box upright: it turns back on the wrist as the crank turns
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [0, 0, -4.5], position: [0, -60.0, 3.0], fov: 34}
display:
  output: j_x
  labels: {j_s: "Crank (driver)", j_x: "Cross-head"}
  proof: {label: "Crank and slotted cross-head", sub: "Clayton's box slides in the slot and drives the cross-head x = r sin t"}

