Skip to content

Commit 3caeae1

Browse files
Merge branch 'master' into dg/Dprint
2 parents ce933f8 + 3c1eac3 commit 3caeae1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1827
-297
lines changed

.github/workflows/Tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ jobs:
4545
with:
4646
julia-version: "${{ matrix.version }}"
4747
group: "${{ matrix.group }}"
48+
# Disable cache for self-hosted runners since they persist between runs
49+
# Set USE_SELF_HOSTED repository variable to 'true' when using self-hosted runners
50+
self-hosted: ${{ vars.USE_SELF_HOSTED == 'true' }}
51+
cache: ${{ vars.USE_SELF_HOSTED != 'true' }}
4852
secrets: "inherit"

Project.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelingToolkit"
22
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
33
authors = ["Yingbo Ma <[email protected]>", "Chris Rackauckas <[email protected]> and contributors"]
4-
version = "10.14.0"
4+
version = "10.22.0"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
@@ -100,8 +100,8 @@ ConstructionBase = "1"
100100
DataInterpolations = "7, 8"
101101
DataStructures = "0.17, 0.18"
102102
DeepDiffs = "1"
103-
DelayDiffEq = "5.50"
104-
DiffEqBase = "6.170.1"
103+
DelayDiffEq = "5.61"
104+
DiffEqBase = "6.189.1"
105105
DiffEqCallbacks = "2.16, 3, 4"
106106
DiffEqNoiseProcess = "5"
107107
DiffRules = "0.1, 1.0"
@@ -119,11 +119,11 @@ ForwardDiff = "0.10.3, 1"
119119
FunctionWrappers = "1.1"
120120
FunctionWrappersWrappers = "0.1"
121121
Graphs = "1.5.2"
122-
ImplicitDiscreteSolve = "0.1.2"
122+
ImplicitDiscreteSolve = "0.1.2, 1"
123123
InfiniteOpt = "0.5"
124124
InteractiveUtils = "1"
125125
JuliaFormatter = "1.0.47, 2"
126-
JumpProcesses = "9.13.1"
126+
JumpProcesses = "9.19"
127127
LabelledArrays = "1.3"
128128
Latexify = "0.11, 0.12, 0.13, 0.14, 0.15, 0.16"
129129
Libdl = "1"
@@ -138,7 +138,7 @@ NonlinearSolve = "4.3"
138138
OffsetArrays = "1"
139139
OrderedCollections = "1"
140140
OrdinaryDiffEq = "6.82.0"
141-
OrdinaryDiffEqCore = "1.15.0"
141+
OrdinaryDiffEqCore = "1.34.0"
142142
OrdinaryDiffEqDefault = "1.2"
143143
OrdinaryDiffEqNonlinearSolve = "1.5.0"
144144
PrecompileTools = "1"
@@ -147,20 +147,20 @@ REPL = "1"
147147
RecursiveArrayTools = "3.26"
148148
Reexport = "0.2, 1"
149149
RuntimeGeneratedFunctions = "0.5.9"
150-
SCCNonlinearSolve = "1.0.0"
151-
SciMLBase = "2.106.0"
150+
SCCNonlinearSolve = "1.4.0"
151+
SciMLBase = "2.115.0"
152152
SciMLPublic = "1.0.0"
153153
SciMLStructures = "1.7"
154154
Serialization = "1"
155155
Setfield = "0.7, 0.8, 1"
156156
SimpleNonlinearSolve = "0.1.0, 1, 2"
157157
SparseArrays = "1"
158158
SpecialFunctions = "1, 2"
159-
StaticArrays = "0.10, 0.11, 0.12, 1.0"
160-
StochasticDelayDiffEq = "1.10"
161-
StochasticDiffEq = "6.72.1"
159+
StaticArrays = "1.9.14"
160+
StochasticDelayDiffEq = "1.11"
161+
StochasticDiffEq = "6.82.0"
162162
SymbolicIndexingInterface = "0.3.39"
163-
SymbolicUtils = "3.26.1"
163+
SymbolicUtils = "3.30.0"
164164
Symbolics = "6.40"
165165
URIs = "1"
166166
UnPack = "0.1, 1.0"

docs/pages.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,8 @@ pages = [
4747
"basics/Precompilation.md",
4848
"basics/FAQ.md"],
4949
"comparison.md",
50-
"internals.md"
50+
"Internal Details" => Any[
51+
"internals.md",
52+
"internals/structural_transformation.md",
53+
"internals/bipartite_graph.md"]
5154
]

docs/src/API/System.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ optimizations).
77

88
```@docs
99
System
10+
ModelingToolkit.AbstractSystem
1011
```
1112

