|
1 | 1 | module SystemStructures
|
2 | 2 |
|
3 | 3 | using ..ModelingToolkit
|
4 |
| -using ..ModelingToolkit: isdiffeq, var_from_nested_derivative, vars!, flatten |
| 4 | +import ..ModelingToolkit: isdiffeq, var_from_nested_derivative, vars!, flatten |
5 | 5 | using SymbolicUtils: arguments
|
6 | 6 | using ..BipartiteGraphs
|
7 | 7 | using UnPack
|
|
37 | 37 |
|
38 | 38 | export SystemStructure, initialize_system_structure
|
39 | 39 | export diffvars_range, dervars_range, algvars_range
|
40 |
| -export isdiffvars, isdervars, isalgvars |
| 40 | +export isdiffvar, isdervar, isalgvar, isdiffeq, isalgeq |
41 | 41 | export DIFFERENTIAL_VARIABLE, ALGEBRAIC_VARIABLE, DERIVATIVE_VARIABLE
|
42 | 42 | export DIFFERENTIAL_EQUATION, ALGEBRAIC_EQUATION
|
43 | 43 | export vartype, eqtype
|
|
73 | 73 |
|
74 | 74 | @enum EquationType DIFFERENTIAL_EQUATION ALGEBRAIC_EQUATION
|
75 | 75 |
|
76 |
| -eqtype(s::SystemStructure, eq::Integer)::EquationType = s.algeqs[eq] ? ALGEBRAIC_EQUATION : DIFFERENTIAL_EQUATION |
| 76 | +isalgeq(s::SystemStructure, eq::Integer) = s.algeqs[eq] |
| 77 | +isdiffeq(s::SystemStructure, eq::Integer) = !isalgeq(s, eq) |
| 78 | +eqtype(s::SystemStructure, eq::Integer)::EquationType = isalgeq(s, eq) ? ALGEBRAIC_EQUATION : DIFFERENTIAL_EQUATION |
77 | 79 |
|
78 | 80 | function initialize_system_structure(sys)
|
79 | 81 | sys, dxvar_offset, fullvars, varassoc, algeqs, graph, solvable_graph = init_graph(flatten(sys))
|
@@ -111,10 +113,10 @@ end
|
111 | 113 | function collect_variables(sys)
|
112 | 114 | dxvars = []
|
113 | 115 | eqs = equations(sys)
|
114 |
| - algeqs = falses(length(eqs)) |
| 116 | + algeqs = trues(length(eqs)) |
115 | 117 | for (i, eq) in enumerate(eqs)
|
116 | 118 | if isdiffeq(eq)
|
117 |
| - algeqs[i] = true |
| 119 | + algeqs[i] = false |
118 | 120 | lhs = eq.lhs
|
119 | 121 | # Make sure that the LHS is a first order derivative of a var.
|
120 | 122 | @assert !(arguments(lhs)[1] isa Differential) "The equation $eq is not first order"
|
|
0 commit comments