@@ -57,6 +57,11 @@ struct NonlinearSystem <: AbstractTimeIndependentSystem
57
57
"""
58
58
connector_type:: Any
59
59
"""
60
+ A mapping from dependent parameters to expressions describing how they are calculated from
61
+ other parameters.
62
+ """
63
+ parameter_dependencies:: Union{Nothing, Dict}
64
+ """
60
65
Metadata for the system, to be used by downstream packages.
61
66
"""
62
67
metadata:: Any
@@ -87,7 +92,7 @@ struct NonlinearSystem <: AbstractTimeIndependentSystem
87
92
88
93
function NonlinearSystem (tag, eqs, unknowns, ps, var_to_name, observed, jac, name,
89
94
systems,
90
- defaults, connector_type, metadata = nothing ,
95
+ defaults, connector_type, parameter_dependencies = nothing , metadata = nothing ,
91
96
gui_metadata = nothing ,
92
97
tearing_state = nothing , substitutions = nothing ,
93
98
complete = false , index_cache = nothing , parent = nothing ; checks:: Union {
@@ -97,8 +102,8 @@ struct NonlinearSystem <: AbstractTimeIndependentSystem
97
102
check_units (u, eqs)
98
103
end
99
104
new (tag, eqs, unknowns, ps, var_to_name, observed, jac, name, systems, defaults,
100
- connector_type, metadata, gui_metadata, tearing_state, substitutions, complete ,
101
- index_cache, parent)
105
+ connector_type, parameter_dependencies, metadata, gui_metadata, tearing_state,
106
+ substitutions, complete, index_cache, parent)
102
107
end
103
108
end
104
109
@@ -113,6 +118,7 @@ function NonlinearSystem(eqs, unknowns, ps;
113
118
continuous_events = nothing , # this argument is only required for ODESystems, but is added here for the constructor to accept it without error
114
119
discrete_events = nothing , # this argument is only required for ODESystems, but is added here for the constructor to accept it without error
115
120
checks = true ,
121
+ parameter_dependencies = nothing ,
116
122
metadata = nothing ,
117
123
gui_metadata = nothing )
118
124
continuous_events === nothing || isempty (continuous_events) ||
@@ -148,9 +154,11 @@ function NonlinearSystem(eqs, unknowns, ps;
148
154
process_variables! (var_to_name, defaults, ps)
149
155
isempty (observed) || collect_var_to_name! (var_to_name, (eq. lhs for eq in observed))
150
156
157
+ parameter_dependencies, ps = process_parameter_dependencies (
158
+ parameter_dependencies, ps)
151
159
NonlinearSystem (Threads. atomic_add! (SYSTEM_COUNT, UInt (1 )),
152
160
eqs, unknowns, ps, var_to_name, observed, jac, name, systems, defaults,
153
- connector_type, metadata, gui_metadata, checks = checks)
161
+ connector_type, parameter_dependencies, metadata, gui_metadata, checks = checks)
154
162
end
155
163
156
164
function NonlinearSystem (eqs; kwargs... )
@@ -233,6 +241,7 @@ function generate_function(
233
241
pre, sol_states = get_substitutions_and_solved_unknowns (sys)
234
242
235
243
p = reorder_parameters (sys, value .(ps))
244
+ @show p ps
236
245
return build_function (rhss, value .(dvs), p... ; postprocess_fbody = pre,
237
246
states = sol_states, kwargs... )
238
247
end
@@ -385,7 +394,7 @@ function process_NonlinearProblem(constructor, sys::NonlinearSystem, u0map, para
385
394
kwargs... )
386
395
eqs = equations (sys)
387
396
dvs = unknowns (sys)
388
- ps = parameters (sys)
397
+ ps = full_parameters (sys)
389
398
390
399
if has_index_cache (sys) && get_index_cache (sys) != = nothing
391
400
u0, defs = get_u0 (sys, u0map, parammap)
0 commit comments