Re: Help with iSpikes

Bill Harris <[email protected]> Sun, 5 Jul 2020 09:12:40 -0700
Newsgroups gmane.comp.gnu.mcsim
Message-ID <CAOBquGoY_+aE+5OcJZziWeThi71=CJ=SisSkfSc9J8m8GKcauw@mail.gmail.com>
--000000000000b261bb05a9b40783
Content-Type: text/plain; charset="UTF-8"

Frederic,

Thanks!

I must have fallen off--or never really joined--this list.  I think I fixed
that.

Okay, so here's my real question.  I'd like to take an SIR model such as
the one shown on the quick reference card and challenge it by having
infectious people flow into the I stock periodically; I think that's a way
to explore herd immunity, right?  I thought I might do that by using
Spikes() much as I showed in my first email yesterday and have that add to
the RHS of the dt(I) statement, but that would require the magnitude
argument of Spikes() to be the AUC, not the peak value.

Since that doesn' t work, what would be an idiomatic way to accomplish that
in MCSim?

I can think of other places that problem would arise. For example, one
might want to count through the months of a year and then reset the month
count to 1 upon leaving month 12.  I guess you could use a C mod function
for that

From the PBPK domain, how do you model taking a pill once a day (or hour or
...)?  I had imagined that Spikes() might be one way, putting x mg of
medication in the stomach each day and letting the model take care of its
disposition via ADME , but I'm certainly open to learning the way it's
really done.

Thanks,

Bill


On Sat, Jul 4, 2020 at 7:53 PM Bill Harris <[email protected]> wrote:

> Mode File:
>
> States = {
>   State
>   };
> Inputs = {
>   inflow
>   };
> Initial_State = 0.0;
> Initialize{
>   State = Initial_State;
>   };
> Dynamics{
>  dt(State) = inflow;
>  };
> End.
>
> $ makemcsim spikestest.model
> Creating model.c file from spikestest.model ...
>
> ________________________________________
>
> Mod v6.1.0 - Model Generator for MCSim
>
> MCSim and associated software comes with ABSOLUTELY NO WARRANTY;
> This is free software, and you are welcome to redistribute it
> under certain conditions; see the GNU General Public License.
>
> No CalcOutputs{} equations. Null function defined.
>
>
> * Created model file 'model.c'.
>
>
> Compiling and linking model ...
> Cleaning up ...
> Created executable mcsim.spikestest
>
> Input File:
>
> Integrate(Lsodes,1.0e-6,1.0e-6,0);
> OutputFile("spikes.test01.out");
> StartTime(0.0);
> Initial_State = 0.0;
>
> Simulation { # Base
> inflow = 1.0;
> PrintStep(State,0.0,200.0,1.0);
> PrintStep(inflow,0.0,200.0,1.0);
> }
>
> Simulation { # Base w/ Spikes
> inflow = Spikes(
>   5,
>   10.0, 10.0,  10.0,  10.0,  10.0,
>    0.0, 50.0, 100.0, 150.0, 200.0);
> PrintStep(State,0.0,200.0,1.0);
> PrintStep(inflow,0.0,200.0,1.0);
> }
>
> End.
>
> OUtput File:
>
> Results of Simulation 1
>
> Time State inflow
> 0 0 1
> 1 1 1
> 2 2 1
> 3 3 1
> 4 4 1
> 5 5 1
> 6 6 1
> .
> .
> .
>
> Results of Simulation 2
>
> Time State inflow
> 0 0 10
> 1 0 0
> 2 0 0
> 3 0 0
> 4 0 0
> 5 0 0
> 6 0 0
> .
> .
> .
>
> Question: Why doesn 't State jump by 10 every 50 time units?  What is
> Spikes doing?
>
> Thanks,
>
> Bill
> --
> Bill Harris
>


-- 
Bill Harris
http://makingsense.facilitatedsystems.com/

--000000000000b261bb05a9b40783
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Frederic,<div><br></div><div>Thanks!</div><div><br></div><=
div>I must have fallen off--or never really joined--this list.=C2=A0 I thin=
k I fixed that.</div><div><br></div><div>Okay, so here&#39;s my real questi=
on.=C2=A0 I&#39;d like to take an SIR model such as the one shown on the qu=
ick reference card and challenge it by having infectious people flow into t=
he I stock periodically; I think that&#39;s a way to explore herd immunity,=
=C2=A0right?=C2=A0 I thought I might do that by using Spikes() much as I sh=
owed in my first email yesterday and have that add to the RHS of the dt(I) =
statement, but that would require the magnitude argument of Spikes() to be =
the AUC, not the peak value.</div><div><br></div><div>Since that doesn&#39;=
 t work, what would be an idiomatic way to accomplish that in MCSim?</div><=
