09-07-2014 04:24 PM - edited 09-07-2014 04:24 PM
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
09-07-2014 05:32 PM
09-07-2014 05:40 PM
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.
09-07-2014 06:31 PM - edited 09-07-2014 06:32 PM
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.
09-07-2014 06:51 PM
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.