*.model.R
)*.in.R
)# Model description file (this is a comment)<Global variable specifications> States = { <state variables for the model, such as quantity> } Outputs = { <output variables, such as concentration> } Inputs = { <input variables, such as exposure dose>}Initialize { <Equations for initializing or scaling model parameters>}Dynamics { <Equations for computing derivatives of the state variables>}CalcOutputs { <Equations for computing output variables>}End. # mandatory ending keyword
## Description ##### 1-compartment model with 1st-order absorption rate and # linear elimination ## version: 1## Date: 04-25-2019# # Units: # - time in hr# - volumes in L# - masses of substances in mg# - concentrations of substances in mg/L
States
are variables for which a first-order differential equation is defined in the Dynamics{}
sectionStates = {A_central, # Quantity in central compartment (mg) A_elim}; # ~ eliminated
Outputs
are dependent model variables (obtainable at any time as analytical functions of the states, inputs or parameters) that do not have dynamics.Dynamics{}
or CalcOutputs{}
sections.Outputs = {C_central, # Concentration in central compartment (mg/l) A_total}; # Total quantity for mass balance
Inputs
are variables independent of the others variables, but eventually varying with time (for example an exposure concentration to a chemical).Inputs = {Oral_input}; # Chemical input (mg)
Global variable specifications
# Chemical-specific parameterKe = 0.1; # Elimination rate constant (1/h)Pct_M_central = 0.05; # % body weight, fractional volume of distribution # Physiological-specific parameterBW = 60; # Body weight (kg) # Exposure parameterOralDose = 100; # Oral dose (mg/kg)Period = 12.0; # period of the exposure/no exposure cycle (h)Tlag = 0.0; # Absorption lagtime (h)Ka = 0.1; # Intestinal absorption rate constant (1/h)# Scale parameter computed in InitializeV_central; # Distribution volume of central compartment (L)IngDose; # Ingested dose (mg) Oral_input = PerExp (IngDose, Period, Tlag, Ka);
[*] The Oral_input
can be defined in input file
Initialize { IngDose = BW * OralDose; V_central = BW * Pct_M_central; }
Dynamics { dt (A_elim) = Ke * A_central; dt (A_central) = Ka * Oral_input - Ke * A_central;}
CalcOutputs { C_central = A_central / V_central; A_total = A_central + A_elim;}
** Error: End keyword is missing in file modeling/one.model.R.One or more fatal errors: Exiting...
** Error: State variable 'A_central' has no dynamics.State equations missing.One or more fatal errors: Exiting...
** Error: Output variable 'A_total' is not computed anywhere.Output equations missing.One or more fatal errors: Exiting...
** Error: line 37: Undefined identifier 'Period'.One or more fatal errors: Exiting...
** Error: Output variable 'l' is not computed anywhere.Output equations missing.One or more fatal errors: Exiting...
# Input-file (text after # are comments)<Global assignments and specifications>Simulation { <Local assignments and specifications> <Specifications for first simulation>}Simulation { <Local assignments and specifications> <Specifications for second simulation>}# Unlimited number of simulation specificationsEnd. # Mandatory End keyword. Everything after this line is ignored
Moving back to the MCSim syntax, this is an example of basic simulation. The only thing you need to do is provide the given condition in your simulation, which is the output time points and the output variables.
You can also use multiple sections to define your simulation. For example, the simulation one can be used to specify the low dose exposure scenario and the second section can be used to specified the high dose exposure scenario.
These functions can use to different exposure types
- PerDose(): # specifies a periodic input of constant PerDose(<magnitude>, <period>, <initial-time>, <exposure-time>);- PerExp(): # specifies a periodic exponential input. PerExp(<magnitude>, <period>, <initial-time>, <decay-constant>); - PerTransit(): models a delayed input mechanism PerTransit(<magnitude>, <period>, <initial-time-in-period>, <decay-constant>, <number-of-input-compartments>); - NDoses(): specifies a number of stepwise inputs of variable magnitude and their starting times NDoses(<n>, <list-of-magnitudes>, <list-of-initial-times>);- Spikes(): specifies a number of instantaneous inputs of variable magnitude and their exact times of occurrence. Spikes(<n>, <list-of-magnitudes>, <list-of-times>);
Here is the list of supported input function in MCSim that can be used to describe the different exposure type. For example, the first one PerDose can be used to describe the periodic intake of the specific compound, so we can use this method to predict the steady state under the particular exposure scenario.
Besides, the NDoses function can let you used the different level of exposure and the starting time points based on the exposure scenario. Also, in pharmacology research, the spikes function can be used to describe the intravenous PK data.
# ./mcsim.one.model.R.exe one.in.RIntegrate (Lsodes, 1e-12, 1e-15, 1);Period = 1E6; # One-time doseKa = 1.3; Pct_M_central = 1;Simulation { # 1 OralDose = 100; BW = 60; PrintStep (Oral_input, A_central, A_elim, A_total, C_central, 0, 96, 0.5);}Simulation { # 2 OralDose = 150; BW = 80; PrintStep (Oral_input, A_central, A_elim, A_total, C_central, 0, 96, 0.5);}End.
Error: line 10: Expected <model-variable> before 'Kb'Reading experiment 1.Error: line 14: Bad definition of experiment 1
Error: line 11: Expected ';' before 'S'.Error: line 15: Unclosed level statementFatal errors. Exiting.
Bois et al. (1996) - Population toxicokinetics of tetrachloroethylene
Chiu and Bois (2006) - Revisiting the population toxicokinetics of tetrachloroethylene
Input file: EB_exercise_1.in.R
# ./mcsim.EB.model.R.exe EB_exercise_1.in.RIntegrate (Lsodes, 1e-9, 1e-11 , 1);Simulation { # Inhalation concentration in ppm Cppm = NDoses (2, 100, 0, 0, 4 ); PrintStep(Cvtot, 0, 6, 0.01); } End.
Input file: EB_exercise_2.in.R
# ./mcsim.EB.model.R.exe EB_exercise_2.in.RIntegrate (Lsodes, 1e-9, 1e-11 , 1);Simulation { # 1 1 ppm # Inhalation concentration in ppm Cppm = NDoses (2, 1, 0, 0, 96 ); PrintStep(Cart, Cvtot, 0, 96, 1); } Simulation { # 2 10 ppm # Inhalation concentration in ppm Cppm = NDoses (2, 10, 0, 0, 96 ); PrintStep(Cart, Cvtot, 0, 96, 1); } Simulation { # 3 100 ppm # Inhalation concentration in ppm Cppm = NDoses (2, 100, 0, 0, 96 ); PrintStep(Cart, Cvtot, 0, 96, 1); } Simulation { # 4 1000 ppm # Inhalation concentration in ppm Cppm = NDoses (2, 1000, 0, 0, 96 ); PrintStep(Cart, Cvtot, 0, 96, 1); } End.
Hint: Add following information in model file:
Amet_Rl, # Amount metabolized in liver (moles)Amet_Rlu, # Amount metabolized in lung (moles)Amet_Rvrg # Amount metabolized in richly perfused tissue (moles)dt(Amet_Rl) = Rl;dt(Amet_Rlu) = Rlu;dt(Amet_Rvrg) = Rvrg;
Input file: EB_exercise_3.in.R
# ./mcsim.EB.model.R.exe EB_exercise_3.in.RIntegrate (Lsodes, 1e-9, 1e-11 , 1);Simulation { # 1 1 ppm # Inhalation concentration in ppm Cppm = NDoses (2, 1, 0, 0, 8 ); PrintStep(Ain, Amet_Rl, Amet_Rlu, Amet_Rvrg, Amet, 0, 8, 0.5); } Simulation { # 2 10 ppm # Inhalation concentration in ppm Cppm = NDoses (2, 10, 0, 0, 8 ); PrintStep(Ain, Amet_Rl, Amet_Rlu, Amet_Rvrg, Amet, 0, 8, 0.5); } Simulation { # 3 100 ppm # Inhalation concentration in ppm Cppm = NDoses (2, 100, 0, 0, 8 ); PrintStep(Ain, Amet_Rl, Amet_Rlu, Amet_Rvrg, Amet, 0, 8, 0.5); } Simulation { # 4 1000 ppm # Inhalation concentration in ppm Cppm = NDoses (2, 1000, 0, 0, 8 ); PrintStep(Ain, Amet_Rl, Amet_Rlu, Amet_Rvrg, Amet, 0, 8, 0.5); } End.
Hint: Add following information in model file:
Oral_inputPO_dose = 0.0; # Ingested dose (mg/kg)Oral_dose; # Oral dose (mg)Period = 1e2; # Period of the exposure/no exposure cycle (h)Tlag = 0.0; # Absorption lagtime (h)Ka = 1.0; # Intestinal absorption rate constant (1/h)Oral_input = PerExp (Oral_dose, Period, Tlag, Ka);Oral_dose = PO_dose * BW;dt(Al) = Oral_input + Ql*(Cart - Cvl) - Rl;
Input file: EB_exercise_4.in.R
# ./mcsim.EB.model.R.exe EB_exercise_4.in.RIntegrate (Lsodes, 1e-9, 1e-11 , 1);Simulation { # 1 PO_dose = 180; Ka = 0.6; PrintStep(Oral_input, Cvtot, 0, 24, 0.1); } End.
*.model.R
)*.in.R
)Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |