Skip to content

Commit 672c96c

Browse files
authored
Merge pull request #184 from SciML/bgc/format
new format rules
2 parents 5fafa79 + f4925d1 commit 672c96c

Some content is hidden

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

68 files changed

+1463
-1403
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ V = 1.0
6060
@named ground = Ground()
6161

6262
rc_eqs = [connect(constant.output, source.V)
63-
connect(source.p, resistor.p)
64-
connect(resistor.n, capacitor.p)
65-
connect(capacitor.n, source.n, ground.g)]
63+
connect(source.p, resistor.p)
64+
connect(resistor.n, capacitor.p)
65+
connect(capacitor.n, source.n, ground.g)]
6666

6767
@named rc_model = ODESystem(rc_eqs, t,
68-
systems = [resistor, capacitor, constant, source, ground])
68+
systems = [resistor, capacitor, constant, source, ground])
6969
sys = structural_simplify(rc_model)
7070
prob = ODEProblem(sys, Pair[], (0, 10.0))
7171
sol = solve(prob, Tsit5())
7272
plot(sol, idxs = [capacitor.v, resistor.i],
73-
title = "RC Circuit Demonstration",
74-
labels = ["Capacitor Voltage" "Resistor Current"])
73+
title = "RC Circuit Demonstration",
74+
labels = ["Capacitor Voltage" "Resistor Current"])
7575
savefig("plot.png")
7676
```
7777

docs/make.jl

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,29 @@ ENV["GKSwstype"] = "100"
1818
include("pages.jl")
1919

2020
makedocs(sitename = "ModelingToolkitStandardLibrary.jl",
21-
authors = "Julia Computing",
22-
clean = true,
23-
doctest = false,
24-
linkcheck = true,
25-
strict = [
26-
:linkcheck,
27-
:doctest,
28-
:example_block,
29-
],
30-
modules = [ModelingToolkit,
31-
ModelingToolkitStandardLibrary,
32-
ModelingToolkitStandardLibrary.Blocks,
33-
ModelingToolkitStandardLibrary.Mechanical,
34-
ModelingToolkitStandardLibrary.Mechanical.Rotational,
35-
ModelingToolkitStandardLibrary.Magnetic,
36-
ModelingToolkitStandardLibrary.Magnetic.FluxTubes,
37-
ModelingToolkitStandardLibrary.Electrical,
38-
ModelingToolkitStandardLibrary.Thermal,
39-
ModelingToolkitStandardLibrary.Hydraulic,
40-
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible],
41-
format = Documenter.HTML(assets = ["assets/favicon.ico"],
42-
canonical = "https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/"),
43-
pages = pages)
21+
authors = "Julia Computing",
22+
clean = true,
23+
doctest = false,
24+
linkcheck = true,
25+
strict = [
26+
:linkcheck,
27+
:doctest,
28+
:example_block,
29+
],
30+
modules = [ModelingToolkit,
31+
ModelingToolkitStandardLibrary,
32+
ModelingToolkitStandardLibrary.Blocks,
33+
ModelingToolkitStandardLibrary.Mechanical,
34+
ModelingToolkitStandardLibrary.Mechanical.Rotational,
35+
ModelingToolkitStandardLibrary.Magnetic,
36+
ModelingToolkitStandardLibrary.Magnetic.FluxTubes,
37+
ModelingToolkitStandardLibrary.Electrical,
38+
ModelingToolkitStandardLibrary.Thermal,
39+
ModelingToolkitStandardLibrary.Hydraulic,
40+
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible],
41+
format = Documenter.HTML(assets = ["assets/favicon.ico"],
42+
canonical = "https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/"),
43+
pages = pages)
4444

4545
deploydocs(repo = "github.com/SciML/ModelingToolkitStandardLibrary.jl";
46-
push_preview = true)
46+
push_preview = true)

docs/src/API/linear_analysis.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ using ModelingToolkitStandardLibrary.Blocks, ModelingToolkit
6060
@named C = Gain(-1) # A P controller
6161
t = ModelingToolkit.get_iv(P)
6262
eqs = [connect(P.output, :plant_output, C.input) # Connect with an automatically created analysis point called :plant_output
63-
connect(C.output, :plant_input, P.input)]
63+
connect(C.output, :plant_input, P.input)]
6464
sys = ODESystem(eqs, t, systems = [P, C], name = :feedback_system)
6565
6666
matrices_S = get_sensitivity(sys, :plant_input)[1] # Compute the matrices of a state-space representation of the (input)sensitivity function.
@@ -75,7 +75,7 @@ using ControlSystemsBase, Plots
7575
S = ss(matrices_S...)
7676
T = ss(matrices_T...)
7777
bodeplot([S, T], lab = ["S" "" "T" ""], plot_title = "Bode plot of sensitivity functions",
78-
margin = 5Plots.mm)
78+
margin = 5Plots.mm)
7979
```
8080

8181
The sensitivity functions obtained this way should be equivalent to the ones obtained with the code below

docs/src/connectors/connections.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ using Plots
9999
@named ground = Ground()
100100
101101
eqs = [connect(capacitor.p, resistor.p)
102-
connect(resistor.n, ground.g, capacitor.n)]
102+
connect(resistor.n, ground.g, capacitor.n)]
103103
104104
@named model = ODESystem(eqs, t; systems = [resistor, capacitor, ground])
105105
@@ -139,7 +139,7 @@ const TV = ModelingToolkitStandardLibrary.Mechanical.Translational
139139
@named ground = TV.Fixed()
140140
141141
eqs = [connect(damping.flange_a, body.flange)
142-
connect(ground.flange, damping.flange_b)]
142+
connect(ground.flange, damping.flange_b)]
143143
144144
@named model = ODESystem(eqs, t; systems = [damping, body, ground])
145145
@@ -172,7 +172,7 @@ const TP = ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition
172172
@named ground = TP.Fixed(s_0 = 0)
173173
174174
eqs = [connect(damping.flange_a, body.flange)
175-
connect(ground.flange, damping.flange_b)]
175+
connect(ground.flange, damping.flange_b)]
176176
177177
@named model = ODESystem(eqs, t; systems = [damping, body, ground])
178178
@@ -267,7 +267,7 @@ Let's define a quick function to simplify and solve the 2 different systems. Not
267267
```@example connections
268268
function simplify_and_solve(damping, spring, body, ground)
269269
eqs = [connect(spring.flange_a, body.flange, damping.flange_a)
270-
connect(spring.flange_b, damping.flange_b, ground.flange)]
270+
connect(spring.flange_b, damping.flange_b, ground.flange)]
271271
272272
@named model = ODESystem(eqs, t; systems = [ground, body, spring, damping])
273273
@@ -345,7 +345,7 @@ Which means both systems are actually solving the same exact system. We can plo
345345

346346
```@example connections
347347
plot(title = "numerical difference: vel. vs. pos. domain", xlabel = "time [s]",
348-
ylabel = "solv[bv.v] .- solp[bp.v]")
348+
ylabel = "solv[bv.v] .- solp[bp.v]")
349349
time = 0:0.1:10
350350
plot!(time, (solv(time)[bv.v] .- solp(time)[bp.v]), label = "")
351351
Plots.ylims!(-1e-15, 1e-15)

