number: 345
slug: inverted-oscillating-pendulum-engine
name: Inverted oscillating or pendulum engine
brown: "Inverted oscillating or pendulum engine. The cylinder has trunnions at its upper end and swings like a pendulum. The crank-shaft is below, and the piston-rod connected directly with crank."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 100, solver: CG, multiccd: true, duration_s: 8, floor: false}
bodies:
  # the framing: the upper beam with the trunnion bearings, the lower beam with the crank-shaft's bearing
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    density: 7800
    color: "#9a9284"
    pieces:
      - {kind: poly, points: [[-32.0000, -2.5000], [32.0000, -2.5000], [32.0000, 2.5000], [-32.0000, 2.5000]], y: [4.6, 6.6], collide: 0}
      - {kind: disc, center: [0.0000, 0.0000], radius: 3.6, y: [4.2, 6.6], collide: 0, color: "#8a8377"}
      - {kind: poly, points: [[-32.0000, -52.5000], [32.0000, -52.5000], [32.0000, -47.5000], [-32.0000, -47.5000]], y: [3.4, 5.4], collide: 0}
      - {kind: disc, center: [0.0000, -50.0000], radius: 3.6, y: [3.0, 5.4], collide: 0, color: "#8a8377"}
  # the crank, turned on its shaft (the driven joint); its pin points forward through the piston-rod's end
  - id: K
    shape: part
    pos: [0.0000, 0, -50.0000]
    mount: frame
    density: 7800
    color: "#a39d90"
    pieces:
      - {kind: disc, center: [0.0000, -50.0000], radius: 3.4, y: [1.0, 2.2], collide: 0}
      - {kind: disc, center: [0.0000, -60.0000], radius: 2.4, y: [1.0, 2.2], collide: 0}
      - {kind: rod, from: [0.0000, 1.6, -50.0000], to: [0.0000, 1.6, -60.0000], radius: 2.0, collide: 0}
      - {kind: rod, from: [0.0000, 1.0, -50.0000], to: [0.0000, 5.4, -50.0000], radius: 1.4, collide: 0, color: "#6f6a60"}
      - {kind: disc, center: [0.0000, -60.0000], radius: 0.6, y: [-1.6, 2.2], collide: 2, color: "#6f6a60"}
  # the cylinder, hung on its trunnions at its upper end, free to swing like a pendulum
  - id: Cy
    shape: part
    pos: [0, 0, 0]
    mount: frame
    density: 2000
    color: "#b0a690"
    pieces:
      - {kind: poly, points: [[-7.5000, -28.0000], [7.5000, -28.0000], [7.5000, 2.0000], [-7.5000, 2.0000]], y: [-6.0, 4.0], collide: 0}
      - {kind: poly, points: [[-8.9000, 2.0000], [8.9000, 2.0000], [8.9000, 3.4000], [-8.9000, 3.4000]], y: [-6.4, 4.4], collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[-8.9000, -29.4000], [8.9000, -29.4000], [8.9000, -28.0000], [-8.9000, -28.0000]], y: [-6.4, 4.4], collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[-3.0000, -30.4000], [3.0000, -30.4000], [3.0000, -29.4000], [-3.0000, -29.4000]], y: [-3.4, 1.8], collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[-4.0000, -31.0000], [4.0000, -31.0000], [4.0000, -30.4000], [-4.0000, -30.4000]], y: [-3.8, 2.2], collide: 0, color: "#8f8a80"}
      - {kind: disc, center: [0.0000, 0.0000], radius: 2.6, y: [-6.6, -6.0], collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [0, -6.6, 0], to: [0, 6.6, 0], radius: 1.4, collide: 0, color: "#6f6a60"}
  # the piston and piston-rod, sliding along the cylinder's axis; the rod's end is the crank-pin's bearing
  - id: P
    shape: part
    pos: [0, 0, -25.0000]
    mount: Cy
    density: 7800
    color: "#b8ad96"
    pieces:
      - {kind: poly, points: [[-7.2000, -26.0000], [7.2000, -26.0000], [7.2000, -24.0000], [-7.2000, -24.0000]], y: [-2.0, 0.4], collide: 0}
      - {kind: rod, from: [0.0000, -0.8, -25.0000], to: [0.0000, -0.8, -58.6000], radius: 0.7, collide: 0}
      - {kind: poly, points: [[-1.8000, -61.8000], [1.8000, -61.8000], [1.8000, -57.4000], [-1.8000, -57.4000]], y: [-1.2, -0.4], collide: 0}
      - {kind: band, center: [0.0000, -60.0000], r: [0.62, 1.4], a: [0, 6.2832], y: [-1.25, -0.35], slices: 36, collide: 1}
joints:
  - {id: j_K, type: hinge, body: K, axis: [0, -1, 0], damping: 0.0005}
  - {id: j_C, type: hinge, body: Cy, axis: [0, -1, 0], damping: 0.002}
  - {id: j_z, type: slide, body: P, axis: [0, 0, 1], damping: 0.05, range: [-1, 21]}
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 crank, through the piston-rod, draws the piston the length of its stroke, twice the crank's 10 cm ...
  - {type: amplitude, joint: j_z, min: 0.098, max: 0.102, settle_s: 0.5, window_s: 7.0}
  # ... and the cylinder, pulled to and fro by the rod, swings like a pendulum on its trunnions to follow the
  # crank-pin, asin(10/50) = 0.201 radian each way
  - {type: amplitude, joint: j_C, min: 0.196, max: 0.206, settle_s: 0.5, window_s: 7.0}
  - {type: penetration, max: 0.0003, settle_s: 0.2}
camera: {target: [0, 0, -43.7], position: [0, -235, -37], fov: 30}
display:
  output: j_z
  labels: {j_K: Crank (driver), j_C: Cylinder swinging on its trunnions, j_z: Piston and piston-rod}

