number: 343
slug: parallel-motion-upright-engine
name: Parallel motion for upright engine
brown: "Parallel motion for upright engine. A, A, are radius-rods connected at one end with the framing and at the other with a vibrating piece on top of piston-rod."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 100, solver: CG, multiccd: true, duration_s: 8, floor: false}
bodies:
  # the framing: two columns and the entablature, a bracket on each column for a radius-rod, the cylinder below
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    density: 7800
    color: "#9a9284"
    pieces:
      - {kind: poly, points: [[-36.0000, -37.4000], [36.0000, -37.4000], [36.0000, -36.0000], [-36.0000, -36.0000]], y: [-7.0, 4.0], collide: 0}
      - {kind: poly, points: [[-30.0000, -36.0000], [-26.0000, -36.0000], [-26.0000, 22.0000], [-30.0000, 22.0000]], y: [-6.6, 4.0], collide: 0}
      - {kind: poly, points: [[26.0000, -36.0000], [30.0000, -36.0000], [30.0000, 22.0000], [26.0000, 22.0000]], y: [-6.6, 4.0], collide: 0}
      - {kind: poly, points: [[-34.0000, 22.0000], [34.0000, 22.0000], [34.0000, 25.2000], [-34.0000, 25.2000]], y: [-6.6, 4.0], collide: 0}
      - {kind: poly, points: [[-26.0000, 9.0000], [-20.0000, 9.0000], [-20.0000, 11.0000], [-26.0000, 11.0000]], y: [2.8, 3.6], collide: 0}
      - {kind: disc, center: [-20.0000, 10.0000], radius: 1.4, y: [2.8, 3.6], collide: 0}
      - {kind: rod, from: [-20.0000, 1.2, 10.0000], to: [-20.0000, 3.6, 10.0000], radius: 0.5, collide: 0, color: "#6f6a60"}
      - {kind: poly, points: [[20.0000, -11.0000], [26.0000, -11.0000], [26.0000, -9.0000], [20.0000, -9.0000]], y: [-6.4, -5.6], collide: 0}
      - {kind: disc, center: [20.0000, -10.0000], radius: 1.4, y: [-6.4, -5.6], collide: 0}
      - {kind: rod, from: [20.0000, -6.4, -10.0000], to: [20.0000, -2.8, -10.0000], radius: 0.5, collide: 0, color: "#6f6a60"}
      - {kind: poly, points: [[-10.0000, -36.0000], [10.0000, -36.0000], [10.0000, -23.2000], [-10.0000, -23.2000]], y: [-8.0, -1.4], collide: 0, color: "#8a8377"}
      - {kind: poly, points: [[-12.0000, -23.2000], [12.0000, -23.2000], [12.0000, -22.0000], [-12.0000, -22.0000]], y: [-8.4, -1.0], collide: 0, color: "#7d776c"}
      - {kind: poly, points: [[-2.0000, -22.0000], [2.0000, -22.0000], [2.0000, -20.4000], [-2.0000, -20.4000]], y: [-6.0, -3.2], collide: 0, color: "#7d776c"}
  # the radius-rod A on the left, rocked on its pivot (the driven joint)
  - id: R1
    shape: part
    pos: [-20.0000, 0, 10.0000]
    mount: frame
    density: 7800
    color: "#a39d90"
    pieces:
      - {kind: rod, from: [-20.0000, 1.8, 10.0000], to: [0.0000, 1.8, 10.0000], radius: 0.8, collide: 0}
      - {kind: disc, center: [-20.0000, 10.0000], radius: 1.0, y: [1.4, 2.2], collide: 0}
      - {kind: disc, center: [0.0000, 10.0000], radius: 1.0, y: [1.4, 2.2], collide: 0}
      - {kind: rod, from: [0.0000, -1.6, 10.0000], to: [0.0000, 2.2, 10.0000], radius: 0.4, collide: 0, color: "#6f6a60"}
  # the vibrating piece, hung on the left rod's end; its lower end a pin in the right rod's eye, its middle the
  # pin of the piston-rod's cross-head
  - id: V
    shape: part
    pos: [0.0000, 0, 10.0000]
    mount: R1
    density: 7800
    color: "#b0a690"
    pieces:
      - {kind: rod, from: [0.0000, -1.25, 10.0000], to: [0.0000, -1.25, -10.0000], radius: 0.8, collide: 0}
      - {kind: disc, center: [0.0000, 10.0000], radius: 1.1, y: [-1.6, -0.9], collide: 0}
      - {kind: disc, center: [0.0000, 0.0000], radius: 1.0, y: [-1.6, -0.9], collide: 0}
      - {kind: disc, center: [0.0000, -10.0000], radius: 1.0, y: [-1.6, -0.9], collide: 0}
      - {kind: disc, center: [0.0000, -10.0000], radius: 0.4, y: [-3.8, -0.9], collide: 2, color: "#6f6a60"}
      - {kind: disc, center: [0.0000, 0.0000], radius: 0.4, y: [-3.8, -0.9], collide: 2, color: "#6f6a60"}
  # the radius-rod A on the right, on its own pivot, its eye round the piece's lower pin
  - id: R2
    shape: part
    pos: [20.0000, 0, -10.0000]
    mount: frame
    density: 7800
    color: "#a39d90"
    pieces:
      - {kind: rod, from: [20.0000, -3.4, -10.0000], to: [0.0000, -3.4, -10.0000], radius: 0.8, collide: 0}
      - {kind: disc, center: [20.0000, -10.0000], radius: 1.0, y: [-3.8, -3.0], collide: 0}
      - {kind: band, center: [0.0000, -10.0000], r: [0.42, 0.95], a: [0, 6.2832], y: [-3.8, -3.0], slices: 36, collide: 1}
  # the cross-head and piston-rod, which runs down through the gland: free to move across and up and down,
  # and only the piece's middle pin places it
  - {id: Px, shape: part, pos: [0.0000, 0, 0.0000], mount: frame, mass: 0.01, color: "#8f8a80", pieces: [{kind: disc, center: [0.0000, -26.0000], radius: 0.1, y: [-4.0, -3.9], collide: 0}]}
  - id: P
    shape: part
    pos: [0.0000, 0, 0.0000]
    mount: Px
    density: 7800
    color: "#b8ad96"
    pieces:
      - {kind: band, center: [0.0000, 0.0000], r: [0.42, 0.95], a: [0, 6.2832], y: [-3.8, -3.0], slices: 36, collide: 1}
      - {kind: poly, points: [[-1.0000, -1.1000], [1.0000, -1.1000], [1.0000, 1.1000], [-1.0000, 1.1000]], y: [-4.4, -3.9], collide: 0}
      - {kind: rod, from: [0.0000, -4.6, -0.5000], to: [0.0000, -4.6, -28.0000], radius: 0.5, collide: 0, color: "#8f8a80"}
