Skip to content

test: make test robust to numerical issues #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Electrical/Analog/transistors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ Early voltage effect.
end
end


"""
PNP(;name, B_F, B_R, Is, V_T, V_A, phi_C, phi_E, Z_C, Z_E, Tau_f, Tau_r, C_jC0, C_jE0, C_CS, gamma_C, gamma_E, NF, NR)

Expand Down Expand Up @@ -329,4 +328,4 @@ Early voltage effect.
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
end
end
13 changes: 6 additions & 7 deletions src/Hydraulic/IsothermalCompressible/components.jl
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ end
vol(t)
end

# let
# let
dm = port.dm
p = port.p

Expand Down Expand Up @@ -454,7 +454,6 @@ See also [`FixedVolume`](@ref), [`DynamicVolume`](@ref)
direction = +1,
x_int,
name)

pars = @parameters begin
area = area
x_int = x_int
Expand Down Expand Up @@ -489,11 +488,11 @@ See also [`FixedVolume`](@ref), [`DynamicVolume`](@ref)
end

eqs = [
# connectors
port.p ~ p
port.dm ~ dm
flange.v * direction ~ dx
flange.f * direction ~ -f
# connectors
port.p ~ p
port.dm ~ dm
flange.v * direction ~ dx
flange.f * direction ~ -f
# differentials
D(x) ~ dx
D(m) ~ dm
Expand Down
6 changes: 1 addition & 5 deletions test/Electrical/analog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,7 @@ end
# savefig(plt, "rc_circuit_test_variable_resistor")
end


@testset "NPN Tests" begin

@mtkmodel SimpleNPNCircuit begin
@components begin
Q1 = NPN()
Expand Down Expand Up @@ -624,10 +622,8 @@ end
sol[sys.Q1.c.i][15] +
sol[sys.Q1.s.i][15],
0.0, atol = 1e-16)

end


@testset "PNP Tests" begin
@mtkmodel SimplePNPCircuit begin
@components begin
Expand Down Expand Up @@ -710,4 +706,4 @@ end
sol[sys.Q1.s.i][15],
0.0,
atol = 1e-16)
end
end
6 changes: 2 additions & 4 deletions test/Thermal/piston.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ using ModelingToolkitStandardLibrary.Blocks
@test SciMLBase.successful_retcode(sol)
# The initial value doesn't add up to absolute zero, while the rest do. To avoid
# tolerance on the latter, the test is split in two parts.
@test sol[piston.gas.Q_flow][1] + sol[piston.coolant.Q_flow][1]≈0 atol=1e-6
@test sol[piston.gas.Q_flow][2:end] +
sol[piston.coolant.Q_flow][2:end]≈
zeros(length(sol) - 1) atol=1e-6
@test sol[piston.gas.Q_flow][1]≈-sol[piston.coolant.Q_flow][1] rtol=1e-6
@test sol[piston.gas.Q_flow][2:end]≈-sol[piston.coolant.Q_flow][2:end] rtol=1e-6
end
Loading