Skip to content

Commit 12bb1ed

Browse files
committed
Format
1 parent 5e0e194 commit 12bb1ed

File tree

89 files changed

+7136
-6876
lines changed

Some content is hidden

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

89 files changed

+7136
-6876
lines changed

docs/make.jl

+49-61
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,52 @@
11
using Documenter, ModelingToolkit
22

3-
makedocs(
4-
sitename="ModelingToolkit.jl",
5-
authors="Chris Rackauckas",
6-
modules=[ModelingToolkit],
7-
clean=true,doctest=false,
8-
strict=[
9-
:doctest,
10-
:linkcheck,
11-
:parse_error,
12-
:example_block,
13-
# Other available options are
14-
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
15-
],
16-
format=Documenter.HTML(analytics = "UA-90474609-3",
17-
assets=["assets/favicon.ico"],
18-
canonical="https://mtk.sciml.ai/stable/"),
19-
pages=[
20-
"Home" => "index.md",
21-
"Symbolic Modeling Tutorials" => Any[
22-
"tutorials/ode_modeling.md",
23-
"tutorials/spring_mass.md",
24-
"tutorials/acausal_components.md",
25-
"tutorials/higher_order.md",
26-
"tutorials/tearing_parallelism.md",
27-
"tutorials/nonlinear.md",
28-
"tutorials/optimization.md",
29-
"tutorials/stochastic_diffeq.md",
30-
"tutorials/nonlinear_optimal_control.md",
31-
"tutorials/parameter_identifiability.md"
32-
],
33-
"ModelingToolkitize Tutorials" => Any[
34-
"mtkitize_tutorials/modelingtoolkitize.md",
35-
"mtkitize_tutorials/modelingtoolkitize_index_reduction.md",
36-
"mtkitize_tutorials/sparse_jacobians.md",
37-
],
38-
"Basics" => Any[
39-
"basics/AbstractSystem.md",
40-
"basics/ContextualVariables.md",
41-
"basics/Variable_metadata.md",
42-
"basics/Composition.md",
43-
"basics/Validation.md",
44-
"basics/DependencyGraphs.md",
45-
"basics/FAQ.md"
46-
],
47-
"System Types" => Any[
48-
"systems/ODESystem.md",
49-
"systems/SDESystem.md",
50-
"systems/JumpSystem.md",
51-
"systems/NonlinearSystem.md",
52-
"systems/OptimizationSystem.md",
53-
"systems/ControlSystem.md",
54-
"systems/PDESystem.md",
55-
],
56-
"comparison.md",
57-
"internals.md",
58-
]
59-
)
3+
makedocs(sitename = "ModelingToolkit.jl",
4+
authors = "Chris Rackauckas",
5+
modules = [ModelingToolkit],
6+
clean = true, doctest = false,
7+
strict = [
8+
:doctest,
9+
:linkcheck,
10+
:parse_error,
11+
:example_block,
12+
# Other available options are
13+
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
14+
],
15+
format = Documenter.HTML(analytics = "UA-90474609-3",
16+
assets = ["assets/favicon.ico"],
17+
canonical = "https://mtk.sciml.ai/stable/"),
18+
pages = [
19+
"Home" => "index.md",
20+
"Symbolic Modeling Tutorials" => Any["tutorials/ode_modeling.md",
21+
"tutorials/spring_mass.md",
22+
"tutorials/acausal_components.md",
23+
"tutorials/higher_order.md",
24+
"tutorials/tearing_parallelism.md",
25+
"tutorials/nonlinear.md",
26+
"tutorials/optimization.md",
27+
"tutorials/stochastic_diffeq.md",
28+
"tutorials/nonlinear_optimal_control.md",
29+
"tutorials/parameter_identifiability.md"],
30+
"ModelingToolkitize Tutorials" => Any["mtkitize_tutorials/modelingtoolkitize.md",
31+
"mtkitize_tutorials/modelingtoolkitize_index_reduction.md",
32+
"mtkitize_tutorials/sparse_jacobians.md"],
33+
"Basics" => Any["basics/AbstractSystem.md",
34+
"basics/ContextualVariables.md",
35+
"basics/Variable_metadata.md",
36+
"basics/Composition.md",
37+
"basics/Validation.md",
38+
"basics/DependencyGraphs.md",
39+
"basics/FAQ.md"],
40+
"System Types" => Any["systems/ODESystem.md",
41+
"systems/SDESystem.md",
42+
"systems/JumpSystem.md",
43+
"systems/NonlinearSystem.md",
44+
"systems/OptimizationSystem.md",
45+
"systems/ControlSystem.md",
46+
"systems/PDESystem.md"],
47+
"comparison.md",
48+
"internals.md",
49+
])
6050

