|
2 | 2 | processes_to_mtkmodel(processes::Vector [, default]; kw...) |
3 | 3 |
|
4 | 4 | Construct a ModelingToolkit.jl model/system using the provided `processes` and `default` processes. |
5 | | -The model/system is _not_ structurally simplified. During construction, the following automations |
6 | | -improve user experience: |
| 5 | +The model/system is _not_ structurally simplified. Use the function |
| 6 | +`processes_to_mtkeqs` to obtain the raw `Vector{Equation}` before it is |
| 7 | +passed to the MTK model/system like `ODESystem`. |
| 8 | +
|
| 9 | +During construction, the following automations improve user experience: |
7 | 10 |
|
8 | 11 | - Variable(s) introduced in `processes` that does not itself have a process obtain |
9 | 12 | a default process from `default`. |
@@ -51,16 +54,24 @@ These registered processes are used when `default` is a `Module`. |
51 | 54 | - `warn_default::Bool = true`: if `true`, throw a warning when a variable does not |
52 | 55 | have an assigned process but it has a default value so that it becomes a parameter instead. |
53 | 56 | """ |
54 | | -processes_to_mtkmodel(procs::Vector; kw...) = |
55 | | -processes_to_mtkmodel(procs, Dict{Num, Any}(); kw...) |
56 | | -processes_to_mtkmodel(procs::Vector, m::Module; kw...) = |
57 | | -processes_to_mtkmodel(procs, default_processes(m); kw...) |
58 | | -processes_to_mtkmodel(procs::Vector, v::Vector; kw...) = |
59 | | -processes_to_mtkmodel(procs, default_dict(v); kw...) |
| 57 | +function processes_to_mtkmodel(args...; |
| 58 | + type = ODESystem, name = nameof(type), independent = t, kw..., |
| 59 | + ) |
| 60 | + eqs = processes_to_mtkeqs(args...; kw...) |
| 61 | + sys = type(eqs, independent; name) |
| 62 | + return sys |
| 63 | +end |
| 64 | + |
| 65 | +processes_to_mtkeqs(procs::Vector; kw...) = |
| 66 | +processes_to_mtkeqs(procs, Dict{Num, Any}(); kw...) |
| 67 | +processes_to_mtkeqs(procs::Vector, m::Module; kw...) = |
| 68 | +processes_to_mtkeqs(procs, default_processes(m); kw...) |
| 69 | +processes_to_mtkeqs(procs::Vector, v::Vector; kw...) = |
| 70 | +processes_to_mtkeqs(procs, default_dict(v); kw...) |
60 | 71 |
|
61 | 72 | # The main implementation has the defaults to be a map from variable to process |
62 | 73 | # because this simplifies a bit the code |
63 | | -function processes_to_mtkmodel(_processes::Vector, default::Dict{Num, Any}; |
| 74 | +function processes_to_mtkeqs(_processes::Vector, default::Dict{Num, Any}; |
64 | 75 | type = ODESystem, name = nameof(type), independent = t, warn_default::Bool = true, |
65 | 76 | ) |
66 | 77 | processes = expand_multi_processes(_processes) |
@@ -116,9 +127,7 @@ function processes_to_mtkmodel(_processes::Vector, default::Dict{Num, Any}; |
116 | 127 | end |
117 | 128 | end |
118 | 129 | end |
119 | | - # return eqs |
120 | | - sys = type(eqs, independent; name) |
121 | | - return sys |
| 130 | + return eqs |
122 | 131 | end |
123 | 132 |
|
124 | 133 | function expand_multi_processes(procs::Vector) |
|
0 commit comments