Skip to content

Commit ca65ea9

Browse files
authored
Merge pull request #1445 from Tred0/nlconnect
Add connections to NonlinearSystem
2 parents fda99af + f21dc89 commit ca65ea9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/systems/nonlinear/nonlinearsystem.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ struct NonlinearSystem <: AbstractTimeIndependentSystem
5151
"""
5252
connector_type::Any
5353
"""
54+
connections: connections in a system
55+
"""
56+
connections::Any
57+
"""
5458
tearing_state: cache for intermediate tearing state
5559
"""
5660
tearing_state::Any
@@ -59,11 +63,11 @@ struct NonlinearSystem <: AbstractTimeIndependentSystem
5963
"""
6064
substitutions::Any
6165

62-
function NonlinearSystem(eqs, states, ps, var_to_name, observed, jac, name, systems, defaults, connector_type, tearing_state=nothing, substitutions=nothing; checks::Bool = true)
66+
function NonlinearSystem(eqs, states, ps, var_to_name, observed, jac, name, systems, defaults, connector_type, connections, tearing_state=nothing, substitutions=nothing; checks::Bool = true)
6367
if checks
6468
all_dimensionless([states;ps]) ||check_units(eqs)
6569
end
66-
new(eqs, states, ps, var_to_name, observed, jac, name, systems, defaults, connector_type, tearing_state, substitutions)
70+
new(eqs, states, ps, var_to_name, observed, jac, name, systems, defaults, connector_type, connections, tearing_state, substitutions)
6771
end
6872
end
6973

@@ -85,7 +89,9 @@ function NonlinearSystem(eqs, states, ps;
8589
#
8690
# # we cannot scalarize in the loop because `eqs` itself might require
8791
# scalarization
88-
eqs = [0 ~ x.rhs - x.lhs for x in scalarize(eqs)]
92+
eqs = [
93+
x.lhs isa Union{Symbolic,Number} ? 0 ~ x.rhs - x.lhs : x for x in scalarize(eqs)
94+
]
8995

9096
if !(isempty(default_u0) && isempty(default_p))
9197
Base.depwarn("`default_u0` and `default_p` are deprecated. Use `defaults` instead.", :NonlinearSystem, force=true)
@@ -105,7 +111,7 @@ function NonlinearSystem(eqs, states, ps;
105111
process_variables!(var_to_name, defaults, ps)
106112
isempty(observed) || collect_var_to_name!(var_to_name, (eq.lhs for eq in observed))
107113

108-
NonlinearSystem(eqs, states, ps, var_to_name, observed, jac, name, systems, defaults, connector_type, checks = checks)
114+
NonlinearSystem(eqs, states, ps, var_to_name, observed, jac, name, systems, defaults, connector_type, nothing, checks = checks)
109115
end
110116

111117
function calculate_jacobian(sys::NonlinearSystem; sparse=false, simplify=false)

0 commit comments

Comments
 (0)