MARTIAN DINGER
MARTIAN DINGER
Differential Equations
Differential Equations
In[]:=
eqs={x''[t]-cdragx'[t]Sqrt[(x'[t]^2+y'[t]^2)/m],y''[t]-gmars-cdragy'[t]Sqrt[(y'[t]^2+y'[t]^2)/m],WhenEvent[y[t]0,endt=t;dist=x[t]]};inits={x'[0]v0Cos[th0],y'[0]v0Sin[th0],x[0]0,y[0]y0};
Numeric Constants
Numeric Constants
110 mph, half a meter off the ground contact, CD=0.003 (????)
110 mph, half a meter off the ground contact, =0.003 (????)
C
D
In[]:=
const=v0QuantityMagnitude,"Meters""Seconds",y0.5(*m*),cdrag->.3*.003*.075^2(*kg/m*),gmars3.71(*m/s^2*),m.145(*kilograms*)
Out[]=
{v049.1744,y00.5,cdrag5.0625×,gmars3.71,m0.145}
-6
10
Simulation
Simulation
In[]:=
numeqs=Join[eqs,inits]/.const;
In[]:=
tf=30;(*secondstorun*)
In[]:=
sol=ParametricNDSolve[numeqs,{x,y},{t,0,tf},{th0}]
Out[]=
x
ParametricFunction
,yParametricFunction
Visualization
Visualization
In[]:=
Manipulate[Grid[{{Plot[Evaluate[{x[angle][t],y[angle][t]}/.sol],{t,0,endt},PlotLabels{"x","y"},PlotLabel"Horizontal and Vertical Position over Time",ImageSize500],SpanFromLeft,SpanFromLeft},{Row[{"Flight time: ",Dynamic@endt}],Row[{"Launch Angle: ",angle*180/Pi}],Row[{"Distance: ",Dynamic@UnitConvert[Quantity[dist,"Meters"],"Feet"]}]}}],{{angle,Pi/4,"Launch Angle (rads)"},Pi/10,Pi/3},SaveDefinitionsTrue]
Out[]=
Sanity check (Earth)
Differential Equations
Differential Equations
In[]:=
eqs={x''[t]-cdragx'[t]Sqrt[(x'[t]^2+y'[t]^2)/m],y''[t]-gmars-cdragy'[t]Sqrt[(y'[t]^2+y'[t]^2)/m],WhenEvent[y[t]0,endt=t;dist=x[t]]};inits={x'[0]v0Cos[th0],y'[0]v0Sin[th0],x[0]0,y[0]y0};
Earth Numeric Constants
Earth Numeric Constants
In[]:=
earthconst=v0QuantityMagnitude,"Meters""Seconds",y0.5,cdrag->.3*1.12*.075^2,gmars9.8,m.145
Out[]=
{v049.1744,y00.5,cdrag0.00189,gmars9.8,m0.145}
Simulation
Simulation
In[]:=
earthnumeqs=Join[eqs,inits]/.earthconst;
In[]:=
tf=30;(*secondstorun*)
In[]:=
earthsol=ParametricNDSolve[earthnumeqs,{x,y},{t,0,tf},{th0}]
Out[]=
x
ParametricFunction
,yParametricFunction
Visualization
Visualization
In[]:=
Grid[{{Plot[Evaluate[{x[Pi/4][t],y[Pi/4][t]}/.earthsol],{t,0,endt},PlotLabels{"x","y"},PlotLabel"Horizontal and Vertical Position over Time",ImageSize500],SpanFromLeft,SpanFromLeft},{Row[{"Flight time: ",endt}],Row[{"Launch Angle: ",Pi/4*180/Pi}],Row[{"Distance: ",UnitConvert[Quantity[dist,"Meters"],"Feet"]}]}}]
Out[]=
Flight time: 6.04717 | Launch Angle: 45 | Distance: |