Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ jobs:
- uses: julia-actions/setup-julia@latest
with:
version: '1'
- run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
run: julia --project=docs/ --code-coverage=user docs/make.jl
run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ --code-coverage=user docs/make.jl
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ModelingToolkit"
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
authors = ["Yingbo Ma <mayingbo5@gmail.com>", "Chris Rackauckas <accounts@chrisrackauckas.com> and contributors"]
version = "8.69.1"
version = "8.71.0"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down Expand Up @@ -85,7 +85,7 @@ PrecompileTools = "1"
RecursiveArrayTools = "2.3"
Reexport = "0.2, 1"
RuntimeGeneratedFunctions = "0.5.9"
SciMLBase = "1.76.1"
SciMLBase = "2.0.1"
Setfield = "0.7, 0.8, 1"
SimpleNonlinearSolve = "0.1.0"
SpecialFunctions = "0.7, 0.8, 0.9, 0.10, 1.0, 2"
Expand Down
4 changes: 3 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
ModelingToolkitDesigner = "23d639d0-9462-4d1e-84fe-d700424865b8"
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
Expand All @@ -23,7 +24,8 @@ DifferentialEquations = "7.6"
Distributions = "0.25"
Documenter = "1"
ModelingToolkit = "8.33"
NonlinearSolve = "0.3, 1"
ModelingToolkitDesigner = "1"
NonlinearSolve = "0.3, 1, 2"
Optim = "1.7"
Optimization = "3.9"
OptimizationOptimJL = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ makedocs(sitename = "ModelingToolkit.jl",
clean = true, doctest = false, linkcheck = true,
warnonly = [:docs_block, :missing_docs, :cross_references],
linkcheck_ignore = ["https://epubs.siam.org/doi/10.1137/0903023"],
format = Documenter.HTML(; analytics = "UA-90474609-3",
format = Documenter.HTML(;
assets = ["assets/favicon.ico"],
mathengine,
canonical = "https://docs.sciml.ai/ModelingToolkit/stable/",
Expand Down
4 changes: 3 additions & 1 deletion docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ pages = [
"tutorials/optimization.md",
"tutorials/modelingtoolkitize.md",
"tutorials/stochastic_diffeq.md",
"tutorials/parameter_identifiability.md"],
"tutorials/parameter_identifiability.md",
"tutorials/domain_connections.md"],
"Examples" => Any["Basic Examples" => Any["examples/higher_order.md",
"examples/spring_mass.md",
"examples/modelingtoolkitize_index_reduction.md",
Expand All @@ -20,6 +21,7 @@ pages = [
"basics/Composition.md",
"basics/Events.md",
"basics/Linearization.md",
"basics/MTKModel_Connector.md",
"basics/Validation.md",
"basics/DependencyGraphs.md",
"basics/FAQ.md"],
Expand Down
6 changes: 4 additions & 2 deletions docs/src/basics/AbstractSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ The values which are common to all `AbstractSystem`s are:
Optionally, a system could have:

- `observed(sys)`: All observed equations of the system and its subsystems.
- `independent_variables(sys)`: The independent variables of a system.
- `defaults(sys)`: A `Dict` that maps variables/parameters into their default values for the system and its subsystems.
- `get_observed(sys)`: Observed equations of the current-level system.
- `get_continuous_events(sys)`: `SymbolicContinuousCallback`s of the current-level system.
- `get_defaults(sys)`: A `Dict` that maps variables into their default values.
- `independent_variables(sys)`: The independent variables of a system.
- `get_defaults(sys)`: A `Dict` that maps variables into their default values
for the current-level system.
- `get_noiseeqs(sys)`: Noise equations of the current-level system.
- `get_metadata(sys)`: Any metadata about the system or its origin to be used by downstream packages.

Expand Down
16 changes: 16 additions & 0 deletions docs/src/basics/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,19 @@ julia> ModelingToolkit.missing_variable_defaults(sys, [1,2,3])
x2ˍtt(t) => 2
x3ˍtt(t) => 3
```

## Change the state vector type

Use the `u0_constructor` keyword argument to map an array to the desired
container type. For example:

```
using ModelingToolkit, StaticArrays
@variables t
sts = @variables x1(t)=0.0
D = Differential(t)
eqs = [D(x1) ~ 1.1 * x1]
@named sys = ODESystem(eqs, t)
sys = structural_simplify(sys)
prob = ODEProblem{false}(sys, [], (0,1); u0_constructor = x->SVector(x...))
```
17 changes: 7 additions & 10 deletions docs/src/basics/MTKModel_Connector.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Defining components with `@mtkmodel`
# Defining components with `@mtkmodel`

`@mtkmodel` is a convenience macro to define ModelingToolkit components. It returns `ModelingToolkit.Model`, which includes a constructor that returns an ODESystem, a `structure` dictionary with metadata and flag `isconnector` which is set to `false`.

### What can an MTK-Model definition have?
## What can an MTK-Model definition have?

`@mtkmodel` definition contains begin blocks of

Expand Down Expand Up @@ -52,7 +52,7 @@ end
end
```

#### `@parameters` and `@variables` begin block
### `@parameters` and `@variables` begin block

- Parameters and variables are declared with respective begin blocks.
- Variables must be functions of an independent variable.
Expand All @@ -67,12 +67,12 @@ julia > ModelingToolkit.getdefault(model_c.v)
2.0
```

#### `@structural_parameters` begin block
### `@structural_parameters` begin block

- This block is for non symbolic input arguements. These are for inputs that usually are not meant to be part of components; but influence how they are defined. One can list inputs like boolean flags, functions etc... here.
- Whenever default values are specified, unlike parameters/variables, they are reflected in the keyword argument list.

#### `@extend` block
### `@extend` block

To extend a partial system,

Expand All @@ -88,7 +88,7 @@ julia> @named model_c = ModelC(; p1 = 2.0)

However, as `p2` isn't listed in the model definition, its default can't be modified by users.

#### `@components` begin block
### `@components` begin block

- Declare the subcomponents within `@components` begin block.
- The arguments in these subcomponents are promoted as keyword arguments as `subcomponent_name__argname` with `nothing` as default value.
Expand All @@ -102,7 +102,7 @@ julia> @named model_c1 = ModelC(; model_a.k1 = 1);

And as `k2` isn't listed in the sub-component definition of `ModelC`, its default value can't be modified by users.

#### `@equations` begin block
### `@equations` begin block

- List all the equations here

Expand Down Expand Up @@ -130,11 +130,8 @@ end
`@connector`s accepts begin blocks of `@components`, `@equations`, `@extend`, `@parameters`, `@structural_parameters`, `@variables`. These keywords mean the same as described above for `@mtkmodel`.

!!! note

For more examples of usage, checkout [ModelingToolkitStandardLibrary.jl](https://github.com/SciML/ModelingToolkitStandardLibrary.jl/)

* * *

### What's a `structure` dictionary?

For components defined with `@mtkmodel` or `@connector`, a dictionary with metadata is created. It lists `:components` (sub-component list), `:extend` (the extended states and base system), `:parameters`, `:variables`, ``:kwargs`` (list of keyword arguments), `:independent_variable`, `:equations`.
Expand Down
35 changes: 10 additions & 25 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,34 +223,19 @@ Pkg.status(; mode = PKGMODE_MANIFEST) # hide
</details>
```

```@raw html
You can also download the
<a href="
```

```@eval
using TOML
using Markdown
version = TOML.parse(read("../../Project.toml", String))["version"]
name = TOML.parse(read("../../Project.toml", String))["name"]
link = Markdown.MD("https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
"/assets/Manifest.toml")
```

```@raw html
">manifest</a> file and the
<a href="
```

```@eval
using TOML
using Markdown
version = TOML.parse(read("../../Project.toml", String))["version"]
name = TOML.parse(read("../../Project.toml", String))["name"]
link = Markdown.MD("https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
"/assets/Project.toml")
```

```@raw html
">project</a> file.
link_manifest = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
"/assets/Manifest.toml"
link_project = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
"/assets/Project.toml"
Markdown.parse("""You can also download the
[manifest]($link_manifest)
file and the
[project]($link_project)
file.
""")
```
Loading