61-
deploydocs(
62-
repo="github.com/SciML/ModelingToolkit.jl.git";
63-
push_preview=true
64-
)
51+
deploydocs(repo = "github.com/SciML/ModelingToolkit.jl.git";
52+
push_preview = true)

examples/electrical_components.jl

+40-48
Original file line numberDiff line numberDiff line change
@@ -2,105 +2,97 @@ using Test
22
using ModelingToolkit, OrdinaryDiffEq
33

44
@isdefined(t) || @parameters t
5-
@connector function Pin(;name)
5+
@connector function Pin(; name)
66
sts = @variables v(t)=1.0 i(t)=1.0 [connect = Flow]
7-
ODESystem(Equation[], t, sts, []; name=name)
7+
ODESystem(Equation[], t, sts, []; name = name)
88
end
99

10-
function Ground(;name)
10+
function Ground(; name)
1111
@named g = Pin()
1212
eqs = [g.v ~ 0]
13-
compose(ODESystem(eqs, t, [], []; name=name), g)
13+
compose(ODESystem(eqs, t, [], []; name = name), g)
1414
end
1515

16-
function OnePort(;name)
16+
function OnePort(; name)
1717
@named p = Pin()
1818
@named n = Pin()
1919
sts = @variables v(t)=1.0 i(t)=1.0
20-
eqs = [
21-
v ~ p.v - n.v
20+
eqs = [v ~ p.v - n.v
2221
0 ~ p.i + n.i
23-
i ~ p.i
24-
]
25-
compose(ODESystem(eqs, t, sts, []; name=name), p, n)
22+
i ~ p.i]
23+
compose(ODESystem(eqs, t, sts, []; name = name), p, n)
2624
end
2725

28-
function Resistor(;name, R = 1.0)
26+
function Resistor(; name, R = 1.0)
2927
@named oneport = OnePort()
3028
@unpack v, i = oneport
31-
ps = @parameters R=R
29+
ps = @parameters R = R
3230
eqs = [
33-
v ~ i * R
34-
]
35-
extend(ODESystem(eqs, t, [], ps; name=name), oneport)
31+
v ~ i * R,
32+
]
33+
extend(ODESystem(eqs, t, [], ps; name = name), oneport)
3634
end
3735

38-
function Capacitor(;name, C = 1.0)
36+
function Capacitor(; name, C = 1.0)
3937
@named oneport = OnePort()
4038
@unpack v, i = oneport
41-
ps = @parameters C=C
39+
ps = @parameters C = C
4240
D = Differential(t)
4341
eqs = [
44-
D(v) ~ i / C
45-
]
46-
extend(ODESystem(eqs, t, [], ps; name=name), oneport)
42+
D(v) ~ i / C,
43+
]
44+
extend(ODESystem(eqs, t, [], ps; name = name), oneport)
4745
end
4846

49-
function ConstantVoltage(;name, V = 1.0)
47+
function ConstantVoltage(; name, V = 1.0)
5048
@named oneport = OnePort()
5149
@unpack v = oneport
52-
ps = @parameters V=V
50+
ps = @parameters V = V
5351
eqs = [
54-
V ~ v
55-
]
56-
extend(ODESystem(eqs, t, [], ps; name=name), oneport)
52+
V ~ v,
53+
]
54+
extend(ODESystem(eqs, t, [], ps; name = name), oneport)
5755
end
5856

