это код:
import numpy as np
def f_func(state,time,cd,mass,rho,A):
"""Calculate the differential of state vector as a function of time
Args:
state (list): the state vector at time t
time (float): the time t
cd (float): the dimensionless drag coefficient
mass (float): mass of the object in kg
rho (float): density of air (kg/m3)
A (float): cross-sectional area of object (kg)
Returns:
(list): the differential of the state vector at time t
"""
# defensive program - check shape of state vector
assert len(state)==2, "Expected length 2 state vector"
vy,y = state
# YOUR CODE HERE
X = np.array([[vy],[y]])
# we know d**2 y / d t**2 = a = -g + 1/(2mass)*(cd*rho*A*vy**2)
d2ydt2 = -g + (1/(2*mass))*(cd*rho*A*vy**2)
a = d2ydt2
# WE KNOW d y / d t = vy
dXdt = np.array([[-g + (1/(2*mass))*(cd*rho*A*(vy)**2)],[vy]])
return dXdt
Проверено на соответствие:
from nose.tools import assert_equal, assert_almost_equal
a,vy = f_func([0.,78.],0.0,0.5,1,1.2,1)
assert_almost_equal(a, -9.8)
assert_almost_equal(vy, 0.0)
a,vy = f_func([-2.,78.],0.0,0.5,1,1.2,1)
assert_almost_equal(a,-8.6)
assert_almost_equal(vy,-2)
'''
Сообщение об ошибке, которое я не понимаю:
type numpy.ndarray doesn't define __round__ method (error from line 6)