Skip to content

Commit 71e4ccb

Browse files
ischoeglspeth
authored andcommitted
[samples] Use numpy.trapz instead of scipy version
Avoids DeprecationWarning: "'scipy.integrate.trapz' is deprecated in favour of 'scipy.integrate.trapezoid' and will be removed in SciPy 1.14.0".
1 parent b62d83b commit 71e4ccb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

samples/python/reactors/ic_engine.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import cantera as ct
1616
import numpy as np
1717

18-
from scipy.integrate import trapz
1918
import matplotlib.pyplot as plt
2019

2120
#########################################################################
@@ -253,13 +252,13 @@ def ca_ticks(t):
253252
######################################################################
254253

255254
# heat release
256-
Q = trapz(states.heat_release_rate * states.V, t)
255+
Q = np.trapz(states.heat_release_rate * states.V, t)
257256
output_str = '{:45s}{:>4.1f} {}'
258257
print(output_str.format('Heat release rate per cylinder (estimate):',
259258
Q / t[-1] / 1000., 'kW'))
260259

261260
# expansion power
262-
W = trapz(states.dWv_dt, t)
261+
W = np.trapz(states.dWv_dt, t)
263262
print(output_str.format('Expansion power per cylinder (estimate):',
264263
W / t[-1] / 1000., 'kW'))
265264

@@ -269,6 +268,6 @@ def ca_ticks(t):
269268

270269
# CO emissions
271270
MW = states.mean_molecular_weight
272-
CO_emission = trapz(MW * states.mdot_out * states('CO').X[:, 0], t)
273-
CO_emission /= trapz(MW * states.mdot_out, t)
271+
CO_emission = np.trapz(MW * states.mdot_out * states('CO').X[:, 0], t)
272+
CO_emission /= np.trapz(MW * states.mdot_out, t)
274273
print(output_str.format('CO emission (estimate):', CO_emission * 1.e6, 'ppm'))

0 commit comments

Comments
 (0)