@@ -149,17 +149,23 @@ def template_model_from_sympy_odes(odes, concept_data=None, param_data=None):
149
149
raise ValueError ("Multiple time variables in the ODEs" )
150
150
time_variable = time_variables .pop ()
151
151
152
- # Step 2: determine LHS variables
152
+ # Step 2: determine LHS variables and handle static concepts
153
+ is_static = set ()
153
154
for ode in odes :
154
155
lhs_fun = ode .lhs .args [0 ]
155
156
variable_name = lhs_fun .name
156
157
variables .append (variable_name )
158
+ if ode .rhs == 0 :
159
+ is_static .add (variable_name )
157
160
158
161
# Step 3: Interpret RHS equations and build a hypergraph
159
162
parameters = set ()
160
163
all_terms = []
161
164
G = Hypergraph ()
162
165
for lhs_variable , eq in zip (variables , odes ):
166
+ # No terms to add for static variables
167
+ if lhs_variable in is_static :
168
+ continue
163
169
# Break up the RHS into a sum of terms
164
170
terms = eq .rhs .as_ordered_terms ()
165
171
for term_idx , term in enumerate (terms ):
@@ -205,9 +211,15 @@ def template_model_from_sympy_odes(odes, concept_data=None, param_data=None):
205
211
# Remove ambiguous edges
206
212
G .remove_ambiguous_edges ()
207
213
208
- # We first look at unconnected nodes of the graph and construct
209
- # production or degradation templates
210
214
templates = []
215
+
216
+ # We first handle static concepts
217
+ for variable in is_static :
218
+ concept = make_concept (variable , concept_data )
219
+ templates .append (StaticConcept (subject = concept ))
220
+
221
+ # We next look at unconnected nodes of the graph and construct
222
+ # production or degradation templates
211
223
for node in G .get_unconnected_nodes ():
212
224
data = G .nodes [node ]
213
225
term = data ['term' ]
0 commit comments