One way is with the Sims package. I'm not sure I got everything right with
your model.

https://tshort.github.io/Sims.jl/

using Sims, Winston

function model()
    # note that the time scale is in hours
    D = Unknown(10.0, "D")
    A1 = Unknown("A1")
    rateConstant1 = 3.0
    rateConstant2 = 5.0
    @equations begin
        der(D) = -rateConstant1*D
        der(A1) = rateConstant1*D - rateConstant2*A1
        Event(sin(2pi/12 * MTime),     # Initiate an event every 12 hours
              Equation[
                  reinit(D, D + 10)  # add a dosage of 10
              ])
    end
end

x = sim(model(), 60);
wplot(x)


On Thu, Aug 20, 2015 at 8:36 PM, Martin J <jmalph...@gmail.com> wrote:

> Hi all,
>
> I am trying to use julia ode or sundials for the following simple
> differential equation.
>
> dD = -rateConstant1*D
> dA1 = rateConstant1*D - rateConstant2*A1
>
> This differential equations explain the disposition of drug in human
> system.
>
> *My question is related to resetting state variable at specified time. *
>
> In this example, drug was administered repeatedly every 12 hours for 48
> hours. So, I need to add an amount to dD every 12 hour to achieve this. In
> R and deSolve package, this repeated addition of dose was achieved by using
> ‘events’ options in ode. (R code attached)
>
> dose.events (please refer R code - line 32) object is presented below:
>
> var time value   method
> depot    0     10 replace
> depot   12     10 replace
> depot   24     10 replace
> depot   36     10 replace
> depot   48     10 replace
>
> With my limited understanding, this ‘events’ option in ode (deSolve),
> replaces the depot (dD) at these mentioned time with the said value.
>
> I am looking for similar option in sundials or julia ode.
>
> Could you please guide me with this ?
>
> Thanks for your suggestions.
>
> regards,
> Martin
>

Reply via email to