Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions ProjectileMotion.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
model ProjectileMotion
"Simple projectile motion model for testing"

// Parameters
parameter Real v0 = 20.0 "Initial velocity (m/s)";
parameter Real angle = 45.0 "Launch angle (degrees)";
parameter Real g = 9.81 "Gravitational acceleration (m/s^2)";
parameter Real m = 1.0 "Mass (kg)";

// State variables
Real x(start = 0.0) "Horizontal position (m)";
Real y(start = 0.0) "Vertical position (m)";
Real vx(start = v0 * cos(angle * 3.14159265359 / 180.0)) "Horizontal velocity (m/s)";
Real vy(start = v0 * sin(angle * 3.14159265359 / 180.0)) "Vertical velocity (m/s)";

equation
// Equations of motion
der(x) = vx;
der(y) = vy;
der(vx) = 0; // No horizontal acceleration
der(vy) = -g; // Gravitational acceleration downward

end ProjectileMotion;
Loading