Hi all,
when converting an SBML model to Matlab the initial conditions are incorrect for species in amounts if the initial values are set via the initialConcentration attribute on species.
Example attached:
%Initial conditions vector
x0=zeros(6,1);
x0(1) = 5.0;
x0(2) = 0.8;
x0(3) = 6.0E-5;
x0(4) = 0.0;
x0(5) = 5.0;
x0(6) = 0.8;
```
For
<listOfCompartments>
<compartment id="Vpa" name="pancreas tissue" spatialDimensions="3" size="0.5" units="litre" constant="true"/>
<compartment id="Vext" name="pancreas blood" spatialDimensions="3" size="0.1" units="litre" constant="true"/>
</listOfCompartments>
<listOfSpecies>
<species id="Aext_glc" name="glucose" compartment="Vext" initialConcentration="5" substanceUnits="mmole" hasOnlySubstanceUnits="true" boundaryCondition="true" constant="false"/>
<species id="Aext_lac" name="lactate" compartment="Vext" initialConcentration="0.8" substanceUnits="mmole" hasOnlySubstanceUnits="true" boundaryCondition="false" constant="false"/>
<species id="Aext_ins" name="insulin" compartment="Vext" initialConcentration="6e-05" substanceUnits="mmole" hasOnlySubstanceUnits="true" boundaryCondition="false" constant="false"/>
<species id="Aext_cpep" name="c-peptide" compartment="Vext" initialConcentration="0" substanceUnits="mmole" hasOnlySubstanceUnits="true" boundaryCondition="false" constant="false"/>
<species id="Apa_glc" name="glucose" compartment="Vpa" initialConcentration="5" substanceUnits="mmole" hasOnlySubstanceUnits="true" boundaryCondition="false" constant="false"/>
<species id="Apa_lac" name="lactate" compartment="Vpa" initialConcentration="0.8" substanceUnits="mmole" hasOnlySubstanceUnits="true" boundaryCondition="false" constant="false"/>
</listOfSpecies>
Due to setting initialConcentrations for species tracked in amount the correct initial conditions are the values divided by the compartment volumes.
Vext=0.1, Vpa=0.5
This has to be done correctly on a species to species basis, i.e. check the `hasOnlySubstanceUnits` flag and thean converting `initialAmount` and `initialConcentration` accordingly.
%Initial conditions vector
x0=zeros(6,1);
x0(1) = 5.0/0.1;
x0(2) = 0.8/0.1;
x0(3) = 6.0E-5/0.1;
x0(4) = 0.0/0.1;
x0(5) = 5.0/0.5;
x0(6) = 0.8/0.5;
``
Most likely the same bug affects species in concentrations ifinitialAmount` is set.
Best Matthias