@@ -355,6 +355,13 @@ function independent_variables(sys::AbstractMultivariateSystem)
355
355
return getfield (sys, :ivs )
356
356
end
357
357
358
+ """
359
+ $(TYPEDSIGNATURES)
360
+
361
+ Get the independent variable(s) of the system `sys`.
362
+
363
+ See also [`@independent_variables`](@ref) and [`ModelingToolkit.get_iv`](@ref).
364
+ """
358
365
function independent_variables (sys:: AbstractSystem )
359
366
@warn " Please declare ($(typeof (sys)) ) as a subtype of `AbstractTimeDependentSystem`, `AbstractTimeIndependentSystem` or `AbstractMultivariateSystem`."
360
367
if isdefined (sys, :iv )
@@ -649,11 +656,29 @@ for prop in [:eqs
649
656
:split_idxs
650
657
:parent
651
658
:index_cache ]
652
- fname1 = Symbol (:get_ , prop)
653
- fname2 = Symbol (:has_ , prop)
659
+ fname_get = Symbol (:get_ , prop)
660
+ fname_has = Symbol (:has_ , prop)
654
661
@eval begin
655
- $ fname1 (sys:: AbstractSystem ) = getfield (sys, $ (QuoteNode (prop)))
656
- $ fname2 (sys:: AbstractSystem ) = isdefined (sys, $ (QuoteNode (prop)))
662
+ """
663
+ $(TYPEDSIGNATURES)
664
+
665
+ Get the internal field `$($ (QuoteNode (prop))) ` of a system `sys`.
666
+ It only includes `$($ (QuoteNode (prop))) ` local to `sys`; not those of its subsystems,
667
+ like `unknowns(sys)`, `parameters(sys)` and `equations(sys)` does.
668
+ This is equivalent to, but preferred over `sys.$($ (QuoteNode (prop))) `.
669
+
670
+ See also [`has_$($ (QuoteNode (prop))) `](@ref).
671
+ """
672
+ $ fname_get (sys:: AbstractSystem ) = getfield (sys, $ (QuoteNode (prop)))
673
+
674
+ """
675
+ $(TYPEDSIGNATURES)
676
+
677
+ Returns whether the system `sys` has the internal field `$($ (QuoteNode (prop))) `.
678
+
679
+ See also [`get_$($ (QuoteNode (prop))) `](@ref).
680
+ """
681
+ $ fname_has (sys:: AbstractSystem ) = isdefined (sys, $ (QuoteNode (prop)))
657
682
end
658
683
end
659
684
@@ -1003,6 +1028,14 @@ function namespace_expr(
1003
1028
end
1004
1029
end
1005
1030
_nonum (@nospecialize x) = x isa Num ? x. val : x
1031
+
1032
+ """
1033
+ $(TYPEDSIGNATURES)
1034
+
1035
+ Get the unknown variables of the system `sys` and its subsystems.
1036
+
1037
+ See also [`ModelingToolkit.get_unknowns`](@ref).
1038
+ """
1006
1039
function unknowns (sys:: AbstractSystem )
1007
1040
sts = get_unknowns (sys)
1008
1041
systems = get_systems (sys)
@@ -1023,6 +1056,13 @@ function unknowns(sys::AbstractSystem)
1023
1056
unique (nonunique_unknowns)
1024
1057
end
1025
1058
1059
+ """
1060
+ $(TYPEDSIGNATURES)
1061
+
1062
+ Get the parameters of the system `sys` and its subsystems.
1063
+
1064
+ See also [`@parameters`](@ref) and [`ModelingToolkit.get_ps`](@ref).
1065
+ """
1026
1066
function parameters (sys:: AbstractSystem )
1027
1067
ps = get_ps (sys)
1028
1068
if ps == SciMLBase. NullParameters ()
@@ -1131,6 +1171,15 @@ end
1131
1171
1132
1172
flatten (sys:: AbstractSystem , args... ) = sys
1133
1173
1174
+ """
1175
+ $(TYPEDSIGNATURES)
1176
+
1177
+ Get the flattened equations of the system `sys` and its subsystems.
1178
+ It may include some abbreviations and aliases of observables.
1179
+ It is often the most useful way to inspect the equations of a system.
1180
+
1181
+ See also [`full_equations`](@ref) and [`ModelingToolkit.get_eqs`](@ref).
1182
+ """
1134
1183
function equations (sys:: AbstractSystem )
1135
1184
eqs = get_eqs (sys)
1136
1185
systems = get_systems (sys)
@@ -1145,6 +1194,13 @@ function equations(sys::AbstractSystem)
1145
1194
end
1146
1195
end
1147
1196
1197
+ """
1198
+ $(TYPEDSIGNATURES)
1199
+
1200
+ Get the initialization equations of the system `sys` and its subsystems.
1201
+
1202
+ See also [`ModelingToolkit.get_initialization_eqs`](@ref).
1203
+ """
1148
1204
function initialization_equations (sys:: AbstractSystem )
1149
1205
eqs = get_initialization_eqs (sys)
1150
1206
systems = get_systems (sys)
@@ -2500,8 +2556,10 @@ end
2500
2556
"""
2501
2557
$(TYPEDSIGNATURES)
2502
2558
2503
- extend the `basesys` with `sys`, the resulting system would inherit `sys`'s name
2559
+ Extend the `basesys` with `sys`, the resulting system would inherit `sys`'s name
2504
2560
by default.
2561
+
2562
+ See also [`compose`](@ref).
2505
2563
"""
2506
2564
function extend (sys:: AbstractSystem , basesys:: AbstractSystem ; name:: Symbol = nameof (sys),
2507
2565
gui_metadata = get_gui_metadata (sys))
@@ -2550,8 +2608,10 @@ end
2550
2608
"""
2551
2609
$(SIGNATURES)
2552
2610
2553
- compose multiple systems together. The resulting system would inherit the first
2611
+ Compose multiple systems together. The resulting system would inherit the first
2554
2612
system's name.
2613
+
2614
+ See also [`extend`](@ref).
2555
2615
"""
2556
2616
function compose (sys:: AbstractSystem , systems:: AbstractArray ; name = nameof (sys))
2557
2617
nsys = length (systems)
@@ -2572,7 +2632,7 @@ end
2572
2632
"""
2573
2633
missing_variable_defaults(sys::AbstractSystem, default = 0.0; subset = unknowns(sys))
2574
2634
2575
- returns a `Vector{Pair}` of variables set to `default` which are missing from `get_defaults(sys)`. The `default` argument can be a single value or vector to set the missing defaults respectively.
2635
+ Returns a `Vector{Pair}` of variables set to `default` which are missing from `get_defaults(sys)`. The `default` argument can be a single value or vector to set the missing defaults respectively.
2576
2636
"""
2577
2637
function missing_variable_defaults (
2578
2638
sys:: AbstractSystem , default = 0.0 ; subset = unknowns (sys))
0 commit comments