Add model transformer for non-dimensionalisation
Currently, physical units and their factors (nano-, micro-, kilo-, etc.) are stored in the model AST and converted by the printers during code generation.
I would suggest to replace this architecture with a transformer, that converts a model with quantities in terms of physical units, to a model containing only real-typed quantities (and int, bool, string, etc). Then, the printers and code generator do not have to deal with conversion factors.
- [ ] A possible downside of this is that the units information is not available at all any more to the printers. So they would not be able to print the original units any longer, even in code comments. We would need to ensure there is a workaround for this; possibly an attribute inside the ASTVariable class.
- [ ] Change NESTML grammar: needed for changing units into quantities? Not necessary, same syntax as physical units. However, can change the name of the rule to keep quantities and units conceptually seperate.
- [ ] Create new ASTPhysicalQuantity class. Change the AST nodes involved: ASTDeclaration would have a physical quantity member instead of data_type member.
- [ ] Change the parser (e.g.
visitDeclaration()andvisitDataType()) inast_builder_visitor.pyto plug in the quantity instead of the unit when creating a declaration. - [ ] Change the ASTExpressionTypeVisitor
- [ ] Change the units for physical quantities also in NESTML function parameter types and return values.
- [ ] Fix the units consistency testing (see e.g. OdeConsistentUnitsVisitor)
See also #608.
Suggestion from @heplesser: to ward against confusion between variable names and unit literals, NESTML should allow unit literals to appear only directly after numeric literals, for example, V' = 2 * V - V_L would have V as voltage, exp(-V / (1 V)) would have the voltage in the numerator, divided by 1 V to make it unitless.