LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Solve non linear differential equation on Labview

Solved!
Go to solution

Hi, I would like to solve a non linear differential equation on labview.  Does anyone know how to do?
The equation is the following:

dx=[A-BC/(2D)]x + (B/2D)*[(Cx)^2+4*D*p]^0.50
where A is a matrix 6x6, B is a matrix 6x1, C is a matrix 1x6, D is a costant and p is a costant.

x is the vector of variables.

 

Thanks for your attention.

0 Kudos
Message 1 of 5
(5,315 Views)

I recommend you check out Mathematica or another programming language designed for these types of problems.  LabVIEW is designed to create Virtual Instruments for handling engineering problems, such as Control, Data Acquisition, and Communication.

 

This is not to say you cannot do non-linear differential equations in LabVIEW, but that it is probably not the most appropriate platform.  I also wouldn't suggest that you use BASIC ...

 

Bob Schor

0 Kudos
Message 2 of 5
(5,276 Views)

The resolution of this equation can be done using the "ODE Solver.vi" in LabVIEW. You can look at this example: 

C:\Program Files (x86)\National Instruments\LabVIEW 2016\examples\Mathematics\Differential Equations - ODE\ODE-PredatorPrey.vi

 

Where you need to build a "call back" that describe your equation below (you need to provide the matrices below as an "Variante" for the data input.

 

Another option is to use the LabVIEW Control Design and Simulation Module. In using this tool, then you can explitly show the equation and you can see the solving process in each timestep. You cna use this example:

 

C:\Program Files (x86)\National Instruments\LabVIEW 2016\examples\Control and Simulation\Case Studies\Nonlinear\Pendulum\SimEx Nonlinear and Linear Pendulum Simulation.vi

 

Or if you want to preserve the equation, you can use Formula Node as this example below:

C:\Program Files (x86)\National Instruments\LabVIEW 2016\examples\Control and Simulation\Case Studies\Nonlinear\van der Pol\Van der Pol.vi

 

Or use Mathscript:

C:\Program Files (x86)\National Instruments\LabVIEW 2016\examples\Control and Simulation\Case Studies\Aerospace\Quadcopter\Quadcopter Dynamics and Control.vi

 

And, by the way, LabVIEW was enhanced to solve this problem that you requested and he is very powerful in several mathematics operations.

 

Hopefully this can help you....

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 3 of 5
(5,250 Views)

Thanks for your answer.

Do you how to solve the differential equation using "MathScript", because I tried to use "ODE solver.vi" but it doesn't work using matrix or array.

Thank for your attention.

0 Kudos
Message 4 of 5
(5,205 Views)
Solution
Accepted by topic author antosch

To make the ODE solver to work you matrices and vectors, you need to "pack" the data into the variant:

 

pack1.PNGpack3.PNG

 

 

and then, unpack using the structure below (the math below is just a demonstration and I did not try to solve your problem): 

pack2.PNG

 

Now, if you want to go in the direction of using Mathscript, here is a page that helps you to understand how to use a ODE solver. notice that, in this case, you need to create a user-defined function (below called lorenz):

 

http://zone.ni.com/reference/en-XX/help/373123C-01/lvtextmath/msfunc_ode_rk45/

Examples

% The lorenz function is defined by:
% function DY = lorenz(times, y)
% DY = zeros(3, 1);
% DY(1) = 10*(y(2)-y(1));
% DY(2) = 28*y(1)-y(2)-y(1)*y(3);
% DY(3) = y(1)*y(2)-8/3*y(3);
[T, Y] = ode_rk45('lorenz', [0, 5], [1; 1; 1])

odepset('AbsTol', 1E-3, 'MinStep', 1E-8, 'MaxStep', 1)
[T2, Y2] = ode_rk45('lorenz', [0, 5], [1; 1; 1])

options = odepset
[T3, Y3] = ode_rk45('lorenz', [0, 5], [1; 1; 1], options)

 

Hopefully this helps a bit more to solve your problem.

 

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 5 of 5
(5,181 Views)