From f85e4b8026042a0994c85ec2d646d742f2758935 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Thu, 4 Jul 2024 00:24:12 +1200 Subject: [PATCH 1/2] Analyser: properly scale the computation of a rate. --- src/analyser.cpp | 2 +- .../cellml_unit_scaling_voi_indirect/model.c | 11 ++-- .../model.cellml | 60 +++++++++++++------ .../cellml_unit_scaling_voi_indirect/model.h | 2 +- .../cellml_unit_scaling_voi_indirect/model.py | 11 ++-- 5 files changed, 58 insertions(+), 28 deletions(-) diff --git a/src/analyser.cpp b/src/analyser.cpp index 9d33025317..8b7c869481 100644 --- a/src/analyser.cpp +++ b/src/analyser.cpp @@ -2453,7 +2453,7 @@ void Analyser::AnalyserImpl::scaleEquationAst(const AnalyserEquationAstPtr &ast) auto astGrandparent = astParent->parent(); if (astGrandparent->mPimpl->mType == AnalyserEquationAst::Type::EQUALITY) { - scaleAst(astGrandparent->mPimpl->mOwnedRightChild, astGrandparent, 1.0 / scalingFactor); + scaleAst(astGrandparent->mPimpl->mOwnedRightChild, astGrandparent, scalingFactor); } else { scaleAst(astParent, astGrandparent, 1.0 / scalingFactor); } diff --git a/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.c b/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.c index 793b2aea23..bdaea3fb38 100644 --- a/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.c +++ b/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.c @@ -8,14 +8,15 @@ const char VERSION[] = "0.5.0"; const char LIBCELLML_VERSION[] = "0.5.0"; -const size_t STATE_COUNT = 2; +const size_t STATE_COUNT = 3; const size_t VARIABLE_COUNT = 0; -const VariableInfo VOI_INFO = {"t", "ms", "environment", VARIABLE_OF_INTEGRATION}; +const VariableInfo VOI_INFO = {"t", "second", "environment", VARIABLE_OF_INTEGRATION}; const VariableInfo STATE_INFO[] = { - {"x", "mM", "t_in_ms", STATE}, - {"x", "mM", "t_in_s", STATE} + {"x", "metre", "t_in_s", STATE}, + {"x", "metre", "t_in_ms", STATE}, + {"x", "metre", "t_in_ks", STATE} }; const VariableInfo VARIABLE_INFO[] = { @@ -52,6 +53,7 @@ void initialiseVariables(double *states, double *rates, double *variables) { states[0] = 3.0; states[1] = 7.0; + states[2] = 11.0; } void computeComputedConstants(double *variables) @@ -62,6 +64,7 @@ void computeRates(double voi, double *states, double *rates, double *variables) { rates[0] = 5.0; rates[1] = 1000.0*9.0; + rates[2] = 0.001*13.0; } void computeVariables(double voi, double *states, double *rates, double *variables) diff --git a/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.cellml b/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.cellml index d8535c5618..20b9d17a45 100644 --- a/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.cellml +++ b/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.cellml @@ -1,29 +1,50 @@ - + - - - + + - - + + - - + + + + + + - + + + + + + + + + + + + t + + x + + 5 + + - + @@ -34,13 +55,13 @@ x - 5 + 9 - - - + + + @@ -51,14 +72,17 @@ x - 9 + 13 + + + - + diff --git a/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.h b/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.h index d683c7fb00..63103f19b5 100644 --- a/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.h +++ b/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.h @@ -20,7 +20,7 @@ typedef enum { typedef struct { char name[2]; - char units[3]; + char units[7]; char component[12]; VariableType type; } VariableInfo; diff --git a/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.py b/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.py index 91d0a5bb94..bd6d5e2beb 100644 --- a/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.py +++ b/tests/resources/generator/cellml_unit_scaling_voi_indirect/model.py @@ -7,7 +7,7 @@ __version__ = "0.4.0" LIBCELLML_VERSION = "0.5.0" -STATE_COUNT = 2 +STATE_COUNT = 3 VARIABLE_COUNT = 0 @@ -19,11 +19,12 @@ class VariableType(Enum): ALGEBRAIC = 4 -VOI_INFO = {"name": "t", "units": "ms", "component": "environment", "type": VariableType.VARIABLE_OF_INTEGRATION} +VOI_INFO = {"name": "t", "units": "second", "component": "environment", "type": VariableType.VARIABLE_OF_INTEGRATION} STATE_INFO = [ - {"name": "x", "units": "mM", "component": "t_in_ms", "type": VariableType.STATE}, - {"name": "x", "units": "mM", "component": "t_in_s", "type": VariableType.STATE} + {"name": "x", "units": "metre", "component": "t_in_s", "type": VariableType.STATE}, + {"name": "x", "units": "metre", "component": "t_in_ms", "type": VariableType.STATE}, + {"name": "x", "units": "metre", "component": "t_in_ks", "type": VariableType.STATE} ] VARIABLE_INFO = [ @@ -41,6 +42,7 @@ def create_variables_array(): def initialise_variables(states, rates, variables): states[0] = 3.0 states[1] = 7.0 + states[2] = 11.0 def compute_computed_constants(variables): @@ -50,6 +52,7 @@ def compute_computed_constants(variables): def compute_rates(voi, states, rates, variables): rates[0] = 5.0 rates[1] = 1000.0*9.0 + rates[2] = 0.001*13.0 def compute_variables(voi, states, rates, variables): From 48c71379045203d3600d1ddec50bca84c0cb3400 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Thu, 4 Jul 2024 00:28:11 +1200 Subject: [PATCH 2/2] Addressed spelling issue. --- .codespellexclude | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.codespellexclude b/.codespellexclude index 2de0f331fa..f675ea3109 100644 --- a/.codespellexclude +++ b/.codespellexclude @@ -13,3 +13,5 @@ if (index < pFunc()->mErrors.size()) { issue = pFunc()->mIssues.at(pFunc()->mErrors.at(index)); return pFunc()->mErrors.size(); +identity and expression, level of experience, education, socio-economic status, + "W3C MathML DTD error: Element apply content does not follow the DTD, expecting (csymbol | ci | cn | apply | reln | lambda | condition | declare | sep | semantics | annotation | annotation-xml | integers | reals | rationals | naturalnumbers | complexes | primes | exponentiale | imaginaryi | notanumber | true | false | emptyset | pi | eulergamma | infinity | interval | list | matrix | matrixrow | set | vector | piecewise | lowlimit | uplimit | bvar | degree | logbase | momentabout | domainofapplication | inverse | ident | domain | codomain | image | abs | conjugate | exp | factorial | arg | real | imaginary | floor | ceiling | not | ln | sin | cos | tan | sec | csc | cot | sinh | cosh | tanh | sech | csch | coth | arcsin | arccos | arctan | arccosh | arccot | arccoth | arccsc | arccsch | arcsec | arcsech | arcsinh | arctanh | determinant | transpose | card | quotient | divide | power | rem | implies | vectorproduct | scalarproduct | outerproduct | setdiff | fn | compose | plus | times | max | min | gcd | lcm | and | or | xor | union | intersect | cartesianproduct | mean | sdev | variance | median | mode | selector | root | minus | log | int | diff | partialdiff | divergence | grad | curl | laplacian | sum | product | limit | moment | exists | forall | neq | factorof | in | notin | notsubset | notprsubset | tendsto | eq | leq | lt | geq | gt | equivalent | approx | subset | prsubset | mi | mn | mo | mtext | ms | mspace | mrow | mfrac | msqrt | mroot | menclose | mstyle | merror | mpadded | mphantom | mfenced | msub | msup | msubsup | munder | mover | munderover | mmultiscripts | mtable | mtr | mlabeledtr | mtd | maligngroup | malignmark | maction)*, got (CDATA bvar ).",