docs/src/tutorials/custom_component.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ function NonlinearResistor(; name, Ga, Gb, Ve)
4343
pars = @parameters Ga=Ga Gb=Gb Ve=Ve
4444
eqs = [
4545
i ~ ifelse(v < -Ve,
46-
Gb * (v + Ve) - Ga * Ve,
47-
ifelse(v > Ve,
48-
Gb * (v - Ve) + Ga * Ve,
49-
Ga * v)),
46+
Gb * (v + Ve) - Ga * Ve,
47+
ifelse(v > Ve,
48+
Gb * (v - Ve) + Ga * Ve,
49+
Ga * v)),
5050
]
5151
extend(ODESystem(eqs, t, [], pars; name = name), oneport)
5252
end
@@ -97,19 +97,19 @@ The final model can now be created with the components from the library and the
9797
@named C1 = Capacitor(C = 10, v_start = 4)
9898
@named C2 = Capacitor(C = 100)
9999
@named Nr = NonlinearResistor(Ga = -0.757576,
100-
Gb = -0.409091,
101-
Ve = 1)
100+
Gb = -0.409091,
101+
Ve = 1)
102102
@named Gnd = Ground()
103103
104104
connections = [connect(L.p, G.p)
105-
connect(G.n, Nr.p)
106-
connect(Nr.n, Gnd.g)
107-
connect(C1.p, G.n)
108-
connect(L.n, Ro.p)
109-
connect(G.p, C2.p)
110-
connect(C1.n, Gnd.g)
111-
connect(C2.n, Gnd.g)
112-
connect(Ro.n, Gnd.g)]
105+
connect(G.n, Nr.p)
106+
connect(Nr.n, Gnd.g)
107+
connect(C1.p, G.n)
108+
connect(L.n, Ro.p)
109+
connect(G.p, C2.p)
110+
connect(C1.n, Gnd.g)
111+
connect(C2.n, Gnd.g)
112+
connect(Ro.n, Gnd.g)]
113113
114114
@named model = ODESystem(connections, t, systems = [L, Ro, G, C1, C2, Nr, Gnd])
115115
nothing # hide
@@ -127,12 +127,12 @@ prob = ODEProblem(sys, Pair[], (0, 5e4), saveat = 0.01)
127127
sol = solve(prob, Rodas4())
128128
129129
Plots.plot(sol[C1.v], sol[C2.v], title = "Chaotic Attractor", label = "",
130-
ylabel = "C1 Voltage in V", xlabel = "C2 Voltage in V")
130+
ylabel = "C1 Voltage in V", xlabel = "C2 Voltage in V")
131131
Plots.savefig("chua_phase_plane.png")
132132
nothing # hide
133133
134134
Plots.plot(sol; vars = [C1.v, C2.v, L.i],
135-
labels = ["C1 Voltage in V" "C1 Voltage in V" "Inductor Current in A"])
135+
labels = ["C1 Voltage in V" "C1 Voltage in V" "Inductor Current in A"])
136136
Plots.savefig("chua.png")
137137
nothing # hide
138138
```

docs/src/tutorials/dc_motor_pi.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,36 @@ The actual model can now be composed.
5050
@named speed_sensor = SpeedSensor()
5151
5252
connections = [connect(fixed.flange, emf.support, friction.flange_b)
53-
connect(emf.flange, friction.flange_a, inertia.flange_a)
54-
connect(inertia.flange_b, load.flange)
55-
connect(inertia.flange_b, speed_sensor.flange)
56-
connect(load_step.output, load.tau)
57-
connect(ref.output, feedback.input1)
58-
connect(speed_sensor.w, :y, feedback.input2)
59-
connect(feedback.output, pi_controller.err_input)
60-
connect(pi_controller.ctr_output, :u, source.V)
61-
connect(source.p, R1.p)
62-
connect(R1.n, L1.p)
63-
connect(L1.n, emf.p)
64-
connect(emf.n, source.n, ground.g)]
53+
connect(emf.flange, friction.flange_a, inertia.flange_a)
54+
connect(inertia.flange_b, load.flange)
55+
connect(inertia.flange_b, speed_sensor.flange)
56+
connect(load_step.output, load.tau)
57+
connect(ref.output, feedback.input1)
58+
connect(speed_sensor.w, :y, feedback.input2)
59+
connect(feedback.output, pi_controller.err_input)
60+
connect(pi_controller.ctr_output, :u, source.V)
61+
connect(source.p, R1.p)
62+
connect(R1.n, L1.p)
63+
connect(L1.n, emf.p)
64+
connect(emf.n, source.n, ground.g)]
6565
6666
@named model = ODESystem(connections, t,
67-
systems = [
68-
ground,
69-
ref,
70-
pi_controller,
71-
feedback,
72-
source,
73-
R1,
74-
L1,
75-
emf,
76-
fixed,
77-
load,
78-
load_step,
79-
inertia,
80-
friction,
81-
speed_sensor,
82-
])
67+
systems = [
68+
ground,
69+
ref,
70+
pi_controller,
71+
feedback,
72+
source,
73+
R1,
74+
L1,
75+
emf,
76+
fixed,
77+
load,
78+
load_step,
79+
inertia,
80+
friction,
81+
speed_sensor,
82+
])
8383
nothing # hide
8484
```
8585

@@ -93,7 +93,7 @@ prob = ODEProblem(sys, [], (0, 6.0))
9393
sol = solve(prob, Rodas4())
9494
9595
p1 = Plots.plot(sol.t, sol[inertia.w], ylabel = "Angular Vel. in rad/s",
96-
label = "Measurement", title = "DC Motor with Speed Controller")
96+
label = "Measurement", title = "DC Motor with Speed Controller")
9797
Plots.plot!(sol.t, sol[ref.output.u], label = "Reference")
9898
p2 = Plots.plot(sol.t, sol[load.tau.u], ylabel = "Disturbance in Nm", label = "")
9999
Plots.plot(p1, p2, layout = (2, 1))
@@ -124,7 +124,7 @@ So = ss(matrices_S...) |> minreal # The output-sensitivity function as a StateSp
124124
matrices_T, simplified_sys = Blocks.get_comp_sensitivity(model, :y)
125125
To = ss(matrices_T...)# The output complementary sensitivity function as a StateSpace system
126126
bodeplot([So, To], label = ["S" "T"], plot_title = "Sensitivity functions",
127-
plotphase = false)
127+
plotphase = false)
128128
```
129129

130130
Similarly, we may compute the loop-transfer function and plot its Nyquist curve
@@ -134,5 +134,5 @@ matrices_L, simplified_sys = Blocks.get_looptransfer(model, :y)
134134
L = -ss(matrices_L...) # The loop-transfer function as a StateSpace system. The negative sign is to negate the built-in negative feedback
135135
Ms, ωMs = hinfnorm(So) # Compute the peak of the sensitivity function to draw a circle in the Nyquist plot
136136
nyquistplot(L, label = "\$L(s)\$", ylims = (-2.5, 0.5), xlims = (-1.2, 0.1),
137-
Ms_circles = Ms)
137+
Ms_circles = Ms)
138138
```

