Question

I'm a Python beginner. I'm trying to switch some programs that I have in matlab. I need solve a stiff ode equation, whose inputs are all matrices. In matlab I use

[ttT,uT] = ode23s('SST',t,fT);
Was it helpful?

Solution

For most things you do in Matlab, you can do them with the NumPy module in Python. It can be found here.

You might also find the related module SciPy useful as well.

PyDSTool might also be of relevance to you. It's a wrapper around the Radau solver.

Then you might like to try matplotlib for plotting. It works quite like Matlab's plotting thing.

The following links might help, too:

OTHER TIPS

If you show me the differential equations I can help you a little more, but in general, a good way to solve a stiff ODE system is through the next sentence:

solution = scipy.integrate.solve_ivp(function, [t_0, t_f], y0, method='BDF', first_step =0.0001, dense_output=True)

where your function has to be defined previously in this way: function(t,variable,parameters)

t_0 = initial value for time
t_f = final value for time
y0  = value of your variables at t_0

For stiff ODE system, I suggest use the method 'BDF' (is typically used in the solve of microkinetic systems in reactors, where the importance of the time could change a lot)

for more infomation about the options of the code: https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top