Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
run: julia -e 'using CompatHelper; CompatHelper.main(;subdirs=["", "docs"])'
run: julia -e 'using CompatHelper; CompatHelper.main(;subdirs=["", "docs", "lib/ModelingToolkitStandardLibrary"])'
23 changes: 23 additions & 0 deletions .github/workflows/Documentation-MTKStdlib.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Documentation - MTKStandardLibrary"

on:
push:
branches:
- master
paths:
- 'lib/ModelingToolkitStandardLibrary'
tags: '*'
pull_request:
paths:
- 'lib/ModelingToolkitStandardLibrary'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch || github.ref != 'refs/tags/v*' }}

jobs:
build-and-deploy-docs:
name: "Documentation"
uses: "SciML/.github/.github/workflows/documentation.yml@v1"
secrets: "inherit"
working-directory: "lib/ModelingToolkitStandardLibrary"
9 changes: 8 additions & 1 deletion .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ jobs:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
- name: Tag ModelingToolkit
uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
- name: Tag ModelingToolkitStandardLibrary
uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
subdir: lib/ModelingToolkitStandardLibrary
85 changes: 67 additions & 18 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ on:
branches:
- master
- 'release-'
- v10
paths-ignore:
- 'docs/**'
# - 'lib/ModelingToolkitStandardLibrary/docs/**'
push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'lib/ModelingToolkitStandardLibrary/docs/**'
- 'benchmark/**'

concurrency:
Expand All @@ -32,21 +33,69 @@ jobs:
- "lts"
- "pre"
group:
- InterfaceI
- InterfaceII
- Initialization
- SymbolicIndexingInterface
- Extended
- Extensions
- Downstream
- RegressionI
- FMI
uses: "SciML/.github/.github/workflows/tests.yml@master"
with:
julia-version: "${{ matrix.version }}"
group: "${{ matrix.group }}"
# Disable cache for self-hosted runners since they persist between runs
# Set USE_SELF_HOSTED repository variable to 'true' when using self-hosted runners
self-hosted: ${{ vars.USE_SELF_HOSTED == 'true' }}
cache: ${{ vars.USE_SELF_HOSTED != 'true' }}
- "ModelingToolkit - InterfaceI"
- "ModelingToolkit - InterfaceII"
- "ModelingToolkit - Initialization"
- "ModelingToolkit - SymbolicIndexingInterface"
- "ModelingToolkit - Extended"
- "ModelingToolkit - Extensions"
- "ModelingToolkit - Downstream"
- "ModelingToolkit - RegressionI"
- "ModelingToolkit - FMI"
- "ModelingToolkitStandardLibrary - QA"
- "ModelingToolkitStandardLibrary - Core"
secrets: "inherit"
steps:
- uses: actions/checkout@v4

- name: "Setup Julia ${{ matrix.version }}"
uses: julia-actions/setup-julia@v2
with:
version: "${{ matrix.version }}"
arch: "${{ runner.arch }}"

- uses: julia-actions/cache@v1
if: ${{ vars.USE_SELF_HOSTED != 'true' }}
with:
token: "${{ secrets.GITHUB_TOKEN }}"

- uses: julia-actions/julia-buildpkg@v1

- name: "Run tests ${{ vars.USE_SELF_HOSTED == 'true' && '' || format('on {0}', inputs.os) }} with Julia v${{ inputs.julia-version }}"
shell: julia --color=yes --check-bounds=yes --depwarn=yes {0}
run: |
import Pkg
PKG_GROUP = ${{ matrix.group }}
NAMES = split(PKG_GROUP, " - ")
@assert length(NAMES) == 2 """
Invalid CI configuration. Test group must be of the form 'Package - Group'. \
Got "$PKG_GROUP".
"""
PKG = NAMES[1]
GROUP = NAMES[2]
ENV["GROUP"] = GROUP
@info "Preparing Environment"
if PKG == "ModelingToolkit"
Pkg.activate(".")
Pkg.develop(; path = "lib/ModelingToolkitStandardLibrary")
else
@assert isdir("lib/$PKG") """
Package $PKG not found in subdirectory `lib/`.
"""
Pkg.activate("lib/$PKG")
Pkg.develop(; path = ".")
end

