|
| 1 | +# [The `System` type](@id System_type) |
| 2 | + |
| 3 | +ModelingToolkit.jl uses `System` to symbolically represent all types of numerical problems. |
| 4 | +Users create `System`s representing the problem they want to solve and `mtkcompile` transforms |
| 5 | +them into a format ModelingToolkit.jl can generate code for (alongside performing other |
| 6 | +optimizations). |
| 7 | + |
| 8 | +```@docs |
| 9 | +System |
| 10 | +``` |
| 11 | + |
| 12 | +## Utility constructors |
| 13 | + |
| 14 | +Several utility constructors also exist to easily construct alternative system formulations. |
| 15 | + |
| 16 | +```@docs |
| 17 | +NonlinearSystem |
| 18 | +SDESystem |
| 19 | +JumpSystem |
| 20 | +OptimizationSystem |
| 21 | +``` |
| 22 | + |
| 23 | +## Accessor functions |
| 24 | + |
| 25 | +Several accessor functions exist to query systems for the information they contain. In general, |
| 26 | +for every field `x` there exists a `has_x` function which checks if the system contains the |
| 27 | +field and a `get_x` function for obtaining the value in the field. Note that fields of a system |
| 28 | +cannot be accessed via `getproperty` - that is reserved for accessing variables, subsystems |
| 29 | +or analysis points of the hierarchical system. |
| 30 | + |
| 31 | +```@docs |
| 32 | +ModelingToolkit.has_eqs |
| 33 | +ModelingToolkit.get_eqs |
| 34 | +equations |
| 35 | +equations_toplevel |
| 36 | +ModelingToolkit.has_noise_eqs |
| 37 | +ModelingToolkit.get_noise_eqs |
| 38 | +ModelingToolkit.has_jumps |
| 39 | +ModelingToolkit.get_jumps |
| 40 | +jumps |
| 41 | +ModelingToolkit.has_constraints |
| 42 | +ModelingToolkit.get_constraints |
| 43 | +constraints |
| 44 | +ModelingToolkit.has_costs |
| 45 | +ModelingToolkit.get_costs |
| 46 | +costs |
| 47 | +ModelingToolkit.has_consolidate |
| 48 | +ModelingToolkit.get_consolidate |
| 49 | +ModelingToolkit.has_unknowns |
| 50 | +ModelingToolkit.get_unknowns |
| 51 | +unknowns |
| 52 | +unknowns_toplevel |
| 53 | +ModelingToolkit.has_ps |
| 54 | +ModelingToolkit.get_ps |
| 55 | +parameters |
| 56 | +parameters_toplevel |
| 57 | +ModelingToolkit.has_brownians |
| 58 | +ModelingToolkit.get_brownians |
| 59 | +brownians |
| 60 | +ModelingToolkit.has_iv |
| 61 | +ModelingToolkit.get_iv |
| 62 | +ModelingToolkit.has_observed |
| 63 | +ModelingToolkit.get_observed |
| 64 | +observed |
| 65 | +observables |
| 66 | +ModelingToolkit.has_name |
| 67 | +ModelingToolkit.get_name |
| 68 | +nameof |
| 69 | +ModelingToolkit.has_description |
| 70 | +ModelingToolkit.get_description |
| 71 | +ModelingToolkit.has_defaults |
| 72 | +ModelingToolkit.get_defaults |
| 73 | +defaults |
| 74 | +ModelingToolkit.has_guesses |
| 75 | +ModelingToolkit.get_guesses |
| 76 | +guesses |
| 77 | +ModelingToolkit.has_initialization_eqs |
| 78 | +ModelingToolkit.get_initialization_eqs |
| 79 | +initialization_equations |
| 80 | +ModelingToolkit.has_continuous_events |
| 81 | +ModelingToolkit.get_continuous_events |
| 82 | +continuous_events |
| 83 | +continuous_events_toplevel |
| 84 | +ModelingToolkit.has_discrete_events |
| 85 | +ModelingToolkit.get_discrete_events |
| 86 | +discrete_events_toplevel |
| 87 | +ModelingToolkit.has_assertions |
| 88 | +ModelingToolkit.get_assertions |
| 89 | +assertions |
| 90 | +ModelingToolkit.has_metadata |
| 91 | +ModelingToolkit.get_metadata |
| 92 | +SymbolicUtils.getmetadata(::ModelingToolkit.AbstractSystem, ::DataType, ::Any) |
| 93 | +SymbolicUtils.setmetadata(::ModelingToolkit.AbstractSystem, ::DataType, ::Any) |
| 94 | +ModelingToolkit.has_is_dde |
| 95 | +ModelingToolkit.get_is_dde |
| 96 | +ModelingToolkit.is_dde |
| 97 | +ModelingToolkit.has_tstops |
| 98 | +ModelingToolkit.get_tstops |
| 99 | +ModelingToolkit.symbolic_tstops |
| 100 | +ModelingToolkit.has_tearing_state |
| 101 | +ModelingToolkit.get_tearing_state |
| 102 | +ModelingToolkit.does_namespacing |
| 103 | +toggle_namespacing |
| 104 | +ModelingToolkit.iscomplete |
| 105 | +ModelingToolkit.has_preface |
| 106 | +ModelingToolkit.get_preface |
| 107 | +ModelingToolkit.preface |
| 108 | +ModelingToolkit.has_parent |
| 109 | +ModelingToolkit.get_parent |
| 110 | +ModelingToolkit.has_initializesystem |
| 111 | +ModelingToolkit.get_initializesystem |
| 112 | +ModelingToolkit.is_initializesystem |
| 113 | +``` |
| 114 | + |
| 115 | +## `getproperty` syntax |
| 116 | + |
| 117 | +ModelingToolkit allows obtaining in a system using `getproperty`. For a system `sys` with a |
| 118 | +subcomponent `inner` containing variable `var`, `sys.inner.var` will obtain the appropriately |
| 119 | +namespaced version of `var`. Note that this can also be used to access subsystems (`sys.inner`) |
| 120 | +or analysis points. |
| 121 | + |
| 122 | +!!! note |
| 123 | + |
| 124 | + By default, top-level systems not marked as `complete` will apply their namespace. Systems |
| 125 | + marked as `complete` will not do this namespacing. This namespacing behavior can be toggled |
| 126 | + independently of whether the system is completed using [`toggle_namespacing`](@ref) and the |
| 127 | + current namespacing behavior can be queried via [`ModelingToolkit.does_namespacing`](@ref). |
| 128 | + |
| 129 | +```@docs |
| 130 | +Base.getproperty(::ModelingToolkit.AbstractSystem, ::Symbol) |
| 131 | +``` |
| 132 | + |
| 133 | +## Functions for querying system equations |
| 134 | + |
| 135 | +```@docs |
| 136 | +has_diff_eqs |
| 137 | +has_alg_eqs |
| 138 | +get_diff_eqs |
| 139 | +get_alg_eqs |
| 140 | +has_diff_equations |
| 141 | +has_alg_equations |
| 142 | +diff_equations |
| 143 | +alg_equations |
| 144 | +is_alg_equation |
| 145 | +is_diff_equation |
| 146 | +``` |
| 147 | + |
| 148 | +## String parsing |
| 149 | + |
| 150 | +ModelingToolkit can parse system variables from strings. |
| 151 | + |
| 152 | +```@docs |
| 153 | +ModelingToolkit.parse_variable |
| 154 | +``` |
| 155 | + |
| 156 | +## Dumping system data |
| 157 | + |
| 158 | +```@docs |
| 159 | +ModelingToolkit.dump_unknowns |
| 160 | +ModelingToolkit.dump_parameters |
| 161 | +ModelingToolkit.dump_variable_metadata |
| 162 | +``` |
| 163 | + |
| 164 | +## Debugging utilities |
| 165 | + |
| 166 | +```@docs |
| 167 | +debug_system |
| 168 | +``` |
0 commit comments