Skip to content
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

Writing result fails when using emulator at 5 min resolution #1245

Open
m-bossart opened this issue Feb 13, 2025 · 0 comments
Open

Writing result fails when using emulator at 5 min resolution #1245

m-bossart opened this issue Feb 13, 2025 · 0 comments
Labels

Comments

@m-bossart
Copy link

Stacktrace:

┌ Error: simulation failed
│   exception =
│    HDF5.API.H5Error: Error writing dataset
│    libhdf5 Stacktrace:
│     [1] H5VL__native_dataset_io_setup: Dataspace/Out of range
│         selection + offset not within extent for file dataspace
│      ⋮
│    Stacktrace:
│      [1] macro expansion
│        @ ~/.julia/packages/HDF5/Z859u/src/api/error.jl:18 [inlined]
│      [2] h5d_write(dataset_id::HDF5.Dataset, mem_type_id::HDF5.Datatype, mem_space_id::HDF5.Dataspace, file_space_id::HDF5.Dataspace, xfer_plist_id::HDF5.DatasetTransferProperties, buf::Matrix{Float64})
│        @ HDF5.API ~/.julia/packages/HDF5/Z859u/src/api/functions.jl:912
│      [3] setindex!(::HDF5.Dataset, ::Matrix{Float64}, ::Int64, ::Colon)
│        @ HDF5 ~/.julia/packages/HDF5/Z859u/src/datasets.jl:381
│      [4] _write_dataset!(dataset::HDF5.Dataset, array::Matrix{Float64}, index::Int64)
│        @ PowerSimulations ~/Documents/PSI Events/PowerSimulations.jl/src/simulation/hdf_simulation_store.jl:1057
│      [5] write_result!(store::PowerSimulations.HdfSimulationStore, ::Symbol, key::InfrastructureSystems.Optimization.ParameterKey{ActivePowerTimeSeriesParameter, RenewableDispatch}, index::Int64, simulation_time::DateTime, data::JuMP.Containers.DenseAxisArray{Float64, 2, Tuple{Vector{String}, UnitRange{Int64}}, Tuple{JuMP.Containers._AxisLookup{Dict{String, Int64}}, JuMP.Containers._AxisLookup{Tuple{Int64, Int64}}}})
│        @ PowerSimulations ~/Documents/PSI Events/PowerSimulations.jl/src/simulation/hdf_simulation_store.jl:650
│      [6] write_model_parameter_results!(store::PowerSimulations.HdfSimulationStore, model::EmulationModel{PowerSimulations.GenericEmulationProblem}, index::Int64, update_timestamp::DateTime, export_params::Nothing)
│        @ PowerSimulations ~/Documents/PSI Events/PowerSimulations.jl/src/core/store_common.jl:88
│      [7] #write_results!#57
│        @ ~/Documents/PSI Events/PowerSimulations.jl/src/core/store_common.jl:26 [inlined]
│      [8] write_results!
│        @ ~/Documents/PSI Events/PowerSimulations.jl/src/core/store_common.jl:6 [inlined]
│      [9] solve!(step::Int64, model::EmulationModel{PowerSimulations.GenericEmulationProblem}, start_time::DateTime, store::PowerSimulations.HdfSimulationStore; exports::Nothing)
│        @ PowerSimulations ~/Documents/PSI Events/PowerSimulations.jl/src/operation/emulation_model.jl:631
│     [10] macro expansion
│        @ ~/Documents/PSI Events/PowerSimulations.jl/src/simulation/simulation.jl:999 [inlined]
│     [11] macro expansion
│        @ ~/.julia/packages/TimerOutputs/6KVfH/src/TimerOutput.jl:237 [inlined]
│     [12] macro expansion
│        @ ~/Documents/PSI Events/PowerSimulations.jl/src/simulation/simulation.jl:998 [inlined]
│     [13] macro expansion
│        @ ~/.julia/packages/TimerOutputs/6KVfH/src/TimerOutput.jl:237 [inlined]
│     [14] _execute!(sim::Simulation; cache_size_mib::Int64, min_cache_flush_size_mib::Int64, exports::Nothing, enable_progress_bar::Bool, disable_timer_outputs::Bool, results_channel::Nothing)
│        @ PowerSimulations ~/Documents/PSI Events/PowerSimulations.jl/src/simulation/simulation.jl:987
│     [15] _execute!
│        @ ~/Documents/PSI Events/PowerSimulations.jl/src/simulation/simulation.jl:906 [inlined]
│     [16] macro expansion
│        @ ~/Documents/PSI Events/PowerSimulations.jl/src/simulation/simulation.jl:1086 [inlined]
│     [17] macro expansion
│        @ ~/.julia/packages/TimerOutputs/6KVfH/src/TimerOutput.jl:237 [inlined]
│     [18] (::PowerSimulations.var"#428#432"{@Kwargs{in_memory::Bool}, Simulation})(store::PowerSimulations.HdfSimulationStore)
│        @ PowerSimulations ~/Documents/PSI Events/PowerSimulations.jl/src/simulation/simulation.jl:1085
│     [19] open_store(func::PowerSimulations.var"#428#432"{@Kwargs{in_memory::Bool}, Simulation}, ::Type{PowerSimulations.HdfSimulationStore}, directory::String, mode::String; filename::String)
│        @ PowerSimulations ~/Documents/PSI Events/PowerSimulations.jl/src/simulation/hdf_simulation_store.jl:108
│     [20] open_store
│        @ ~/Documents/PSI Events/PowerSimulations.jl/src/simulation/hdf_simulation_store.jl:98 [inlined]
│     [21] (::PowerSimulations.var"#427#431"{@Kwargs{in_memory::Bool}, Simulation, DataType})()
│        @ PowerSimulations ~/Documents/PSI Events/PowerSimulations.jl/src/simulation/simulation.jl:1081
│     [22] with_logstate(f::PowerSimulations.var"#427#431"{@Kwargs{in_memory::Bool}, Simulation, DataType}, logstate::Base.CoreLogging.LogState)
│        @ Base.CoreLogging ./logging/logging.jl:522
│     [23] with_logger
│        @ ./logging/logging.jl:632 [inlined]
│     [24] execute!(sim::Simulation; kwargs::@Kwargs{in_memory::Bool})
│        @ PowerSimulations ~/Documents/PSI Events/PowerSimulations.jl/src/simulation/simulation.jl:1080
│     [25] top-level scope
│        @ ~/Documents/PSI Events/PowerSimulations.jl/test/test_events.jl:122
│     [26] include
│        @ ./sysimg.jl:38 [inlined]
│     [27] macro expansion
│        @ ~/Documents/PSI Events/PowerSimulations.jl/test/runtests.jl:92 [inlined]
│     [28] macro expansion
│        @ /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/Test/src/Test.jl:1704 [inlined]
│     [29] macro expansion
│        @ ~/Documents/PSI Events/PowerSimulations.jl/test/runtests.jl:127 [inlined]
│     [30] macro expansion
│        @ ./timing.jl:581 [inlined]
│     [31] (::var"#28#31"{ConsoleLogger})(file_logger::InfrastructureSystems.FileLogger)
│        @ Main ~/Documents/PSI Events/PowerSimulations.jl/test/runtests.jl:126
│     [32] open_file_logger(func::var"#28#31"{ConsoleLogger}, filename::String, level::Base.CoreLogging.LogLevel, mode::String)
│        @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/nVUI1/src/utils/logging.jl:346
│     [33] open_file_logger(func::Function, filename::String, level::Base.CoreLogging.LogLevel)
│        @ InfrastructureSystems ~/.julia/packages/InfrastructureSystems/nVUI1/src/utils/logging.jl:343
│     [34] run_tests()
│        @ Main ~/Documents/PSI Events/PowerSimulations.jl/test/runtests.jl:116
│     [35] top-level scope
│        @ ~/Documents/PSI Events/PowerSimulations.jl/test/runtests.jl:139
│     [36] include(fname::String)
│        @ Main ./sysimg.jl:38
│     [37] top-level scope
│        @ REPL[10]:1
│     [38] eval
│        @ ./boot.jl:430 [inlined]
│     [39] eval
│        @ ./Base.jl:130 [inlined]
│     [40] repleval(m::Module, code::Expr, ::String)
│        @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.127.2/scripts/packages/VSCodeServer/src/repl.jl:229
│     [41] #112
│        @ ~/.vscode/extensions/julialang.language-julia-1.127.2/scripts/packages/VSCodeServer/src/repl.jl:192 [inlined]
│     [42] with_logstate(f::VSCodeServer.var"#112#114"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt}, logstate::Base.CoreLogging.LogState)
│        @ Base.CoreLogging ./logging/logging.jl:522
│     [43] with_logger
│        @ ./logging/logging.jl:632 [inlined]
│     [44] (::VSCodeServer.var"#111#113"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
│        @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.127.2/scripts/packages/VSCodeServer/src/repl.jl:193
│     [45] #invokelatest#2
│        @ ./essentials.jl:1055 [inlined]
│     [46] invokelatest(::Any)
│        @ Base ./essentials.jl:1052
│     [47] (::VSCodeServer.var"#64#65")()
│        @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.127.2/scripts/packages/VSCodeServer/src/eval.jl:34
└ @ PowerSimulations ~/Documents/PSI Events/PowerSimulations.jl/src/simulation/simulation.jl:1097
Begin PowerSimulations tests: Test Failed at /Users/mbossart/Documents/PSI Events/PowerSimulations.jl/test/test_events.jl:123
  Expression: execute_out == PSI.RunStatus.SUCCESSFULLY_FINALIZED
   Evaluated: InfrastructureSystems.Simulation.RunStatusModule.RunStatus.FAILED = 2 == InfrastructureSystems.Simulation.RunStatusModule.RunStatus.SUCCESSFULLY_FINALIZED = 0

Script to reproduce:

    template_d1 = get_template_basic_uc_simulation()
    template_d2 = get_template_nomin_ed_simulation()
    template_em = get_template_nomin_ed_simulation()

    set_device_model!(template_em, Line, StaticBranchUnbounded)
    # We remove the services from the template for the emulator to allow the units to "deploy"
    # the reserves
    empty!(template_em.services)
    #set_device_model!(template_d1, PowerLoad, StaticPowerLoad)

    set_device_model!(template_d2, InterruptiblePowerLoad, StaticPowerLoad)
    set_network_model!(template_d1, NetworkModel(
        CopperPlatePowerModel,
        # MILP "duals" not supported with free solvers
        # duals = [CopperPlateBalanceConstraint],
    ))
    set_network_model!(
        template_d2,
        NetworkModel(
            CopperPlatePowerModel;
            duals = [CopperPlateBalanceConstraint],
            use_slacks = true,
        ),
    )

    c_sys5_d1 = PSB.build_system(PSISystems, "c_sys5_pjm")
    transform_single_time_series!(c_sys5_d1, Day(2), Day(1))
    c_sys5_d2 = PSB.build_system(PSISystems, "c_sys5_pjm")
    transform_single_time_series!(c_sys5_d2, Hour(4), Hour(1))
    #c_sys5_em = PSB.build_system(PSISystems, "c_sys5_pjm")
    c_sys5_em =  PSB.build_system(PSISystems, "c_sys5_pjm_rt")


    models = SimulationModels(;
        decision_models = [
            DecisionModel(
                template_d1,
                c_sys5_d1;
                name = "D1",
                optimizer = HiGHS_optimizer),
            DecisionModel(
                template_d2,
                c_sys5_d2;
                name = "D2",
                optimizer = ipopt_optimizer,
            ),
        ],
        emulation_model = EmulationModel(
            template_em, 
            c_sys5_em;
            name = "EM",
            optimizer = HiGHS_optimizer
        ),   
    )

    sequence = SimulationSequence(;
        models = models,
        #feedforwards = Dict(
        #    "D2" => [
        #        SemiContinuousFeedforward(;
        #            component_type = ThermalStandard,
        #            source = OnVariable,
        #            affected_values = [ActivePowerVariable],
        #        ),
        #    ],
        #),
        ini_cond_chronology = InterProblemChronology(),
    )

    sim = Simulation(;
        name = "no_cache",
        steps = 1,
        models = models,
        sequence = sequence, 
        simulation_folder = mktempdir(; cleanup = true),
    )

    build_out = build!(sim; console_level = Logging.Info)
    @test build_out == PSI.SimulationBuildStatus.BUILT
    execute_out = execute!(sim; in_memory = false)  #Hit bug if true 
    @test execute_out == PSI.RunStatus.SUCCESSFULLY_FINALIZED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant