LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using the RK4 VI, had a question about implementation

Here's a link to the system I'm approximating:http://i.imgur.com/EXnswBm.png

 

The way it's going to be used, it will use current values to calculate values that will be important in the next iteration of a while loop. The values passed into it via the X0 input will be from the last loop iterate, and the values coming out will be sent into a shift register. The length of each iteration varies according to another VI, so it'll be flipping between 5 and 10 minute cycles.

My question pertains to that max[] that's in the DE for I1(t).

 

Since labview isn't a functional language, I know that whatever I put into the F(X,t) array will be interpreted as a string, and not parsed as a function. Since the max operates on one of the variables, I can't simply apply the max[] operation outside and just leave that space as a number, or a dummy variable.

 

So is there any way to do this? Even a case structure wouldn't handle it, because it'd have to be applied for every iteration of RK4, and not just to the VI as a whole

0 Kudos
Message 1 of 5
(2,505 Views)
First thing is that you need to understand is the nature of LV -- which is most definitely a functional language. It is not, however, a text based language so you have to express your functions in graphical form.

Second, it would probably be worth your while to go through some of the tutorials that NI has online.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 5
(2,491 Views)

Sorry, I definitely misspoke there. I guess my question boils down to how best to incorporate the max() bit. One solution might be to just use a for loop with a case structure containing the RK4 VI, and the start time and end time separate by just one delta-t. I know a fair bit about LabVIEW after working with it over the past summer, I was just in want of the ability to include max() as it might be in a text based language. Also, I felt that my solution was kind of inelegant, and that there might be a better way that I'd just missed.

0 Kudos
Message 3 of 5
(2,488 Views)

The fundamental issue is that max() is not a differentiable function so the system of equations is not one which RK would be expected to solve.  Any differential equation solver in LabVIEW or a text-based language will need to do something beyond the normal solving process to deal with the discontinuities created by max().

 

If I2 is reasonably well behaved near zero, creating two sets of equations for I2 > 0 and I2 < 0 and switching based on the previous value of I2 might work.  It will be much slower because you will need to stop and start the solution process.

 

The RK algorithms are documented in a number of references. It might not be too difficult to program your own with the max() function built in.

 

Lynn

 

You can insert images directly into your posts. Look for the tree icon in the toolbar above the message box.

0 Kudos
Message 4 of 5
(2,462 Views)

Thanks. The solution I described above is as you said; stopping and starting the solution process, while checking the value of I2 all the while. These DE's are very well behaved in the context of their use (glucose control), so I don't believe I'll have issue implementing max() directly. 

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