# No. 418 (Brown 1868): "Buchanan & Righter's patent slide-valve motion. Valve, A, is attached to lower end of rod, B, and free to slide horizontally on valve-seat. Upper end of rod, B, is attached to a pin which slides in vertical slots, and a roller, C, attached to the said rod, slides in two suspended and vertically adjustable arcs, D. This arrangement is intended to prevent the valve from being pressed with too great force against its seat by the pressure of steam, and to relieve it of friction."
#
# Model (cm, Brown's section across the steam-chest, gravity on). The valve A is moved to and fro on its seat by its stem (the one driven joint, the
# eccentric's stroke) through a buckle in which it is free up and down; it stands for the steam's load on it by its weight. Its pin carries the
# lower end of the rod B; the rod's head pin runs in vertical slots, and the roller C on the rod runs in a slot in each of the two arcs D, which
# hang from the chest's cover and are set for height. With the head pin kept upright over the valve and the valve's pin kept level, the roller's
# path is an ellipse (semi-axes 7 and 6 cm, a trammel); the arcs' slots follow it and are set so the valve rides 1 mm clear of the seat:
# the load on the valve goes up the rod to the roller and into the arcs, not onto the seat. Generator: opencode-runs/batch13/gen418.py.
number: 418
slug: buchanan-righters-slide-valve-motion
name: Buchanan & Righter's slide-valve motion
brown: "Buchanan & Righter's patent slide-valve motion. Valve, A, is attached to lower end of rod, B, and free to slide horizontally on valve-seat. Upper end of rod, B, is attached to a pin which slides in vertical slots, and a roller, C, attached to the said rod, slides in two suspended and vertically adjustable arcs, D. This arrangement is intended to prevent the valve from being pressed with too great force against its seat by the pressure of steam, and to relieve it of friction."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  duration_s: 8
  floor: false
