# No. 423 (Brown 1868): "Root's patent double-quadrant engine. This is on the same principle as 422; but two single-acting pistons, B, B,
# are used, and both connected with one crank, D. The steam is admitted to act on the outer sides of the two pistons alternately by means of one
# induction valve, a, and is exhausted through the space between the pistons. The piston and crank connections are such that the steam acts on
# each piston during about two-thirds of the revolution of the crank, and hence there are no dead points."
# Model (cm, Brown's section, no gravity; only the back half of the cut casing is drawn). Two quadrant pistons B, B are vanes on pivots at the
# casing's left (-8.2, 11.6) and right (8, 11.6), each sweeping a quadrant chamber closed on its outer side and open on its inner side to the
# exhaust space between them, where the crank-shaft D (0, 11.6) is. Each piston takes a rod from a pin on its inner face to the one
# crank-pin (2.8 cm crank): the left rod 7.9 cm from 9.9 cm out on the left piston, the right rod 8.1 cm from 9.65 cm out on the right.
# The steam (the one input) presses on the outer side of each piston in turn, 0.05 N m, let in by the crank's own position as the induction
# valve a would let it in (feet.timed on j_c: each piston for half a turn); the valve a is drawn but carries no motion. No fly-wheel: the two
# pistons' dead points fall at different places, so one always has a lever on the crank. The crank works against a load (0.0013 N m s).
# Generator: opencode-runs/batch13/gen423.py.
number: 423
slug: roots-double-quadrant-engine
name: Root's double-quadrant engine
brown: "Root's patent double-quadrant engine. This is on the same principle as 422; but two single-acting pistons, B, B, are used, and both connected with one crank, D. The steam is admitted to act on the outer sides of the two pistons alternately by means of one induction valve, a, and is exhausted through the space between the pistons. The piston and crank connections are such that the steam acts on each piston during about two-thirds of the revolution of the crank, and hence there are no dead points."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  duration_s: 10
  floor: false
  gravity: 0
