Skip to content

Commit 29d3dfb

Browse files
author
SciML Bot
committed
Apply JuliaFormatter to fix code formatting
- Applied JuliaFormatter with SciML style guide - Formatted 9 files 🤖 Generated by OrgMaintenanceScripts.jl
1 parent 1b6c1cd commit 29d3dfb

File tree

9 files changed

+58
-54
lines changed

9 files changed

+58
-54
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/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/sources.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ function ParametrizedInterpolation(
871871
name)
872872
end
873873

874-
function ParametrizedInterpolation(; interp_type, u::AbstractVector, x::AbstractVector, name)
874+
function ParametrizedInterpolation(;
875+
interp_type, u::AbstractVector, x::AbstractVector, name)
875876
ParametrizedInterpolation(interp_type, u, x; name)
876877
end

src/Electrical/Analog/mosfets.jl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,16 @@ Based on the MOSFET models in (Sedra, A. S., Smith, K. C., Carusone, T. C., & Ga
7171
d.i ~ ifelse(d.v < s.v, -1, 1) * ifelse(V_GS < V_tn,
7272
V_DS / R_DS,
7373
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-
)
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
7776
)
77+
)
7878

7979
g.i ~ 0
8080
s.i ~ -d.i
8181
end
8282
end
8383

84-
85-
8684
"""
8785
PMOS(;name, V_tp, R_DS, lambda)
8886
@@ -154,13 +152,13 @@ Based on the MOSFET models in (Sedra, A. S., Smith, K. C., Carusone, T. C., & Ga
154152
d.i ~ -ifelse(d.v > s.v, -1.0, 1.0) * ifelse(V_GS > V_tp,
155153
V_DS / R_DS,
156154
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,
155+
k_p * (1 + lambda * V_DS) * ((V_GS - V_tp) - V_DS / 2) * V_DS +
156+
V_DS / R_DS,
157+
((k_p * (V_GS - V_tp)^2) / 2) * (1 + lambda * V_DS) + V_DS / R_DS
160158
)
161159
)
162160

163161
g.i ~ 0
164162
s.i ~ -d.i
165163
end
166-
end
164+
end

test/Blocks/sources.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,6 @@ end
499499
end
500500

501501
@testset "Interpolation in model macro" begin
502-
503502
function MassSpringDamper(; name)
504503
@named input = RealInput()
505504
@variables f(t) x(t)=0 dx(t)=0 ddx(t)
@@ -527,7 +526,7 @@ end
527526
connect(src.input, clk.output)
528527
connect(src.output, model.input)
529528
end
530-
end;
529+
end
531530
@mtkcompile sys = model_with_lut()
532531

533532
prob = ODEProblem(sys, [], (0.0, 1))

test/Electrical/analog.jl

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ end
7272
connect(R2.n, voltage.n, ground.g)]
7373

7474
@named model = System(connections, t,
75-
systems = [R0, R1, R2, source, short, voltage, ground]; guesses = [R2.v => 0.0, R1.v => 0.0])
75+
systems = [R0, R1, R2, source, short, voltage, ground]; guesses = [
76+
R2.v => 0.0, R1.v => 0.0])
7677
sys = mtkcompile(model)
7778
prob = ODEProblem(sys, [], (0, 2.0))
7879
sol = solve(prob, Rodas4()) # has no state; does not work with Tsit5
@@ -541,16 +542,15 @@ end
541542
# savefig(plt, "rc_circuit_test_variable_resistor")
542543
end
543544
@testset "NMOS Transistor" begin
544-
545545
@mtkmodel SimpleNMOSCircuit begin
546546
@components begin
547547
Q1 = NMOS()
548548
Vcc = Voltage()
549549
Vb = Voltage()
550550
ground = Ground()
551551

552-
Vcc_const = Constant(k=V_cc)
553-
Vb_const = Constant(k=V_b)
552+
Vcc_const = Constant(k = V_cc)
553+
Vb_const = Constant(k = V_b)
554554
end
555555

556556
@parameters begin
@@ -589,8 +589,8 @@ end
589589
Vb = Voltage()
590590
ground = Ground()
591591

592-
Vcc_const = Constant(k=V_cc)
593-
Vb_const = Constant(k=V_b)
592+
Vcc_const = Constant(k = V_cc)
593+
Vb_const = Constant(k = V_b)
594594
end
595595

596596
@parameters begin
@@ -611,19 +611,16 @@ end
611611
end
612612
end
613613

614-
@mtkbuild flipped_sys = FlippedNMOSCircuit(V_cc=5.0, V_b=3.5)
614+
@mtkbuild flipped_sys = FlippedNMOSCircuit(V_cc = 5.0, V_b = 3.5)
615615

616616
flipped_prob = ODEProblem(flipped_sys, Pair[], (0.0, 10.0))
617617
flipped_sol = solve(flipped_prob)
618618
@test flipped_sol[flipped_sys.Q1.d.i][1] < 0
619-
@test flipped_sol[flipped_sys.Q1.s.i][1] > 0
619+
@test flipped_sol[flipped_sys.Q1.s.i][1] > 0
620620
@test flipped_sol[flipped_sys.Q1.s.v] > flipped_sol[flipped_sys.Q1.d.v]
621-
622621
end
623622

624-
625623
@testset "PMOS Transistor" begin
626-
627624
@mtkmodel SimplePMOSCircuit begin
628625
@components begin
629626
Q1 = PMOS()
@@ -632,9 +629,9 @@ end
632629
Vd = Voltage()
633630
ground = Ground()
634631

635-
Vs_const = Constant(k=V_s)
636-
Vb_const = Constant(k=V_b)
637-
Vd_const = Constant(k=V_d)
632+
Vs_const = Constant(k = V_s)
633+
Vb_const = Constant(k = V_b)
634+
Vd_const = Constant(k = V_d)
638635
end
639636

640637
@parameters begin
@@ -646,7 +643,7 @@ end
646643
#voltage sources
647644
connect(Vs_const.output, Vs.V)
648645
connect(Vb_const.output, Vb.V)
649-
connect(Vd_const.output, Vd.V )
646+
connect(Vd_const.output, Vd.V)
650647

651648
#ground connections
652649
connect(Vs.n, Vb.n, ground.g, Vd.n)
@@ -658,7 +655,7 @@ end
658655
end
659656
end
660657

661-
@mtkbuild sys = SimplePMOSCircuit(V_s=5.0, V_b=2.5, V_d = 3)
658+
@mtkbuild sys = SimplePMOSCircuit(V_s = 5.0, V_b = 2.5, V_d = 3)
662659

663660
prob = ODEProblem(sys, Pair[], (0.0, 10.0))
664661
sol = solve(prob)
@@ -675,9 +672,9 @@ end
675672
Vd = Voltage()
676673
ground = Ground()
677674

678-
Vs_const = Constant(k=V_s)
679-
Vb_const = Constant(k=V_b)
680-
Vd_const = Constant(k=V_d)
675+
Vs_const = Constant(k = V_s)
676+
Vb_const = Constant(k = V_b)
677+
Vd_const = Constant(k = V_d)
681678
end
682679

683680
@parameters begin
@@ -689,7 +686,7 @@ end
689686
#voltage sources
690687
connect(Vs_const.output, Vs.V)
691688
connect(Vb_const.output, Vb.V)
692-
connect(Vd_const.output, Vd.V )
689+
connect(Vd_const.output, Vd.V)
693690

694691
#ground connections
695692
connect(Vs.n, Vb.n, ground.g, Vd.n)
@@ -701,15 +698,13 @@ end
701698
end
702699
end
703700

704-
@mtkbuild flipped_sys = FlippedPMOSCircuit(V_s=5.0, V_b=2.5, V_d = 3)
701+
@mtkbuild flipped_sys = FlippedPMOSCircuit(V_s = 5.0, V_b = 2.5, V_d = 3)
705702

706703
flipped_prob = ODEProblem(flipped_sys, Pair[], (0.0, 10.0))
707704
flipped_sol = solve(flipped_prob)
708705

709706
@test flipped_sol[flipped_sys.Q1.d.i][1] > 0.0
710707
@test flipped_sol[flipped_sys.Q1.s.i][1] < 0.0
711-
712-
713708
end
714709

715710
@testset "NPN Tests" begin
@@ -867,7 +862,8 @@ end
867862

868863
@mtkcompile sys = SimplePNPCircuitSubstrate(V_b = 0.70)
869864

870-
prob = ODEProblem(sys, [sys.Q1.c.i => 0.0], (0.0, 10.0); guesses = [sys.Q1.I_sub => 1.0])
865+
prob = ODEProblem(
866+
sys, [sys.Q1.c.i => 0.0], (0.0, 10.0); guesses = [sys.Q1.I_sub => 1.0])
871867
sol = solve(prob)
872868

873869
@test isapprox(

test/Hydraulic/isothermal_compressible.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ end
9898
end
9999

100100
@testset "DynamicVolume and minimum_volume feature" begin # Need help here
101-
function TestSystem(; name, area = 0.01, length = 0.1, damping_volume = length * area * 0.1)
101+
function TestSystem(;
102+
name, area = 0.01, length = 0.1, damping_volume = length * area * 0.1)
102103
pars = []
103104

104105
# DynamicVolume values

test/Mechanical/rotational.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ end
8989

9090
@mtkcompile sys = TwoInertiasWithDrivingTorque()
9191
deqs = [eq.lhs => eq.rhs for eq in equations(sys)]
92-
prob = DAEProblem(sys, [deqs;
93-
D(D(sys.inertia2.phi)) => 1.0; sys.spring.flange_b.phi => 0.0], (0, 10.0))
92+
prob = DAEProblem(
93+
sys, [deqs;
94+
D(D(sys.inertia2.phi)) => 1.0; sys.spring.flange_b.phi => 0.0],
95+
(0, 10.0))
9496
sol = solve(prob, DFBDF())
9597
@test SciMLBase.successful_retcode(sol)
9698

@@ -216,8 +218,10 @@ end
216218
end
217219

218220
@mtkcompile sys = StickSlip()
219-
prob = DAEProblem(sys, [D.(unknowns(sys)) .=> 0.0;
220-
[sys.inertia.flange_b.tau => 0.0; unknowns(sys) .=> 0.0...]], (0, 10.0))
221+
prob = DAEProblem(sys,
222+
[D.(unknowns(sys)) .=> 0.0;
223+
[sys.inertia.flange_b.tau => 0.0; unknowns(sys) .=> 0.0...]],
224+
(0, 10.0))
221225

222226
sol = solve(prob, DFBDF())
223227
@test SciMLBase.successful_retcode(sol)

0 commit comments

Comments
 (0)