@info "Running tests"
Pkg.test(PKG; coverage = true, julia_args=["--check-bounds=yes", "--compiled-modules=yes", "--depwarn=yes"], force_latest_compatible_version=false, allow_reresolve=true)

- uses: julia-actions/julia-processcoverage@v1
with:
directories: "src,lib/ModelingToolkitStandardLibrary/src"

- name: "Report Coverage with Codecov"
uses: codecov/codecov-action@v5
with:
files: lcov.info
token: "${{ secrets.CODECOV_TOKEN }}"
fail_ci_if_error: true
10 changes: 10 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ ser = "ser"
isconnection = "isconnection"
Ue = "Ue"
Derivate = "Derivate"
Nd = "Nd"
coul = "coul"
setp = "setp"
getp = "getp"
indexin = "indexin"
ists = "ists"
ispcs = "ispcs"
eqs = "eqs"
rhs = "rhs"
MTK = "MTK"
21 changes: 21 additions & 0 deletions lib/ModelingToolkitStandardLibrary/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Julia Computing

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
53 changes: 53 additions & 0 deletions lib/ModelingToolkitStandardLibrary/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name = "ModelingToolkitStandardLibrary"
uuid = "16a59e39-deab-5bd0-87e4-056b12336739"
authors = ["Chris Rackauckas and Julia Computing"]
version = "2.25.0"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"

[compat]
ADTypes = "1"
Aqua = "0.8"
ChainRulesCore = "1.24"
ControlSystemsBase = "1.4"
DataFrames = "1.7"
DataInterpolations = "6"
DiffEqBase = "6.152"
ForwardDiff = "0.10"
IfElse = "0.1"
LinearAlgebra = "1.10"
ModelingToolkit = "10"
OrdinaryDiffEq = "6.87"
OrdinaryDiffEqDefault = "1.1"
PreallocationTools = "0.4.23"
SafeTestsets = "0.1"
SciMLStructures = "1.4.2"
SymbolicIndexingInterface = "0.3.28"
Symbolics = "6.14"
Test = "1"
julia = "1.10"

[extras]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataInterpolations = "82cc6244-b520-54b8-b5a6-8a565e85f1d0"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
OrdinaryDiffEqDefault = "50262376-6c5a-4cf5-baba-aaf4f84d72d7"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SciMLStructures = "53ae85a6-f571-4167-b2af-e1d143709226"
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["ADTypes", "Aqua", "LinearAlgebra", "OrdinaryDiffEqDefault", "OrdinaryDiffEq", "SafeTestsets", "Test", "ControlSystemsBase", "DataFrames", "DataInterpolations", "SciMLStructures", "SymbolicIndexingInterface", "ForwardDiff"]
83 changes: 83 additions & 0 deletions lib/ModelingToolkitStandardLibrary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# ModelingToolkitStandardLibrary.jl