bodies:
  - id: stem
    shape: part
    pos: [0, 0, 0.9]
    mass: 0.4
    color: "#6f6a60"
    pieces:
      - {kind: poly, points: [[-3.0, 0.44999999999999996], [3.0, 0.44999999999999996], [3.0, 1.35], [-3.0, 1.35]], y: [-2.3, -1.8], color: "#6f6a60"}   # the valve's buckle on the stem: the valve is free up and down in it
      - {kind: rod, from: [3.0, -2.05, 0.9], to: [12.5, -2.05, 0.9], radius: 0.3, color: "#6f6a60"}   # the valve-stem, from the eccentric
  - id: valve
    shape: part
    pos: [0, 0, 2.7]
    mount: stem
    mass: 3
    friction: 0.3
    color: "#b8ad97"
    pieces:
      - {kind: poly, points: [[-3.4, 0.1], [3.4, 0.1], [3.0, 1.7000000000000002], [-3.0, 1.7000000000000002]], y: [-1.8, 1.8], collide: 1}   # the valve A on its seat
      - {kind: poly, points: [[-1.1, 1.7000000000000002], [1.1, 1.7000000000000002], [1.1, 3.1], [-1.1, 3.1]], y: [-0.9, 0.9]}   # its lug for the rod's pin
  - id: rod
    shape: part
    pos: [0, 0, 2.7]
    mount: valve
    mass: 0.2
    friction: 0.1
    color: "#8f8a80"
    pieces:
      - {kind: poly, points: [[-0.45, 2.7], [0.45, 2.7], [0.45, 15.7], [-0.45, 15.7]], y: [-0.3, 0.3]}   # the rod B
      - {kind: disc, center: [0, 2.7], radius: 0.8, inner: 0.3, y: [-0.35, 0.35]}
      - {kind: disc, center: [0, 8.7], radius: 0.95, y: [-0.4, 0.4]}
      - {kind: disc, center: [0, 15.7], radius: 0.9, y: [-0.35, 0.35]}
      - {kind: disc, center: [0, 15.7], radius: 0.45, y: [-1.4, 1.4], collide: 1, color: "#5a564e"}   # the head pin, in the vertical slots
  - id: roller
    shape: part
    pos: [0, 0, 8.7]
    mount: rod
    mass: 0.05
    friction: 0.5
    color: "#5a564e"
    pieces:
      - {kind: disc, center: [0, 8.7], radius: 0.7, y: [-1.55, -0.6], collide: 1}   # the roller C (one each side of the rod)
      - {kind: disc, center: [0, 8.7], radius: 0.7, y: [0.6, 1.55], collide: 1}
      - {kind: disc, center: [0, 8.7], radius: 0.3, y: [-1.55, 1.55]}
  - id: arcs
    shape: part
    pos: [0, 0, 0]
    fixed: true
    friction: 0.5
    color: "#a89a7e"
    pieces:
      - {kind: poly, points: [[-1.4953, 7.1318], [-1.3491, 7.1635], [-1.4899, 7.8492], [-1.6516, 7.8141]], y: [-1.6, -0.55], collide: 2}   # the arcs D: the slot's lower edge, that carries the roller
      - {kind: poly, points: [[-1.4953, 7.1318], [-1.3491, 7.1635], [-1.4899, 7.8492], [-1.6516, 7.8141]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[-1.3491, 7.1635], [-1.2019, 7.192], [-1.3271, 7.8807], [-1.4899, 7.8492]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[-1.3491, 7.1635], [-1.2019, 7.192], [-1.3271, 7.8807], [-1.4899, 7.8492]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[-1.2019, 7.192], [-1.0538, 7.2172], [-1.1634, 7.9086], [-1.3271, 7.8807]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[-1.2019, 7.192], [-1.0538, 7.2172], [-1.1634, 7.9086], [-1.3271, 7.8807]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[-1.0538, 7.2172], [-0.9048, 7.2391], [-0.9988, 7.9328], [-1.1634, 7.9086]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[-1.0538, 7.2172], [-0.9048, 7.2391], [-0.9988, 7.9328], [-1.1634, 7.9086]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[-0.9048, 7.2391], [-0.7551, 7.2577], [-0.8334, 7.9533], [-0.9988, 7.9328]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[-0.9048, 7.2391], [-0.7551, 7.2577], [-0.8334, 7.9533], [-0.9988, 7.9328]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[-0.7551, 7.2577], [-0.6048, 7.2729], [-0.6675, 7.9701], [-0.8334, 7.9533]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[-0.7551, 7.2577], [-0.6048, 7.2729], [-0.6675, 7.9701], [-0.8334, 7.9533]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[-0.6048, 7.2729], [-0.454, 7.2847], [-0.501, 7.9832], [-0.6675, 7.9701]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[-0.6048, 7.2729], [-0.454, 7.2847], [-0.501, 7.9832], [-0.6675, 7.9701]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[-0.454, 7.2847], [-0.3029, 7.2932], [-0.3342, 7.9925], [-0.501, 7.9832]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[-0.454, 7.2847], [-0.3029, 7.2932], [-0.3342, 7.9925], [-0.501, 7.9832]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[-0.3029, 7.2932], [-0.1515, 7.2983], [-0.1672, 7.9981], [-0.3342, 7.9925]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[-0.3029, 7.2932], [-0.1515, 7.2983], [-0.1672, 7.9981], [-0.3342, 7.9925]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[-0.1515, 7.2983], [0.0, 7.3], [0.0, 8.0], [-0.1672, 7.9981]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[-0.1515, 7.2983], [0.0, 7.3], [0.0, 8.0], [-0.1672, 7.9981]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[0.0, 7.3], [0.1515, 7.2983], [0.1672, 7.9981], [0.0, 8.0]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[0.0, 7.3], [0.1515, 7.2983], [0.1672, 7.9981], [0.0, 8.0]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[0.1515, 7.2983], [0.3029, 7.2932], [0.3342, 7.9925], [0.1672, 7.9981]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[0.1515, 7.2983], [0.3029, 7.2932], [0.3342, 7.9925], [0.1672, 7.9981]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[0.3029, 7.2932], [0.454, 7.2847], [0.501, 7.9832], [0.3342, 7.9925]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[0.3029, 7.2932], [0.454, 7.2847], [0.501, 7.9832], [0.3342, 7.9925]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[0.454, 7.2847], [0.6048, 7.2729], [0.6675, 7.9701], [0.501, 7.9832]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[0.454, 7.2847], [0.6048, 7.2729], [0.6675, 7.9701], [0.501, 7.9832]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[0.6048, 7.2729], [0.7551, 7.2577], [0.8334, 7.9533], [0.6675, 7.9701]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[0.6048, 7.2729], [0.7551, 7.2577], [0.8334, 7.9533], [0.6675, 7.9701]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[0.7551, 7.2577], [0.9048, 7.2391], [0.9988, 7.9328], [0.8334, 7.9533]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[0.7551, 7.2577], [0.9048, 7.2391], [0.9988, 7.9328], [0.8334, 7.9533]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[0.9048, 7.2391], [1.0538, 7.2172], [1.1634, 7.9086], [0.9988, 7.9328]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[0.9048, 7.2391], [1.0538, 7.2172], [1.1634, 7.9086], [0.9988, 7.9328]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[1.0538, 7.2172], [1.2019, 7.192], [1.3271, 7.8807], [1.1634, 7.9086]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[1.0538, 7.2172], [1.2019, 7.192], [1.3271, 7.8807], [1.1634, 7.9086]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[1.2019, 7.192], [1.3491, 7.1635], [1.4899, 7.8492], [1.3271, 7.8807]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[1.2019, 7.192], [1.3491, 7.1635], [1.4899, 7.8492], [1.3271, 7.8807]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[1.3491, 7.1635], [1.4953, 7.1318], [1.6516, 7.8141], [1.4899, 7.8492]], y: [-1.6, -0.55], collide: 2}
      - {kind: poly, points: [[1.3491, 7.1635], [1.4953, 7.1318], [1.6516, 7.8141], [1.4899, 7.8492]], y: [0.55, 1.6], collide: 2}
      - {kind: poly, points: [[-1.9911, 9.2957], [-1.7956, 9.3382], [-1.9324, 10.0043], [-2.143, 9.9585]], y: [-1.6, -0.55]}   # and its upper edge
      - {kind: poly, points: [[-1.9911, 9.2957], [-1.7956, 9.3382], [-1.9324, 10.0043], [-2.143, 9.9585]], y: [0.55, 1.6]}
      - {kind: poly, points: [[-1.7956, 9.3382], [-1.599, 9.3762], [-1.7206, 10.0453], [-1.9324, 10.0043]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[-1.7956, 9.3382], [-1.599, 9.3762], [-1.7206, 10.0453], [-1.9324, 10.0043]], y: [0.55, 1.6]}
      - {kind: poly, points: [[-1.599, 9.3762], [-1.4013, 9.4098], [-1.5078, 10.0815], [-1.7206, 10.0453]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[-1.599, 9.3762], [-1.4013, 9.4098], [-1.5078, 10.0815], [-1.7206, 10.0453]], y: [0.55, 1.6]}
      - {kind: poly, points: [[-1.4013, 9.4098], [-1.2028, 9.439], [-1.2941, 10.1129], [-1.5078, 10.0815]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[-1.4013, 9.4098], [-1.2028, 9.439], [-1.2941, 10.1129], [-1.5078, 10.0815]], y: [0.55, 1.6]}
      - {kind: poly, points: [[-1.2028, 9.439], [-1.0035, 9.4637], [-1.0796, 10.1395], [-1.2941, 10.1129]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[-1.2028, 9.439], [-1.0035, 9.4637], [-1.0796, 10.1395], [-1.2941, 10.1129]], y: [0.55, 1.6]}
      - {kind: poly, points: [[-1.0035, 9.4637], [-0.8036, 9.484], [-0.8645, 10.1612], [-1.0796, 10.1395]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[-1.0035, 9.4637], [-0.8036, 9.484], [-0.8645, 10.1612], [-1.0796, 10.1395]], y: [0.55, 1.6]}
      - {kind: poly, points: [[-0.8036, 9.484], [-0.6031, 9.4997], [-0.6488, 10.1782], [-0.8645, 10.1612]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[-0.8036, 9.484], [-0.6031, 9.4997], [-0.6488, 10.1782], [-0.8645, 10.1612]], y: [0.55, 1.6]}
      - {kind: poly, points: [[-0.6031, 9.4997], [-0.4023, 9.511], [-0.4327, 10.1903], [-0.6488, 10.1782]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[-0.6031, 9.4997], [-0.4023, 9.511], [-0.4327, 10.1903], [-0.6488, 10.1782]], y: [0.55, 1.6]}
      - {kind: poly, points: [[-0.4023, 9.511], [-0.2012, 9.5177], [-0.2164, 10.1976], [-0.4327, 10.1903]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[-0.4023, 9.511], [-0.2012, 9.5177], [-0.2164, 10.1976], [-0.4327, 10.1903]], y: [0.55, 1.6]}
      - {kind: poly, points: [[-0.2012, 9.5177], [0.0, 9.52], [0.0, 10.2], [-0.2164, 10.1976]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[-0.2012, 9.5177], [0.0, 9.52], [0.0, 10.2], [-0.2164, 10.1976]], y: [0.55, 1.6]}
      - {kind: poly, points: [[0.0, 9.52], [0.2012, 9.5177], [0.2164, 10.1976], [0.0, 10.2]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[0.0, 9.52], [0.2012, 9.5177], [0.2164, 10.1976], [0.0, 10.2]], y: [0.55, 1.6]}
      - {kind: poly, points: [[0.2012, 9.5177], [0.4023, 9.511], [0.4327, 10.1903], [0.2164, 10.1976]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[0.2012, 9.5177], [0.4023, 9.511], [0.4327, 10.1903], [0.2164, 10.1976]], y: [0.55, 1.6]}
      - {kind: poly, points: [[0.4023, 9.511], [0.6031, 9.4997], [0.6488, 10.1782], [0.4327, 10.1903]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[0.4023, 9.511], [0.6031, 9.4997], [0.6488, 10.1782], [0.4327, 10.1903]], y: [0.55, 1.6]}
      - {kind: poly, points: [[0.6031, 9.4997], [0.8036, 9.484], [0.8645, 10.1612], [0.6488, 10.1782]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[0.6031, 9.4997], [0.8036, 9.484], [0.8645, 10.1612], [0.6488, 10.1782]], y: [0.55, 1.6]}
      - {kind: poly, points: [[0.8036, 9.484], [1.0035, 9.4637], [1.0796, 10.1395], [0.8645, 10.1612]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[0.8036, 9.484], [1.0035, 9.4637], [1.0796, 10.1395], [0.8645, 10.1612]], y: [0.55, 1.6]}
      - {kind: poly, points: [[1.0035, 9.4637], [1.2028, 9.439], [1.2941, 10.1129], [1.0796, 10.1395]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[1.0035, 9.4637], [1.2028, 9.439], [1.2941, 10.1129], [1.0796, 10.1395]], y: [0.55, 1.6]}
      - {kind: poly, points: [[1.2028, 9.439], [1.4013, 9.4098], [1.5078, 10.0815], [1.2941, 10.1129]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[1.2028, 9.439], [1.4013, 9.4098], [1.5078, 10.0815], [1.2941, 10.1129]], y: [0.55, 1.6]}
      - {kind: poly, points: [[1.4013, 9.4098], [1.599, 9.3762], [1.7206, 10.0453], [1.5078, 10.0815]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[1.4013, 9.4098], [1.599, 9.3762], [1.7206, 10.0453], [1.5078, 10.0815]], y: [0.55, 1.6]}
      - {kind: poly, points: [[1.599, 9.3762], [1.7956, 9.3382], [1.9324, 10.0043], [1.7206, 10.0453]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[1.599, 9.3762], [1.7956, 9.3382], [1.9324, 10.0043], [1.7206, 10.0453]], y: [0.55, 1.6]}
      - {kind: poly, points: [[1.7956, 9.3382], [1.9911, 9.2957], [2.143, 9.9585], [1.9324, 10.0043]], y: [-1.6, -0.55]}
      - {kind: poly, points: [[1.7956, 9.3382], [1.9911, 9.2957], [2.143, 9.9585], [1.9324, 10.0043]], y: [0.55, 1.6]}
      - {kind: poly, points: [[-3.408, 7.0964], [-2.108, 7.0964], [-2.108, 9.9964], [-3.408, 9.9964]], y: [-1.6, 1.6]}   # the arcs' ends
      - {kind: poly, points: [[2.108, 7.0964], [3.408, 7.0964], [3.408, 9.9964], [2.108, 9.9964]], y: [-1.6, 1.6]}
      - {kind: rod, from: [-2.808, -1.9, 9.9964], to: [-2.808, -1.9, 19.6], radius: 0.25}   # the hangers (screwed for height)
      - {kind: rod, from: [2.808, -1.9, 9.9964], to: [2.808, -1.9, 19.6], radius: 0.25}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    friction: 0.3
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-12, -1.3], [12, -1.3], [12, 0], [-12, 0]], y: [-2.6, 2.6]}   # the cylinder's face and the valve-seat
      - {kind: poly, points: [[-6.5, -0.2], [6.5, -0.2], [6.5, 0], [-6.5, 0]], y: [-1.9, 1.9], collide: 2, color: "#a39d90"}
      - {kind: poly, points: [[-9.3, 0], [-8.3, 0], [-5.3, 20.5], [-6.3, 20.5]], y: [-2.6, 2.6], color: "#a39d90"}   # the steam-chest's walls
      - {kind: poly, points: [[8.3, 0], [9.3, 0], [6.3, 20.5], [5.3, 20.5]], y: [-2.6, 2.6], color: "#a39d90"}
      - {kind: poly, points: [[-6.3, 19.6], [6.3, 19.6], [6.3, 20.5], [-6.3, 20.5]], y: [-2.6, 2.6], color: "#a39d90"}
      - {kind: poly, points: [[-1.08, 13.7], [-0.48, 13.7], [-0.48, 19.6], [-1.08, 19.6]], y: [-1.4, 1.4], collide: 2}   # the vertical slots for the head pin
      - {kind: poly, points: [[0.48, 13.7], [1.08, 13.7], [1.08, 19.6], [0.48, 19.6]], y: [-1.4, 1.4], collide: 2}
