Python与物理学-计算阻力&;确定对象是否已达到终点速度

Python与物理学-计算阻力&;确定对象是否已达到终点速度,python,python-2.7,physics,Python,Python 2.7,Physics,我试图计算一个球体的阻力,如果它从建筑物上掉下来,程序会运行,但是方程是错误的。可能是我把这件事搞得太复杂了,但我现在被卡住了。。我想做的是确定球体在分配的时间内经过的距离(这是可行的),但我无法找到一种将阻力作为因素的方法。任何帮助都将不胜感激 import math height = float(raw_input("Enter the height of the building: ")) #meters weight = float(raw_input("Enter the weigh

我试图计算一个球体的阻力,如果它从建筑物上掉下来,程序会运行,但是方程是错误的。可能是我把这件事搞得太复杂了,但我现在被卡住了。。我想做的是确定球体在分配的时间内经过的距离(这是可行的),但我无法找到一种将阻力作为因素的方法。任何帮助都将不胜感激

import math

height = float(raw_input("Enter the height of the building: ")) #meters
weight = float(raw_input("Enter the weight of the sphere: ")) #weight of sphere in kilograms
mass = float(raw_input("Mass of the sphere: ")) #mass of the sphere
time = float(raw_input("Enter the time interval: ")) #determines how long to continue the experiment after the sphere has been dropped

# kilograms
#variables
velocity = math.sqrt(2) * height * weight #calculate the velocity
energy = 1 / 2 * mass * velocity ** 2 #kinetic energy
gravity = 9.81      #gravity
radius = 0.5       #radius of the sphere being dropped
volume = 4.3 * math.pi * radius ** 3 #calculate the volume
speed = gravity * time #determine the maximum speed in the time allotted
density = mass / volume #determine the density of the sphere
force = mass * gravity  #determine the force in newtons 
drag = gravity * density * speed ** 2 #calculate the drag
distance = .5 * gravity * time ** 2 #calculate the distance traveled

print "Force = {} Newtons".format(force)
print "The ball is", height - distance, "meters from the ground"
print "The maximum speed of the ball was:", speed
print "It would take the ball {} seconds to reach terminal velocity"#.format(None)
print "Density:", density
print "Drag: ", drag
print "Mass: ", mass
print "Volume: ", volume
print "Velocity: ", velocity

Python2.7默认为整数除法,因此

energy = 1 / 2 * mass * vellocity ** 2 
相当于

energy = (1 // 2) * mass * velocity ** 2 = 0 * mass * velocity ** 2 = 0
要默认为浮点除法,请在脚本顶部放置以下行:

from __future__ import division
或者简单地将
energy
写成:

energy = 0.5 * mass * velocity ** 2

Python 2.7默认为整数除法,因此
energy=1/2*mass*vellocity**2
相当于
energy=(1//2)*质量*速度**2=0*质量*速度**2=0
。在确定流体运动阻力的公式中,阻力系数可用
S*Cx
表示:
0.5*rho*S*Cx*速度**2
(其中
rho
为大气密度)。当
质量*重力==阻力
时达到终点速度。由于所有这些都与速度平方有关,积分需要一点数学知识;)相关:以及