bodies:
  - id: piston_l
    shape: part
    pos: [-8.2, 0, 11.6]
    density: 7800
    color: "#a39d90"
    pieces:
      - {kind: poly, points: [[-7.2824, 11.8409], [2.849, 18.4563], [2.521, 18.9587], [-7.6104, 12.3432]], y: [0, 1.6]}   # the left piston B, cut through
      - {kind: disc, center: [-8.2, 11.6], radius: 1.0, y: [0, 1.6], color: "#6f6a60"}
      - {kind: rod, from: [0.0894, 0.2, 17.0126], to: [0.0894, -1.1, 17.0126], radius: 0.3, color: "#5a564e"}   # its pin
  - id: rod_l
    shape: part
    pos: [0.0894, 0, 17.0126]
    mount: piston_l
    density: 7800
    color: "#b8ad97"
    pieces:
      - {kind: rod, from: [0.0894, -0.8, 17.0126], to: [1.5086, -0.8, 9.2411], radius: 0.3}   # the left rod
      - {kind: disc, center: [0.0894, 17.0126], radius: 0.65, inner: 0.3, y: [-1.05, -0.55]}
      - {kind: disc, center: [1.5086, 9.2411], radius: 0.65, inner: 0.3, y: [-1.05, -0.55]}
  - id: piston_r
    shape: part
    pos: [8, 0, 11.6]
    density: 7800
    color: "#a39d90"
    pieces:
      - {kind: poly, points: [[7.4859, 10.8027], [5.1264, 1.6004], [5.7076, 1.4513], [8.0671, 10.6537]], y: [0, 1.6]}   # the right piston B, cut through
      - {kind: disc, center: [8, 11.6], radius: 1.0, y: [0, 1.6], color: "#6f6a60"}
      - {kind: rod, from: [5.6033, 0.2, 2.2524], to: [5.6033, -1.7, 2.2524], radius: 0.3, color: "#5a564e"}
  - id: rod_r
    shape: part
    pos: [5.6033, 0, 2.2524]
    mount: piston_r
    density: 7800
    color: "#b8ad97"
    pieces:
      - {kind: rod, from: [5.6033, -1.4, 2.2524], to: [1.5086, -1.4, 9.2411], radius: 0.3}   # the right rod
      - {kind: disc, center: [5.6033, 2.2524], radius: 0.65, inner: 0.3, y: [-1.65, -1.15]}
      - {kind: disc, center: [1.5086, 9.2411], radius: 0.65, inner: 0.3, y: [-1.65, -1.15]}
  - id: crank
    shape: part
    pos: [0, 0, 11.6]
    density: 7800
    color: "#7d776c"
    pieces:
      - {kind: disc, center: [0, 11.6], radius: 0.8, y: [-2.3, 4.3], color: "#6f6a60"}   # the crank-shaft D
      - {kind: disc, center: [0, 11.6], radius: 3.6, y: [2.7, 4.2], color: "#8f8a80"}   # the crank-disc behind the casing (Brown's dotted circle)
      - {kind: poly, points: [[-0.5055, 11.2767], [1.0031, 8.9179], [2.014, 9.5644], [0.5055, 11.9233]], y: [-2.3, -1.85]}   # the crank
      - {kind: disc, center: [0, 11.6], radius: 0.8, y: [-2.3, -1.85]}
      - {kind: disc, center: [1.5086, 9.2411], radius: 0.6, y: [-2.3, -1.85]}
      - {kind: rod, from: [1.5086, -1.85, 9.2411], to: [1.5086, -0.5, 9.2411], radius: 0.3, color: "#5a564e"}   # the crank-pin, both rods on it
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[4.2391, 17.4593], [3.94, 18.0562], [3.6123, 18.6379], [3.2567, 19.203], [2.8741, 19.7502], [2.4654, 20.2782], [2.0316, 20.7857], [1.5736, 21.2715], [1.0926, 21.7346], [0.5897, 22.1737], [0.0661, 22.5879], [-0.4771, 22.9762], [-1.0384, 23.3377], [-1.6166, 23.6715], [-2.2104, 23.9769], [-2.8183, 24.253], [-3.4388, 24.4994], [-4.0706, 24.7153], [-4.7121, 24.9003], [-5.3619, 25.0539], [-6.0183, 25.1758], [-6.6799, 25.2657], [-7.3451, 25.3234], [-8.0122, 25.3487], [-8.6799, 25.3416], [-8.6589, 24.742], [-8.0204, 24.7488], [-7.3824, 24.7246], [-6.7462, 24.6694], [-6.1135, 24.5834], [-5.4857, 24.4668], [-4.8643, 24.3199], [-4.2508, 24.143], [-3.6466, 23.9365], [-3.0531, 23.7009], [-2.4717, 23.4368], [-1.9039, 23.1448], [-1.3509, 22.8255], [-0.8141, 22.4798], [-0.2946, 22.1085], [0.2062, 21.7123], [0.6871, 21.2923], [1.1471, 20.8495], [1.5851, 20.3849], [2, 19.8995], [2.3909, 19.3946], [2.7568, 18.8713], [3.0968, 18.3308], [3.4102, 17.7745], [3.6963, 17.2036]], y: [0, 2.0]}   # the left quadrant's arc,
      - {kind: poly, points: [[-8.2419, 12.7993], [-8.6799, 25.3416], [-9.2795, 25.3207], [-8.8415, 12.7783]], y: [0, 2.0]}   # and its outer side
      - {kind: poly, points: [[-1.8828, 6.4374], [-1.6269, 5.9745], [-1.3492, 5.5243], [-1.0506, 5.0877], [-0.7316, 4.6658], [-0.3929, 4.2595], [-0.0353, 3.8698], [0.3404, 3.4974], [0.7333, 3.1432], [1.1425, 2.8081], [1.5672, 2.4928], [2.0063, 2.198], [2.459, 1.9243], [2.9241, 1.6724], [3.4006, 1.4428], [3.8875, 1.2361], [4.3837, 1.0527], [4.888, 0.8931], [5.3992, 0.7576], [5.9164, 0.6464], [6.4382, 0.5599], [6.9636, 0.4983], [7.4912, 0.4616], [8.0201, 0.45], [8.5488, 0.4635], [8.5193, 1.0628], [8.019, 1.05], [7.5186, 1.061], [7.0193, 1.0957], [6.5223, 1.154], [6.0285, 1.2358], [5.5392, 1.341], [5.0554, 1.4693], [4.5783, 1.6203], [4.1088, 1.7938], [3.6481, 1.9894], [3.1972, 2.2066], [2.7572, 2.4449], [2.3289, 2.7039], [1.9133, 2.9829], [1.5115, 3.2812], [1.1243, 3.5983], [0.7525, 3.9334], [0.3971, 4.2857], [0.0588, 4.6545], [-0.2617, 5.039], [-0.5636, 5.4382], [-0.8462, 5.8513], [-1.1088, 6.2773], [-1.351, 6.7152]], y: [0, 2.0]}   # the right quadrant's arc,
      - {kind: poly, points: [[8.0591, 10.4015], [8.5488, 0.4635], [7.9496, 0.434], [7.4598, 10.3719]], y: [0, 2.0]}
      - {kind: disc, center: [5.6359, 17.1297], radius: 1.7, inner: 1.15, y: [0, 2.0]}   # the induction valve's chest
      - {kind: poly, points: [[5.0359, 18.6297], [6.2359, 18.6297], [6.2359, 20.1297], [5.0359, 20.1297]], y: [0, 2.0]}   # the steam-pipe
      - {kind: poly, points: [[4.3359, 20.1297], [6.9359, 20.1297], [6.9359, 20.6297], [4.3359, 20.6297]], y: [0, 2.0]}
      - {kind: disc, center: [5.6359, 17.1297], radius: 1.1, y: [0.2, 1.8], color: "#7d776c"}   # the valve a
      - {kind: poly, points: [[-9.8, 10], [-9.6, 5.5], [4.3837, 1.0527], [4.888, 0.8931], [5.3992, 0.7576], [5.9164, 0.6464], [6.4382, 0.5599], [6.9636, 0.4983], [7.4912, 0.4616], [8.0201, 0.45], [8.5488, 0.4635], [9.6, 5.5], [9.6, 10], [7.2359, 17.1297], [5.6359, 18.7297], [-0.4771, 22.9762], [-1.0384, 23.3377], [-1.6166, 23.6715], [-2.2104, 23.9769], [-2.8183, 24.253], [-3.4388, 24.4994], [-4.0706, 24.7153], [-4.7121, 24.9003], [-5.3619, 25.0539], [-6.0183, 25.1758], [-6.6799, 25.2657], [-7.3451, 25.3234], [-8.0122, 25.3487], [-8.6799, 25.3416]], y: [2.0, 2.5], color: "#bdb4a2"}   # the casing's back plate
      - {kind: poly, points: [[-13.5, -1], [13.5, -1], [13.5, 0], [-13.5, 0]], y: [-3.5, 3.0], color: "#bdb4a2"}   # the bed
      - {kind: poly, points: [[-12.5, 0], [12.5, 0], [10, 6], [-10, 6]], y: [2.5, 3.0], color: "#bdb4a2"}