joints:
  - {id: j_A, type: slide, body: stem, axis: [1, 0, 0], damping: 1}   # the valve-stem (driven)
  - {id: j_vz, type: slide, body: valve, axis: [0, 0, 1], damping: 2}   # the valve free up and down in its buckle (+ : up off the seat)
  - {id: j_B, type: hinge, body: rod, axis: [0, 1, 0], damping: 0.002}   # the rod B on the valve's pin
  - {id: j_C, type: hinge, body: roller, axis: [0, 1, 0], damping: 0.0005}   # the roller C
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_A, kind: velocity, rpm: 0, swing: {amplitude: 0.025, hz: 0.5}, kv: 200, max_torque: 200}
checks:
  - {type: position, joint: j_vz, min: -0.03, max: 0.03, settle_s: 0.5, window_s: 7}   # the valve rides at its set height (1 mm clear), never pressed down on the seat
  - {type: follow, out: j_B, in: j_A, expect: -7.7284, tol: 0.3091, min_r2: 0.99, settle_s: 0.5, window_s: 7}   # the rod swings on its head pin as the valve goes to and fro (asin(x / 13 cm); - : the valve to the right, the rod leans left)
  - {type: penetration, max: 0.002}
camera: {target: [0, 0, 8.0], position: [0, -80, 8.0], fov: 22}
display:
  output: j_vz
  labels: {j_A: "The valve-stem (driver)", j_vz: "The valve A's height", j_B: "The rod B", j_C: "The roller C"}
  proof: {label: "Arcs taken away", sub: "the valve drops onto its seat"}
