From 08b1f850f570e617bc0c0a179f9354593911d452 Mon Sep 17 00:00:00 2001 From: SciML Bot Date: Thu, 31 Jul 2025 16:38:28 -0400 Subject: [PATCH] Apply JuliaFormatter to fix code formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Applied JuliaFormatter with SciML style guide - Formatted 17 files 🤖 Generated by OrgMaintenanceScripts.jl --- docs/src/connectors/connections.md | 4 +-- docs/src/tutorials/MOSFET_calibration.md | 23 +++++++----- docs/src/tutorials/dc_motor_pi.md | 9 +++-- docs/src/tutorials/input_component.md | 4 +-- src/Blocks/continuous.jl | 10 +++--- src/Blocks/nonlinear.jl | 4 +-- src/Blocks/utils.jl | 4 +-- src/Electrical/Analog/mosfets.jl | 22 ++++++------ src/Electrical/Analog/transistors.jl | 10 +++--- src/Mechanical/MultiBody2D/components.jl | 5 +-- src/Mechanical/Rotational/components.jl | 8 +++-- src/Mechanical/Rotational/sources.jl | 3 +- test/Blocks/sources.jl | 1 - test/Blocks/test_analysis_points.jl | 12 ++++--- test/Electrical/analog.jl | 43 ++++++++++------------- test/Hydraulic/isothermal_compressible.jl | 3 +- test/Mechanical/rotational.jl | 11 +++--- 17 files changed, 97 insertions(+), 79 deletions(-) diff --git a/docs/src/connectors/connections.md b/docs/src/connectors/connections.md index a5150b987..be93f9302 100644 --- a/docs/src/connectors/connections.md +++ b/docs/src/connectors/connections.md @@ -191,7 +191,7 @@ nothing # hide 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. ```@example connections -prob = ODEProblem(sys, [], (0, 10.0), fully_determined=true) +prob = ODEProblem(sys, [], (0, 10.0), fully_determined = true) sol_p = solve(prob) p1 = plot(sol_p, idxs = [body.v]) @@ -281,7 +281,7 @@ function simplify_and_solve(damping, spring, body, ground; initialization_eqs = println.(full_equations(sys)) - prob = ODEProblem(sys, [], (0, 10.0); initialization_eqs, fully_determined=true) + prob = ODEProblem(sys, [], (0, 10.0); initialization_eqs, fully_determined = true) sol = solve(prob; abstol = 1e-9, reltol = 1e-9) return sol diff --git a/docs/src/tutorials/MOSFET_calibration.md b/docs/src/tutorials/MOSFET_calibration.md index ee7cab059..e4e5b4eb6 100644 --- a/docs/src/tutorials/MOSFET_calibration.md +++ b/docs/src/tutorials/MOSFET_calibration.md @@ -1,5 +1,6 @@ -# MOSFET I-V Curves -In this example, first we'll demonstrate the I-V curves of the NMOS transistor model. +# MOSFET I-V Curves + +In this example, first we'll demonstrate the I-V curves of the NMOS transistor model. 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. ```@example NMOS @@ -12,6 +13,7 @@ using Plots ``` 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`. + ```@example NMOS @mtkmodel SimpleNMOSCircuit begin @components begin @@ -20,8 +22,8 @@ Here we just connect the source pin to ground, the drain pin to a voltage source Vb = Voltage() ground = Ground() - Vcc_const = Constant(k=V_cc) - Vb_const = Constant(k=V_b) + Vcc_const = Constant(k = V_cc) + Vb_const = Constant(k = V_b) end @parameters begin @@ -48,7 +50,8 @@ prob = ODEProblem(sys, Pair[], (0.0, 10.0)) sol = solve(prob) ``` -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. +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. + ```@example NMOS v_cc_list = collect(0.05:0.1:10.0) @@ -58,7 +61,7 @@ I_D_lists = [] for V_b in [1.0, 1.4, 1.8, 2.2, 2.6] I_D_list = [] for V_cc in v_cc_list - @mtkbuild sys = SimpleNMOSCircuit(V_cc=V_cc, V_b=V_b) + @mtkbuild sys = SimpleNMOSCircuit(V_cc = V_cc, V_b = V_b) prob = ODEProblem(sys, Pair[], (0.0, 10.0)) sol = solve(prob) 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] end reduce(hcat, I_D_lists) -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)") +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)") ``` -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. -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. \ No newline at end of file +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. +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. diff --git a/docs/src/tutorials/dc_motor_pi.md b/docs/src/tutorials/dc_motor_pi.md index 573462e5a..e21908167 100644 --- a/docs/src/tutorials/dc_motor_pi.md +++ b/docs/src/tutorials/dc_motor_pi.md @@ -107,10 +107,12 @@ T(s) &= \dfrac{P(s)C(s)}{I + P(s)C(s)} ```@example dc_motor_pi using ControlSystemsBase -matrices_S, simplified_sys = Blocks.get_sensitivity( +matrices_S, +simplified_sys = Blocks.get_sensitivity( model, :y, op = Dict(unknowns(sys) .=> 0.0)) So = ss(matrices_S...) |> minreal # The output-sensitivity function as a StateSpace system -matrices_T, simplified_sys = Blocks.get_comp_sensitivity( +matrices_T, +simplified_sys = Blocks.get_comp_sensitivity( model, :y, op = Dict(unknowns(sys) .=> 0.0)) To = ss(matrices_T...)# The output complementary sensitivity function as a StateSpace system bodeplot([So, To], label = ["S" "T"], plot_title = "Sensitivity functions", @@ -120,7 +122,8 @@ bodeplot([So, To], label = ["S" "T"], plot_title = "Sensitivity functions", Similarly, we may compute the loop-transfer function and plot its Nyquist curve ```@example dc_motor_pi -matrices_L, simplified_sys = Blocks.get_looptransfer( +matrices_L, +simplified_sys = Blocks.get_looptransfer( model, :y, op = Dict(unknowns(sys) .=> 0.0)) L = -ss(matrices_L...) # The loop-transfer function as a StateSpace system. The negative sign is to negate the built-in negative feedback Ms, ωMs = hinfnorm(So) # Compute the peak of the sensitivity function to draw a circle in the Nyquist plot diff --git a/docs/src/tutorials/input_component.md b/docs/src/tutorials/input_component.md index 55daf2b2c..dbab21ff4 100644 --- a/docs/src/tutorials/input_component.md +++ b/docs/src/tutorials/input_component.md @@ -84,7 +84,7 @@ my_interpolation = LinearInterpolation(df.data, df.time) @mtkmodel MassSpringDamperSystem2 begin @components begin - src = Interpolation(itp=my_interpolation) + src = Interpolation(itp = my_interpolation) clk = ContinuousClock() model = MassSpringDamper() end @@ -174,7 +174,7 @@ plot(sol2) ``` !!! note - + Note that when changing the data, the length of the new data must be the same as the length of the original data. ## Custom Component with External Data diff --git a/src/Blocks/continuous.jl b/src/Blocks/continuous.jl index a12fb8068..9f40b7de1 100644 --- a/src/Blocks/continuous.jl +++ b/src/Blocks/continuous.jl @@ -572,11 +572,13 @@ linearized around the operating point `x₀, u₀`, we have `y0, u0 = h(x₀, u ] # pars = @parameters A=A B=B C=C D=D # This is buggy eqs = [ # FIXME: if array equations work - [Differential(t)(x[i]) ~ sum(A[i, k] * x[k] for k in 1:nx) + - sum(B[i, j] * (input.u[j] - u0[j]) for j in 1:nu) + [Differential(t)(x[i]) ~ + sum(A[i, k] * x[k] for k in 1:nx) + + sum(B[i, j] * (input.u[j] - u0[j]) for j in 1:nu) for i in 1:nx]..., # cannot use D here - [output.u[j] ~ sum(C[j, i] * x[i] for i in 1:nx) + - sum(D[j, k] * (input.u[k] - u0[k]) for k in 1:nu) + y0[j] + [output.u[j] ~ + sum(C[j, i] * x[i] for i in 1:nx) + + sum(D[j, k] * (input.u[k] - u0[k]) for k in 1:nu) + y0[j] for j in 1:ny]... ] compose(System(eqs, t, vcat(x...), [], name = name), [input, output]) diff --git a/src/Blocks/nonlinear.jl b/src/Blocks/nonlinear.jl index 46c4504ae..b8350669d 100644 --- a/src/Blocks/nonlinear.jl +++ b/src/Blocks/nonlinear.jl @@ -21,8 +21,8 @@ Limit the range of a signal. m = (y_max + y_min) / 2 siso = SISO(u_start = m, y_start = m, name = :siso) # Default signals to center of saturation to minimize risk of saturation while linearizing etc. @unpack u, y = siso - pars = @parameters y_max=y_max [description = "Maximum allowed output of Limiter $name"] y_min=y_min [ - description = "Minimum allowed output of Limiter $name" + pars = @parameters y_max=y_max [description="Maximum allowed output of Limiter $name"] y_min=y_min [ + description="Minimum allowed output of Limiter $name" ] eqs = [ y ~ _clamp(u, y_min, y_max) diff --git a/src/Blocks/utils.jl b/src/Blocks/utils.jl index c5bf71e0e..61cbb484e 100644 --- a/src/Blocks/utils.jl +++ b/src/Blocks/utils.jl @@ -159,8 +159,8 @@ Base class for a multiple input multiple output (MIMO) continuous system block. y_start = zeros(nout)) @named input = RealInput(nin = nin, guess = u_start) @named output = RealOutput(nout = nout, guess = y_start) - @variables(u(t)[1:nin]=u_start, [description = "Input of MIMO system $name"], - y(t)[1:nout]=y_start, [description = "Output of MIMO system $name"],) + @variables(u(t)[1:nin]=u_start, [description="Input of MIMO system $name"], + y(t)[1:nout]=y_start, [description="Output of MIMO system $name"],) eqs = [ [u[i] ~ input.u[i] for i in 1:nin]..., [y[i] ~ output.u[i] for i in 1:nout]... diff --git a/src/Electrical/Analog/mosfets.jl b/src/Electrical/Analog/mosfets.jl index 42b1adcca..1b12a6afe 100644 --- a/src/Electrical/Analog/mosfets.jl +++ b/src/Electrical/Analog/mosfets.jl @@ -68,21 +68,20 @@ Based on the MOSFET models in (Sedra, A. S., Smith, K. C., Carusone, T. C., & Ga V_GS ~ g.v - ifelse(d.v < s.v, d.v, s.v) V_OV ~ V_GS - V_tn - d.i ~ ifelse(d.v < s.v, -1, 1) * ifelse(V_GS < V_tn, + d.i ~ + ifelse(d.v < s.v, -1, 1) * ifelse(V_GS < V_tn, V_DS / R_DS, ifelse(V_DS < V_OV, - k_n * (1 + lambda * V_DS) * (V_OV - V_DS / 2) * V_DS + V_DS / R_DS, - ((k_n * V_OV^2) / 2) * (1 + lambda * V_DS) + V_DS / R_DS - ) + k_n * (1 + lambda * V_DS) * (V_OV - V_DS / 2) * V_DS + V_DS / R_DS, + ((k_n * V_OV^2) / 2) * (1 + lambda * V_DS) + V_DS / R_DS ) + ) g.i ~ 0 s.i ~ -d.i end end - - """ PMOS(;name, V_tp, R_DS, lambda) @@ -151,16 +150,17 @@ Based on the MOSFET models in (Sedra, A. S., Smith, K. C., Carusone, T. C., & Ga V_DS ~ ifelse(d.v > s.v, s.v - d.v, d.v - s.v) V_GS ~ g.v - ifelse(d.v > s.v, d.v, s.v) - d.i ~ -ifelse(d.v > s.v, -1.0, 1.0) * ifelse(V_GS > V_tp, + d.i ~ + -ifelse(d.v > s.v, -1.0, 1.0) * ifelse(V_GS > V_tp, V_DS / R_DS, ifelse(V_DS > (V_GS - V_tp), - k_p * (1 + lambda * V_DS) * ((V_GS - V_tp) - V_DS / 2) * V_DS + - V_DS / R_DS, - ((k_p * (V_GS - V_tp)^2) / 2) * (1 + lambda * V_DS) + V_DS / R_DS, + k_p * (1 + lambda * V_DS) * ((V_GS - V_tp) - V_DS / 2) * V_DS + + V_DS / R_DS, + ((k_p * (V_GS - V_tp)^2) / 2) * (1 + lambda * V_DS) + V_DS / R_DS ) ) g.i ~ 0 s.i ~ -d.i end -end \ No newline at end of file +end diff --git a/src/Electrical/Analog/transistors.jl b/src/Electrical/Analog/transistors.jl index ec1ccf483..3dad46c45 100644 --- a/src/Electrical/Analog/transistors.jl +++ b/src/Electrical/Analog/transistors.jl @@ -157,8 +157,9 @@ Early voltage effect. I_sub ~ ifelse(use_substrate, -C_CS * D(V_CS), -C_CS * D(V_sub)) - c.i ~ (ICC - IEC) * ifelse(use_Early, (1 - V_BC * V_A), 1.0) - IEC / B_R - - (C_jC + C_DC) * D(V_BC) - I_sub + c.i ~ + (ICC - IEC) * ifelse(use_Early, (1 - V_BC * V_A), 1.0) - IEC / B_R - + (C_jC + C_DC) * D(V_BC) - I_sub b.i ~ IEC / B_R + ICC / B_F + (C_jC + C_DC) * D(V_BC) + (C_jE + C_DE) * D(V_BE) e.i ~ -c.i - b.i - I_sub end @@ -323,8 +324,9 @@ Early voltage effect. I_sub ~ ifelse(use_substrate, -C_CS * D(V_CS), -C_CS * D(V_sub)) - c.i ~ IEC / B_R - (ICC - IEC) * ifelse(use_Early, (1 - V_CB * V_A), 1.0) + - (C_jC + C_DC) * D(V_CB) - I_sub + c.i ~ + IEC / B_R - (ICC - IEC) * ifelse(use_Early, (1 - V_CB * V_A), 1.0) + + (C_jC + C_DC) * D(V_CB) - I_sub b.i ~ -IEC / B_R - ICC / B_F - (C_jC + C_DC) * D(V_CB) - (C_jE + C_DE) * D(V_EB) e.i ~ -c.i - b.i - I_sub end diff --git a/src/Mechanical/MultiBody2D/components.jl b/src/Mechanical/MultiBody2D/components.jl index 9fd0ca79a..2e45de98f 100644 --- a/src/Mechanical/MultiBody2D/components.jl +++ b/src/Mechanical/MultiBody2D/components.jl @@ -67,8 +67,9 @@ m * ddy_cm ~ m * g + fy1 + fy2 # torques - I * ddA ~ -fy1 * (x2 - x1) / 2 + fy2 * (x2 - x1) / 2 + fx1 * (y2 - y1) / 2 - - fx2 * (y2 - y1) / 2 + I * ddA ~ + -fy1 * (x2 - x1) / 2 + fy2 * (x2 - x1) / 2 + fx1 * (y2 - y1) / 2 - + fx2 * (y2 - y1) / 2 # geometry x2 ~ l * cos(A) + x1 diff --git a/src/Mechanical/Rotational/components.jl b/src/Mechanical/Rotational/components.jl index 9d511bdfc..f734c1862 100644 --- a/src/Mechanical/Rotational/components.jl +++ b/src/Mechanical/Rotational/components.jl @@ -200,7 +200,8 @@ This element characterizes any type of gear box which is fixed in the ground and - `use_support`: If support flange enabled, otherwise implicitly grounded. By default it is `false` """ @mtkmodel IdealGear begin - @extend phi_support, flange_a, flange_b = partial_element = PartialElementaryTwoFlangesAndSupport2(; + @extend phi_support, flange_a, + flange_b = partial_element = PartialElementaryTwoFlangesAndSupport2(; use_support = false) @parameters begin ratio, [description = "Transmission ratio"] @@ -261,7 +262,8 @@ Friction model: "Armstrong, B. and C.C. de Wit, Friction Modeling and Compensati w_coul = w_brk / 10 end @equations begin - tau ~ str_scale * (exp(-(w_rel / w_st)^2) * w_rel / w_st) + - tau_c * tanh(w_rel / w_coul) + f * w_rel # Stribeck friction + Coulomb friction + Viscous friction + tau ~ + str_scale * (exp(-(w_rel / w_st)^2) * w_rel / w_st) + + tau_c * tanh(w_rel / w_coul) + f * w_rel # Stribeck friction + Coulomb friction + Viscous friction end end diff --git a/src/Mechanical/Rotational/sources.jl b/src/Mechanical/Rotational/sources.jl index f3a4496c1..a93496292 100644 --- a/src/Mechanical/Rotational/sources.jl +++ b/src/Mechanical/Rotational/sources.jl @@ -1,5 +1,6 @@ @mtkmodel PartialTorque begin - @extend flange, phi_support = partial_element = PartialElementaryOneFlangeAndSupport2(; + @extend flange, + phi_support = partial_element = PartialElementaryOneFlangeAndSupport2(; use_support = false) @variables begin phi(t), diff --git a/test/Blocks/sources.jl b/test/Blocks/sources.jl index 691442725..752ad08ab 100644 --- a/test/Blocks/sources.jl +++ b/test/Blocks/sources.jl @@ -499,7 +499,6 @@ end end @testset "Interpolation in model macro" begin - function MassSpringDamper(; name) @named input = RealInput() @variables f(t) x(t)=0 dx(t)=0 ddx(t) diff --git a/test/Blocks/test_analysis_points.jl b/test/Blocks/test_analysis_points.jl index 61b176ab5..7244c7e4b 100644 --- a/test/Blocks/test_analysis_points.jl +++ b/test/Blocks/test_analysis_points.jl @@ -333,7 +333,8 @@ eqs = [connect(r.output, F.input) connect(F.output, sys_inner.add.input1)] sys_outer = System(eqs, t, systems = [F, sys_inner, r], name = :outer) -matrices, _ = get_sensitivity( +matrices, +_ = get_sensitivity( sys_outer, [sys_outer.inner.plant_input, sys_outer.inner.plant_output]) Ps = tf(1, [1, 1]) |> ss @@ -348,7 +349,8 @@ So = CS.feedback(1, Ps * Cs) @test tf(G[1, 2]) ≈ tf(-CS.feedback(Cs, Ps)) @test tf(G[2, 1]) ≈ tf(CS.feedback(Ps, Cs)) -matrices, _ = get_comp_sensitivity( +matrices, +_ = get_comp_sensitivity( sys_outer, [sys_outer.inner.plant_input, sys_outer.inner.plant_output]) G = CS.ss(matrices...) |> sminreal @@ -372,7 +374,8 @@ L = CS.ss(matrices...) |> sminreal @test tf(L[1, 1]) ≈ -tf(Ps * Cs) # Calling looptransfer like below is not the intended way, but we can work out what it should return if we did so it remains a valid test -matrices, _ = get_looptransfer( +matrices, +_ = get_looptransfer( sys_outer, [sys_outer.inner.plant_input, sys_outer.inner.plant_output]) L = CS.ss(matrices...) |> sminreal @test tf(L[1, 1]) ≈ tf(0) @@ -380,7 +383,8 @@ L = CS.ss(matrices...) |> sminreal @test sminreal(L[1, 2]) ≈ ss(-1) @test tf(L[2, 1]) ≈ tf(Ps) -matrices, _ = linearize( +matrices, +_ = linearize( sys_outer, [sys_outer.inner.plant_input], [sys_outer.inner.plant_output]) G = CS.ss(matrices...) |> sminreal @test tf(G) ≈ tf(CS.feedback(Ps, Cs)) diff --git a/test/Electrical/analog.jl b/test/Electrical/analog.jl index db0c639f1..cac7a1dd7 100644 --- a/test/Electrical/analog.jl +++ b/test/Electrical/analog.jl @@ -72,7 +72,8 @@ end connect(R2.n, voltage.n, ground.g)] @named model = System(connections, t, - systems = [R0, R1, R2, source, short, voltage, ground]; guesses = [R2.v => 0.0, R1.v => 0.0]) + systems = [R0, R1, R2, source, short, voltage, ground]; guesses = [ + R2.v => 0.0, R1.v => 0.0]) sys = mtkcompile(model) prob = ODEProblem(sys, [], (0, 2.0)) sol = solve(prob, Rodas4()) # has no state; does not work with Tsit5 @@ -413,7 +414,7 @@ end # Tests @test all(diode_current .>= -1e-3) - @test capacitor_voltage[end].≈8.26 rtol=3e-1 + @test capacitor_voltage[end] .≈ 8.26 rtol=3e-1 # For visual inspection # plt = plot(sol; idxs = [diode.i, resistor.i, capacitor.v], @@ -541,7 +542,6 @@ end # savefig(plt, "rc_circuit_test_variable_resistor") end @testset "NMOS Transistor" begin - @mtkmodel SimpleNMOSCircuit begin @components begin Q1 = NMOS() @@ -549,8 +549,8 @@ end Vb = Voltage() ground = Ground() - Vcc_const = Constant(k=V_cc) - Vb_const = Constant(k=V_b) + Vcc_const = Constant(k = V_cc) + Vb_const = Constant(k = V_b) end @parameters begin @@ -589,8 +589,8 @@ end Vb = Voltage() ground = Ground() - Vcc_const = Constant(k=V_cc) - Vb_const = Constant(k=V_b) + Vcc_const = Constant(k = V_cc) + Vb_const = Constant(k = V_b) end @parameters begin @@ -611,19 +611,16 @@ end end end - @mtkbuild flipped_sys = FlippedNMOSCircuit(V_cc=5.0, V_b=3.5) + @mtkbuild flipped_sys = FlippedNMOSCircuit(V_cc = 5.0, V_b = 3.5) flipped_prob = ODEProblem(flipped_sys, Pair[], (0.0, 10.0)) flipped_sol = solve(flipped_prob) @test flipped_sol[flipped_sys.Q1.d.i][1] < 0 - @test flipped_sol[flipped_sys.Q1.s.i][1] > 0 + @test flipped_sol[flipped_sys.Q1.s.i][1] > 0 @test flipped_sol[flipped_sys.Q1.s.v] > flipped_sol[flipped_sys.Q1.d.v] - end - @testset "PMOS Transistor" begin - @mtkmodel SimplePMOSCircuit begin @components begin Q1 = PMOS() @@ -632,9 +629,9 @@ end Vd = Voltage() ground = Ground() - Vs_const = Constant(k=V_s) - Vb_const = Constant(k=V_b) - Vd_const = Constant(k=V_d) + Vs_const = Constant(k = V_s) + Vb_const = Constant(k = V_b) + Vd_const = Constant(k = V_d) end @parameters begin @@ -646,7 +643,7 @@ end #voltage sources connect(Vs_const.output, Vs.V) connect(Vb_const.output, Vb.V) - connect(Vd_const.output, Vd.V ) + connect(Vd_const.output, Vd.V) #ground connections connect(Vs.n, Vb.n, ground.g, Vd.n) @@ -658,7 +655,7 @@ end end end - @mtkbuild sys = SimplePMOSCircuit(V_s=5.0, V_b=2.5, V_d = 3) + @mtkbuild sys = SimplePMOSCircuit(V_s = 5.0, V_b = 2.5, V_d = 3) prob = ODEProblem(sys, Pair[], (0.0, 10.0)) sol = solve(prob) @@ -675,9 +672,9 @@ end Vd = Voltage() ground = Ground() - Vs_const = Constant(k=V_s) - Vb_const = Constant(k=V_b) - Vd_const = Constant(k=V_d) + Vs_const = Constant(k = V_s) + Vb_const = Constant(k = V_b) + Vd_const = Constant(k = V_d) end @parameters begin @@ -689,7 +686,7 @@ end #voltage sources connect(Vs_const.output, Vs.V) connect(Vb_const.output, Vb.V) - connect(Vd_const.output, Vd.V ) + connect(Vd_const.output, Vd.V) #ground connections connect(Vs.n, Vb.n, ground.g, Vd.n) @@ -701,15 +698,13 @@ end end end - @mtkbuild flipped_sys = FlippedPMOSCircuit(V_s=5.0, V_b=2.5, V_d = 3) + @mtkbuild flipped_sys = FlippedPMOSCircuit(V_s = 5.0, V_b = 2.5, V_d = 3) flipped_prob = ODEProblem(flipped_sys, Pair[], (0.0, 10.0)) flipped_sol = solve(flipped_prob) @test flipped_sol[flipped_sys.Q1.d.i][1] > 0.0 @test flipped_sol[flipped_sys.Q1.s.i][1] < 0.0 - - end @testset "NPN Tests" begin diff --git a/test/Hydraulic/isothermal_compressible.jl b/test/Hydraulic/isothermal_compressible.jl index 4525c3a6e..407438a8b 100644 --- a/test/Hydraulic/isothermal_compressible.jl +++ b/test/Hydraulic/isothermal_compressible.jl @@ -98,7 +98,8 @@ end end @testset "DynamicVolume and minimum_volume feature" begin # Need help here - function TestSystem(; name, area = 0.01, length = 0.1, damping_volume = length * area * 0.1) + function TestSystem(; name, area = 0.01, length = 0.1, damping_volume = length * area * + 0.1) pars = [] # DynamicVolume values diff --git a/test/Mechanical/rotational.jl b/test/Mechanical/rotational.jl index 7f1c34936..b295e2bf1 100644 --- a/test/Mechanical/rotational.jl +++ b/test/Mechanical/rotational.jl @@ -89,8 +89,9 @@ end @mtkcompile sys = TwoInertiasWithDrivingTorque() deqs = [eq.lhs => eq.rhs for eq in equations(sys)] - prob = DAEProblem(sys, [deqs; - D(D(sys.inertia2.phi)) => 1.0; sys.spring.flange_b.phi => 0.0], (0, 10.0)) + prob = DAEProblem( + sys, [deqs; + D(D(sys.inertia2.phi)) => 1.0; sys.spring.flange_b.phi => 0.0], (0, 10.0)) sol = solve(prob, DFBDF()) @test SciMLBase.successful_retcode(sol) @@ -216,8 +217,10 @@ end end @mtkcompile sys = StickSlip() - prob = DAEProblem(sys, [D.(unknowns(sys)) .=> 0.0; - [sys.inertia.flange_b.tau => 0.0; unknowns(sys) .=> 0.0...]], (0, 10.0)) + prob = DAEProblem(sys, + [D.(unknowns(sys)) .=> 0.0; + [sys.inertia.flange_b.tau => 0.0; unknowns(sys) .=> 0.0...]], + (0, 10.0)) sol = solve(prob, DFBDF()) @test SciMLBase.successful_retcode(sol)