joints:
  - {id: j_A1, type: hinge, body: R1, axis: [0, -1, 0], damping: 0.001}
  - {id: j_V, type: hinge, body: V, axis: [0, -1, 0], damping: 0.001}
  - {id: j_A2, type: hinge, body: R2, axis: [0, -1, 0], damping: 0.001}
  - {id: j_x, type: slide, body: Px, axis: [1, 0, 0], damping: 0.2, range: [-1, 1]}
  - {id: j_z, type: slide, body: P, axis: [0, 0, 1], damping: 0.2, range: [-9, 9]}
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_A1, kind: velocity, rpm: 0, swing: {amplitude: 0.25, hz: 0.25}, kv: 2000, max_torque: 100}
checks:
  # the left radius-rod, rocked on its pivot, lifts and lowers the vibrating piece, and the piece carries the
  # cross-head and piston-rod up and down with it, 0.2 m a radian ...
  - {type: follow, out: j_z, in: j_A1, expect: 0.198, tol: 0.006, min_r2: 0.999, settle_s: 0.5, window_s: 7.0}
  - {type: amplitude, joint: j_z, min: 0.047, max: 0.052, settle_s: 0.5, window_s: 7.0}
  # ... the right radius-rod, through the piece's lower pin, swinging as far the other way ...
  - {type: follow, out: j_A2, in: j_A1, expect: -1.0, tol: 0.03, min_r2: 0.999, settle_s: 0.5, window_s: 7.0}
  # ... so that the middle of the piece keeps to an upright line: the cross-head strays across under a millimetre
  - {type: position, joint: j_x, min: -0.1, max: 0.1, settle_s: 0.5, window_s: 7.0}
  - {type: penetration, max: 0.0003, settle_s: 0.2}
camera: {target: [0, 0, -17], position: [0, -260, -9], fov: 30}
display:
  output: j_z
  labels: {j_A1: "Radius-rod A, left (driver)", j_V: Vibrating piece, j_A2: "Radius-rod A, right", j_x: Cross-head across, j_z: Cross-head and piston-rod}

