number: 346
slug: table-engine
name: Table engine
brown: "Table engine. The cylinder is fixed on a table-like base. The piston-rod has a cross-head working in straight slotted guides fixed on top of cylinder, and is connected by two side connecting-rods with two parallel cranks on shaft under the table."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 100, solver: CG, multiccd: true, duration_s: 8, floor: false}
bodies:
  # the framing: the table with the cylinder on it, the slotted guides on the cylinder's top, the shaft's bearings
  # under the table
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    density: 7800
    color: "#9a9284"
    pieces:
      - {kind: poly, points: [[-24.0000, -11.4000], [24.0000, -11.4000], [24.0000, -10.0000], [-24.0000, -10.0000]], y: [-12, 12], collide: 0}
      - {kind: poly, points: [[-20.0000, 8.6000], [20.0000, 8.6000], [20.0000, 10.0000], [-20.0000, 10.0000]], y: [-11, 11], collide: 0}
      - {kind: poly, points: [[-20.0000, -10.0000], [-17.0000, -10.0000], [-17.0000, 8.6000], [-20.0000, 8.6000]], y: [-11, 11], collide: 0}
      - {kind: poly, points: [[17.0000, -10.0000], [20.0000, -10.0000], [20.0000, 8.6000], [17.0000, 8.6000]], y: [-11, 11], collide: 0}
      - {kind: poly, points: [[-2.6000, -10.0000], [2.6000, -10.0000], [2.6000, 0.0000], [-2.6000, 0.0000]], y: [-11.6, -10.0], collide: 0}
      - {kind: disc, center: [0.0000, 0.0000], radius: 2.6, y: [-11.6, -10.0], collide: 0}
      - {kind: poly, points: [[-2.6000, -10.0000], [2.6000, -10.0000], [2.6000, 0.0000], [-2.6000, 0.0000]], y: [10.0, 11.6], collide: 0}
      - {kind: disc, center: [0.0000, 0.0000], radius: 2.6, y: [10.0, 11.6], collide: 0}
      - {kind: poly, points: [[-5.7000, 10.0000], [5.7000, 10.0000], [5.7000, 26.0000], [-5.7000, 26.0000]], y: [-5.7, 5.7], collide: 0, color: "#b0a690"}
      - {kind: poly, points: [[-6.9000, 10.0000], [6.9000, 10.0000], [6.9000, 11.2000], [-6.9000, 11.2000]], y: [-6.9, 6.9], collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[-6.9000, 26.0000], [6.9000, 26.0000], [6.9000, 27.2000], [-6.9000, 27.2000]], y: [-6.9, 6.9], collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[-2.0000, 27.2000], [2.0000, 27.2000], [2.0000, 28.6000], [-2.0000, 28.6000]], y: [-2.0, 2.0], collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[-7.4200, 27.2000], [-6.4200, 27.2000], [-6.4200, 56.0000], [-7.4200, 56.0000]], y: [-1.2, 1.2], collide: 1}
      - {kind: poly, points: [[6.4200, 27.2000], [7.4200, 27.2000], [7.4200, 56.0000], [6.4200, 56.0000]], y: [-1.2, 1.2], collide: 1}
      - {kind: poly, points: [[-7.4200, 56.0000], [7.4200, 56.0000], [7.4200, 57.4000], [-7.4200, 57.4000]], y: [-1.2, 1.2], collide: 0}
  # the shaft with its two parallel cranks, one each side of the cylinder (the driven joint)
  - id: K
    shape: part
    pos: [0.0000, 0, 0.0000]
    mount: frame
    density: 7800
    color: "#a39d90"
    pieces:
      - {kind: rod, from: [0, -11.6, 0], to: [0, 11.6, 0], radius: 1.3, collide: 0, color: "#6f6a60"}
      - {kind: disc, center: [0.0000, 0.0000], radius: 2.6, y: [-6.8, -5.8], collide: 0}
      - {kind: disc, center: [0.0000, 8.0000], radius: 1.8, y: [-6.8, -5.8], collide: 0}
      - {kind: rod, from: [0.0000, -6.3, 0.0000], to: [0.0000, -6.3, 8.0000], radius: 1.6, collide: 0}
      - {kind: disc, center: [0.0000, 0.0000], radius: 2.6, y: [5.8, 6.8], collide: 0}
      - {kind: disc, center: [0.0000, 8.0000], radius: 1.8, y: [5.8, 6.8], collide: 0}
      - {kind: rod, from: [0.0000, 6.3, 0.0000], to: [0.0000, 6.3, 8.0000], radius: 1.6, collide: 0}
      - {kind: rod, from: [0.0000, -8.4, 8.0000], to: [0.0000, -5.8, 8.0000], radius: 0.6, collide: 0, color: "#6f6a60"}
      - {kind: rod, from: [0.0000, 5.8, 8.0000], to: [0.0000, 8.4, 8.0000], radius: 0.6, collide: 0, color: "#6f6a60"}
  # the two side connecting-rods, each on its crank-pin; their upper eyes go round the cross-head's pin
  - id: R1
    shape: part
    pos: [0.0000, 0, 8.0000]
    mount: K
    density: 7800
    color: "#a39d90"
    pieces:
      - {kind: rod, from: [0.0000, -7.6, 8.0000], to: [0.0000, -7.6, 47.2000], radius: 0.6, collide: 0}
      - {kind: disc, center: [0.0000, 8.0000], radius: 1.5, y: [-8.0, -7.199999999999999], collide: 0}
      - {kind: band, center: [0.0000, 47.2000], r: [0.62, 1.4], a: [0, 6.2832], y: [-8.0, -7.199999999999999], slices: 36, collide: 1}
  - id: R2
    shape: part
    pos: [0.0000, 0, 8.0000]
    mount: K
    density: 7800
    color: "#a39d90"
    pieces:
      - {kind: rod, from: [0.0000, 7.6, 8.0000], to: [0.0000, 7.6, 47.2000], radius: 0.6, collide: 0}
      - {kind: disc, center: [0.0000, 8.0000], radius: 1.5, y: [7.199999999999999, 8.0], collide: 0}
      - {kind: band, center: [0.0000, 47.2000], r: [0.62, 1.4], a: [0, 6.2832], y: [7.199999999999999, 8.0], slices: 36, collide: 1}
  # the cross-head and piston-rod: free to move across, up and down and to turn, and only the guides' bars, on
  # either side of its shoes, and the side rods' eyes on its pin place it
  - {id: Xa, shape: part, pos: [0.0000, 0, 47.2000], mount: frame, mass: 0.01, color: "#8f8a80", pieces: [{kind: disc, center: [0, 26.0000], radius: 0.1, y: [-0.3, -0.25], collide: 0}]}
  - {id: Xb, shape: part, pos: [0.0000, 0, 47.2000], mount: Xa, mass: 0.01, color: "#8f8a80", pieces: [{kind: disc, center: [0, 26.0000], radius: 0.1, y: [-0.3, -0.25], collide: 0}]}
  - id: X
    shape: part
    pos: [0.0000, 0, 47.2000]
    mount: Xb
    density: 7800
    color: "#b8ad96"
    pieces:
      - {kind: poly, points: [[-4.4200, 45.6000], [4.4200, 45.6000], [4.4200, 48.8000], [-4.4200, 48.8000]], y: [-1.0, 1.0], collide: 0}
      - {kind: poly, points: [[-6.4000, 44.8000], [-4.4200, 44.8000], [-4.4200, 49.6000], [-6.4000, 49.6000]], y: [-1.0, 1.0], collide: 2, color: "#a39a88"}
      - {kind: poly, points: [[4.4200, 44.8000], [6.4000, 44.8000], [6.4000, 49.6000], [4.4200, 49.6000]], y: [-1.0, 1.0], collide: 2, color: "#a39a88"}
      - {kind: disc, center: [0.0000, 47.2000], radius: 0.6, y: [-8.4, 8.4], collide: 2, color: "#6f6a60"}
      - {kind: rod, from: [0.0000, 0, 45.6000], to: [0.0000, 0, 25.2000], radius: 0.7, collide: 0}
