Chemical Reaction Differential Equations in Python

preview_player
Показать описание
Concentrations on chemical species from mole balances are solved for 1, 2, and 4 species in Python with the Scipy.Integrate package ODEINT.
Рекомендации по теме
Комментарии
Автор

I really appreciate the effort people like you put in sharing their knowledge. Very helpful tutorial. Thank you so much!!

Albert-PhotonChem
Автор

Thank you so so so much, you saved my bachelor degree and sanity

freekillerwhale
Автор

How would you plot the conversion of that last reaction vs time?

PiyushKumar-kfei
Автор

Hi great vids, could you handle in python this type of system of equations:
diA/dt=La+diB/dt+iB(t)
diB/dt=diA/dt+ Lb+iA(t)
Because on all the videos I have seen about odeint in python I never saw a system which included a diferential in both sides of the equations. I truly appreciate any lead, thank you.

JoseAlvarez-dlhm
Автор

Thanks a lot. But I got a question.
I built two models to calculate total mass loss of reaction below, but why my second one was wrong?
A -> kB + (1-k)gas



def dmdT(m, T, A, E, n, k):

m_plywood = m[0]
m_residue = m[1]
m_total = m[2]

r1 = -A * exp(-E/R/T) * m_plywood**n / beta
r2 = k * A * exp(-E/R/T) * m_plywood**n / beta
dm_plywooddT = r1
dm_residuedT = r2
dm_totaldT = r1 + r2
return [dm_plywooddT, dm_residuedT, dm_totaldT]


def dm_totaldT(m, T, A, E, n, k):
r1 = -A * exp(-E/R/T) * m**n / beta
r2 = k * A * exp(-E/R/T) * m**n / beta
return r1 + r2

王俊翔-mv
Автор

Thank you so much. Could you please include the noise, and solve it using Gillepsie Algorithm?

algerianinusa
Автор

How can I get the worksheet for Jupyter?

NadineLynch
Автор

I tried to replicate this code in Anaconda / Spyder (Python 3.5), but I got a synthax error at "%matplotlib inline". What is this line of code doing, and why is it not recognized by Python 3.5-Spyder-Anaconda?

Antonio-ltsp
Автор

Any suggestions how to solve a system of pde

devargyachakraborty
Автор

Hello, I do the exact same code in Python and Jupyter and I get that the selectivity and the concentracion of C get to be negative, I have honestly checked the code line by line and haven't found the error.

And there where you call the concentracion for the last exercise, when you say "conc=odeint(rxn, Z0, t)" wouldn't it be conc=odeint(rxn(Z0, t)) because you are passing data to a function?

thanks again

rvilleg
Автор

Thank you very much for the video, very useful your channel. I have a system very similar to that of problem 3. In this case we have experimental values of the concentrations and we do not know the values of the kinetic constants "K's". We solved the ODEs assuming the values of the "K's". Any suggestion (video, exercise, etc) of how to adjust the values of these kinetic constants so that the result of the ODEs approaches the experimental results and thus determine the real "K's".

oscargomez
Автор

Hi, it's really a great video!
As a beginner, I would like to ask:
S=np.empty(len(cC))
for i in range(len(cC)):
if abs(cC[i]+cD[i]>1e-10):
S[i]=cC[i]/(cC[i]+cD[i])
else:
S[i]=1.0
What does it mean?(problem 3)
thanks a lot : )

kai
Автор

Hi, it's really a great video!
As a beginner, I would like to ask, y my ODEINT solver can't run but I follow ur steps last question. odeint() missing 2 required positional arguments: 'y0' and 't' is pops out. BTW the code is as follow:

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')

I hope u can help me

vengdasankumaresan
Автор

Can I do the same problem as discrete model? Please help!

vidyam
Автор

thank you sooo fine
please can you help me in this :
x(2x+1)y '' +2(x+1)y' -2y =0
y'(1)= 0
y(3)-y'(3) = 31/9
y(x) = x+1+1/x
this all question please if you can help me ?

MosPol