Skip to content

Commit 486497e

Browse files
Merge pull request #404 from ChrisRackauckas/fix-formatting
Apply JuliaFormatter to fix code formatting
2 parents 3347623 + 08b1f85 commit 486497e

File tree

17 files changed

+97
-79
lines changed

17 files changed

+97
-79
lines changed

docs/src/connectors/connections.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ nothing # hide
191191
As can be seen, we get exactly the same result. The only difference here is that we are solving an extra equation, which allows us to plot the body position as well.
192192

193193
```@example connections
194-
prob = ODEProblem(sys, [], (0, 10.0), fully_determined=true)
194+
prob = ODEProblem(sys, [], (0, 10.0), fully_determined = true)
195195
sol_p = solve(prob)
196196
197197
p1 = plot(sol_p, idxs = [body.v])
@@ -281,7 +281,7 @@ function simplify_and_solve(damping, spring, body, ground; initialization_eqs =
281281
282282
println.(full_equations(sys))
283283
284-
prob = ODEProblem(sys, [], (0, 10.0); initialization_eqs, fully_determined=true)
284+
prob = ODEProblem(sys, [], (0, 10.0); initialization_eqs, fully_determined = true)
285285
sol = solve(prob; abstol = 1e-9, reltol = 1e-9)
286286
287287
return sol

docs/src/tutorials/MOSFET_calibration.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# MOSFET I-V Curves
2-
In this example, first we'll demonstrate the I-V curves of the NMOS transistor model.
1+
# MOSFET I-V Curves
2+
3+
In this example, first we'll demonstrate the I-V curves of the NMOS transistor model.
34
First of all, we construct a circuit using the NMOS transistor. We'll need to import ModelingToolkit and the Electrical standard library that holds the transistor models.
45

56
```@example NMOS
@@ -12,6 +13,7 @@ using Plots
1213
```
1314

1415
Here we just connect the source pin to ground, the drain pin to a voltage source named `Vcc`, and the gate pin to a voltage source named `Vb`.
16+
1517
```@example NMOS
1618
@mtkmodel SimpleNMOSCircuit begin
1719
@components begin
@@ -20,8 +22,8 @@ Here we just connect the source pin to ground, the drain pin to a voltage source
2022
Vb = Voltage()
2123
ground = Ground()
2224
23-
Vcc_const = Constant(k=V_cc)
24-
Vb_const = Constant(k=V_b)
25+
Vcc_const = Constant(k = V_cc)
26+
Vb_const = Constant(k = V_b)
2527
end
2628
2729
@parameters begin
@@ -48,7 +50,8 @@ prob = ODEProblem(sys, Pair[], (0.0, 10.0))
4850
sol = solve(prob)
4951
```
5052

51-
Now to make sure that the transistor model is working like it's supposed to, we can examine the plots of the drain-source voltage vs. the drain current, otherwise knowns as the I-V curve of the transistor.
53+
Now to make sure that the transistor model is working like it's supposed to, we can examine the plots of the drain-source voltage vs. the drain current, otherwise knowns as the I-V curve of the transistor.
54+
5255
```@example NMOS
5356
v_cc_list = collect(0.05:0.1:10.0)
5457
@@ -58,7 +61,7 @@ I_D_lists = []
5861
for V_b in [1.0, 1.4, 1.8, 2.2, 2.6]
5962
I_D_list = []
6063
for V_cc in v_cc_list
61-
@mtkbuild sys = SimpleNMOSCircuit(V_cc=V_cc, V_b=V_b)
64+
@mtkbuild sys = SimpleNMOSCircuit(V_cc = V_cc, V_b = V_b)
6265
prob = ODEProblem(sys, Pair[], (0.0, 10.0))
6366
sol = solve(prob)
6467
push!(I_D_list, sol[sys.Q1.d.i][1])
@@ -67,8 +70,10 @@ for V_b in [1.0, 1.4, 1.8, 2.2, 2.6]
6770
end
6871
6972
reduce(hcat, I_D_lists)
70-
plot(v_cc_list, I_D_lists, title="NMOS IV Curves", label=["V_GS: 1.0 V" "V_GS: 1.4 V" "V_GS: 1.8 V" "V_GS: 2.2 V" "V_GS: 2.6 V"], xlabel = "Drain-Source Voltage (V)", ylabel = "Drain Current (A)")
73+
plot(v_cc_list, I_D_lists, title = "NMOS IV Curves",
74+
label = ["V_GS: 1.0 V" "V_GS: 1.4 V" "V_GS: 1.8 V" "V_GS: 2.2 V" "V_GS: 2.6 V"],
75+
xlabel = "Drain-Source Voltage (V)", ylabel = "Drain Current (A)")
7176
```
7277

73-
We can see that we get exactly what we would expect: as the drain-source voltage increases, the drain current increases, until the the transistor gets in to the saturation region of operation.
74-
Then the only increase in drain current is due to the channel-length modulation effect. Additionally, we can see that the maximum current reached increases as the gate voltage increases.
78+
We can see that we get exactly what we would expect: as the drain-source voltage increases, the drain current increases, until the the transistor gets in to the saturation region of operation.
79+
Then the only increase in drain current is due to the channel-length modulation effect. Additionally, we can see that the maximum current reached increases as the gate voltage increases.

docs/src/tutorials/dc_motor_pi.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,12 @@ T(s) &= \dfrac{P(s)C(s)}{I + P(s)C(s)}
107107

108108
```@example dc_motor_pi
109109
using ControlSystemsBase
110-
matrices_S, simplified_sys = Blocks.get_sensitivity(
110+
matrices_S,
111+
simplified_sys = Blocks.get_sensitivity(
111112
model, :y, op = Dict(unknowns(sys) .=> 0.0))
112113
So = ss(matrices_S...) |> minreal # The output-sensitivity function as a StateSpace system
113-
matrices_T, simplified_sys = Blocks.get_comp_sensitivity(
114+
matrices_T,
115+
simplified_sys = Blocks.get_comp_sensitivity(
114116
model, :y, op = Dict(unknowns(sys) .=> 0.0))
115117
To = ss(matrices_T...)# The output complementary sensitivity function as a StateSpace system
116118
bodeplot([So, To], label = ["S" "T"], plot_title = "Sensitivity functions",
@@ -120,7 +122,8 @@ bodeplot([So, To], label = ["S" "T"], plot_title = "Sensitivity functions",
120122
Similarly, we may compute the loop-transfer function and plot its Nyquist curve
121123

122124
```@example dc_motor_pi
123-
matrices_L, simplified_sys = Blocks.get_looptransfer(
125+
matrices_L,
126+
simplified_sys = Blocks.get_looptransfer(
124127
model, :y, op = Dict(unknowns(sys) .=> 0.0))
125128
L = -ss(matrices_L...) # The loop-transfer function as a StateSpace system. The negative sign is to negate the built-in negative feedback
126129
Ms, ωMs = hinfnorm(So) # Compute the peak of the sensitivity function to draw a circle in the Nyquist plot

docs/src/tutorials/input_component.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ my_interpolation = LinearInterpolation(df.data, df.time)
8484
8585
@mtkmodel MassSpringDamperSystem2 begin
8686
@components begin
87-
src = Interpolation(itp=my_interpolation)
87+
src = Interpolation(itp = my_interpolation)
8888
clk = ContinuousClock()
8989
model = MassSpringDamper()
9090
end
@@ -174,7 +174,7 @@ plot(sol2)
174174
```
175175

176176
!!! note
177-
177+
178178
Note that when changing the data, the length of the new data must be the same as the length of the original data.
179179

180180
## Custom Component with External Data

src/Blocks/continuous.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,13 @@ linearized around the operating point `x₀, u₀`, we have `y0, u0 = h(x₀, u
572572
]
573573
# pars = @parameters A=A B=B C=C D=D # This is buggy
574574
eqs = [ # FIXME: if array equations work
575-
[Differential(t)(x[i]) ~ sum(A[i, k] * x[k] for k in 1:nx) +
576-
sum(B[i, j] * (input.u[j] - u0[j]) for j in 1:nu)
575+
[Differential(t)(x[i]) ~
576+
sum(A[i, k] * x[k] for k in 1:nx) +
577+
sum(B[i, j] * (input.u[j] - u0[j]) for j in 1:nu)
577578
for i in 1:nx]..., # cannot use D here
578-
[output.u[j] ~ sum(C[j, i] * x[i] for i in 1:nx) +
579-
sum(D[j, k] * (input.u[k] - u0[k]) for k in 1:nu) + y0[j]
579+
[output.u[j] ~
580+
sum(C[j, i] * x[i] for i in 1:nx) +
581+
sum(D[j, k] * (input.u[k] - u0[k]) for k in 1:nu) + y0[j]
580582
for j in 1:ny]...
581583
]
582584
compose(System(eqs, t, vcat(x...), [], name = name), [input, output])

src/Blocks/nonlinear.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Limit the range of a signal.
2121
m = (y_max + y_min) / 2
2222
siso = SISO(u_start = m, y_start = m, name = :siso) # Default signals to center of saturation to minimize risk of saturation while linearizing etc.
2323
@unpack u, y = siso
24-
pars = @parameters y_max=y_max [description = "Maximum allowed output of Limiter $name"] y_min=y_min [
25-
description = "Minimum allowed output of Limiter $name"
24+
pars = @parameters y_max=y_max [description="Maximum allowed output of Limiter $name"] y_min=y_min [
25+
description="Minimum allowed output of Limiter $name"
2626
]
2727
eqs = [
2828
y ~ _clamp(u, y_min, y_max)

src/Blocks/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ Base class for a multiple input multiple output (MIMO) continuous system block.
159159
y_start = zeros(nout))
160160
@named input = RealInput(nin = nin, guess = u_start)
161161
@named output = RealOutput(nout = nout, guess = y_start)
162-
@variables(u(t)[1:nin]=u_start, [description = "Input of MIMO system $name"],
163-
y(t)[1:nout]=y_start, [description = "Output of MIMO system $name"],)
162+
@variables(u(t)[1:nin]=u_start, [description="Input of MIMO system $name"],
163+
y(t)[1:nout]=y_start, [description="Output of MIMO system $name"],)
164164
eqs = [
165165
[u[i] ~ input.u[i] for i in 1:nin]...,
166166
[y[i] ~ output.u[i] for i in 1:nout]...

src/Electrical/Analog/mosfets.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,20 @@ Based on the MOSFET models in (Sedra, A. S., Smith, K. C., Carusone, T. C., & Ga
6868
V_GS ~ g.v - ifelse(d.v < s.v, d.v, s.v)
6969
V_OV ~ V_GS - V_tn
7070

71-
d.i ~ ifelse(d.v < s.v, -1, 1) * ifelse(V_GS < V_tn,
71+
d.i ~
72+
ifelse(d.v < s.v, -1, 1) * ifelse(V_GS < V_tn,
7273
V_DS / R_DS,
7374
ifelse(V_DS < V_OV,
74-
k_n * (1 + lambda * V_DS) * (V_OV - V_DS / 2) * V_DS + V_DS / R_DS,
75-
((k_n * V_OV^2) / 2) * (1 + lambda * V_DS) + V_DS / R_DS
76-
)
75+
k_n * (1 + lambda * V_DS) * (V_OV - V_DS / 2) * V_DS + V_DS / R_DS,
76+
((k_n * V_OV^2) / 2) * (1 + lambda * V_DS) + V_DS / R_DS
7777
)
78+
)
7879

7980
g.i ~ 0
8081
s.i ~ -d.i
8182
end
8283
end
8384

84-
85-
8685
"""
8786
PMOS(;name, V_tp, R_DS, lambda)
8887
@@ -151,16 +150,17 @@ Based on the MOSFET models in (Sedra, A. S., Smith, K. C., Carusone, T. C., & Ga
151150
V_DS ~ ifelse(d.v > s.v, s.v - d.v, d.v - s.v)
152151
V_GS ~ g.v - ifelse(d.v > s.v, d.v, s.v)
153152

154-
d.i ~ -ifelse(d.v > s.v, -1.0, 1.0) * ifelse(V_GS > V_tp,
153+
d.i ~
154+
-ifelse(d.v > s.v, -1.0, 1.0) * ifelse(V_GS > V_tp,
155155
V_DS / R_DS,
156156
ifelse(V_DS > (V_GS - V_tp),
157-
k_p * (1 + lambda * V_DS) * ((V_GS - V_tp) - V_DS / 2) * V_DS +
158-
V_DS / R_DS,
159-
((k_p * (V_GS - V_tp)^2) / 2) * (1 + lambda * V_DS) + V_DS / R_DS,
157+
k_p * (1 + lambda * V_DS) * ((V_GS - V_tp) - V_DS / 2) * V_DS +
158+
V_DS / R_DS,
159+
((k_p * (V_GS - V_tp)^2) / 2) * (1 + lambda * V_DS) + V_DS / R_DS
160160
)
161161
)
162162

163163
g.i ~ 0
164164
s.i ~ -d.i
165165
end
166-
end
166+
end

src/Electrical/Analog/transistors.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ Early voltage effect.
157157

158158
I_sub ~ ifelse(use_substrate, -C_CS * D(V_CS), -C_CS * D(V_sub))
159159

160-
c.i ~ (ICC - IEC) * ifelse(use_Early, (1 - V_BC * V_A), 1.0) - IEC / B_R -
161-
(C_jC + C_DC) * D(V_BC) - I_sub
160+
c.i ~
161+
(ICC - IEC) * ifelse(use_Early, (1 - V_BC * V_A), 1.0) - IEC / B_R -
162+
(C_jC + C_DC) * D(V_BC) - I_sub
162163
b.i ~ IEC / B_R + ICC / B_F + (C_jC + C_DC) * D(V_BC) + (C_jE + C_DE) * D(V_BE)
163164
e.i ~ -c.i - b.i - I_sub
164165
end
@@ -323,8 +324,9 @@ Early voltage effect.
323324

324325
I_sub ~ ifelse(use_substrate, -C_CS * D(V_CS), -C_CS * D(V_sub))
325326

326-
c.i ~ IEC / B_R - (ICC - IEC) * ifelse(use_Early, (1 - V_CB * V_A), 1.0) +
327-
(C_jC + C_DC) * D(V_CB) - I_sub
327+
c.i ~
328+
IEC / B_R - (ICC - IEC) * ifelse(use_Early, (1 - V_CB * V_A), 1.0) +
329+
(C_jC + C_DC) * D(V_CB) - I_sub
328330
b.i ~ -IEC / B_R - ICC / B_F - (C_jC + C_DC) * D(V_CB) - (C_jE + C_DE) * D(V_EB)
329331
e.i ~ -c.i - b.i - I_sub
330332
end

src/Mechanical/MultiBody2D/components.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@
6767
m * ddy_cm ~ m * g + fy1 + fy2
6868

6969
# torques
70-
I * ddA ~ -fy1 * (x2 - x1) / 2 + fy2 * (x2 - x1) / 2 + fx1 * (y2 - y1) / 2 -
71-
fx2 * (y2 - y1) / 2
70+
I * ddA ~
71+
-fy1 * (x2 - x1) / 2 + fy2 * (x2 - x1) / 2 + fx1 * (y2 - y1) / 2 -
72+
fx2 * (y2 - y1) / 2
7273

7374
# geometry
7475
x2 ~ l * cos(A) + x1

0 commit comments

Comments
 (0)