5957
function Inductor(; name, L = 1.0)
6058
@named oneport = OnePort()
6159
@unpack v, i = oneport
62-
ps = @parameters L=L
60+
ps = @parameters L = L
6361
D = Differential(t)
6462
eqs = [
65-
D(i) ~ v / L
66-
]
67-
extend(ODESystem(eqs, t, [], ps; name=name), oneport)
63+
D(i) ~ v / L,
64+
]
65+
extend(ODESystem(eqs, t, [], ps; name = name), oneport)
6866
end
6967

70-
@connector function HeatPort(;name)
68+
@connector function HeatPort(; name)
7169
@variables T(t)=293.15 Q_flow(t)=0.0 [connect = Flow]
72-
ODESystem(Equation[], t, [T, Q_flow], [], name=name)
70+
ODESystem(Equation[], t, [T, Q_flow], [], name = name)
7371
end
7472

75-
function HeatingResistor(;name, R=1.0, TAmbient=293.15, alpha=1.0)
73+
function HeatingResistor(; name, R = 1.0, TAmbient = 293.15, alpha = 1.0)
7674
@named p = Pin()
7775
@named n = Pin()
7876
@named h = HeatPort()
7977
@variables v(t) RTherm(t)
8078
@parameters R=R TAmbient=TAmbient alpha=alpha
81-
eqs = [
82-
RTherm ~ R*(1 + alpha*(h.T - TAmbient))
79+
eqs = [RTherm ~ R * (1 + alpha * (h.T - TAmbient))
8380
v ~ p.i * RTherm
8481
h.Q_flow ~ -v * p.i # -LossPower
8582
v ~ p.v - n.v
86-
0 ~ p.i + n.i
87-
]
88-
compose(ODESystem(
89-
eqs, t, [v, RTherm], [R, TAmbient, alpha],
90-
name=name,
91-
), p, n, h)
83+
0 ~ p.i + n.i]
84+
compose(ODESystem(eqs, t, [v, RTherm], [R, TAmbient, alpha],
85+
name = name), p, n, h)
9286
end
9387

94-
function HeatCapacitor(;name, rho=8050, V=1, cp=460, TAmbient=293.15)
88+
function HeatCapacitor(; name, rho = 8050, V = 1, cp = 460, TAmbient = 293.15)
9589
@parameters rho=rho V=V cp=cp
96-
C = rho*V*cp
90+
C = rho * V * cp
9791
@named h = HeatPort()
9892
D = Differential(t)
9993
eqs = [
100-
D(h.T) ~ h.Q_flow / C
101-
]
102-
compose(ODESystem(
103-
eqs, t, [], [rho, V, cp],
104-
name=name,
105-
), h)
94+
D(h.T) ~ h.Q_flow / C,
95+
]
96+
compose(ODESystem(eqs, t, [], [rho, V, cp],
97+
name = name), h)
10698
end

examples/rc_model.jl

+5-7
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ include("electrical_components.jl")
33
R = 1.0
44
C = 1.0
55
V = 1.0
6-
@named resistor = Resistor(R=R)
7-
@named capacitor = Capacitor(C=C)
8-
@named source = ConstantVoltage(V=V)
6+
@named resistor = Resistor(R = R)
7+
@named capacitor = Capacitor(C = C)
8+
@named source = ConstantVoltage(V = V)
99
@named ground = Ground()
1010

11-
rc_eqs = [
12-
connect(source.p, resistor.p)
11+
rc_eqs = [connect(source.p, resistor.p)
1312
connect(resistor.n, capacitor.p)
1413
connect(capacitor.n, source.n)
15-
connect(capacitor.n, ground.g)
16-
]
14+
connect(capacitor.n, ground.g)]
1715

