# SecondOrder ODEProblem 二阶导数常微分问题

## 介绍

\frac{du}{dt} = velocity

\frac{dv}{dt} = acceleration

\frac{d^2u}{dt^2} = acceleration

\frac{d^2u}{dt^2} = f(du, u, p, t)

## 描述问题

f(du, u, p, t) = -g
f(du, u, p, t) = -g


g = 9.8067

• du_begin 初始的速度，既向上抛出的速度为 10m/s
• u_begin 初始的位置，既抛出时y的位置为 0m
• tspan 时间的间隔为 [0.0, 2.0] 0 - 2 秒之内

prob = SecondOrderODEProblem(f, du_begin, u_begin, tspan)


## 解决问题

sol = solve(prob)


plot(sol)


# SecondOrder ODEProblem 抛球问题

## 描述问题

\frac{d^2u}{dt^2} = acceleration

\frac{d^2u}{dt^2} = f(du, u, p, t) = [0, -g]

\cos \theta = \frac{\text{adjacent}}{\text{hypotenuse}} = \frac{vx}{v}
\sin \theta = \frac{\text{opposite}}{\text{hypotenuse}} = \frac{vy}{v}

• v_begin 抛出速度为 100 m/s
• theta 抛出的角度为 \frac{\pi}{4}
• du_begin 抛出的速度向量为 [cos(theta) * v_begin, sin(theta) * v_begin]
• u_begin 抛出的位置为 [0.0, 0.0]
• tspan 时间间隔为 [0.0, 20.0]

prob = SecondOrderODEProblem(f, du_begin, u_begin, tspan)


## 解决问题

sol = solve(prob)


plot(sol,
legend = (0.15, 0.85),
linewidth = 2,
title = "Projectile Motion (All Values)",
xaxis = "Time in Seconds",
yaxis = "Velocity (m/s) | Position(m)",
labels = ["x Velocity" "y Velocity" "x Position" "y Position"],
formatter = :plain,
widen = true,
xlims = (0.0, 20.0),
ylims = (-500.0, 1500.0))


2 个赞