LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Differential equation system to solve a BZ reaction model

Solved!
Go to solution

Hello,

I wrote this small code to visualise the oscillation of BZ reaction. I expect to see oscillation like in the page 3 and 7 of the link below

http://home2.fvcc.edu/~dhicketh/DiffEqns/spring2014projects/SilasSchwarz/Final/Final/bzreaction.pdf

This work is done in Matlab and I would like to reproduce it in Labview with the same parameters. But so far I couldn't see the oscillation.

Could anybody body spot what is wrong in this code?

Cheers,

Zied

 
0 Kudos
Message 1 of 14
(4,252 Views)

You're not using a differential equations solver. You're using a calculator. I would recommend you look under Mathematics -> Differential Equations -> Ordinary Differential Equations -> ODE Solver.vi

 

It has an implementation of the "ode45" algorithm that's popularly used in Matlab.

Message 2 of 14
(4,231 Views)

Hi,

I followed the tutorial in Labview using the control and simulation module. The calculators are just to simplify the code but I am using the integrators. I think it can work in this way according to the tutorial below.

The ODE under mathematics seems more complicated and less user friendly.

 

 

0 Kudos
Message 3 of 14
(4,218 Views)

I'd say they're no less friendly, just less fancy looking. Here's a VI that solves your ode and plots it as in that article.

 

 

Message 4 of 14
(4,209 Views)

Thank you very much Ilovemath.

I run your ODE but I couldn't see the oscillations like in page 7 of the document attached above.

And the graph I get reminded me of the graph I obtained with the first version of the VI I built with the control and simulation module with explicit math operations and not the formulas.

I attached here.

Thanks,

Zied

0 Kudos
Message 5 of 14
(4,188 Views)
Solution
Accepted by ziedhosni

I did notice that, but didn't have time yesterday to look into it. I implemented their matlab scripts and it turns out the constants they give; e , e' and q are actually 10^-n and not 10^n. A typo in a student paper, how rare 🙂 Once I changed this I got the correct plot as seen here:

 

 

Attached the VI. It runs much slower than in Matlab, so be warned.

 

 

Message 6 of 14
(4,171 Views)

Perfect. Now I have 2 ways to do it. Ilovemath, you are amazing. I wish I could give you more kudos.

Thanks,

Zied

0 Kudos
Message 7 of 14
(4,159 Views)

No problem! Does the way I set it up make enough sense that you could do this in the future with other ODEs?

Message 8 of 14
(4,150 Views)

Hi again,

Indeed, your method is straightforward. I just need to copy paste my equations and variables.

1- I would like to ask you about the ODE solvers. I noticed that each time I change the solver, I get a different graph ( it is still oscillating BTW).

I think it should be one that is correct and the others are wrong.

I checked in the litterature and I found that the authors  confirm  that for the model I am using the Runge-Kutta (4,5) algorithm fails to solve the system of  differential Equations and that the model is too stiff and highly dependant of the initial conditions.

Also they recommend the use of the multi-stage Adomian decomposition method (MADM) or just the ADM to give reliable result. Un fortunately I could't find in Labview.

Do you have any suggestion to add it?

 

2- I am trying to avoid using external software but maybe the unique solution is to use a solver from Matlab through the mathscript.

 

3- I would like also to ask whether it is possible to get the analytical formula of the integrated model (ie. in my case x(t)=...or y(t)) instead of just a graph because I plan to feed back control the model (the frequency or the chaos) and it is likely to be easier to tweak a formula than a curve.

 

4- As I said earlier, I would like to study the chaotic  behaviour of some models. As a mathematician, do you think that ODE can be used to describe this kind of phenomena?

 

I hope I didn't not exagerate of asking many questions at once.

Cheers,

Zied

 

0 Kudos
Message 9 of 14
(4,127 Views)
1. There is no "right" or "wrong" method. Only the one that works best for your particular system. Check the BDF method, which converges very quickly to a nice approximation, nicer than RK23. I don't think LV has MADM but to be honest BDF is more than adequate for this particular system.

2. Again, I don't think you need to do this. If you really want to I would recommend you use numpy or scipy which has a wonderfully fleshed out ODE module with any algorithm you could think of. Write the script, and interface with it via the Shell Exec vi, parsing stdout to get your results. That's the fastest and doesn't require the purchase of a Matlab license.

3. No. It's a diffeq for the reason that it can't be solved analytically only numerically.

4. This is just a reaction model. What are you bringing "control" and "chaos" in for? Could you explain a bit more your end goal?
Message 10 of 14
(4,117 Views)