Skip to content

Commit 403073f

Browse files
committed
clean up tests
1 parent 9c166c8 commit 403073f

16 files changed

Lines changed: 2255 additions & 5603 deletions

Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1111
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1212
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
1313
OMJulia = "0f4fe800-344e-11e9-2949-fb537ad918e1"
14-
OrdinaryDiffEqBDF = "6ad6398a-0878-4a85-9266-38940aa047c8"
1514
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1615
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1716
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

src/BaseModelicaLibraryTesting.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import OMJulia
55
import OMJulia: sendExpression
66
import BaseModelica
77
import DifferentialEquations
8-
import OrdinaryDiffEqBDF
98
import ModelingToolkit
109
import Dates: now
1110
import Printf: @sprintf

src/pipeline.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ end
5757
5858
Run the four-phase pipeline for a single model and return its result.
5959
"""
60-
function test_model(omc::OMJulia.OMCSession, model::String, results_root::String,
60+
function test_model(omc::OMJulia.OMCSession,
61+
model::String,
62+
results_root::String,
6163
ref_root::String;
6264
sim_settings ::SimulateSettings = _SIM_SETTINGS,
6365
csv_max_size_mb::Int = CSV_MAX_SIZE_MB)::ModelResult

src/simulate.jl

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# ── Phase 3: ODE simulation with DifferentialEquations / MTK ──────────────────
22

33
import DifferentialEquations
4-
import LinearAlgebra
5-
import OrdinaryDiffEqBDF
64
import Logging
75
import ModelingToolkit
86
import Printf: @sprintf
@@ -16,7 +14,7 @@ const _SIM_SETTINGS = SimulateSettings(solver = DifferentialEquations.Rodas5Pr()
1614
Update the module-level simulation settings in-place and return them.
1715
1816
# Keyword arguments
19-
- `solver` — any SciML ODE/DAE algorithm instance (e.g. `FBDF()`, `Rodas5Pr()`).
17+
- `solver` — any SciML ODE/DAE algorithm instance (e.g. `Rodas5Pr`, `FBDF()`).
2018
- `saveat_n` — number of uniform time points for purely algebraic systems.
2119
2220
# Example
@@ -63,6 +61,7 @@ function run_simulate(ode_prob,
6361
settings ::SimulateSettings = _SIM_SETTINGS,
6462
cmp_signals ::Vector{String} = String[],
6563
csv_max_size_mb::Int = CSV_MAX_SIZE_MB)::Tuple{Bool,Float64,String,Any}
64+
6665
sim_success = false
6766
sim_time = 0.0
6867
sim_error = ""
@@ -84,31 +83,13 @@ function run_simulate(ode_prob,
8483
# internal steps and sol.t would be empty with saveat=[].
8584
# Supply explicit time points so observed variables can be evaluated.
8685
sys = ode_prob.f.sys
87-
M = ode_prob.f.mass_matrix
88-
unknowns = ModelingToolkit.unknowns(sys)
89-
n_unknowns = length(unknowns)
90-
n_diff = if M isa LinearAlgebra.UniformScaling
91-
n_unknowns
92-
else
93-
count(!iszero, LinearAlgebra.diag(M))
94-
end
86+
n_unknowns = length(ModelingToolkit.unknowns(sys))
9587

9688
kwargs = if n_unknowns == 0
97-
# No unknowns at all (e.g. BusUsage): the solver takes no
98-
# internal steps with saveat=[], leaving sol.t empty.
99-
# Use a fixed grid + adaptive=false so observed variables
100-
# can be evaluated.
101-
t0_s, t1_s = ode_prob.tspan
102-
saveat_s = collect(range(t0_s, t1_s; length = settings.saveat_n))
103-
dt_s = saveat_s[2] - saveat_s[1]
104-
(saveat = saveat_s, adaptive = false, dt = dt_s, dense = false)
105-
elseif n_diff == 0
106-
# Algebraic unknowns only (e.g. CharacteristicIdealDiodes):
107-
# the solver must take adaptive steps to track discontinuities.
108-
# Keep saveat=[] + dense=true so the solver drives its own
109-
# step selection; dense output is unreliable but the solution
110-
# values at each step are correct.
111-
(saveat = Float64[], dense = true)
89+
# No unknowns at all (e.g. BusUsage):
90+
# Supply explicit time points so observed variables can be evaluated.
91+
saveat_s = collect(range(ode_prob.tspan[1], ode_prob.tspan[end]; length = settings.saveat_n))
92+
(saveat = saveat_s, dense = true)
11293
else
11394
(saveat = Float64[], dense = true)
11495
end
@@ -119,9 +100,9 @@ function run_simulate(ode_prob,
119100
# Use our own `saveat` vector for the log: integ.opts.saveat is a
120101
# BinaryHeap which does not support iterate/minimum/maximum.
121102
integ = DifferentialEquations.init(ode_prob, solver; kwargs...)
122-
saveat = kwargs.saveat
103+
saveat_s = kwargs.saveat
123104
solver_settings_string = if hasproperty(integ, :opts)
124-
sv_str = isempty(saveat) ? "[]" : "$(length(saveat)) points in [$(first(saveat)), $(last(saveat))]"
105+
sv_str = isempty(saveat_s) ? "[]" : "$(length(saveat_s)) points in [$(first(saveat_s)), $(last(saveat_s))]"
125106
"""
126107
Solver $(parentmodule(typeof(solver))).$(nameof(typeof(solver)))
127108
saveat: $sv_str
@@ -131,14 +112,14 @@ function run_simulate(ode_prob,
131112
dense: $(integ.opts.dense)
132113
"""
133114
else
134-
sv_str = isempty(saveat) ? "[]" : "$(length(saveat)) points in [$(first(saveat)), $(last(saveat))]"
115+
sv_str = isempty(saveat_s) ? "[]" : "$(length(saveat_s)) points in [$(first(saveat_s)), $(last(saveat_s))]"
135116
"Solver (NullODEIntegrator — no unknowns)
136117
saveat: $sv_str
137118
dense: true"
138119
end
139120

140121
# Solve
141-
DifferentialEquations.solve(ode_prob, OrdinaryDiffEqBDF.FBDF(); kwargs...)
122+
DifferentialEquations.solve(ode_prob, solver; kwargs...)
142123
end
143124
sim_time = time() - t0
144125
if sol.retcode == DifferentialEquations.ReturnCode.Success

test/bus_usage.jl

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/characteristic_ideal_diodes.jl

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)