# No. 137 (Brown 1868): "Expansion eccentric used in France to work the slide-valve of a steam engine. The eccentric is fixed on the crank-shaft, and communicates motion to the forked vibrating arm to the bottom of which the valve-rod is attached."
#
# Model (cm, gravity on): the shaft (the one driven joint, 12 turns a minute, clockwise in the view) carries an eccentric (5.5 cm radius, 1.5 cm eccentricity). The C-shaped arm swings about a pivot 18 cm to the right,
# with two rollers either side of the eccentric (the lower with 10 mm slack); the arm's weight holds the upper roller on it by real contact. The arm swings -0.062..0.106 rad, the valve-rod
# hanging from the lower roller's pin. Generator: opencode-runs/batch10/gen137.py.
number: 137
slug: expansion-eccentric-forked-arm
name: An eccentric working a forked vibrating arm
brown: "Expansion eccentric used in France to work the slide-valve of a steam engine. The eccentric is fixed on the crank-shaft, and communicates motion to the forked vibrating arm to the bottom of which the valve-rod is attached."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 20.0
  floor: false
bodies:
  - id: cam
    shape: part
    pos: [0, 0, 0]
    mass: 20.0
    friction: 0.03
    color: "#d9cfb6"
    pieces:
      - {kind: rod, from: [0, -2.0, 0], to: [0, 3.6, 0], radius: 1.4, color: "#8f8a80"}   # the crank-shaft (hatched in the plate)
      - {kind: poly, points: [[7.0, 0.0], [6.9791, 0.4794], [6.9164, 0.9551], [6.8126, 1.4235], [6.6683, 1.8811], [6.4847, 2.3244], [6.2631, 2.75], [6.0053, 3.1547], [5.7132, 3.5353], [5.3891, 3.8891], [5.0353, 4.2132], [4.6547, 4.5053], [4.25, 4.7631], [3.8244, 4.9847], [3.3811, 5.1683], [2.9235, 5.3126], [2.4551, 5.4164], [1.9794, 5.4791], [1.5, 5.5], [1.0206, 5.4791], [0.5449, 5.4164], [0.0765, 5.3126], [-0.3811, 5.1683], [-0.8244, 4.9847], [-1.25, 4.7631], [-1.6547, 4.5053], [-2.0353, 4.2132], [-2.3891, 3.8891], [-2.7132, 3.5353], [-3.0053, 3.1547], [-3.2631, 2.75], [-3.4847, 2.3244], [-3.6683, 1.8811], [-3.8126, 1.4235], [-3.9164, 0.9551], [-3.9791, 0.4794], [-4.0, 0.0], [-3.9791, -0.4794], [-3.9164, -0.9551], [-3.8126, -1.4235], [-3.6683, -1.8811], [-3.4847, -2.3244], [-3.2631, -2.75], [-3.0053, -3.1547], [-2.7132, -3.5353], [-2.3891, -3.8891], [-2.0353, -4.2132], [-1.6547, -4.5053], [-1.25, -4.7631], [-0.8244, -4.9847], [-0.3811, -5.1683], [0.0765, -5.3126], [0.5449, -5.4164], [1.0206, -5.4791], [1.5, -5.5], [1.9794, -5.4791], [2.4551, -5.4164], [2.9235, -5.3126], [3.3811, -5.1683], [3.8244, -4.9847], [4.25, -4.7631], [4.6547, -4.5053], [5.0353, -4.2132], [5.3891, -3.8891], [5.7132, -3.5353], [6.0053, -3.1547], [6.2631, -2.75], [6.4847, -2.3244], [6.6683, -1.8811], [6.8126, -1.4235], [6.9164, -0.9551], [6.9791, -0.4794]], y: [-0.8, 0.8], collide: 1}   # the eccentric
  - id: arm
    shape: part
    pos: [18.0, 0, 0]
    mass: 0.3
    friction: 0.03
    color: "#b8ad97"
    pieces:
      - {kind: rod, from: [-1.0, -0.6, 6.2161], to: [-1.0, 1.6, 6.2161], radius: 1.2, collide: 2, capsule: true, color: "#8f8a80"}   # the upper roller
      - {kind: rod, from: [-1.0, -0.6, -7.2161], to: [-1.0, 1.6, -7.2161], radius: 1.2, collide: 2, capsule: true, color: "#8f8a80"}   # the lower roller
      - {kind: poly, points: [[-3.0, 5.2161], [-3.0, 7.2161], [9, 7.2161], [9, 5.2161]], y: [1.0, 2.0], collide: 0}   # the upper prong
      - {kind: poly, points: [[-3.0, -8.2161], [-3.0, -6.2161], [9, -6.2161], [9, -8.2161]], y: [1.0, 2.0], collide: 0}   # the lower prong
      - {kind: poly, points: [[7.5, -8.2161], [10, -8.2161], [10, 7.2161], [7.5, 7.2161]], y: [1.0, 2.0], collide: 0}   # the spine of the C
      - {kind: poly, points: [[9, -1.4], [18.0, -1.4], [18.0, 0.6], [9, 0.6]], y: [1.0, 2.0], collide: 0}   # the lever to the pivot
      - {kind: rod, from: [18.0, 1.0, 0], to: [18.0, 2.0, 0], radius: 2.2, collide: 0}   # the pivot's eye
      - {kind: poly, points: [[-1.9, -16.2161], [-0.09999999999999998, -16.2161], [-0.09999999999999998, -7.2161], [-1.9, -7.2161]], y: [1.0, 2.0], collide: 0, color: "#cfc6b4"}   # the valve-rod
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-1.8, -12], [1.8, -12], [1.4, 0], [-1.4, 0]], y: [3.2, 4.2]}   # the shaft's standard, behind
      - {kind: poly, points: [[16.8, -12], [19.2, -12], [18.8, 0], [17.2, 0]], y: [3.2, 4.2]}   # the pivot's standard
      - {kind: rod, from: [18.0, 2.0, 0], to: [18.0, 3.4, 0], radius: 0.8, color: "#8f8a80"}
      - {kind: poly, points: [[-6, -13], [24.0, -13], [24.0, -12], [-6, -12]], y: [-3, 3], color: "#b9b09c"}
joints:
  - {id: j_s, type: hinge, body: cam, axis: [0, 1, 0], damping: 0.002}   # the one driven joint; + : clockwise
  - {id: j_a, type: hinge, body: arm, axis: [0, 1, 0], range: [-0.6, 0.6], damping: 0.002}   # the forked arm; + : clockwise (its rollers rise)
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_s, kind: velocity, rpm: 12.0, kv: 30000.0, max_torque: 30000.0}
checks:
  - {type: follow, out: j_a, in: j_s, expect: -0.0904, tol: 0.0045, min_r2: 0.99, settle_s: 9.5361, window_s: 0.3333}   # mid-stroke, shaft turns -12..12 deg from the start of turn 2
  - {type: follow, out: j_a, in: j_s, expect: 0.0767, tol: 0.0038, min_r2: 0.99, settle_s: 12.0361, window_s: 0.3333}   # mid-stroke, shaft turns 168..192 deg from the start of turn 2
  - {type: follow, out: j_a, in: j_s, expect: -0.0904, tol: 0.0045, min_r2: 0.99, settle_s: 14.5361, window_s: 0.3333}   # mid-stroke, shaft turns -12..12 deg from the start of turn 3
  - {type: follow, out: j_a, in: j_s, expect: 0.0767, tol: 0.0038, min_r2: 0.99, settle_s: 17.0361, window_s: 0.3333}   # mid-stroke, shaft turns 168..192 deg from the start of turn 3
  - {type: position, joint: j_a, min: -0.0673, max: 0.1113, settle_s: 1.0, window_s: 18.5}   # the swing
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [8.0, 0, -3.0], position: [8.0, -74.0, -3.0], fov: 34}
display:
  output: j_a
  labels: {j_s: "Eccentric (driver)", j_a: "Forked arm"}
  proof: {label: "Eccentric out of contact", sub: "the shaft turns but the arm hangs on its stop"}

