Unit validation not working on AssignmentRule
Closed this issue · 3 comments
Hi all,
I have a model were the units in the math of the AssignmentRule do not match the variable. But the unit validation does not raise a UnitError. The model is attached here: dapagliflozin_kidney.zip
<unitDefinition id="g_per_mole" name="g/mole">
<listOfUnits>
<unit kind="gram" exponent="1" scale="0" multiplier="1"/>
<unit kind="mole" exponent="-1" scale="0" multiplier="1"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="mmole" name="mmole">
<listOfUnits>
<unit kind="mole" exponent="1" scale="0" multiplier="0.001"/>
</listOfUnits>
</unitDefinition>
<species metaid="meta_glc_urine" sboTerm="SBO:0000247" id="glc_urine" name="glucose (urine)" compartment="Vurine" initialConcentration="0" substanceUnits="mmole" hasOnlySubstanceUnits="true" boundaryCondition="false" constant="false"/>
The variable is UGE (urinary glucose excretion) with the unit "gram".
<parameter id="UGE" name="urinary glucose excretion (UGE)" value="NaN" units="gram" constant="false"/>
<parameter metaid="meta_Mr_glc" sboTerm="SBO:0000647" id="Mr_glc" name="Molecular weight glc [g/mole]" value="180" units="g_per_mole" constant="true"/>
And the corresponding assignment rule:
<assignmentRule name="urinary glucose excretion (UGE)" variable="UGE">
<notes>
<body xmlns="http://www.w3.org/1999/xhtml">
<p>Urinary glucose excretion is calculated from cumulative amount of glucose in urine.</p>
</body>
</notes>
<math xmlns="http://www.w3.org/1998/Math/MathML" xmlns:sbml="http://www.sbml.org/sbml/level3/version2/core">
<apply>
<divide/>
<apply>
<times/>
<ci> glc_urine </ci>
<ci> Mr_glc </ci>
</apply>
<cn sbml:units="dimensionless" type="integer"> 1000 </cn>
</apply>
</math>
</assignmentRule>
glc_urine [mmole] * Mr_glc [g/mole] = mg != g
, i.e., the variable is in g, but the math of the assignment has the units mg. This should give a UnitError.
The same issue happens when not using the factor 1000 in the equation (just but this in so the values are correct)
Normally such errors are correctly handled, not sure why this is not the case here.
Best Matthias
Hi all,
thanks for looking into this.
Let me know if you need any more information on the issue.
Best Matthias
Hi Matthias,
Are you using checkConsistencyWithStrictUnits? This does report an error
Perfect. Thanks. Solves the issue.
Did not know about that ;)