help-mcsim
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with iSpikes


From: fredomatic
Subject: Re: Help with iSpikes
Date: Sun, 5 Jul 2020 20:45:14 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

Well, nothing happens instantaneously in real life, only in Xmen movies.
People are not teleported to a place, etc. So, you may want to use a
first order rate over a short period of time. That would deliver the
right amount of stuff over a reasonably short period of time. Like
boarding off a boat: takes an hour or so; spiking a solution with a
pipette: takes 2 to 5 seconds; intra-venous injection: 5-10 seconds in
fact; etc.
If you really want to simulate an instantaneous change of a state
variable, you should use an Event. At the said time, the state variable
changes instantaneously (the integration is paused and restarted to go
over the discontinuity). But that is just an approximation of the real
process, most of the times.
You should not try to use Spikes for all of that. Spikes is only for
obscure "clever" uses which are probably bad ideas anyway!

Frederic



On 05/07/2020 18:12, Bill Harris wrote:
> 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 <wsharris13@gmail.com
> <mailto:wsharris13@gmail.com>> 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/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]