<?xml version="1.0"?>
<JSim version="1.6.70">
  <project name="proj1">
    <plotpage name="plotpage_1">
      <control name="confPlot" value="0"/>
      <control name="nRow" value="1"/>
      <control name="nCol" value="1"/>
      <control name="liveUpdate" value="false"/>
      <control name="showConf" value="true"/>
      <control name="showXRule" value="false"/>
      <control name="xRule" value="0.5"/>
      <control name="showYRule" value="false"/>
      <control name="yRule" value="0.5"/>
      <control name="showMinMaxSliders" value="false"/>
      <control name="animeDuration" value="10"/>
      <control name="animeRate" value="10"/>
      <control name="animeLoop" value="false"/>
      <control name="animeDir" value="true"/>
      <plot name="plot0">
        <control name="nItems" value="2"/>
        <control name="title" value="[Title]"/>
        <control name="titleX" value="0.5"/>
        <control name="titleY" value="1"/>
        <control name="footer" value="%TIME"/>
        <control name="footerX" value="0"/>
        <control name="footerY" value="0"/>
        <control name="showLegend" value="true"/>
        <control name="showTitle" value="true"/>
        <control name="showFooter" value="true"/>
        <control name="legendX" value="1"/>
        <control name="legendY" value="1"/>
        <control name="style" value="XY plot"/>
        <control name="confItem" value="1"/>
        <control name="confAxis" value="Y"/>
        <plotaxis name="xaxis">
          <control name="log" value="linear"/>
          <control name="autoscale" value="true"/>
          <control name="label" value="axis label"/>
          <control name="showLabel" value="true"/>
          <control name="min" value="0"/>
          <control name="max" value="1"/>
        </plotaxis>
        <plotaxis name="yaxis">
          <control name="log" value="linear"/>
          <control name="autoscale" value="true"/>
          <control name="label" value="axis label"/>
          <control name="showLabel" value="true"/>
          <control name="min" value="0"/>
          <control name="max" value="1"/>
        </plotaxis>
        <plotaxis name="zaxis">
          <control name="log" value="linear"/>
          <control name="autoscale" value="true"/>
          <control name="label" value="axis label"/>
          <control name="showLabel" value="true"/>
          <control name="min" value="0"/>
          <control name="max" value="1"/>
        </plotaxis>
        <plotitem name="item0">
          <control name="src" value="intro1"/>
          <control name="expr" value="C1"/>
          <control name="color" value="black"/>
          <control name="size" value="small"/>
          <control name="shape" value="none"/>
          <control name="line" value="solid"/>
          <control name="thickness" value="medium"/>
          <control name="colorMap" value="none"/>
          <control name="palette" value="heat"/>
          <control name="show" value="true"/>
          <control name="xExpr" value=""/>
          <control name="yExpr" value=""/>
        </plotitem>
        <plotitem name="item1">
          <control name="src" value="intro1"/>
          <control name="expr" value="C2"/>
          <control name="color" value="red"/>
          <control name="size" value="small"/>
          <control name="shape" value="none"/>
          <control name="line" value="solid"/>
          <control name="thickness" value="medium"/>
          <control name="colorMap" value="none"/>
          <control name="palette" value="heat"/>
          <control name="show" value="true"/>
          <control name="xExpr" value=""/>
          <control name="yExpr" value=""/>
        </plotitem>
      </plot>
    </plotpage>
    <model name="intro1">
      <control name="desc" value=""/>
      <control name="easelVariant" value=""/>
      <control name="notes"></control>
      <control name="modelSource">// Introduction to JSim tutorial model

math example1 {		 // simple ODE example
  realDomain t;          // time
  t.min   = 0; 
  t.max   = 30; 
  t.delta = 0.15; 

  real	Fp=0.016666667,  // static variables
        Vp=0.07, 
        Wp=0.94, 
        PSg=0.05, 
        Visfp=0.35;

  extern real Cin(t);	 // externally calculated variable	

  real C1(t), C2(t);     // State variables
		
  // initial conditions
  when(t=t.min) {
    C1 = 0;
    C2 = 0;
  }

  // ODEs
  C1:t = Fp/Vp*(Cin-C1) - PSg/Vp*(C1/Wp-C2);
  C2:t = PSg/Visfp*(C1/Wp-C2);
}

