Lag in integration

13 views
Skip to first unread message

Hector Lestani

unread,
Nov 12, 2019, 12:18:43 PM11/12/19
to was...@seamplex.com
Hello all,
I am solving a differential equation like:
n_dot(t) .= f[n(t)]

How can I recall the value of n corresponding to a previous time?

Something like:
n_dot(t) .= f[n(t-1)]

Thanks for any suggestion.
Best regards,
Héctor.

jeremy theler

unread,
Nov 12, 2019, 12:23:13 PM11/12/19
to was...@seamplex.com
with the HISTORY keyword

--
jeremy theler
www.seamplex.com

--
You received this message because you are subscribed to the Google Groups "wasora" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wasora+un...@seamplex.com.
To view this discussion on the web visit https://groups.google.com/a/seamplex.com/d/msgid/wasora/5bcf2a08-4836-9a48-d750-71164a7428a6%40cab.cnea.gov.ar.

Jeremy Theler

unread,
Nov 12, 2019, 1:20:33 PM11/12/19
to was...@seamplex.com
Sorry for my previous slim response, I was over the phone.
I have added an example called history.was:

https://github.com/seamplex/wasora/blob/master/examples/history.was


It is this simple:

PHASE_SPACE a
end_time = 1
a_0 = 1
a_dot .= -a
HISTORY a b
PRINT t a b(t-0.1)


If you plot the results, you get something like the attached pdf.
I know I have to update the docs:

https://www.seamplex.com/wasora/reference.html#history


HISTORY <variable> <function>

It takes a variable and builds a time-dependent function which can be
evaluated at any time (linearly interpolated between definition
points).
qdp.pdf

Hector Lestani

unread,
Nov 13, 2019, 8:53:59 AM11/13/19
to was...@seamplex.com
Thank you Germán,
this is precisely what I needed.
I assume that, for t<0, b is constant, something like:
b(t<0)=b(t=0)
right?
Thank you man, you are a machine, really.
Best regards,
Héctor.

Jeremy Theler

unread,
Nov 13, 2019, 8:58:19 AM11/13/19
to was...@seamplex.com
yes, that is correct (the part of t<0, not the machine part :-) )

If you need help with the computation of the maximum flux and the
parametric sweep on the delay, just ask...

Ramiro Vignolo

unread,
Nov 13, 2019, 9:09:19 AM11/13/19
to was...@seamplex.com
Hi,

Wasora is solving the DAE (actually, ODE) from time t = 0 to t = end_time.

Each time, all phase space variables (in this case just variable a) are computed. When using HISTORY, you store that value in a new function, such that b(t) = a for each time that the ODE solver hits.

Later, you just plot the shifted function b(t - shift), which is not defined for negative argument value. Linear interpolators assume constant extrapolation using the first (left extrapolation) or last (rigth extrapolation) values.

So you are right!

Jeremy just answer but I will send this anyway hahaha



--
You received this message because you are subscribed to the Google Groups "wasora" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wasora+un...@seamplex.com.

Jeremy Theler

unread,
Nov 13, 2019, 9:20:37 AM11/13/19
to was...@seamplex.com
Well, that is not entirely true...

When 1D pointwise defined functinos need to return data outside the interval of definition, wasora linearly extrapolates the last two arguments. So they do not assume constant extrapolation.
In the particular case of functions that come from a HISTORY, an explicit setup of 5 points in the negative range from 0 to -infinite are added with the initial value of the argument.
See src/history.c:72

Side note: 5 is the minimum number of data points required by the akima interpolator, should we change the default interpolator from linear to akima.

Hector Lestani

unread,
Nov 14, 2019, 8:06:01 AM11/14/19
to was...@seamplex.com
Thank you very much Ramiro, very clear ;)
Reply all
Reply to author
Forward
0 new messages