Hi can you help me this reaction kinetics - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Hi can you help me this reaction kinetics (/thread-36365.html) |
Hi can you help me this reaction kinetics - Vengdasan - Feb-11-2022 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')
RE: Hi can you help me this reaction kinetics - jefsummers - Feb-11-2022 Need the complete error code. Lots of added info that is needed to analyze. Complete code as well. RE: Hi can you help me this reaction kinetics - BashBedlam - Feb-11-2022 When I run the posted script just as it is, I get:
RE: Hi can you help me this reaction kinetics - Vengdasan - Feb-12-2022 Actually, I have to do virtual lab using python GUI. For that I have use and solve some odes that other researchers drive. Here are the odes and constants. Actually I learn MATLAB only my lecturers also mastered in MATLAB only. I hope u guys can help me to do my project I will post credits for u all in my report. Equation : https://drive.google.com/file/d/1OnJNGV7bZmVSNoNih9tgWyl90XM6LUXY/view?usp=sharing K constant : https://drive.google.com/file/d/1qiwTLp6g_X-1vgp9Y30v4UQdUR-lMyfz/view?usp=sharing RE: Hi can you help me this reaction kinetics - jefsummers - Feb-13-2022 I see the error. In that line (21 in your posted code, 25 when BashBedlam ran it) you need an operator in the middle of (Feb-11-2022, 03:54 PM)Vengdasan Wrote: K3*M[1](M[3]-M[4]) As it stands, you are calling M[1] a function which it is not, because M[1] is followed immediately by the parentheses. |