1213
## Utility constructors
@@ -185,3 +186,65 @@ ModelingToolkit.is_bound
185186
```@docs
186187
debug_system
187188
```
189+
190+
## Input validation
191+
192+
The following values can be passed to the `check` keyword of `System` to toggle validation
193+
of input. Flags can be combined with bitwise `|` and `&`.
194+
195+
```@docs
196+
ModelingToolkit.CheckAll
197+
ModelingToolkit.CheckNone
198+
ModelingToolkit.CheckComponents
199+
ModelingToolkit.CheckUnits
200+
```
201+
202+
These can also be used by custom `AbstractSystem` subtypes.
203+
204+
## Utility functions
205+
206+
These utility functions can be useful when manipulating systems, especially when building
207+
custom `AbstractSystem` subtypes.
208+
209+
```@docs
210+
ModelingToolkit.collect_scoped_vars!
211+
ModelingToolkit.collect_var_to_name!
212+
ModelingToolkit.collect_vars!
213+
ModelingToolkit.eqtype_supports_collect_vars
214+
ModelingToolkit.modified_unknowns!
215+
```
216+
217+
## Namepsace manipulation
218+
219+
ModelingToolkit namespaces variables from subsystems when using them in a parent system to
220+
disambiguate from identically named variables in other subsystems or the parent system. The
221+
following functions are useful for manipulating namespacing functionality.
222+
223+
```@docs
224+
ModelingToolkit.renamespace
225+
ModelingToolkit.namespace_equations
226+
```
227+
228+
## Linearization and Analysis
229+
230+
Functions for linearization and analysis of systems.
231+
232+
```@docs
233+
linearization_ap_transform
234+
get_sensitivity_function
235+
get_comp_sensitivity_function
236+
get_looptransfer_function
237+
get_sensitivity
238+
get_comp_sensitivity
239+
get_looptransfer
240+
open_loop
241+
```
242+
243+
## Additional Equation Classification
244+
245+
```@docs
246+
alg_equations
247+
diff_equations
248+
has_alg_equations
249+
has_diff_equations
250+
```

docs/src/API/model_building.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,29 @@
33
This page lists functionality and utilities related to building hierarchical models. It is
44
recommended to read the page on the [`System`](@ref System_type) before this.
55

6+
## Common definitions of `t` and `D`
7+
8+
ModelingToolkit provides common definitions for the independent variable `t` (time) and the
9+
derivative with respect to it `D`.
10+
11+
```@docs
12+
ModelingToolkit.t_nounits
13+
ModelingToolkit.D_nounits
14+
ModelingToolkit.t
15+
ModelingToolkit.D
16+
ModelingToolkit.t_unitful
17+
ModelingToolkit.D_unitful
18+
```
19+
20+
Users are recommended to use the appropriate common definition in their models. The required
21+
definitions can be imported with convenient aliased names. For example:
22+
23+
```julia
24+
using ModelingToolkit: t_nounits as t, D_nounits as D
25+
```
26+
27+
Allows using `t` and `D` to refer to `t_nounits` and `D_nounits` respectively.
28+
629
## Hierarchical model composition
730

