1 Star 0 Fork 1

霍开拓/ComputationalPhysics

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
PHYS613 A8 Exercise5.9 ProjectileMotion.py 955 Bytes
一键复制 编辑 原始数据 按行查看 历史
Nick Crump 提交于 2015-10-14 20:32 . computational physics
"""
Created on Sat Nov 09 13:53:23 2013
PHYS 613, Assignment 8
Nick Crump
"""
# Exercise 5.9: Projectile Motion
"""
Implement the Runge-Kutta-Fehlberg method to solve the 1st-order
vector differential equation of projectile motion.
"""
import numpy as np
import ODEsolve as ode
import matplotlib.pyplot as plt
# function for projectile motion w/air resistance
# ***************************************************
def f(ti,IC):
g = 9.8
c = 0.1
vx = IC[0]
vy = IC[1]
vxy = (vx**2 + vy**2)**0.5
func = np.array([-c*vx*vxy, -g-c*vy*vxy])
return func
# ***************************************************
# set initial conditions as Vx0, Vy0
IC = [20, 0]
# call RKF45 method from my ODE solve module
t,s = ode.RKF45HO(f,IC,0,10,0.01,1e-5,stp=1)
# plot components of velocity
plt.plot(t,s[0],'b.-',label='$V_x$')
plt.plot(t,s[1],'r.-',label='$V_y$')
plt.xlabel('Time (sec)')
plt.ylabel('Velocity (m/s)')
plt.legend()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/huo-kaituo/ComputationalPhysics.git
git@gitee.com:huo-kaituo/ComputationalPhysics.git
huo-kaituo
ComputationalPhysics
ComputationalPhysics
master

搜索帮助