1
- # This code is from the Modia project and is licensed as follows:
1
+ # This code is derived from the Modia project and is licensed as follows:
2
2
# https://github.com/ModiaSim/Modia.jl/blob/b61daad643ef7edd0c1ccce6bf462c6acfb4ad1a/LICENSE
3
3
4
- # ###############################################
5
- #
6
- # Functions to tear systems of equations
7
- #
8
- # Author: Martin Otter, DLR-SR (first version: Jan. 14, 2017)
9
- #
10
- # Details are described in the paper:
11
- # Otter, Elmqvist (2017): Transformation of Differential Algebraic Array Equations to
12
- # Index One Form. Modelica'2017 Conference.
13
- #
14
- # ###############################################
15
-
16
4
function try_assign_eq! (ict:: IncrementalCycleTracker , vj:: Integer , eq:: Integer )
17
5
G = ict. graph
18
6
add_edge_checked! (ict, Iterators. filter (!= (vj), 𝑠neighbors (G. graph, eq)), vj) do G
@@ -21,19 +9,6 @@ function try_assign_eq!(ict::IncrementalCycleTracker, vj::Integer, eq::Integer)
21
9
end
22
10
end
23
11
24
- """
25
- (eSolved, vSolved, eResidue, vTear) = tearEquations!(td, Gsolvable, es, vs)
26
-
27
- Equations es shall be solved with respect to variables vs. The function returns
28
- the teared equation so that if vTear is given, vSolved can be computed from eSolved
29
- in a forward sequence (so solving eSolved[1] for vSolved[1], eSolved[2] for vSolved[2],
30
- and so on). vTear must be selected, so that the equations eResidues are fulfilled.
31
- Equations es are the union of eSolved and eResidue.
32
- Variables vs are the union of vSolved and vTear.
33
-
34
- Gsolvable defines the variables that can be explicitly solved in every equation without influencing the solution space
35
- (= rank preserving operation).
36
- """
37
12
function tearEquations! (ict:: IncrementalCycleTracker , Gsolvable, es:: Vector{Int} , vs:: Vector{Int} )
38
13
G = ict. graph
39
14
vActive = BitSet (vs)
@@ -59,13 +34,8 @@ function tear_graph_block_modia!(var_eq_matching, graph, solvable_graph, eqs, va
59
34
return nothing
60
35
end
61
36
62
- """
63
- tear_graph_modia(sys) -> sys
64
-
65
- Tear the bipartite graph in a system. End users are encouraged to call [`structural_simplify`](@ref)
66
- instead, which calls this function internally.
67
- """
68
- function tear_graph_modia (graph:: BipartiteGraph , solvable_graph:: BipartiteGraph ; varfilter= v-> true , eqfilter= eq-> true )
37
+ function tear_graph_modia (structure:: SystemStructure ; varfilter= v-> true , eqfilter= eq-> true )
38
+ @unpack graph, solvable_graph = structure
69
39
var_eq_matching = complete (maximal_matching (graph, eqfilter, varfilter))
70
40
var_sccs:: Vector{Union{Vector{Int}, Int}} = find_var_sccs (graph, var_eq_matching)
71
41
0 commit comments