Skip to content

Commit

Permalink
Unit test for solution type
Browse files Browse the repository at this point in the history
Adding unit tests to verify that the solution type is a number
  • Loading branch information
hskkanth committed Oct 16, 2024
1 parent 4259e62 commit 0c3e690
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/core/transient_expression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,4 @@ function expression_compressor_power(gm::AbstractGasModel, nw::Int; report::Bool
W = 286.76 * gm.ref[:it][gm_it_sym][:temperature] / gm.ref[:it][gm_it_sym][:gas_specific_gravity] / m
var(gm, nw, :compressor_power_expr)[i] = JuMP.@expression(gm.model, W * abs(f) * (alpha^m - 1.0))
end

end
10 changes: 10 additions & 0 deletions test/transient.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,14 @@ end
@test isapprox(result["solution"]["nw"]["2"]["receipt"]["1"]["injection"], 0.0, atol = 1)
@test isapprox(result["solution"]["nw"]["1"]["storage"]["1"]["storage_flow"], 83, atol = 1)
@test isapprox(result["solution"]["nw"]["2"]["storage"]["1"]["storage_flow"], 83, atol = 1)
@test isa(result["solution"]["nw"]["2"]["storage"]["1"]["well_density_derivative"]["1"],Number)
end

@testset "transient solution type check" begin
mn_data = parse_files("../test/data/matgas/case-6-storage.m", "../test/data/transient/time-series-case-6b.csv", spatial_discretization = 1e4, additional_time = 7200.0)
result = run_transient_ogf(mn_data, WPGasModel, nlp_solver)
@test isa(result["solution"]["nw"]["2"]["junction"]["1"]["net_nodal_edge_out_flow"],Number)
@test isa(result["solution"]["nw"]["2"]["junction"]["1"]["net_injection"],Number)
@test isa(result["solution"]["nw"]["2"]["storage"]["1"]["reservoir_density_derivative"],Number)
@test isa(result["solution"]["nw"]["2"]["compressor"]["1"]["power_var"],Number)
end

0 comments on commit 0c3e690

Please sign in to comment.