831
The `System` data structure can represent a tree-like hierarchy of systems for building models
@@ -203,6 +226,8 @@ change_independent_variable
203226
add_accumulations
204227
noise_to_brownians
205228
convert_system_indepvar
229+
subset_tunables
230+
respecialize
206231
```
207232

208233
## Hybrid systems

docs/src/API/variables.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ Symbolic variables can have metadata attached to them. The defaults and guesses
1818
at variable construction time are examples of this metadata. ModelingToolkit also defines
1919
additional types of metadata.
2020

21+
## Variable defaults
22+
23+
Variables can be assigned default values to avoid having to specify defaults to the
24+
[`System`](@ref) constructor.
25+
26+
```@docs
27+
ModelingToolkit.hasdefault
28+
ModelingToolkit.getdefault
29+
ModelingToolkit.setdefault
30+
```
31+
2132
## Variable descriptions
2233

2334
Descriptive strings can be attached to variables using the `[description = "descriptive string"]` syntax:
@@ -56,6 +67,7 @@ help?> u
5667
```@docs
5768
hasdescription
5869
getdescription
70+
ModelingToolkit.VariableDescription
5971
```
6072

6173
## Connect
@@ -83,6 +95,7 @@ getconnect(k)
8395
```@docs
8496
hasconnect
8597
getconnect
98+
ModelingToolkit.VariableConnectType
8699
```
87100

88101
```@docs; canonical=false
@@ -112,6 +125,8 @@ isinput
112125
isoutput
113126
ModelingToolkit.setinput
114127
ModelingToolkit.setoutput
128+
ModelingToolkit.VariableInput
129+
ModelingToolkit.VariableOutput
115130
```
116131

117132
## Bounds
@@ -144,6 +159,7 @@ hasbounds(x[2])
144159
```@docs
145160
hasbounds
146161
getbounds
162+
ModelingToolkit.VariableBounds
147163
```
148164

149165
## Guess
@@ -232,6 +248,7 @@ isirreducible(important_value)
232248

233249
```@docs
234250
isirreducible
251+
ModelingToolkit.VariableIrreducible
235252
```
236253

237254
## State Priority
@@ -245,6 +262,7 @@ state_priority(important_dof)
245262

246263
```@docs
247264
state_priority
265+
ModelingToolkit.VariableStatePriority
248266
```
249267

250268
## Units
@@ -261,6 +279,17 @@ getunit(speed)
261279
```@docs
262280
hasunit
263281
getunit
282+
ModelingToolkit.VariableUnit
283+
```
284+
285+
## Variable type
286+
287+
This metadata is used by the [`System`](@ref) constructor for automatically identifying the different types of variables in a system.
288+
289+
```@docs
290+
ModelingToolkit.VariableType
291+
ModelingToolkit.MTKVariableTypeCtx
292+
ModelingToolkit.isparameter
264293
```
265294

266295
## Miscellaneous metadata
@@ -277,6 +306,7 @@ getmisc(y)
277306
```@docs
278307
hasmisc
279308
getmisc
309+
ModelingToolkit.VariableMisc
280310
```
281311

282312
## Dumping metadata

docs/src/basics/Debugging.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ sys = mtkcompile(sys)
1919
This problem causes the ODE solver to crash:
2020

2121
```@repl debug
22-
prob = ODEProblem(sys, [], (0.0, 10.0), []);
22+
prob = ODEProblem(sys, [], (0.0, 10.0));
2323
sol = solve(prob, Tsit5());
2424
```
2525

@@ -28,7 +28,7 @@ In such situations, the `debug_system` function is helpful:
2828

2929
```@repl debug
3030
dsys = debug_system(sys; functions = [sqrt]);
31-
dprob = ODEProblem(dsys, [], (0.0, 10.0), []);
31+
dprob = ODEProblem(dsys, [], (0.0, 10.0));
3232
dsol = solve(dprob, Tsit5());
3333
```
3434

docs/src/basics/MTKLanguage.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ set to `false`.
3131
- `@equations`: for the list of equations
3232
- `@extend`: for extending a base system and unpacking its unknowns
3333
- `@icon` : for embedding the model icon
34+
- `@metadata`: for assigning key-value pairs as model level metadata
3435
- `@parameters`: for specifying the symbolic parameters
3536
- `@structural_parameters`: for specifying non-symbolic parameters
3637
- `@variables`: for specifying the unknowns
@@ -94,6 +95,16 @@ end
9495
v_for_defaults => 2.0
9596
end
9697
end
98+
99+
struct Author end
100+
struct ModelVersion end
101+
@mtkmodel ModelD begin
102+
@description "A component with some metadata."
103+
@metadata begin
104+
Author = "Test Author"
105+
ModelVersion = "1.0.0"
106+
end
107+
end
97108
```
98109

99110
#### `@description`
@@ -257,6 +268,30 @@ using ModelingToolkit
257268
end
258269
```
259270

271+
#### `@metadata` begin block
272+
273+
- Assign key-value pairs as model level metadata.
274+
- The keys must be `DataType` to avoid any key collisions.
275+
- Assignments can be made using either `=` or `=>`.
276+
- Metadata can be retrieved using [`getmetadata`](@ref).
277+
- Metadata can be set using [`setmetadata`](@ref).
278+
279+
```@example mtkmodel-example
280+
using ModelingToolkit
281+
282+
struct Author end
283+
struct ModelVersion end
284+
285+
@mtkmodel MetadataModel begin
286+
@metadata begin
287+
Author = "Test Author"
288+
ModelVersion => "1.0.0"
289+
end
290+
end
291+
@named model = MetadataModel()
292+
getmetadata(model, Author, nothing) == "Test Author"
293+
```
294+
260295
#### A begin block
261296

262297
- Any other Julia operations can be included with dedicated begin blocks.

docs/src/examples/modelingtoolkitize_index_reduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ But that's not a satisfying answer, so what do you do about it?
122122
### Transforming Higher Order DAEs to Index-1 DAEs
123123

124124
It turns out that higher order DAEs can be transformed into lower order DAEs.
125-
[If you differentiate the last equation two times and perform a substitution,
126-
you can arrive at the following set of equations](https://people.math.wisc.edu/%7Echr/am205/g_act/DAE_slides.pdf):
125+
If you differentiate the last equation two times and perform a substitution,
126+
you can arrive at the following set of equations:
127127

128128
```math
129129
\begin{aligned}

docs/src/internals.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
# Internal Details
22

3-
This is a page for detailing some of the inner workings to help future
4-
contributors to the library.
3+
This section documents the internal implementation details of ModelingToolkit. These APIs are not considered stable and may change without notice in non-breaking releases. They are documented here to help future contributors understand the library's inner workings.
4+
5+
## Overview
6+
7+
ModelingToolkit's internal architecture consists of several key components:
8+
9+
- **Structural Transformation**: Algorithms for transforming equation systems, including index reduction, tearing, and algebraic simplification
10+
- **Bipartite Graphs**: Graph representations used to analyze relationships between equations and variables
11+
- **System Structure**: Internal representations of system state and transformations
12+
13+
These components work together to enable ModelingToolkit's symbolic manipulation and code generation capabilities.
14+
15+
!!! warning
16+
The functions and types documented in this section are internal implementation details. Users should not rely on these APIs as they may change or be removed without deprecation warnings.

0 commit comments

Comments
 (0)