Projectile motion plot with odeint

In summary, the conversation discusses the use of the numpy and scipy libraries to solve an ODE and plot the results. The code includes the definition of initial conditions, the use of the odeint function, and the plotting of the results. The question asked is about the values of dx/dt, dy/dt, and dv/dt and how they should be determined.
  • #1
nobodyhere
2
0
Homework Statement
Im a little stuck here.

I need to make a plot that shows the trajectory in the x,y plane of an object of mass m launched at an angle of 𝜃. The equation of motion of the projectile with atmospheric drag (at low enough speeds that no turbulence is created) is:

m(dv/dt)=−mgy−cv

where v(t)=(vx(t),vy(t)) is the projectile velocity at time t. The constant c characterizes the atmospheric friction. (As an aside, if the motion of the projectile is fast enough that turbulence is created, the friction term changes to −bv^2). We will integrate the equation of motion numerically in this project. However, in this case, an analytic solution is possible. If we call r(t)=(x(t),y(t)) the position of the projectile at time t, the equation of motion can be integrated to give:

x(t)=(v0vT)/g*(1−e^(gt/vT))cos(θx(t))

y(t)=vT*g(vT+v0sin(θ))(1−e^(gt/vT))−vTt

where vT=(mg)/c is the terminal velocity, and v0 is the initial speed.

I need to implement a numerical solution of the differential equation with odeint() and compare the trajectory you find to the analytic solution above.

Use the following parameters and initial conditions:

𝑐 = 0.65 kg/s,
𝑔 = 9.81 m/s2,
𝑚 = 0.1 kg,
𝑣0 = 10 m/s,
𝜃 = 50 above the horizontal,
The questions you need to consider are:

What is the distance 𝑑 to impact?
What is the maximum height, ℎ, reached?
What is the time of flight, 𝑇?
What is the velocity, 𝑣 at the impact point
So far I have the following but I don't know what to put for dx/dt, dy/dt, dv/dt
Relevant Equations
m(dv/dt)=−mgy−cv

x(t)=(v0vT)/g*(1−e^(gt/vT))cos(θx(t))

y(t)=vT*g(vT+v0sin(θ))(1−e^(gt/vT))−vTt
Python:
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
c=0.65
g=9.81 # gravitational force on earth
angle=50 # angle at which projectile is launched
m=0.1
#returning dx/dt, dy/dt, dv/dt as an array
def model(yaf,t):
    x=yaf[0] # x position is first element of yaf
    y=yaf[1] # y position is second element of yaf
    v=yaf[2] # velocity is third element of yaf
    return np.array([dx/dt, dy/dt, dv/dt])

t0=0 # initial condition for time
tmax=20 # max time
steps=20 # numer of steps

# time points
t = np.linspace(0,tmax, steps)

#initial conditions for x position, y position and velocity
initial=[0,0,10]

# solve ODE
y = odeint(model,initial,t)
print(y)

# plot results
plt.plot(t,y)
plt.show()
 
Last edited:
Physics news on Phys.org
  • #2
What is your question ?

"I don't know what to put for dx/dt, dy/dt, dv/dt" You want to put some values for this terms? I did not understand the question
 

FAQ: Projectile motion plot with odeint

What is projectile motion plot with odeint?

Projectile motion plot with odeint is a mathematical model used to describe the motion of a projectile (such as a thrown ball or a bullet) in a gravitational field. It uses the odeint function in Python to solve the differential equations that govern the motion of the projectile.

How does odeint work in projectile motion plot?

Odeint is a function in Python's scipy library that integrates a system of ordinary differential equations (ODEs). In projectile motion plot, it is used to solve the equations of motion for the projectile, taking into account the effects of gravity and air resistance.

What are the variables in a projectile motion plot with odeint?

The variables in a projectile motion plot with odeint include the initial position and velocity of the projectile, the acceleration due to gravity, and the drag coefficient of the object. These variables are used to solve the differential equations and plot the trajectory of the projectile.

How accurate is projectile motion plot with odeint?

The accuracy of projectile motion plot with odeint depends on the values of the variables used in the model. As long as the initial conditions and physical parameters are accurately measured, the model can provide a fairly accurate representation of the projectile's motion.

What are some real-life applications of projectile motion plot with odeint?

Projectile motion plot with odeint has many practical applications, such as in ballistic missile trajectories, sports science (e.g. analyzing the trajectory of a thrown baseball), and engineering (e.g. designing a projectile for a specific range and speed). It is also used in physics classrooms to demonstrate the principles of projectile motion.

Similar threads

Replies
6
Views
1K
Replies
3
Views
2K
Replies
3
Views
2K
Replies
3
Views
1K
Replies
4
Views
1K
Replies
6
Views
2K
Replies
6
Views
2K
Replies
2
Views
2K
Back
Top