Hi there, just want to say thank you very much for this video. I am taking a Python class I was having a lot of trouble with solving ODEs. I was just staring at my problem set and had no idea how to do systems of ODEs until I found your video. Thank you! Your lecture is very informative and easy to understand. I kinda hoped that you teach at our university lol.
When I tried to use the times=np.linspace function I ran into issues because my endpoint is a decimal. What are my alternatives? Scale the problem differently so that my decile 0.3815 is 3815?
Hi Lila, the linspace function can take decimals at both starting and endpoints: t = np.linspace(start, end, Npoints) So, for example: times = np.linspace(0., 0.3815, 50) should give you 50 linearly spaced points between 0 and 0.3815. What linspace cannot take is a floating point value for Npoints. That has to be an integer.
Thank you very much for the tutorial, just subscribed! I want to solve a problem involving four CSTRs operating in series. Thus, y0 needs to be a 2D array (numpy.ndarray in Python) to account for the initial conditions in each CSTR. Unfortunately, solve_ivp seems to accept only 1D arrays as initial conditions (shape(n,)). Do you have a tip on how to go about this problem?
Hi Dean, I'm not sure why you would need a 2D array for y0. If you have a system of differential equations, you should be able to express y0 as a n-dimensional 1d array. In this case, if you have 4 CSTRs that form a coupled system of 4 ODEs, you should be able to have a 4-dimensional array for y0. Check out the videos and notes here: www.et.byu.edu/~treedoug/_pages/teaching/ChEn263/Lectures/Lec22.html for more details about how to do this.
As an addendum, I had the thought that maybe you have multiple concentrations in each CSTR. This would mean that if you have (for example) two concentrations in each, you would have 8 coupled ODEs. In this case you can make an 8-dimensional array for y0. y0[0] = c1 in CSTR 1 and y0[1] = c2 in CSTR 1, y0[2] = c1 in CSTR 2, and so forth.
@@TreeSoftMatter That's exactly my case sir, excuse me for not stating it properly. Thank you for your suggestion. The 4 CSTR problem tries to model a biological system, so unfortunately there are over 60 species (i.e., over 60 individual concentrations in each CSTR). This would make it a bit tedious to create the multidimensional array for y0, but it appears this is the only way. Thank you once again for taking the time to answer and keep up your great work!
I have videos on that! Here is one on linear algebraic equations:ua-cam.com/video/8X0SHplJRCg/v-deo.html, and here is one on nonlinear equations: ua-cam.com/video/paGJSaR4kcM/v-deo.html
I think you're going to have to be more specific with your question. Most of the time the "state space" models that I am familiar with are still ODEs (say in time), but the time ends up being implicit in the final analysis. So for example, you might have x_dot(t) = f(x, y, t) and y_dot(t) = g(x, y, t). Then you solve it for x(t) and y(t), but you are only interested in plots of y(x). This would be straightforward using the methods I outline in the video. I would need a more specific question to give a more detailed answer than this.
Hi Peter, Unfortunately I don't have time to give this kind of help on UA-cam, as I am busy with classes, research, and administrative tasks. However, this should be pretty straightforward if you follow the examples given here: www.et.byu.edu/~treedoug/_pages/teaching/ChEn263/Lectures/Lec22.html. If you have a more specific question, please do ask.
@@lunthangify This example shows systems: www.et.byu.edu/~treedoug/_pages/teaching/ChEn263/Lectures/Lec22-Ex-Systems_of_ODEs.py. Your system of equations is very similar to example (C).
@@TreeSoftMatter sir, I follwed exactly but no output/result. It says local variable 'times is assigned to but never used (line 40). Please have a look at the code when you have time. drive.google.com/file/d/143LHVglKq6root-PSLUS2o6egoP10mhB/view?usp=sharing
Hi there, just want to say thank you very much for this video. I am taking a Python class I was having a lot of trouble with solving ODEs. I was just staring at my problem set and had no idea how to do systems of ODEs until I found your video. Thank you! Your lecture is very informative and easy to understand. I kinda hoped that you teach at our university lol.
Glad to hear it helped! Best of luck in the rest of your course.
This is life saving
Glad it was helpful!
Tarea numérica-fcfm? Xd
@@mathy2062 Jaja si xd
Thanks a lot!
You're welcome!
thanks, may Allah give you the guidance
You're welcome and god bless you as well!
Yess, thanks!!
You're welcome!
nice blazer, man
When I tried to use the times=np.linspace function I ran into issues because my endpoint is a decimal. What are my alternatives? Scale the problem differently so that my decile 0.3815 is 3815?
Hi Lila, the linspace function can take decimals at both starting and endpoints: t = np.linspace(start, end, Npoints)
So, for example:
times = np.linspace(0., 0.3815, 50)
should give you 50 linearly spaced points between 0 and 0.3815.
What linspace cannot take is a floating point value for Npoints. That has to be an integer.
Thank you very much for the tutorial, just subscribed! I want to solve a problem involving four CSTRs operating in series. Thus, y0 needs to be a 2D array (numpy.ndarray in Python) to account for the initial conditions in each CSTR. Unfortunately, solve_ivp seems to accept only 1D arrays as initial conditions (shape(n,)). Do you have a tip on how to go about this problem?
Hi Dean, I'm not sure why you would need a 2D array for y0. If you have a system of differential equations, you should be able to express y0 as a n-dimensional 1d array. In this case, if you have 4 CSTRs that form a coupled system of 4 ODEs, you should be able to have a 4-dimensional array for y0. Check out the videos and notes here: www.et.byu.edu/~treedoug/_pages/teaching/ChEn263/Lectures/Lec22.html for more details about how to do this.
As an addendum, I had the thought that maybe you have multiple concentrations in each CSTR. This would mean that if you have (for example) two concentrations in each, you would have 8 coupled ODEs. In this case you can make an 8-dimensional array for y0. y0[0] = c1 in CSTR 1 and y0[1] = c2 in CSTR 1, y0[2] = c1 in CSTR 2, and so forth.
@@TreeSoftMatter That's exactly my case sir, excuse me for not stating it properly. Thank you for your suggestion. The 4 CSTR problem tries to model a biological system, so unfortunately there are over 60 species (i.e., over 60 individual concentrations in each CSTR). This would make it a bit tedious to create the multidimensional array for y0, but it appears this is the only way. Thank you once again for taking the time to answer and keep up your great work!
How can we introduce also algebraic equations along with ODEs?
I have videos on that! Here is one on linear algebraic equations:ua-cam.com/video/8X0SHplJRCg/v-deo.html, and here is one on nonlinear equations: ua-cam.com/video/paGJSaR4kcM/v-deo.html
How would you do this with a state space model?
I think you're going to have to be more specific with your question. Most of the time the "state space" models that I am familiar with are still ODEs (say in time), but the time ends up being implicit in the final analysis. So for example, you might have x_dot(t) = f(x, y, t) and y_dot(t) = g(x, y, t). Then you solve it for x(t) and y(t), but you are only interested in plots of y(x). This would be straightforward using the methods I outline in the video. I would need a more specific question to give a more detailed answer than this.
Sir, please solve the following set of equations:
drdt = x
dxdt = r*(y**2 + (z+Ω)**2 * sin(θ)**2 - β*z*sin(θ)*B_θ)
dθdt = y
dydt = (-2*x*y-r*(z+Ω)**2*sin(θ)*cos(θ)+β*r*z*sin(θ)*B_r)/r
dϕdt = z
dzdt = (-2*x*(z+Ω)*sin(θ)-2*r*y*(z+Ω)*cos(θ)+β*(x*B_θ-r*y*B_r))/(r*sin(θ))
with constants
Ω=9.74e-3
B_θ=-8.6e-6*sin(θ)
B_r=25893.2e-9*cos(θ)
β=-9.36e-10
initial conditions
r0 = 0.7e+8
θ0 = 0.5*pi
ϕ0 = 0
x0 = 0
y0 = 0
z0 = 0
Hi Peter, Unfortunately I don't have time to give this kind of help on UA-cam, as I am busy with classes, research, and administrative tasks. However, this should be pretty straightforward if you follow the examples given here: www.et.byu.edu/~treedoug/_pages/teaching/ChEn263/Lectures/Lec22.html. If you have a more specific question, please do ask.
@@TreeSoftMatter Thank you for the videos anyway. If you would includes as one of your solved examples it would be very helpful for learners like me.
@@lunthangify This example shows systems: www.et.byu.edu/~treedoug/_pages/teaching/ChEn263/Lectures/Lec22-Ex-Systems_of_ODEs.py. Your system of equations is very similar to example (C).
@@TreeSoftMatter sir, I follwed exactly but no output/result. It says local variable 'times is assigned to but never used (line 40). Please have a look at the code when you have time. drive.google.com/file/d/143LHVglKq6root-PSLUS2o6egoP10mhB/view?usp=sharing
Thanks so much!
You're welcome!