div><br></div><div>I can think of other places that problem would arise. Fo=
r example, one might want to count through the months of a year and then re=
set the month count to 1 upon leaving month 12.=C2=A0 I guess you could use=
 a C mod function for that</div><div><br></div><div>From the PBPK domain, h=
ow do you model taking a pill once a day (or hour or ...)?=C2=A0 I had imag=
ined that Spikes() might be one way, putting x mg of medication in the stom=
ach each day and letting the=C2=A0model take care of its disposition via AD=
ME , but I&#39;m certainly open to learning the way it&#39;s really done.</=
div><div><br></div><div>Thanks,</div><div><br></div><div>Bill</div><div><br=
></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail=
_attr">On Sat, Jul 4, 2020 at 7:53 PM Bill Harris &lt;<a href=3D"mailto:wsh=
[email protected]">[email protected]</a>&gt; wrote:<br></div><blockquote=
 class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px so=
lid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">Mode File:<div><br>=
</div>States =3D {<br>=C2=A0 State<br>=C2=A0 };<br>Inputs =3D {<br>=C2=A0 i=
nflow<br>=C2=A0 };<br>Initial_State =3D 0.0;<br>Initialize{<br>=C2=A0 State=
 =3D Initial_State;<br>=C2=A0 };<br>Dynamics{<br>=C2=A0dt(State) =3D inflow=
;<br>=C2=A0};<br><div>End.</div><div>=C2=A0=C2=A0</div><div>$ makemcsim spi=
kestest.model <br>Creating model.c file from spikestest.model ...<br><br>__=
______________________________________<br><br>Mod v6.1.0 - Model Generator =
for MCSim<br><br>MCSim and associated software comes with ABSOLUTELY NO WAR=
RANTY;<br>This is free software, and you are welcome to redistribute it<br>=
under certain conditions; see the GNU General Public License.<br><br>No Cal=
cOutputs{} equations. Null function defined.<br><br><br>* Created model fil=
e &#39;model.c&#39;.<br><br><br>Compiling and linking model ...<br>Cleaning=
 up ...<br>Created executable mcsim.spikestest<br><div><br></div><div>Input=
 File:</div><div><br></div><div>Integrate(Lsodes,1.0e-6,1.0e-6,0);<br>Outpu=
tFile(&quot;spikes.test01.out&quot;);<br>StartTime(0.0);<br>Initial_State =
=3D 0.0;<br><br>Simulation { # Base<br>inflow =3D 1.0;<br>PrintStep(State,0=
.0,200.0,1.0);<br>PrintStep(inflow,0.0,200.0,1.0);<br>}<br><br>Simulation {=
 # Base w/ Spikes<br>inflow =3D Spikes(<br>=C2=A0 5,<br>=C2=A0 10.0, 10.0, =
=C2=A010.0, =C2=A010.0, =C2=A010.0,<br>=C2=A0 =C2=A00.0, 50.0, 100.0, 150.0=
, 200.0); =C2=A0 =C2=A0 <br>PrintStep(State,0.0,200.0,1.0);<br>PrintStep(in=
flow,0.0,200.0,1.0);<br>}<br><br>End.<br></div><div><br></div><div>OUtput F=
ile:<br><br></div><div>Results of Simulation 1<br><br>Time	State	inflow<br>=
0	0	1<br>1	1	1<br>2	2	1<br>3	3	1<br>4	4	1<br>5	5	1<br>6	6	1<br></div><div>.=
</div><div>.</div><div>.</div><div><br></div><div>Results of Simulation 2<b=
r><br>Time	State	inflow<br>0	0	10<br>1	0	0<br>2	0	0<br>3	0	0<br>4	0	0<br>5	=
0	0<br>6	0	0<br></div><div>.</div><div>.</div><div>.</div><div><br></div><d=
iv>Question: Why doesn &#39;t State jump by 10 every 50 time units?=C2=A0 W=
hat is Spikes doing?</div><div><br></div><div>Thanks,</div><div><br></div><=
div>Bill</div><div>-- <br><div dir=3D"ltr"><div dir=3D"ltr"><div><div dir=
=3D"ltr"><div>Bill Harris=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</div></d=
iv></div></div></div></div></div></div>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div>Bill=
 Harris=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0<br><a href=3D"http://makingsense.facilitatedsystems.com/" target=3D"_bl=
ank">http://makingsense.facilitatedsystems.com/</a></div></div></div></div>=
</div>

--000000000000b261bb05a9b40783--