![]() |
I tried to solve basic reaction kinetics ode but i cant run the simulation. Plz help - 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: I tried to solve basic reaction kinetics ode but i cant run the simulation. Plz help (/thread-36328.html) |
I tried to solve basic reaction kinetics ode but i cant run the simulation. Plz help - Vengdasan - Feb-08-2022 import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt def rxn(Z, t): k1 = 1 k2 = 1.5 r1 = k1*Z[0]*Z[1] r2 = k2*Z[1]*Z[2] dAdt = -r1 dBdt = -r1 -r2 dCdt = r1 -r2 dDdt = r2 return[dAdt,dBdt,dCdt,dDdt] t = np.arange(0,3.01,0.2) Z0 = [1,1,0,0] Conc = odeint(rxn(Z0,t)) cA = Conc[:,0] cB = Conc[:,1] cC = Conc[:,2] cD = Conc[:,3] S = np.empty(len(cC)) for i in range(len(cC)): if abs(cC[i]+cD[i]>1e-10): S[i] = cC/(cC+cD) else: S[i] = 1.0 plt.plot(t,cA) plt.plot(t,cB) plt.plot(t,cC) plt.plot(t,cD) plt.xlabel(time) plt.ylabel(Concentration) plt.legend('Ca','Cb','Cc','Cd') RE: I tried to solve basic reaction kinetics ode but i cant run the simulation. Plz help - Larz60+ - Feb-08-2022 Tried running, you are missing arguments:
|