1816
@named rc_model = ODESystem(rc_eqs, t)
1917
rc_model = compose(rc_model, [resistor, capacitor, source, ground])

examples/serial_inductor.jl

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
include("electrical_components.jl")
22

3-
@named source = ConstantVoltage(V=10.0)
4-
@named resistor = Resistor(R=1.0)
5-
@named inductor1 = Inductor(L=1.0e-2)
6-
@named inductor2 = Inductor(L=2.0e-2)
3+
@named source = ConstantVoltage(V = 10.0)
4+
@named resistor = Resistor(R = 1.0)
5+
@named inductor1 = Inductor(L = 1.0e-2)
6+
@named inductor2 = Inductor(L = 2.0e-2)
77
@named ground = Ground()
88

9-
eqs = [
10-
connect(source.p, resistor.p)
9+
eqs = [connect(source.p, resistor.p)
1110
connect(resistor.n, inductor1.p)
1211
connect(inductor1.n, inductor2.p)
1312
connect(source.n, inductor2.n)
14-
connect(inductor2.n, ground.g)
15-
]
13+
connect(inductor2.n, ground.g)]
1614

1715
@named ll_model = ODESystem(eqs, t)
1816
ll_model = compose(ll_model, [source, resistor, inductor1, inductor2, ground])

src/ModelingToolkit.jl

+7-5
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ for fun in [:toexpr]
6868
Expr(:(=), $fun(eq.lhs; kw...), $fun(eq.rhs; kw...))
6969
end
7070

71-
$fun(eqs::AbstractArray; kw...) = map(eq->$fun(eq; kw...), eqs)
71+
$fun(eqs::AbstractArray; kw...) = map(eq -> $fun(eq; kw...), eqs)
7272
$fun(x::Integer; kw...) = x
7373
$fun(x::AbstractFloat; kw...) = x
7474
end
@@ -158,7 +158,8 @@ for S in subtypes(ModelingToolkit.AbstractSystem)
158158
@eval convert_system(::Type{<:$S}, sys::$S) = sys
159159
end
160160

161-
export AbstractTimeDependentSystem, AbstractTimeIndependentSystem, AbstractMultivariateSystem
161+
export AbstractTimeDependentSystem, AbstractTimeIndependentSystem,
162+
AbstractMultivariateSystem
162163
export ODESystem, ODEFunction, ODEFunctionExpr, ODEProblemExpr, convert_system
163164
export DAEFunctionExpr, DAEProblemExpr
164165
export SDESystem, SDEFunction, SDEFunctionExpr, SDESystemExpr
@@ -174,15 +175,17 @@ export NonlinearSystem, OptimizationSystem
174175
export ControlSystem
175176
export alias_elimination, flatten
176177
export connect, @connector, Connection, Flow, Stream, instream
177-
export isinput, isoutput, getbounds, hasbounds, isdisturbance, istunable, getdist, hasdist, tunable_parameters
178+
export isinput, isoutput, getbounds, hasbounds, isdisturbance, istunable, getdist, hasdist,
179+
tunable_parameters
178180
export ode_order_lowering, dae_order_lowering, liouville_transform
179181
export runge_kutta_discretize
180182
export PDESystem
181183
export Differential, expand_derivatives, @derivatives
182184
export Equation, ConstrainedEquation
183185
export Term, Sym
184186
export SymScope, LocalScope, ParentScope, GlobalScope
185-
export independent_variables, independent_variable, states, parameters, equations, controls, observed, structure, full_equations
187+
export independent_variables, independent_variable, states, parameters, equations, controls,
188+
observed, structure, full_equations
186189
export structural_simplify, expand_connections
187190
export DiscreteSystem, DiscreteProblem
188191

@@ -208,5 +211,4 @@ export modelingtoolkitize
208211
export @variables, @parameters
209212
export @named, @nonamespace, @namespace, extend, compose
210213

211-
212214
end # module

0 commit comments

Comments
 (0)