odesys
Description
The odesys object handles a system of ordinary differential equations. Optionally, the ODEs can be solved in real-time, with input/output from/to a National Instruments data acquisition card.
- Set the model:
- Solve the model:
- Run control:
- Set I/O:
- I/O Buffer management:
- Triggers:
- Display and record data:
- Run-time parameter changes and notes:
- Run-time properties:
Properties
v = pauseconditionvalue; |
pauseconditionvalue = v; |
v = stopconditionvalue; |
stopconditionvalue = v; |
n = idevicename; |
idevicename = n; |
Make sure idevicename matches the name of your input device, as set in the NI Measurement and Automation Explorer.
The default value is Dev1.
Note that you can use different devices for input and output but all input channels must be on the same device; likewise for output.
n = digitalidevicename; |
digitalidevicename = n; |
n = odevicename; |
odevicename = n; |
Make sure odevicename matches the name of your output device, as set in the NI Measurement and Automation Explorer.
The default value is Dev1.
Note that you can use different devices for input and output but all output channels must be on the same device; likewise for input.
n = digitalodevicename; |
digitalodevicename = n; |
s = inputscaling(i); |
inputscaling(i) = s; |
o = inputoffset(i); |
inputoffset(i) = o; |
s = outputscaling(i); |
outputscaling(i) = s; |
o = outputoffset(i); |
outputoffset(i) = o; |
r = inputfrombuffercount; |
This function returns the number of available buffers.
s = buffersize(buffer); |
buffersize(buffer) = s; |
Read or write the size of a particular buffer.
f = bufferfirst(buffer); |
bufferfirst(buffer) = f; |
l = bufferlast(buffer); |
bufferlast(buffer) = l; |
p = bufferpos[ition](buffer); |
bufferpos[ition](buffer) = p; |
r = bufferrepeat(buffer); |
bufferrepeat(buffer) = r; |
If bufferrepeat = 0, I/O buffer operations will recycle the buffer indefinitely.
If bufferrepeat = n, where n > 0, I/O operations will use the buffer n times.
r = bufferrunning(buffer); |
r = buffer[data](buffer, point); |
buffer[data](buffer, point) = d; |
bufferfill(buffer = b, first = f, last = l, value = v); |
v = triggervalue({index|name}); |
triggervalue({index|name}) = v; |
v = outtriggervalue({index|name}); |
outtriggervalue({index|name}) = v; |
c = triggeredcount({index|name}); |
t = triggeredtimes({index|name}, point); |
c = triggeredtimescount({index|name}); |
c = outtriggeredcount(trigger); |
t = outtriggeredtimes({index|name}, point); |
c = outtriggeredtimescount({index|name}); |
d = data(row, col); |
data(row, col) = d; |
s = timescale; |
timescale = s; |
Methods
Use setindvar to set the independent variable of the ODE (generally, the time).
v sould be an expression returning a floating point variable, i.e., declared with the dbl option.
To reset the independent variable to nothing, call setindvar without arguments.
Example:
var dbl time; //Declare a floating point variable "time"
odesys ode; //Declare an odesys object "ode"
ode.setindvar(var = time); //Set the ode independent variable as "time"
...
ode.setindvar; //Set the independent variable to nothing
adddiff(var = v, diff = d); |
Use adddiff to add a differential equation to the ODE model. v sould be an expression returning a floating point variable.
d stands for d(v)/d(IndVar).
Example:
var dbl V, I, Cm, t; //Declare several floating point variables
odesys ode; //Declare an odesys object "ode"
ode.setindvar(var = t); //Set the ode independent variable as "t"
ode.adddiff(var = V, diff = I/Cm); //Add the o.d.e. dV/dt = I/Cm to the model
addjac(var1 = v1, var2 = v2, jac = j); |
addalg(var = v, eq = e, last = l); |
If last = false (default), then the algebraic equation is executed before the ODEs, otherwise it is executed after.
addion(channel = c,
dt = t,
stoch = s,
amatrix = a,
proc = p,
vthrdir = d,
vthr = v); |
For non-real-time solvers, the proc, vthrdir and vthr arguments are ignored.
The stoch and amatrix arguments are mutually exclusive.
When using the real-time solver, an ion channel can be assigned to a specific processor proc.
In this case (proc <> -1), the stoch and amatrix arguments can be combined.
If vthrdir > 0, the ion channel is integrated stochastically when the voltage < vthr,
and using the amatrix method when the voltage is > vthr, or the other way around if vthrdir < 0.
solve( |
starttime = st, |
endttime = et, |
stepsize = dt, |
minstepsize = mindt, |
maxstepsize = maxdt, |
timescale = ts, |
reltol = rt, |
abstol = at, |
method = m, |
usejac = uj, |
mainthreadaffinity = ta, |
graphthreadaffinity = gta, |
triggerthreadaffinity = tta, |
iothreadaffinity = iota, |
ithreadaffinity = ita, |
othreadaffinity = ota, |
digitaliothreadaffinity = diota, |
digitalithreadaffinity = dita, |
digitalothreadaffinity = dota, |
emptythreadaffinity = eta, |
dohist = dh, |
histmin = hmin, |
histmax = hmax, |
histbincount = hbc, |
dograph = dg, |
newsegment = ns, |
stochasticfast = sfast, |
outputrefresh = or, |
quiet = q, |
asynchronous = a |
); |
If asynchronous = true, then solve returns control immediately but the solver continues to run until it is stopped, or until the calling script terminates.
start({pauseaftertime = t | pauseafterpoints = p}, newsegment = n); |
setinput(var = v, scale = s, offset = o, channel = c, filter = f, min = mn, max = mx, prevvar = pv); |
The var and prevvar arguments must be variables declared as dbl.
setdigitalinput(var = v, port = p, line = l, prevvar = pv); |
The var and prevvar arguments must be variables declared as int.
setinputfrombuffer(var = v, scale = s, offset = o, buffer = b, filter = f, min = mn, max = mx, prevvar = pv); |
The var argument must be a variable declared as dbl.
setoutput(var = v, scale = s, offset = o, channel = c, filter = f, min = mn, max = mx, default = d, prevvar = pv); |
The var argument can be any numerical expression. The prevvar argument must be a variable declared as dbl.
setdigitaloutput(var = v, port = p, line = l, default = d, prevvar = pv); |
The var argument can be any numerical expression. The prevvar argument must be a variable declared as int.
setoutputtobuffer(var = v, scale = s, offset = o, buffer = c, filter = f, min = mn, max = mx, default = d, prevvar = pv); |
The var argument can be any numerical expression. The prevvar argument must be a variable declared as dbl.
bufferstart(buffer = b, first = f, last = l, repeat = r); |
buffersave(buffer = b, filename = n, first = f, last = l); |
Use buffersave to save to disk the content of the buffer, from the "first" to the "last" point. If these arguments are not specified, then the entire buffer is saved.
The format is binary, single-precision floating point.
bufferload(buffer = b, filename = n, first = f, last = l); |
Use bufferload to load data from disk into the buffer, from the "first" to the "last" point. If these arguments are not specified, then the buffer will be filled starting with the first (zero index) point.
After loading, bufferfirst and bufferlast point to the actually loaded data.
The format of the file should be binary, single-precision floating point.
buffercopytodata(buffer = b, bufferfirst = f, bufferlast = l, data = d, datachannel = c, datafirst = df, newsegment = s); |
buffercopyfromdata(buffer = b, bufferfirst = f, data = d, datachannel = c, datafirst = df, datalast = dl); |
addtrigger( |
name = n, |
mode = m, |
store = s, |
storecount = sc, |
channel = ch, |
value = v, |
slope = s, |
delay = d, |
freezetime = ft, |
actionname = an, |
assignvar = v, |
assignexp = e, |
bufferop = bop, |
buffer = b, |
copydata = cd, |
copyfromchannel = cf, |
copytochannel = ct, |
copyleft = cl, |
copyright = cr, |
filter = f, |
scriptname = sn, |
scriptdontsynch = ds, |
scriptdontwait = dw, |
scriptaffinity = sa, |
scriptpriority = sp |
); |
addtriggeraction( |
name = n, |
actionname = an, |
assignvar = v, |
assignexp = e, |
bufferop = bop, |
buffer = b, |
copydata = cd, |
copyfromchannel = cf, |
copytochannel = ct, |
copyleft = cl, |
copyright = cr, |
filter = f, |
); |
addouttrigger( |
name = n, |
mode = m, |
store = s, |
storecount = sc, |
channel = ch, |
value = v, |
slope = s, |
delay = d, |
freezetime = ft, |
actionname = an, |
assignvar = v, |
assignexp = e, |
bufferop = bop, |
buffer = b, |
copydata = cd, |
copyfromchannel = cf, |
copytochannel = ct, |
copyleft = cl, |
copyright = cr, |
filter = f, |
scriptname = sn, |
scriptdontsynch = ds, |
scriptdontwait = dw, |
scriptaffinity = sa, |
scriptpriority = sp |
); |
addouttriggeraction( |
name = n, |
actionname = an, |
assignvar = v, |
assignexp = e, |
bufferop = bop, |
buffer = b, |
copydata = cd, |
copyfromchannel = cf, |
copytochannel = ct, |
copyleft = cl, |
copyright = cr, |
filter = f, |
); |
resettrigger({index|name}); |
resetouttrigger({index|name}); |
adddisplay(var = v, name = n, units = u); |
The var argument can be any numerical expression.
text = textdata(vars = v, firstpoint = f, lastpoint = l, scaling = s); |
data = intdata(vars = v, firstpoint = f, lastpoint = l, scaling = s); |
storepars(point = p, note = n, all = a); |
addnote(note = n, list = l, point = p); |
Constants
Examples
See also
(C) 2008-2011 Lorin Milescu. Last modified: 02-03-2011