This repository simulates a planar two-link rotating mechanism and computes the signed axial force in link AB for all geometry-motion combinations. It now supports a global gravity setting in scenarios.json, explicit gravity on/off labeling in all reports, and saved comparison exports for both gravity states.
run_assignment.py: command-line entry point for the full workflow.src/mechanism_assignment.py: scenario parsing, simulation, plotting, animation, and reporting.scenarios.json: example input with 5 geometry sets and 5 motion sets.MODEL_APPROACH.md: derivation, sign convention, and gravity-force model.output/: current generated outputs for the activescenarios.json.output_gravity_on/: saved reference export with gravity on.output_gravity_off/: saved reference export with gravity off.
python -m pip install -r requirements.txtThe input file is split into:
gravity: one global gravity configuration for the full rungeometry_scenarios: link lengths and point massesmotion_scenarios: angular velocities forABandBC
Example:
{
"gravity": {
"enabled": false,
"gravity_m_s2": 9.81
},
"geometry_scenarios": [
{
"name": "G1",
"length_ab_m": 1.0,
"length_bc_m": 0.6,
"mass_b_kg": 3.0,
"mass_c_kg": 1.0
}
],
"motion_scenarios": [
{
"name": "M1",
"omega_ab_rad_s": 2.0,
"omega_bc_clockwise_rad_s": 4.0
}
]
}Notes:
gravity.enabled: falseturns gravity off for the full scenario set.gravity.gravity_m_s2sets the gravity magnitude when gravity is enabled.- Gravity acts in the
-ydirection. omega_bc_clockwise_rad_sis provided as a positive clockwise magnitude and is applied internally with clockwise sign.
Default run:
python run_assignment.py --scenarios scenarios.json --output-dir output --steps 721Useful overrides:
python run_assignment.py --scenarios scenarios.json --output-dir output_gravity_off --steps 721 --gravity 0
python run_assignment.py --scenarios scenarios.json --output-dir output_gravity_on --steps 721 --gravity 9.81Flags:
--scenarios: path to the JSON input file. Default:scenarios.json--output-dir: destination folder for plots, animations, and reports. Default:output--steps: number of samples over one fullABrotation. Default:721--gravity: optional global gravity override inm/s^2. If omitted, the run uses the top-level JSON gravity setting. Use0to force gravity off.
Each run produces:
plots/*.png: one force-vs-angle plot per geometry-motion combinationall_combinations_grid.png: a compact comparison grid across all casessummary_metrics.csv: peak tension/compression per case, includinggravity_statusandgravity_m_s2engineering_insight.md: global extremes, gravity state, and a simple driver rankinganimations/*.gif: GIFs for the highest-tension and highest-compression cases
Gravity state is made explicit in:
- plot titles
- grid subplot titles
- GIF titles and overlays
summary_metrics.csvengineering_insight.md- terminal run summary
The repository currently includes three output folders:
output/: generated from the currentscenarios.jsonoutput_gravity_on/: saved comparison export with gravityON (9.810 m/s^2)output_gravity_off/: saved comparison export with gravityOFF
At the moment, the committed scenarios.json has:
"gravity": {
"enabled": false,
"gravity_m_s2": 9.81
}So the tracked output/ folder currently corresponds to the gravity-off case.
- Positive axial force means tension in link
AB. - Negative axial force means compression in link
AB. - The code applies gravity as a downward force vector
[0, -m g]. - With gravity toggled on, the axial-force result differs from the gravity-off case by the projection of that downward load onto the current
ABdirection.
output/engineering_insight.md: fastest high-level summary of the current runoutput/summary_metrics.csv: best machine-readable summary of all 25 casesoutput_gravity_on/engineering_insight.md: saved high-level summary for gravity onoutput_gravity_off/engineering_insight.md: saved high-level summary for gravity off
- length: meters
- mass: kilograms
- angular velocity: radians/second
- gravity: meters/second^2