[![Join the chat at https://julialang.zulipchat.com #sciml-bridged](https://img.shields.io/static/v1?label=Zulip&message=chat&color=9558b2&labelColor=389826)](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
[![Global Docs](https://img.shields.io/badge/docs-SciML-blue.svg)](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/)

[![codecov](https://codecov.io/gh/SciML/ModelingToolkitStandardLibrary.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/SciML/ModelingToolkitStandardLibrary.jl)
[![Build Status](https://github.com/SciML/ModelingToolkitStandardLibrary.jl/workflows/CI/badge.svg)](https://github.com/SciML/ModelingToolkitStandardLibrary.jl/actions?query=workflow%3ACI)

[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle)

The ModelingToolkit Standard Library is a standard library of components to model the world and beyond.

![](https://user-images.githubusercontent.com/1814174/172000112-3579f5cf-c370-48c2-8047-558fbc46aeb6.png)

## Installation

Assuming that you already have Julia correctly installed, it suffices to import
ModelingToolkitStandardLibrary.jl in the standard way:

```julia
import Pkg;
Pkg.add("ModelingToolkitStandardLibrary");
```

## Tutorials and Documentation

For information on using the package,
[see the stable documentation](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/). Use the
[in-development documentation](https://docs.sciml.ai/ModelingToolkitStandardLibrary/dev/) for the version of
the documentation, which contains the unreleased features.

## Libraries

The following are the constituent libraries of the ModelingToolkit Standard Library.

- [Basic Blocks](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/blocks/)
- [Mechanical Components](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/mechanical/)
- [Electrical Components](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/electrical/)
- [Magnetic Components](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/magnetic/)
- [Thermal Components](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/thermal/)

## Example

The following is the [RC Circuit Demonstration](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/tutorials/rc_circuit/):

```julia
using ModelingToolkit, OrdinaryDiffEq, Plots
using ModelingToolkitStandardLibrary.Electrical
using ModelingToolkitStandardLibrary.Blocks: Constant
using ModelingToolkit: t_nounits as t

@mtkmodel RC begin
@parameters begin
R = 1.0
C = 1.0
V = 1.0
end
@components begin
resistor = Resistor(R = R)
capacitor = Capacitor(C = C, v = 0.0)
source = Voltage()
constant = Constant(k = V)
ground = Ground()
end
@equations begin
connect(constant.output, source.V)
connect(source.p, resistor.p)
connect(resistor.n, capacitor.p)
connect(capacitor.n, source.n, ground.g)
end
end

@mtkcompile sys = RC()
prob = ODEProblem(sys, Pair[], (0, 10.0))
sol = solve(prob)

plot(sol, idxs = [sys.capacitor.v, sys.resistor.i],
title = "RC Circuit Demonstration",
labels = ["Capacitor Voltage" "Resistor Current"])
```

![](https://user-images.githubusercontent.com/1814174/164912983-c3f73628-0e19-4e42-b085-4f62ba6f23d1.png)
20 changes: 20 additions & 0 deletions lib/ModelingToolkitStandardLibrary/docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[deps]
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataInterpolations = "82cc6244-b520-54b8-b5a6-8a565e85f1d0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
ModelingToolkitStandardLibrary = "16a59e39-deab-5bd0-87e4-056b12336739"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

[compat]
ControlSystemsBase = "1.1"
DataFrames = "1.7"
DataInterpolations = "6.4, 7, 8"
Documenter = "1"
IfElse = "0.1"
ModelingToolkit = "10"
OrdinaryDiffEq = "6.31"
Plots = "1.36"
41 changes: 41 additions & 0 deletions lib/ModelingToolkitStandardLibrary/docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Documenter, ModelingToolkitStandardLibrary
using ModelingToolkit
using ModelingToolkitStandardLibrary.Blocks
using ModelingToolkitStandardLibrary.Mechanical
using ModelingToolkitStandardLibrary.Mechanical.Rotational
using ModelingToolkitStandardLibrary.Magnetic
using ModelingToolkitStandardLibrary.Magnetic.FluxTubes
using ModelingToolkitStandardLibrary.Electrical
using ModelingToolkitStandardLibrary.Thermal
using ModelingToolkitStandardLibrary.Hydraulic
using ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible

cp("./docs/Manifest.toml", "./docs/src/assets/Manifest.toml", force = true)
cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)

ENV["GKSwstype"] = "100"

include("pages.jl")

makedocs(sitename = "ModelingToolkitStandardLibrary.jl",
authors = "Julia Computing",
modules = [ModelingToolkit,
ModelingToolkitStandardLibrary,
ModelingToolkitStandardLibrary.Blocks,
ModelingToolkitStandardLibrary.Mechanical,
ModelingToolkitStandardLibrary.Mechanical.Rotational,
ModelingToolkitStandardLibrary.Magnetic,
ModelingToolkitStandardLibrary.Magnetic.FluxTubes,
ModelingToolkitStandardLibrary.Electrical,
ModelingToolkitStandardLibrary.Thermal,
ModelingToolkitStandardLibrary.Hydraulic,
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible],
clean = true, doctest = false, linkcheck = true,
linkcheck_ignore = ["https://www.mathworks.com/help/simscape/ug/basic-principles-of-modeling-physical-networks.html#bq89sba-6"],
warnonly = [:docs_block, :missing_docs, :cross_references],
format = Documenter.HTML(assets = ["assets/favicon.ico"],
canonical = "https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/"),
pages = pages)

deploydocs(repo = "github.com/SciML/ModelingToolkitStandardLibrary.jl";
push_preview = true)
Loading
Loading