# No. 315 (Brown 1868): "Conical pendulum, hung by a thin piece of round wire. Lower end connected with and driven in a circle by an arm attached to a vertical rotating spindle. The pendulum-rod describes a cone in its revolution."
#
# Model (cm, gravity on). The pendulum hangs from the bracket at the top on a little gimbal (two crossed pivots: what the thin round wire allows,
# a swing any way and no twist). Its rod runs 40 down, with the bob 34 down, and ends in a square pin 14 long. The pin stands in the slot of
# the arm, on the top of the vertical spindle below. The spindle is the one driven joint (56 turns a minute). The pin is free to slide
# out along the slot and up it, so the arm only carries the rod's end round; the pendulum flies out until gravity balances the spin, and the rod
# describes a cone. It is drawn 3 degrees aside at the start. Generator: opencode-runs/batch12/gen315.py.
number: 315
slug: conical-pendulum
name: Conical pendulum
brown: "Conical pendulum, hung by a thin piece of round wire. Lower end connected with and driven in a circle by an arm attached to a vertical rotating spindle. The pendulum-rod describes a cone in its revolution."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 100, duration_s: 20, floor: false}
bodies:
  - id: spindle
    shape: part
    pos: [0, 0, 0]
    mass: 0.4
    color: "#e4d9bf"
    pieces:
      - {kind: rod, from: [0, 0, 0], to: [0, 0, 15], radius: 0.8, collide: 0}   # the spindle
      - {kind: rod, from: [0, 0, 15], to: [0, 0, 18.9], radius: 1.0, collide: 0, color: "#a89a7e"}   # the arm's boss
      - {kind: rod, from: [34, -0.72, 17.3], to: [34, 0.72, 17.3], radius: 1.3, collide: 0, color: "#a89a7e"}   # the fork's closed end
      - {kind: poly, points: [[-1.0, 16], [34, 16], [34, 18.6], [-1.0, 18.6]], y: [0.42, 0.72], collide: 1, color: "#a89a7e"}   # the arm: one side of its slot
      - {kind: poly, points: [[-1.0, 16], [34, 16], [34, 18.6], [-1.0, 18.6]], y: [-0.72, -0.42], collide: 1, color: "#a89a7e"}   # the arm: the other side
  - id: gimbal
    shape: part
    pos: [0, 0, 60]
    mass: 0.01
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [-0.8, 0, 60], to: [0.8, 0, 60], radius: 0.25, collide: 0}   # the wire's top (a gimbal)
  - id: pendulum
    shape: part
    pos: [0, 0, 60]
    mount: gimbal
    mass: 0.5
    color: "#b8ad97"
    pieces:
      - {kind: rod, from: [0, 0, 60], to: [2.09344, 0, 20.05482], radius: 0.3, collide: 0}   # the pendulum-rod
      - {kind: rod, from: [1.70092, 0, 27.54454], to: [1.85793, 0, 24.54865], radius: 2.5, collide: 0, color: "#8f8a80"}   # the bob
      - {kind: poly, points: [[1.76768, 20.53843], [2.52655, 6.0583], [3.12573, 6.08971], [2.36686, 20.56983]], y: [-0.3, 0.3], collide: 2, color: "#b85c38"}   # the pin at the rod's lower end
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-35, -2.4], [12, -2.4], [12, -1.0], [-35, -1.0]], y: [-8, 8], collide: 0, color: "#b9b09c"}   # the base
      - {kind: rod, from: [0, 0, -1.0], to: [0, 0, 3.0], radius: 1.4, collide: 0, color: "#8f8a80"}   # the spindle's bearing
      - {kind: rod, from: [-32, 0, -1.0], to: [-32, 0, 62], radius: 0.8, collide: 0}   # the pillar
      - {kind: rod, from: [-32, 0, 62], to: [0, 0, 62], radius: 0.8, collide: 0}   # the bracket
      - {kind: rod, from: [0, 0, 62], to: [0, 0, 60.3], radius: 0.12, collide: 0, color: "#8f8a80"}   # the wire
joints:
  - {id: j_s, type: hinge, body: spindle, axis: [0, 0, 1], damping: 0.002}   # the one driven joint: the spindle; + : counter-clockwise seen from above
  - {id: j_px, type: hinge, body: gimbal, axis: [1, 0, 0], damping: 2e-05}   # the wire's swing about x (toward and from the eye)
  - {id: j_py, type: hinge, body: pendulum, axis: [0, 1, 0], damping: 2e-05}   # the wire's swing about y (left and right)
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_s, kind: velocity, rpm: 56, kv: 20, max_torque: 5}
checks:
  - {type: period, joint: j_px, expect_s: 1.07143, tol: 0.01, settle_s: 8, window_s: 10}   # the rod goes round once a turn of the spindle
  - {type: amplitude, joint: j_px, min: 0.5236, max: 0.68068, sustain: 0.95, settle_s: 8, window_s: 10}   # the cone's half-angle, seen as the swing about x
  - {type: amplitude, joint: j_py, min: 0.5236, max: 0.68068, sustain: 0.95, settle_s: 8, window_s: 10}   # and about y: a cone, not a swing in a plane
  - {type: penetration, max: 0.0005, settle_s: 0.5}
camera: {target: [-6.0, 0, 24.6], position: [-6.0, -144.0, 54.0], fov: 34}
display:
  output: j_px
  labels: {j_s: "Spindle and arm (driver)", j_px: "Pendulum: swing about x", j_py: "Pendulum: swing about y"}
  proof: {label: "Fork off the pin", sub: "the arm turns but the pendulum only swings in its plane"}