joints:
  - {id: j_L, type: hinge, body: piston_l, axis: [0, -1, 0], range: [-0.0982, 0.7344], damping: 0.00005}   # the left piston (steam); + : anticlockwise as drawn; its range: the quadrant's ends
  - {id: j_rl, type: hinge, body: rod_l, axis: [0, -1, 0], damping: 0.00001}
  - {id: j_R, type: hinge, body: piston_r, axis: [0, -1, 0], range: [-0.7984, 0.0602], damping: 0.00005}   # the right piston (steam)
  - {id: j_rr, type: hinge, body: rod_r, axis: [0, -1, 0], damping: 0.00001}
  - {id: j_c, type: hinge, body: crank, axis: [0, -1, 0], damping: 0.0013}   # the crank D; + : anticlockwise as drawn
pins:
  - {id: pin_l, a: rod_l, b: crank, at: [1.5086, -0.8, 9.2411]}   # the left rod on the crank-pin
  - {id: pin_r, a: rod_r, b: crank, at: [1.5086, -1.4, 9.2411]}   # the right rod on the crank-pin
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_L, kind: feet, feet: {joints: [j_L, j_R], sign: [-1, -1], force: 0.05, timed: {joint: j_c, shape: sin, gain: 1, offset: 5.9586}}, max_torque: 0.1}
checks:
  - {type: monotonic, joint: j_c, direction: -1, max_back: 0.05, settle_s: 0.0, window_s: 9.5}   # from rest, with no fly-wheel, the crank goes one way only: no dead points
  - {type: turning, joint: j_c, direction: -1, min_mean: 4.0, min_fraction: 0.9, settle_s: 3.0, window_s: 6.5}
  - {type: amplitude, joint: j_L, min: 0.3456, max: 0.367, sustain: 0.95, settle_s: 3.0, window_s: 6.5}   # the left piston rocks through its quadrant (four-bar: 0.3563 rad)
  - {type: amplitude, joint: j_R, min: 0.3582, max: 0.3804, sustain: 0.95, settle_s: 3.0, window_s: 6.5}   # and the right (0.3693 rad)
  - {type: penetration, max: 0.002}
camera: {target: [0, 0, 11.0], position: [0, -95, 11.0], fov: 28}
display:
  output: j_c
  labels: {j_L: "Left piston B (steam)", j_R: "Right piston B (steam)", j_c: "Crank D", j_rl: "Left rod", j_rr: "Right rod"}
  proof: {label: "Rods off the crank-pin", sub: "the steam drives the pistons to their stops but the crank stands"}