docs/src/tutorials/input_component.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ function System(f; name)
2828
pars = @parameters m=10 k=1000 d=1
2929

3030
eqs = [f ~ src.output.u
31-
ddx * 10 ~ k * x + d * dx + f
32-
D(x) ~ dx
33-
D(dx) ~ ddx]
31+
ddx * 10 ~ k * x + d * dx + f
32+
D(x) ~ dx
33+
D(dx) ~ ddx]
3434

3535
ODESystem(eqs, t, vars, pars; systems = [src], name)
3636
end
@@ -74,9 +74,9 @@ function System(; name)
7474
pars = @parameters m=10 k=1000 d=1
7575

7676
eqs = [f ~ get_sampled_data(t)
77-
ddx * 10 ~ k * x + d * dx + f
78-
D(x) ~ dx
79-
D(dx) ~ ddx]
77+
ddx * 10 ~ k * x + d * dx + f
78+
D(x) ~ dx
79+
D(dx) ~ ddx]
8080

8181
ODESystem(eqs, t, vars, pars; name)
8282
end
@@ -115,9 +115,9 @@ function System(; name)
115115
pars = @parameters m=10 k=1000 d=1
116116

117117
eqs = [f ~ src.output.u
118-
ddx * 10 ~ k * x + d * dx + f
119-
D(x) ~ dx
120-
D(dx) ~ ddx]
118+
ddx * 10 ~ k * x + d * dx + f
119+
D(x) ~ dx
120+
D(dx) ~ ddx]
121121

122122
ODESystem(eqs, t, vars, pars; systems = [src], name)
123123
end

docs/src/tutorials/rc_circuit.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ V = 1.0
2222
@named ground = Ground()
2323
2424
rc_eqs = [connect(constant.output, source.V)
25-
connect(source.p, resistor.p)
26-
connect(resistor.n, capacitor.p)
27-
connect(capacitor.n, source.n, ground.g)]
25+
connect(source.p, resistor.p)
26+
connect(resistor.n, capacitor.p)
27+
connect(capacitor.n, source.n, ground.g)]
2828
2929
@named rc_model = ODESystem(rc_eqs, t,
30-
systems = [resistor, capacitor, constant, source, ground])
30+
systems = [resistor, capacitor, constant, source, ground])
3131
sys = structural_simplify(rc_model)
3232
prob = ODAEProblem(sys, Pair[], (0, 10.0))
3333
sol = solve(prob, Tsit5())
3434
plot(sol, vars = [capacitor.v, resistor.i],
35-
title = "RC Circuit Demonstration",
36-
labels = ["Capacitor Voltage" "Resistor Current"])
35+
title = "RC Circuit Demonstration",
36+
labels = ["Capacitor Voltage" "Resistor Current"])
3737
savefig("plot.png");
3838
nothing; # hide
3939
```

docs/src/tutorials/thermal_model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ connections = [
2727
]
2828
2929
@named model = ODESystem(connections, t,
30-
systems = [mass1, mass2, conduction, Tsensor1, Tsensor2])
30+
systems = [mass1, mass2, conduction, Tsensor1, Tsensor2])
3131
sys = structural_simplify(model)
3232
prob = ODEProblem(sys, Pair[], (0, 5.0))
3333
sol = solve(prob, Tsit5())

src/Blocks/Blocks.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export Log, Log10
1818
include("math.jl")
1919

2020
export Constant, TimeVaryingFunction, Sine, Cosine, ContinuousClock, Ramp, Step, ExpSine,
21-
Square, Triangular, Parameter, SampledData
21+
Square, Triangular, Parameter, SampledData
2222
include("sources.jl")
2323

2424
export Limiter, DeadZone, SlewRateLimiter
@@ -29,7 +29,7 @@ export PI, LimPI, PID, LimPID
2929
include("continuous.jl")
3030

3131
export AnalysisPoint, get_sensitivity, get_comp_sensitivity,
32-
get_looptransfer, open_loop
32+
get_looptransfer, open_loop
3333
include("analysis_points.jl")
3434

3535
end

0 commit comments

Comments
 (0)