NEURON
codegen.yaml
Go to the documentation of this file.
1 # Copyright 2023 Blue Brain Project, EPFL.
2 # See the top-level LICENSE file for details.
3 #
4 # SPDX-License-Identifier: Apache-2.0
5 
6 ######################### NMODL Abstract Language Definition ##############################
7 #
8 # PURPOSE
9 # =======
10 #
11 # NMODL language specification in nmod.yaml takes care of representing NMODL language
12 # AST generation. This AST is sufficient for NMODL level analysis and optimizations.
13 # In order to perform code generation transformations, we need to perform various
14 # transoformations on AST and add new node types. For example, PROCEDURE and FUNCTION
15 # nodes in NMODL doesn't have return type (double by default). Also, we can't represent
16 # code generation specific information (e.g. variable or function qualifiers) with the
17 # existing AST nodes. This yaml specification describe additional node types that can
18 # be used for code generation purpose. Note that they are using same inheritance
19 # hierarchy because we would like to use single AST to represent the NMODL with and
20 # without code generation transformations.
21 
22 - AST:
23  children:
24  - Node:
25  children:
26  - Expression:
27  children:
28  - Number:
29  - Identifier:
30  - Block:
31  children:
32  - NrnStateBlock:
33  nmodl: "NRN_STATE "
34  brief: "Represents the coreneuron nrn_state callback function"
35  members:
36  - solve_statements:
37  brief: "solve blocks to be called or generated"
38  type: Statement
39  vector: true
40  - EigenNewtonSolverBlock:
41  brief: "Represent newton solver solution block based on Eigen"
42  nmodl: "EIGEN_NEWTON_SOLVE"
43  members:
44  - n_state_vars:
45  brief: "number of state vars used in solve"
46  type: Integer
47  prefix: {value: "["}
48  suffix: {value: "]"}
49  - variable_block:
50  brief: "Statements to be declared in the functor"
51  type: StatementBlock
52  - initialize_block:
53  brief: "Statement block to be executed before calling newton solver"
54  type: StatementBlock
55  - setup_x_block:
56  brief: "update X from states"
57  type: StatementBlock
58  - functor_block:
59  brief: "odes as functor for eigen"
60  type: StatementBlock
61  - update_states_block:
62  brief: "update back states from X"
63  type: StatementBlock
64  - finalize_block:
65  brief: "Statement block to be executed after calling newton solver"
66  type: StatementBlock
67  - EigenLinearSolverBlock:
68  brief: "Represent linear solver solution block based on Eigen"
69  nmodl: "EIGEN_LINEAR_SOLVE"
70  members:
71  - n_state_vars:
72  brief: "number of state vars used in solve"
73  type: Integer
74  prefix: {value: "["}
75  suffix: {value: "]"}
76  - variable_block:
77  brief: "Statements to be declared in the functor"
78  type: StatementBlock
79  - initialize_block:
80  brief: "Statement block to be executed before calling linear solver"
81  type: StatementBlock
82  - setup_x_block:
83  brief: "update X from states"
84  type: StatementBlock
85  - update_states_block:
86  brief: "update back states from X"
87  type: StatementBlock
88  - finalize_block:
89  brief: "Statement block to be executed after calling linear solver"
90  type: StatementBlock
91  - MatexpBlock:
92  brief: "Represent matexp solver solution block based on Eigen"
93  nmodl: "MATEXP_SOLVE"
94  members:
95  - steadystate:
96  brief: "If true then find steadystate solution, else advance by dt"
97  type: Boolean
98  prefix: {value: " ("}
99  suffix: {value: ") "}
100  - jacobian_block:
101  brief: "Block of statements that assign to the Jacobian matrix"
102  type: StatementBlock
103  - conserve:
104  brief: "Conserve statements found in jacobian block"
105  type: Conserve
106  vector: true
107  prefix: {value: " CONSERVE("}
108  suffix: {value: ")"}
109  separator: ", "
110  - CvodeBlock:
111  nmodl: "CVODE_BLOCK "
112  members:
113  - name:
114  brief: "Name of the block"
115  type: Name
116  node_name: true
117  suffix: {value: " "}
118  - n_odes:
119  brief: "number of ODEs to solve"
120  type: Integer
121  prefix: {value: "["}
122  suffix: {value: "]"}
123  - non_stiff_block:
124  brief: "Block with statements of the form Dvar = f(var), used for updating non-stiff systems"
125  type: StatementBlock
126  - stiff_block:
127  brief: "Block with statements of the form Dvar = Dvar / (1 - dt * J(f)), used for updating stiff systems"
128  type: StatementBlock
129  brief: "Represents a block used for variable timestep integration (CVODE) of DERIVATIVE blocks"
130  - LongitudinalDiffusionBlock:
131  brief: "Extracts information required for LONGITUDINAL_DIFFUSION for each KINETIC block."
132  nmodl: "LONGITUDINAL_DIFFUSION_BLOCK"
133  members:
134  - name:
135  brief: "Name of the longitudinal diffusion block"
136  type: Name
137  node_name: true
138  prefix: { value: " "}
139  suffix: { value: " "}
140  - longitudinal_diffusion_statements:
141  brief: "All LONGITUDINAL_DIFFUSION statements in the KINETIC block."
142  type: StatementBlock
143  - compartment_statements:
144  brief: "All (required) COMPARTMENT statements in the KINETIC block."
145  type: StatementBlock
146 
147  - WrappedExpression:
148  brief: "Wrap any other expression type"
149  members:
150  - expression:
151  brief: "Expression that is being wrapped"
152  type: Expression
153  - DerivimplicitCallback:
154  brief: "Represent a callback to NEURON's derivimplicit solver"
155  members:
156  - node_to_solve:
157  brief: "Block to be solved (typically derivative)"
158  type: Block
159  - SolutionExpression:
160  brief: "Represent solution of a block in the AST"
161  members:
162  - solve_block:
163  type: SolveBlock
164  - node_to_solve:
165  brief: "Block to be solved (callback node or solution node itself)"
166  type: Expression
167  - Statement:
168  brief: "Statement base class"
169  children:
170  - UpdateDt:
171  nmodl: "dt"
172  members:
173  - value:
174  brief: "Value of new timestep"
175  type: Double
176  prefix: {value: " = "}
177  brief: "Statement to indicate a change in timestep in a given block"