number: 326
slug: slide-guided-piston-rod
name: Slide-Guided Piston-Rod
brown: "A simple means of guiding or obtaining a parallel motion of the piston-rod of an engine. The slide, A, moves in and is guided by the vertical slot in the frame, which is planed to a true surface."
units: cm
sim: {timestep: 0.0005, integrator: implicitfast, iterations: 50, duration_s: 8, floor: false}
bodies:
  # the engine frame, with the vertical slot (two guide bars, planed true) and the cylinder over it
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    friction: 0.05
    color: "#9a9284"
    pieces:
      - {kind: poly, points: [[-9.0000, -6.5000], [9.0000, -6.5000], [9.0000, -5.5000], [-9.0000, -5.5000]], y: [-3.5, 1.5], collide: 0}
      # the frame stands on splayed legs over the fly-wheel's pit, as in Brown's figure
      - {kind: poly, points: [[-13.0000, -24.0000], [-12.0000, -24.0000], [-8.0000, -6.5000], [-9.0000, -6.5000]], y: [-1, 1], collide: 0}
      - {kind: poly, points: [[12.0000, -24.0000], [13.0000, -24.0000], [9.0000, -6.5000], [8.0000, -6.5000]], y: [-1, 1], collide: 0}
      - {kind: poly, points: [[-16.0000, -25.0000], [16.0000, -25.0000], [16.0000, -24.0000], [-16.0000, -24.0000]], y: [-3.5, 4.0], collide: 0}
      - {kind: poly, points: [[-1.2000, -5.5000], [1.2000, -5.5000], [1.2000, -0.6000], [-1.2000, -0.6000]], y: [0.4, 1.4], collide: 0}
      - {kind: poly, points: [[-2.7100, 8.5000], [-1.5100, 8.5000], [-1.5100, 23.5000], [-2.7100, 23.5000]], y: [-1, 1], collide: 1}
      - {kind: poly, points: [[1.5100, 8.5000], [2.7100, 8.5000], [2.7100, 23.5000], [1.5100, 23.5000]], y: [-1, 1], collide: 1}
      - {kind: poly, points: [[-2.7100, 23.5000], [-1.5100, 23.5000], [-1.5100, 24.3000], [-2.7100, 24.3000]], y: [-1, 1], collide: 0}
      - {kind: poly, points: [[1.5100, 23.5000], [2.7100, 23.5000], [2.7100, 24.3000], [1.5100, 24.3000]], y: [-1, 1], collide: 0}
      - {kind: poly, points: [[-7.0000, -5.5000], [-6.0000, -5.5000], [-6.0000, 24.3000], [-7.0000, 24.3000]], y: [-1, 1], collide: 0}
      - {kind: poly, points: [[6.0000, -5.5000], [7.0000, -5.5000], [7.0000, 24.3000], [6.0000, 24.3000]], y: [-1, 1], collide: 0}
      - {kind: poly, points: [[-7.0000, 24.3000], [7.0000, 24.3000], [7.0000, 25.3000], [-7.0000, 25.3000]], y: [-1, 1], collide: 0}
      - {kind: poly, points: [[-3.5000, 25.3000], [3.5000, 25.3000], [3.5000, 33.5000], [-3.5000, 33.5000]], y: [-1.5, 1.5], collide: 0, color: "#7d776c"}
  # the crank with its fly-wheel, turned at a steady speed (the one driven joint)
  - id: K
    shape: part
    pos: [0, 0, 0]
    mount: frame
    density: 7800
    color: "#8f8a80"
    pieces:
      - {kind: disc, center: [0, 0], radius: 1.0, y: [-0.4, 0.4], collide: 0}
      - {kind: rod, from: [0, 0.4, 0], to: [0, 1.6, 0], radius: 0.6, collide: 0}
      # the fly-wheel, as large as Brown draws it (it stands in a pit below the frame's floor)
      - {kind: disc, center: [0, 0], radius: 22.0, inner: 20.2, y: [1.7, 2.5], collide: 0, color: "#6f6a60"}
      - {kind: disc, center: [0, 0], radius: 1.6, y: [1.7, 2.5], collide: 0, color: "#6f6a60"}
      - {kind: poly, points: [[1.2642, 0.2103], [17.8919, 9.8103], [17.4419, 10.5897], [0.8142, 0.9897]], y: [1.85, 2.35], collide: 0, color: "#6f6a60"}
      - {kind: poly, points: [[0.4500, 1.2000], [0.4500, 20.4000], [-0.4500, 20.4000], [-0.4500, 1.2000]], y: [1.85, 2.35], collide: 0, color: "#6f6a60"}
      - {kind: poly, points: [[-0.8142, 0.9897], [-17.4419, 10.5897], [-17.8919, 9.8103], [-1.2642, 0.2103]], y: [1.85, 2.35], collide: 0, color: "#6f6a60"}
      - {kind: poly, points: [[-1.2642, -0.2103], [-17.8919, -9.8103], [-17.4419, -10.5897], [-0.8142, -0.9897]], y: [1.85, 2.35], collide: 0, color: "#6f6a60"}
      - {kind: poly, points: [[-0.4500, -1.2000], [-0.4500, -20.4000], [0.4500, -20.4000], [0.4500, -1.2000]], y: [1.85, 2.35], collide: 0, color: "#6f6a60"}
      - {kind: poly, points: [[0.8142, -0.9897], [17.4419, -10.5897], [17.8919, -9.8103], [1.2642, -0.2103]], y: [1.85, 2.35], collide: 0, color: "#6f6a60"}
      - {kind: poly, points: [[-0.8, 0], [0.8, 0], [0.6, 4.0], [-0.6, 4.0]], y: [-3.0, -2.2], collide: 0}
      - {kind: rod, from: [0, -2.6, 0], to: [0, 0.4, 0], radius: 0.6, collide: 0}
      - {kind: disc, center: [0, 4.0], radius: 0.4, y: [-2.2, -0.9], collide: 2, color: "#6f6a60"}
  # the slide A (the cross-head) with the piston-rod: free to move across, up and down and to turn,
  # kept on its line only by the guide bars
  - {id: Ax, shape: part, pos: [0, 0, 20.0000], mount: frame, mass: 0.01, color: "#8f8a80", pieces: [{kind: disc, center: [0, 20.0000], radius: 0.1, y: [1.0, 1.05], collide: 0}]}
  - {id: Az, shape: part, pos: [0, 0, 20.0000], mount: Ax, mass: 0.01, color: "#8f8a80", pieces: [{kind: disc, center: [0, 20.0000], radius: 0.1, y: [1.0, 1.05], collide: 0}]}
  - id: A
    shape: part
    pos: [0, 0, 20.0000]
    mount: Az
    density: 7800
    friction: 0.05
    color: "#b8ad96"
    pieces:
      - {kind: poly, points: [[-1.5000, 18.0000], [1.5000, 18.0000], [1.5000, 22.0000], [-1.5000, 22.0000]], y: [-0.95, 0.95], collide: 2}
      - {kind: rod, from: [0, 0, 22.0000], to: [0, 0, 32.5000], radius: 0.4, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [0, -1.9, 20.0000], to: [0, -0.95, 20.0000], radius: 0.4, collide: 0, color: "#6f6a60"}
  # the connecting-rod, on the cross-head pin; its big end is a bearing on the crank-pin
  - id: R
    shape: part
    pos: [0, 0, 20.0000]
    mount: A
    density: 7800
    color: "#a39a88"
    pieces:
      - {kind: rod, from: [0, -1.6, 19.4000], to: [0, -1.6, 5.0000], radius: 0.35, collide: 0}
      - {kind: disc, center: [0, 20.0000], radius: 0.7, y: [-1.9, -1.3], collide: 0}
      - {kind: band, center: [0, 4.0], r: [0.42, 1.0], a: [0, 6.2832], y: [-1.9, -1.3], slices: 36, collide: 1}
joints:
  - {id: j_K, type: hinge, body: K, axis: [0, -1, 0], damping: 0.001}
  - {id: j_x, type: slide, body: Ax, axis: [1, 0, 0], damping: 0.01, range: [-3, 3]}
  - {id: j_z, type: slide, body: Az, axis: [0, 0, 1], damping: 0.01, range: [-12, 3]}
  - {id: j_rot, type: hinge, body: A, axis: [0, -1, 0], damping: 0.001}
  - {id: j_R, type: hinge, body: R, axis: [0, -1, 0], damping: 0.001}
contact: {solref: [0.001, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_K, kind: velocity, rpm: 30, kv: 0.5, max_torque: 5}
checks:
  - {type: turning, joint: j_K, direction: 1, min_mean: 3.0, min_fraction: 0.95, settle_s: 0.5, window_s: 7.0}
  # the crank throws the slide up and down its full stroke, twice the crank's 4 cm radius ...
  - {type: amplitude, joint: j_z, min: 0.039, max: 0.041, settle_s: 0.5, window_s: 7.0}
  # ... and the guide bars keep it on its line, though the connecting-rod pushes it sideways: it moves
  # across the slot by no more than its clearance, and barely turns
  - {type: position, joint: j_x, min: -0.03, max: 0.03, settle_s: 0.5, window_s: 7.0}
  - {type: position, joint: j_rot, min: -0.006, max: 0.006, settle_s: 0.5, window_s: 7.0}
  - {type: penetration, max: 0.0003, settle_s: 0.2}
camera: {target: [0, 0, 1], position: [0, -175, 5], fov: 30}
display:
  output: j_z
  labels: {j_K: Crank (driver), j_x: Slide A across the slot, j_z: Slide A and piston-rod, j_rot: Turn of slide A, j_R: Connecting-rod}