joints:
  - {id: j_K, type: hinge, body: K, axis: [0, -1, 0], damping: 0.0005}
  - {id: j_R1, type: hinge, body: R1, axis: [0, -1, 0], damping: 0.001}
  - {id: j_R2, type: hinge, body: R2, axis: [0, -1, 0], damping: 0.001}
  - {id: j_x, type: slide, body: Xa, axis: [1, 0, 0], damping: 0.05, range: [-1, 1]}
  - {id: j_z, type: slide, body: Xb, axis: [0, 0, 1], damping: 0.05, range: [-17, 1]}
  - {id: j_rot, type: hinge, body: X, axis: [0, -1, 0], damping: 0.001}
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_K, kind: velocity, rpm: 30, kv: 30, max_torque: 50}
checks:
  - {type: turning, joint: j_K, direction: 1, min_mean: 2.8, min_fraction: 0.95, settle_s: 0.5, window_s: 7.0}
  # the two cranks, through the side rods, draw the cross-head and piston-rod the length of the stroke, twice the
  # cranks' 8 cm ...
  - {type: amplitude, joint: j_z, min: 0.078, max: 0.082, settle_s: 0.5, window_s: 7.0}
  # ... the two side rods, on parallel cranks, swinging together ...
  - {type: follow, out: j_R2, in: j_R1, expect: 1.0, tol: 0.02, min_r2: 0.999, settle_s: 0.5, window_s: 7.0}
  # ... and the slotted guides keep the cross-head on its line though the rods push it sideways: it moves across by
  # no more than its play, and barely turns
  - {type: position, joint: j_x, min: -0.05, max: 0.05, settle_s: 0.5, window_s: 7.0}
  - {type: position, joint: j_rot, min: -0.012, max: 0.012, settle_s: 0.5, window_s: 7.0}
  - {type: penetration, max: 0.0003, settle_s: 0.2}
camera: {target: [0, 0, 3.3], position: [-60, -228, 10], fov: 30}
display:
  output: j_z
  labels: {j_K: Shaft and cranks (driver), j_R1: Side rod (front), j_R2: Side rod (back), j_x: Cross-head across, j_z: Cross-head and piston-rod, j_rot: Turn of cross-head}

