Thank you for doing this. This is great. I wish I had started to learn python sooner, seeing the importance that it has nowadays. I'm doing a masters on reactor engineering, and now I see how much they are linked together.
Hello Sir. Chemical Engineering student here. I’ve been watching your videos looking for an answer to my problem. Hope you can help me! I have a reactor wirh 3 simultaneous reactions. I have some additional information about the selectivity: they give me 3 different equations that implies the value of some species concentrations ratios and conversion of the limitant reactant. I know that I can solve the mole balance of my reactor because when I calculate the degrees of freedom I find its value is zero. My matrix to solve would be the mole balance for each species involved in the reactions. I can solve it by hand using those extra equations of selectivity and conversion just by replacing and doing the basic algebra, but I want to program it on Python. I just can’t find the way to tell Python to consider the linear extra equations that they give me along the mole balance matrix that represent a linear equation system. I’ve tried with Gekko, numpy, linalg without success. Thank you for your time.
I'd be glad to give some suggestions. Please post the problem and your attempt to solve it on StackOverflow with tag gekko: stackoverflow.com/questions/tagged/gekko
Dear professor, I have some problems with the equilibrium equations. The chain rules make sense to me. In the slide set for the energy equation it says (m*cp* dTdt) on the left side. But doesn't this only apply if the mass or density and volume are constant. Otherwise I don't understand how the chain rule should work here. In other words, am I correct that instead of "(m*cp* dTdt)", the term "(rho * cp* d(VT)dt)" should be in the slides?
Please see this problem and solution for an example of how to use the chain rule when accumulation mass and concentration both vary: apmonitor.com/pdc/index.php/Main/DeriveBalanceEquations
Energy / time is the correct dimension for continuous processes. Here is more information on energy balances: apmonitor.com/pdc/index.php/Main/PhysicsBasedModels If you are modeling a batch process then time isn't important.
Enery/time is the correct dimension indeed. but work and heat have dimension of enery, so that's why i think we should use a power wich has the correct dimension . am I wrong?
Thank you very much, your derivations simplified the task. What do I do in the first instance where density is not constant and if there is a change in density due to heat? Really appreciate your videos.
Here is the source code: apmonitor.com/pdc/index.php/Main/PhysicsBasedModels It uses ODEINT (an ode integrator that uses a Runga Kutta method for integration). See apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations You can also use Python Gekko: apmonitor.com/pdc/index.php/Main/PythonDifferentialEquations
They are the same if the times are uniform and there is no "t" in the model. You could also use [0,10/99] or [0,0.10101010101] and get the same answer with t=np.linspace(0,10,100). If I had used t=np.linspace(0,10,101) it would have [0,0.1] time steps at 11:00 in the video.
What an excellent Tutorial. Hello Professor, I understood everything until I got to this point: V[i+1] = y[-1] [0] Ca[i+1] = y[-1] [1] T[i+1] = y[-1] [2] Please kindly explain more. Thank you.
It is storing the last value of the integration step from ODEINT in individual arrays for plotting. More info on differential equation solutions is at apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations
@@apm Thank you for your timely response. I know that it was intended to store the previous value of the integration steps, however, my doubt is the introduction of double brackets that contains -1 each and 0,1, and 2 respectively at the RHS.
-1 means the last row. If you put -2 it would be the second to last row. The second bracket is for the column and is 0, 1, 2 for the 1st, 2nd, and 3rd column. There is more on lists and Numpy arrays here: apmonitor.com/che263/index.php/Main/PythonArrays
qf is the feed concentration and is 5.2 initially and then drops to 5.1 at cycle 51. The variable q is the outlet concentration and is initially equal to 5.0. It rises faster with the feed of 5.2 and then levels out at 5.1 with the reduction in feed concentration.
Thank you for doing this. This is great. I wish I had started to learn python sooner, seeing the importance that it has nowadays. I'm doing a masters on reactor engineering, and now I see how much they are linked together.
Biotechnology + Python = Success
Hello Sir. Chemical Engineering student here. I’ve been watching your videos looking for an answer to my problem. Hope you can help me! I have a reactor wirh 3 simultaneous reactions. I have some additional information about the selectivity: they give me 3 different equations that implies the value of some species concentrations ratios and conversion of the limitant reactant. I know that I can solve the mole balance of my reactor because when I calculate the degrees of freedom I find its value is zero.
My matrix to solve would be the mole balance for each species involved in the reactions. I can solve it by hand using those extra equations of selectivity and conversion just by replacing and doing the basic algebra, but I want to program it on Python. I just can’t find the way to tell Python to consider the linear extra equations that they give me along the mole balance matrix that represent a linear equation system. I’ve tried with Gekko, numpy, linalg without success.
Thank you for your time.
I'd be glad to give some suggestions. Please post the problem and your attempt to solve it on StackOverflow with tag gekko: stackoverflow.com/questions/tagged/gekko
Dear professor,
I have some problems with the equilibrium equations. The chain rules make sense to me. In the slide set for the energy equation it says (m*cp* dTdt) on the left side. But doesn't this only apply if the mass or density and volume are constant. Otherwise I don't understand how the chain rule should work here. In other words, am I correct that instead of "(m*cp* dTdt)", the term "(rho * cp* d(VT)dt)" should be in the slides?
Please see this problem and solution for an example of how to use the chain rule when accumulation mass and concentration both vary: apmonitor.com/pdc/index.php/Main/DeriveBalanceEquations
Sir, for command odeint not available right now, and change with solve_ivp. Could you please to make another video regarding this exercise? Thankyouuu
Great idea. solve_ivp uses the ODEINT algorithm for one of the options.
in the energy balance you must use the power instead of the work it have a dimension of energy over time . (same thing for Q as well)
Energy / time is the correct dimension for continuous processes. Here is more information on energy balances: apmonitor.com/pdc/index.php/Main/PhysicsBasedModels If you are modeling a batch process then time isn't important.
Enery/time is the correct dimension indeed. but work and heat have dimension of enery, so that's why i think we should use a power wich has the correct dimension . am I wrong?
Thank you very much, your derivations simplified the task. What do I do in the first instance where density is not constant and if there is a change in density due to heat?
Really appreciate your videos.
You’ll need to use the chain rule as shown in this exercise: apmonitor.com/pdc/index.php/Main/PhysicsBasedModels
Very nice! Good exercise for beginners
Awesome video sir. Thank you!
Dear developer:
May I ask you what numerical method is the integrator using to solve this ODE problem?
Thanks
Here is the source code: apmonitor.com/pdc/index.php/Main/PhysicsBasedModels It uses ODEINT (an ode integrator that uses a Runga Kutta method for integration). See apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations
You can also use Python Gekko: apmonitor.com/pdc/index.php/Main/PythonDifferentialEquations
Your work is absolutely amazing, while being open access. I would like to wish you all the best and express my gratitude too.
Please, where find cour about Mpc linear of cstr , and elso typicl obtain linear plant model with adaptive mpc?
Thank u🎆
Here is a course on MPC with many examples of linear and adaptive MPC: apmonitor.com/do
Dear professor,
What is the difference between solving odeint using just t and ts = [t[i],t[i+1]] or ts = [t[i-1],t[i]]? Thanks a million.
They are the same if the times are uniform and there is no "t" in the model. You could also use [0,10/99] or [0,0.10101010101] and get the same answer with t=np.linspace(0,10,100). If I had used t=np.linspace(0,10,101) it would have [0,0.1] time steps at 11:00 in the video.
What an excellent Tutorial.
Hello Professor, I understood everything until I got to this point:
V[i+1] = y[-1] [0]
Ca[i+1] = y[-1] [1]
T[i+1] = y[-1] [2]
Please kindly explain more.
Thank you.
It is storing the last value of the integration step from ODEINT in individual arrays for plotting. More info on differential equation solutions is at apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations
@@apm Thank you for your timely response. I know that it was intended to store the previous value of the integration steps, however, my doubt is the introduction of double brackets that contains -1 each and 0,1, and 2 respectively at the RHS.
-1 means the last row. If you put -2 it would be the second to last row. The second bracket is for the column and is 0, 1, 2 for the 1st, 2nd, and 3rd column. There is more on lists and Numpy arrays here: apmonitor.com/che263/index.php/Main/PythonArrays
@@apm OMG, you're the best!
# Inlet Volumetric Flowrate (L/min)
qf = np.ones(len(t))* 5.2
qf[50:] = 5.1
# Outlet Volumetric Flowrate (L/min)
q = np.ones(len(t))*5.0
please, how did you get 5.2,5.1, and 5???
qf is the feed concentration and is 5.2 initially and then drops to 5.1 at cycle 51. The variable q is the outlet concentration and is initially equal to 5.0. It rises faster with the feed of 5.2 and then levels out at 5.1 with the reduction in feed concentration.
Great example. Thanks!
sir can i make snap shot of your video
search for snipping tool in Windows. You can also find these notes at apmonitor.com/pdc
thanks sir