//
// This is a linear, constant-parameter, two-region model:
//
//            _________________
// Fp         |Vp,Wp   C1(t)  |
// Cin(t) ---&gt;|               |---&gt; C1(t)
//            |      PSg      |
//            |       ^       |
//            --------|--------
//            |       v       |
//            |               |
//            |Visfp   C2(t)  |
//            -----------------
// ODEs:
//    dC1(t)/dt = Fp/Vp*(Cin-C1) - PSg/Vp*(C1/Wp-C2)
//    dC2(t)/dt = PSg/Visfp*(C1/Wp-C2)
//
// I.C.: C1(t)|t=0 = 0
//       C2(t)|t=0 = 0
//
// Model Parameters:
//    Fp    - Flow, 0.01667 ml/sec/g
//    Vp    - Plasma volume, 0.07 ml/g
//    Wp    - Water content for plasma, 0.94, unitless
//    Vp*Wp - Volume of distribution of plasma region, ml/g
//    Visfp - Volume of distribution of ISF region, 0.35 ml/g
//    PSg   - Permeability-surface area product between ISF to plasma, ml/sec/g
//
//    time unit for ODE solutions - second
//
// Model input function:
//    Cin - inflow concentration, mmol/ml of plasma
//          (external and provided by XSIM)
//
//          Note: The model is implemented such that the input function
//                is taken as constant value for each time step t to t+dt.
//                However, C1 and C2 are the concentrations at the end of
//                the time step.
//
// Model output function:
//    C1   - Concentration in plasma (Vp), mmol/ml of plasma
//    C2   - Concentration in ISF (Visfp), mmol/ml of volume of distribution
//           in interstitial region.
</control>
      <control name="sourceType" value="mml"/>
      <control name="auxName" value=""/>
      <control name="parSetName" value=""/>
      <control name="parSetModified" value="true"/>
      <control name="built" value="true"/>
      <control name="customRTML"></control>
      <control name="customBuilt" value="false"/>
      <vars name="vars"/>
      <parset name="last">
        <vars name="vars">
          <solver name="solver">
            <control name="ode_which" value="Auto"/>
            <control name="ode_Dopri5_reltol" value="1E-7"/>
            <control name="ode_Dopri5_abstol" value="1E-7"/>
            <control name="ode_Dopri5_nstep" value="100000"/>
            <control name="ode_Dopri5_stiff" value="1000"/>
            <control name="ode_Dopri5_round" value="2.3E-16"/>
            <control name="ode_Dopri5_safety" value="0.9"/>
            <control name="ode_Dopri5_loselect" value="0.2"/>
            <control name="ode_Dopri5_hiselect" value="10"/>
            <control name="ode_Dopri5_beta" value="0.04"/>
            <control name="ode_Euler_nstep" value="2"/>
            <control name="ode_Fehlberg_minstep" value="1E-4"/>
            <control name="ode_Fehlberg_maxstep" value="0.1"/>
            <control name="ode_Fehlberg_tol" value="1E-6"/>
            <control name="ode_KM_minstep" value="1E-4"/>
            <control name="ode_KM_maxstep" value="0.1"/>
            <control name="ode_KM_tol" value="1E-6"/>
            <control name="ode_Radau_reltol" value="1E-4"/>
            <control name="ode_Radau_abstol" value="1E-7"/>
            <control name="ode_Radau_nstep" value="100000"/>
            <control name="ode_Radau_round" value="1E-16"/>
            <control name="ode_Radau_safety" value="0.9"/>
            <control name="ode_Radau_minord" value="3"/>
            <control name="ode_Radau_maxord" value="7"/>
            <control name="ode_Radau_initord" value="3"/>
            <control name="ode_Radau_newton" value="7"/>
            <control name="ode_Radau_jacob" value="0.001"/>
            <control name="ode_Radau_losize" value="1"/>
            <control name="ode_Radau_hisize" value="1.2"/>
            <control name="ode_Radau_loselect" value="0.2"/>
            <control name="ode_Radau_hiselect" value="8"/>
            <control name="ode_Radau_locontract" value="0.002"/>
            <control name="ode_Radau_hicontract" value="0.8"/>
            <control name="ode_Radau_hiorder" value="1.2"/>
            <control name="ode_Radau_loorder" value="0.8"/>
            <control name="ode_RK4_nstep" value="2"/>
            <control name="ode_CVode_reltol" value="1E-7"/>
            <control name="ode_CVode_abstol" value="1E-8"/>
            <control name="ode_CVode_maxsteps" value="100000"/>
            <control name="ode_CVode_stiff" value="false"/>
            <control name="pde_which" value="LSFEA"/>
            <control name="pde_MacCormack_FCT" value="false"/>
            <control name="fzero_unbound" value="ggopt"/>
            <control name="fzero_bound" value="simplex"/>
            <control name="fzero_errtol" value="1E-6"/>
            <control name="fzero_maxcalls" value="500"/>
            <control name="fzero_maxiters" value="100"/>
            <control name="fzero_eps" value="1E-6"/>
            <control name="fzero_istep" value="0.01"/>
            <control name="fzero_npoints" value="5"/>
          </solver>
          <assign name="vars">
            <control name="t.min" value="0"/>
            <control name="t.max" value="30"/>
            <control name="t.delta" value="0.15"/>
            <control name="Fp" value="0.016666667"/>
            <control name="Vp" value="0.07"/>
            <control name="Wp" value="0.94"/>
            <control name="PSg" value="0.05"/>
            <control name="Visfp" value="0.35"/>
            <control name="C1__init" value="0"/>
            <control name="C2__init" value="0"/>
            <control name="Cin" value="exp(-t)"/>
          </assign>
        </vars>
        <control name="desc" value=""/>
        <control name="notes"></control>
      </parset>
      <imageset name="images"/>
      <loops name="loops">
        <loop name="outer">
          <control name="mode" value="auto"/>
          <control name="ntimes" value="3"/>
          <control name="npars" value="1"/>
          <looppar name="looppar0">
            <control name="par" value=""/>
            <control name="values" value=""/>
            <control name="enabled" value="true"/>
          </looppar>
        </loop>
        <loop name="inner">
          <control name="mode" value="auto"/>
          <control name="ntimes" value="3"/>
          <control name="npars" value="1"/>
          <looppar name="looppar0">
            <control name="par" value=""/>
            <control name="values" value=""/>
            <control name="enabled" value="true"/>
          </looppar>
        </loop>
      </loops>
      <sens name="sens">
        <control name="npars" value="1"/>
        <senspar name="senspar0">
          <control name="par" value=""/>
          <control name="delta" value="0.01"/>
          <control name="enabled" value="true"/>
        </senspar>
      </sens>
      <optim name="optim">
        <control name="npars" value="1"/>
        <control name="nmatches" value="1"/>
        <control name="alg" value="simplex"/>
        <control name="maxCalls" value="50"/>
        <control name="maxIters" value="10"/>
        <control name="errTol" value="0.001"/>
        <control name="stepTol" value="1E-6"/>
        <control name="gradTol" value="1E-6"/>
        <control name="npoints" value="5"/>
        <control name="eps" value="1E-6"/>
        <optpar name="optpar0">
          <control name="par" value=""/>
          <control name="min" value="NaN"/>
          <control name="max" value="NaN"/>
          <control name="step" value="0.01"/>
          <control name="enabled" value="true"/>
        </optpar>
        <optmatch name="optmatch0">
          <control name="src" value=""/>
          <control name="data" value=""/>
          <control name="expr" value=""/>
          <control name="pointWgts" value="1"/>
          <control name="step" value="1"/>
          <control name="enabled" value="true"/>
        </optmatch>
      </optim>
      <rtml name="rtml"/>
    </model>
  </project>
</JSim>
