Feb-11-2022, 03:54 PM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt import math def rxn(M,t): R = 8.314 T = 415 K1 = ( 2.19 * 10 * * - 1 ) * (math.exp(( - 1.148 * 10 * * 5 ) / R * T)) #KTi K2 = ( 1.051 * 10 * * 4 ) * (math.exp(( - 2.957 * 10 * * 4 ) / R * T)) #Kp K3 = ( 2.31 * 10 * * 3 ) * (math.exp(( - 5.302 * 10 * * 4 ) / R * T)) #Ktrm K4 = ( 2.0497 * 10 * * 3 ) * (math.exp(( - 5.24 * 10 * * 4 ) / R * T)) #Ktrs K5 = ( 6.275 * 10 * * 5 ) * (math.exp(( - 7.026 * 10 * * 4 ) / R * T)) #Ktc K6 = 0 dMdt = - 2 * K1 * (M[ 1 ] * * 3 ) - (K2 + K3) * (M[ 1 ]) * (M[ 3 ]) dSdt = - K4 * M[ 2 ] * M[ 3 ] dY0dt = 2 * K1 * (M[ 1 ] * * 3 ) - (K5 + K6) * M[ 3 ] * * 2 dU0dt = K3 * M[ 3 ] * M[ 1 ] + K4 * M[ 3 ] * M[ 2 ] + K6 * M[ 3 ] * * 2 + 0.5 * K5 * M[ 3 ] * * 2 dY1dt = 2 * K1 * M[ 1 ] * * 3 + K2 * M[ 1 ] * M[ 3 ] - K3 * M[ 1 ](M[ 3 ] - M[ 4 ]) - K4 * M[ 2 ] * (M[ 3 ] - M[ 4 ]) - (K5 + K6) * M[ 3 ] * M[ 4 ] dU1dt = K3 * M[ 4 ] * M[ 1 ] + K4 * M[ 4 ] * M[ 2 ] + (K5 + K6) * M[ 3 ] * M[ 4 ] return (dMdt,dSdt,dY0dt,dU0dt,dY1dt,dU1dt) t = np.linspace( 0 , 400 , 20 ) M0 = [ 7632.2 , 587.47 , 0 , 0 , 0 ] Conc = odeint(rxn,M0,t) cM = Conc[:, 0 ] cS = Conc[:, 1 ] cY0 = Conc[:, 2 ] cU0 = Conc[:, 3 ] cY1 = Conc[:, 4 ] cU1 = Conc[:, 5 ] plt.plot(t,cM) plt.plot(t,cS) plt.plot(t,cY0) plt.plot(t,cU0) plt.plot(t,cY1) plt.plot(t,cU1) plt.xlabel( 'time' ) plt.ylabel( 'Concentration' ) |
Error:'numpy.float64' object is not callable