You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/chemistry_functionality.jl
+9-12Lines changed: 9 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -56,28 +56,22 @@ function make_compound(expr)
56
56
57
57
# Extracts the composite species name, as well as the expression which creates it (with e.g. meta data and default values included).
58
58
species_expr = expr.args[2] # E.g. :(CO2 = 1.0, [metadata=true])
59
-
iv_expr = :(unique(reduce(vcat, arguments.(ModelingToolkit.unwrap.($(components)))))) # Expression which, when evaluated, becoems a list of all the independent variables the compound should depend on.
60
-
species_expr =insert_independent_variable(species_expr, iv_expr) # Add independent variable (e.g. goes from `CO2` to `CO2(t)`).
59
+
species_expr =insert_independent_variable(species_expr, :(..)) # Prepare iv addition, i.e. turns CO to CO(..).
61
60
species_name =find_varname_in_declaration(expr.args[2]) # E.g. :CO2
61
+
ivs_get_expr = :(unique(reduce(vcat,[arguments(ModelingToolkit.unwrap(iv)) for iv in$components]))) # Expression which when evaluated gives a vector with all the ivs of the components.
62
62
63
-
64
63
# Creates the found expressions that will create the compound species.
65
-
# The `Expr(:escape, :(...))` is required so that teh expressions are evaluated in the scope the users use the macro in (to e.g. detect already exiting species). # E.g. `@species CO2(t)`
66
-
species_declaration_expr =Expr(:escape, :(@species$species_expr)) # E.g. `@species CO2(t)`
64
+
# The `Expr(:escape, :(...))` is required so that the expressions are evaluated in the scope the users use the macro in (to e.g. detect already exiting species).
65
+
species_declaration_expr =Expr(:escape, :(@species$species_expr)) # E.g. `@species CO2(..)`
66
+
iv_designation_expression =Expr(:escape, :($species_name =$(species_name)($(ivs_get_expr)...))) # E.g. `CO2 = CO2([...]..)` where [...] is something which evaluates to a vector with all the ivs of the components.
0 commit comments