-
Notifications
You must be signed in to change notification settings - Fork 52
Add model transformer for non-dimensionalisation #984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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, |
As discussed in Meeting of 01.04.2025: A model_transformer should be implemented, that can convert the variable magnitudes according to their units simulation-target specific. For example, the hardware accelerators on SpiNNaker2 only support a 16.15 fixed point format. In .nestml files variables should have their quantity symbol on the left hand side and their unit Symbol on the right.
This way it can be kept track of what type a variable is, e.g. electrical current, and what the magnitude is, e.g. pA. A possibility to deal with the units is to handle them similarly to LEMS/NeuroML where every supported unit is described as a combination of the 7 base SI units needed but AstroPy already handles dimensional analysis so there is no real benefit in that. A list of the supported physical types(dimensions) and units can be found here. It seems like the IEC 60027 standard does regulate such symbols, however I am unable to find an open copy of the text, here is a link to the wikipedia page. If such a short-hand should not be allowed, the grammar will need to be adjusted more than previously thought as the syntax will not be the same as for the units used at the moment. The advantage of using the full names as in Astropy would be that dimensional analysis should already be possible and it can be checked if the rhs of a calculation is in fact a unit of the physical type defined on the lhs of the equation. tl;dr I tink there are 3 options
|
The fundamental question is: what determines the representation format of the quantity, the (platform-agnostic) NESTML model, or the (platform-specific) code generator options? Heretofore, it was always assumed (although not implemented correctly) that the unit on the left-hand side of the defining equation meant "this is the unit that the floating-number implicitly has", for instance:
would be represented as x = 70, whereas
would be represented as x = 0.07. However, these two forms are mathematically equivalent, and we tend to assume that the NESTML model describes a mathematically idealised reality. Instead, representational formats are platform-specific (e.g. float vs. 16.15 fixed-point on SpiNNaker-2). So instead of having variants of iaf_psc_exp like The left-hand side physical units in equations can then be replaced by a physical quantity. |
This syntax is similar to the LEMS approach, see
See also [2] and [3]. [1] Cannon RC, Gleeson P, Crook S, Ganapathy G, Marin B, Piasini E and Silver RA (2014) LEMS: a language for expressing complex biological models in concise and hierarchical form and its use in underpinning NeuroML 2. Front. Neuroinform. 8:79. doi: 10.3389/fninf.2014.00079 [2] Ankur Sinha Padraig Gleeson Bóris Marin Salvador Dura-Bernal Sotirios Panagiotou Sharon Crook Matteo Cantarelli Robert C Cannon Andrew P Davison Harsha Gurnani Robin Angus Silver. (2025) The NeuroML ecosystem for standardized multi-scale modeling in neuroscience eLife 13:RP95135. |
In NESTML, we have a mathematical idealisation of the model, not caring about how it is represented, for instance, In NEST, we have, for instance:
In SpiNNaker-2, we have, for instance:
Do we write them both as We prefer to have only one STDP synapse model. This is to be combined with a table of preferred units for each simulation platform, for instance (hypothetical):
Then, the proposal for new NESTML syntax, is that the left-hand side has physical quantities instead of units, e.g. x V = 70 mV # V for voltage
C_m C = 250 pF # C for capacitance
I_syn I = 42 pA # I for current
substance_amt n = 250 mmol # n for "amount of substance" What about notation -- for example, the following would probably give a parse error due to the space between "luminous" and "intensity":
|
exp(-.07) = 32736182793 (some number) So now let's say we have the expression -> exp(V_m) not allowed! |
Notes from Bernhard:
|
|
Uh oh!
There was an error while loading. Please reload this page.
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.
visitDeclaration()
andvisitDataType()
) inast_builder_visitor.py
to plug in the quantity instead of the unit when creating a declaration.See also #608.
The text was updated successfully, but these errors were encountered: