I almost lost my patience while looking at some examples of couple differential equations. Thank you for your amazing tutorials.
@apm6 жыл бұрын
Thanks!
@MrNevermorefu4 жыл бұрын
Great tutorial! Helped me figure out how to solve ODEs like Matlabs's ODE45.
@manuel563544 жыл бұрын
I tried solving it with Gekko but I'm getting a "Solution Not Found" error. May you suggest me what could I tweak please? years = 15 resolution = 10 m = GEKKO() m.time = np.linspace(0, years, years * resolution + 1) H = m.Var(1e6) I = m.Var(0) V = m.Var(100) kr1 = m.Param(1e5) # new healthy cells per year kr2 = m.Param(0.1) # death rate of healthy cells kr3 = m.Param(2e-7) # healthy cells converting to infected cells kr4 = m.Param(0.5) # death rate of infected cells kr5 = m.Param(5) # death rate of virus kr6 = m.Param(100) # production of virus by infected cells m.Equation(H.dt() == kr1 - kr2 * H - kr3 * H * V) m.Equation(I.dt() == kr3 * H * V - kr4 * I) m.Equation(V.dt() == -kr3 * H * V - kr5 * V + kr6 * I) m.options.IMODE = 4 m.options.NODES = 3 m.solve()
@apm4 жыл бұрын
You may need to apply some initialization strategies as discussed here: apmonitor.com/do/index.php/Main/ModelInitialization There is also a solution in Gekko at the bottom.
@manuel563544 жыл бұрын
@@apm Thank you!
@kaustuvray50662 жыл бұрын
This is such a great video. I was so confused what to do in my project. Thanks a lot!!!
@mathematicslessonsandtutor8006 Жыл бұрын
Amazing video, thank you. Please any link to watch a videa where you explain how to format the style of the lines and also make a key for the various lines? Thank you
@apm Жыл бұрын
This Jupyter notebook and video solution should help with that: apmonitor.com/pds/notebooks/04_visualize.html
@chrisogonas Жыл бұрын
That was well illustrated and explained. Thanks
@SuperNova9934 жыл бұрын
Very helpful! I have a question, is this method useful for second-order ODEs?
@apm4 жыл бұрын
Yes. Here is an example: apmonitor.com/wiki/index.php/Apps/2ndOrderDifferential
@anandamoymukhopadhyay51582 жыл бұрын
Suppose we have two parameters whose initial values are known. Now if these parameters changes then what to do?
@apm2 жыл бұрын
If they change to new values then you could just resimulate with the new values. If they need to be optimized then I recommend using a solver such as Gekko: apmonitor.com/do
@MademoiselleNettie6 жыл бұрын
You literally just saved my life! Thank you so much, now I understand what I have to do with my project!
@basic-games6214 жыл бұрын
how do you do it if there is three more pramaters like if dhdt < L then dhdt/dt
@apm4 жыл бұрын
You can put those conditions in your model function. You can also see how to integrate in steps as shown in example 4 here: apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations If you integrate in a steps (in a for loop) then you can check when the tank is empty and stop the integration.
@myblog8713 жыл бұрын
Thank you so much Sir
@thedanyboyftw5 жыл бұрын
Thank you so much for this! You explain this in such an understandable way.
@madduxcamden85303 жыл бұрын
You probably dont care but if you are stoned like me during the covid times you can watch pretty much all of the new movies and series on Instaflixxer. I've been watching with my brother these days =)
@reneharrison15813 жыл бұрын
@Maddux Camden Yup, I have been using instaflixxer for months myself =)
@peymanfahimi64972 жыл бұрын
Thanks a lot for your great videos. Do you have any videos on partial differential equations (PDEs) with python?
@apm2 жыл бұрын
Here is content on PDEs: apmonitor.com/do/index.php/Main/PartialDifferentialEquations
@peymanfahimi64972 жыл бұрын
@@apm excellent! Thanks.
@johandiaztovar40972 жыл бұрын
What a great video!!! I have a question, how can I face the problem where one of my constants, for example, kr1 depends on the path "z", and I already know the function: kr1 = kr1_0*exp(-k*z). The best way to solve it, is making a for before define the function?
@apm2 жыл бұрын
That requires a differential algebraic equation solver such as Gekko: apmonitor.com/pdc/index.php/Main/PythonDifferentialEquations
@ABHINAN1608984 жыл бұрын
Can you put a video explaining how to make a dynamical model of a PMDC motor on Python, where user can define how the Voltage is being applied? [ Actually in my system, i have a pedelec, and i want to control the motor based on the force applied by the cyclist on the pedal. So i want to model this system, with motor,cyclist input, and torque load on motor. How can I do so? I have the diff equations of motor(2 , coupled), and the relation between the torque load and the cyclist input , and relation between cyclist input and Voltage applied accross the motor.. How to do this? Please help]
@apm4 жыл бұрын
Here are tutorials on solving differential equations in Python: apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations You may also want to check out the Python Gekko link if you are interested in transforming your simulation model into an estimator or predictive controller: apmonitor.com/pdc/index.php/Main/PythonDifferentialEquations
@kmlk19236 жыл бұрын
life saver !!!! No not really life but saved part of my life, may be 4 or 5 months :)) apreciate it. thanks.
@mathematicslessonsandtutor8006 Жыл бұрын
Thank so much for this great video Sir. Its so nicely explained. I followed this and was able to have my system simulated but when I vary my initial conditions I still get just the same plot as before. What are my missing out? Thank you once more.
@apm Жыл бұрын
Please see the 2nd example here: apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations
@elladakasarjyan58463 жыл бұрын
how do you simulate the same thing in second order?
@apm3 жыл бұрын
Here is help on second order equations: apmonitor.com/wiki/index.php/Apps/2ndOrderDifferential
@elladakasarjyan58463 жыл бұрын
@@apm thank you for replying! this video is for a single 2nd order ode is there a video for 2nd order coupled odes? Or perhaps does APmonitor offer tutoring?
@vadisayamini59514 жыл бұрын
hav a small doubt .in our previous video about solving difeerential equation 4th case was also solved coupled equations but there u did integration for single time slot by using for loop and solved.when that can be solved this easy why did we solve like that previously?
@apm4 жыл бұрын
You need to solve in a loop if the input (u) is unknown until you integrate to a certain time. It is also useful to change the input (u) every cycle of the loop such as when you are replaying historical data. Here are additional examples: apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations
@vadisayamini59514 жыл бұрын
@@apm thanks for reply.but we do know our input(u),whic h is 0 till a time and 2 afterwards we can simply use if t5 u=2 in the function model and solve problem directly by the way this hiv problem is solved right?whats main difference between these 2 questions that we used 2 different answers
@apm4 жыл бұрын
@@vadisayamini5951 the loop is needed where the input changes every simulation period, such as in a PID controller. If your input only has one step then you could embed the if statement in your function. If you have 10+ input changes then it is often easier to manage it as an external input to the model. Here is an example of inputs changing every second: apmonitor.com/pdc/index.php/Main/TankLevel
@vadisayamini59514 жыл бұрын
@@apm thanku sir,the lecture was v helpful.i understood now.am trying to solve 1 problem of my course and even though i follwed all the steps told by u precisely am not getting results (its thrwoing many errors).i reached your website also checking if there is some section where i can post my doubt.is there any way that we could reach sir?
@vadisayamini59514 жыл бұрын
its showing error of The array return by func must be one-dimensional, but got ndim=2. and odeint(func, y0, t, args, Dfun, col_deriv, full_output, ml, mu, rtol, atol, tcrit, h0, hmax, hmin, ixpr, mxstep, mxhnil, mxordn, mxords, printmessg, tfirst) 242 full_output, rtol, atol, tcrit, h0, hmax, hmin, 243 ixpr, mxstep, mxhnil, mxordn, mxords, --> 244 int(bool(tfirst))) 245 if output[-1] < 0: 246 warning_msg = _msgs[output[-1]] + " Run with full_output = 1 to get quantitative information."
@sriharshakodati4 жыл бұрын
This is awesome! May I know how can we repeat this symbolically? The analytical solution? Thanks!!!
@apm4 жыл бұрын
There is more information on symbolic solutions with Sympy here: github.com/APMonitor/data_science/blob/master/11.%20Differential_Equations.ipynb
@myblog8713 жыл бұрын
I am trying to run the same code. But it does not work for me.
@apm3 жыл бұрын
Try using the code here: apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations You may have a typo somewhere.
@myblog8713 жыл бұрын
import numpy as np ModuleNotFoundError: No module named 'numpy'
@myblog8713 жыл бұрын
This is the error.
@apm3 жыл бұрын
Try installing numpy, scipy, and matplotlib. Here is some help: apmonitor.com/pds/index.php/Main/InstallPythonPackages and apmonitor.com/che263/index.php/Main/PythonIntroduction
@myblog8713 жыл бұрын
@@apm Thank you Sir.
@nischalkarki29606 жыл бұрын
How can I see the simulated value at a particular time, for example: no. of healthy cells at t=7 or say finding the exact steady state values?
@apm6 жыл бұрын
You just need to feed in the times where you want to see the solution. Here is a tutorial with additional examples: apmonitor.com/pdc/index.php/Main/SolveDifferentialEquations
@jtekmmx6 жыл бұрын
How did you arrive with the value of 100 for the initial value of the free virus cell count? I cannot find this value in the reference book chapter.
@apm6 жыл бұрын
The initial condition is arbitrary but will affect the solution. If you start with less then it will take more time to reach 100 and beyond.
@hosseinamini57936 жыл бұрын
Do you have any tutorials on how to create an ODE of N differential equations (let's say dydt(i)) and solve it?
@apm6 жыл бұрын
This page apmonitor.com/pdc/index.php/Main/ModelSimulation has examples with first, second, and higher order differential equation solutions.
@nayelyvelez-cruz47854 жыл бұрын
you're seriously the best
@apm4 жыл бұрын
Thanks!
@haemin87593 жыл бұрын
what a life-saving video! Thank you so much!
@interestingthingsaround43084 жыл бұрын
Thanks
@interestingthingsaround43084 жыл бұрын
Hi Thanks a lot for this , it made a lot of sense now. where can I find the optimization part on this
@apm4 жыл бұрын
More information on optimization of differential equations is here: apmonitor.com/do The HIV example is specifically here: apmonitor.com/do/index.php/Main/EstimatorObjective
@ismaelchiamenti59015 жыл бұрын
Great job!!
@hsinghal14 жыл бұрын
really nice
@xsw2ws8916 жыл бұрын
Actually, you saved my life too! Thanks a lot, and all that films are very usefull
@apm6 жыл бұрын
I'm glad that you like the videos and they are helping.
@walacejunior34493 жыл бұрын
Thanks so much!
@ABHINAN1608984 жыл бұрын
source code?
@apm4 жыл бұрын
Here is the problem statement: apmonitor.com/pdc/index.php/Main/SimulateHIV and source code help: apmonitor.com/do/index.php/Main/ModelInitialization