Reputation: 1
I would like some help on calculating how a function needs to use the trapezoid method.
The required data are:
import numpy as np
P=np.array([0.0,150,300,450,600,750,900,1050,1200,1350,1500,1650,1800,1950,2100,2250,2400,2550,2700,2850,3000,3150])
mi_g=np.array([0.0,0.01238,0.01254,0.01274,0.01303,0.01329,0.0136,0.01387,0.01428,0.01451,0.01485,0.0152,0.01554,0.01589,0.0163,0.01676,0.01721,0.01767,0.0183,0.01862,0.01911,0.01961])
z=np.array([0.0,0.9856,0.9717,0.9582,0.9453,0.9332,0.9218,0.9112,0.9016,0.8931,0.8857,0.8795,0.8745,0.8708,0.8684,0.8671,0.8671,0.8683,0.8705,0.8738,0.8780,0.8830])
dP=150
I can insert the trapezoidal method as follows:
for i in range(len(P)):
f = (2*P[i-1]/(mi_g[i-1]*z[i-1]))/2*dP+(2*P[i]/(mi_g[i]*z[i]))/2*dP
print(f)
Some of the data generated are: 1844001.11, 5537030.55, 92222431.64
I would like each generated data to be summed as follows:
mp1=1844001.11+5537030.55=7381032, mp2=5537030.55+92222431.64=16603463.
But I couldn't find a viable solution.
Upvotes: 0
Views: 133