NREL / PRAS

NREL's Probabilistic Resource Adequacy Suite (PRAS)
https://www.nrel.gov/analysis/pras.html
Other
46 stars 12 forks source link

Error During Test at SystemModel.jl #58

Open bobbyaguirre opened 5 months ago

bobbyaguirre commented 5 months ago

I attempted to run the runtest.jl script; however, I encountered an error specifically related to SystemModel.jl.

The error message is as follows:

SystemModel: Error During Test at c:\Users\ASUS VIVOBOOK\PRAS\test\PRASBase\SystemModel.jl:1 Got exception outside of a @test MethodError: no method matching step(::Vector{DateTime})

Test Summary

GordStephen commented 4 months ago

Hi @bobbyaguirre, can you confirm what version of PRAS you're working with here? The mention of a call to step(::Vector{DateTime}) seems unusual. Have you modified the value of the timestamps variable in \test\PRASBase\SystemModel.jl? timestamps should normally be a range of DateTimes, not a vector of DateTimes

bobbyaguirre commented 4 months ago

Yes @GordStephen, I am using the latest version of PRAS. I haven't modified or edited the value of timestamps. I just rerun the same copy from repository. I also have no clue on how to turn DateTimes from vector to range. Timestamps

GordStephen commented 4 months ago

Hmm, ok. Have you changed anything else? I'm guessing the source of the issue is here: https://github.com/NREL/PRAS/blob/bc95ac2b1b9b139f27ff3e1d0f1b41d00597eef3/src/PRASBase/SystemModel.jl#L77

But there timestamps should still always be a range, so I'm not sure where the error you're seeing would be coming from.

bobbyaguirre commented 4 months ago

Thanks @GordStephen. I successfully ran runtest.jl by recloning the repository and reinstalling the PRAS packages. Moreover, I have two inquiries:

  1. Let's say I want to extend up to 'd5' and add "D" in the resourcename and interfacenames variables. What steps should I follow to accomplish this? Also, do I need to make changes in any other scripts?
  2. What software do you use to visualize the results? DummyData
GordStephen commented 4 months ago

The DummyData module probably isn't the most useful to look at, since it defines data fragments that get used in different ways in different parts of the test suite, making it hard to see the full picture. Instead, for learning purposes I would focus on testsystems.jl - for example, here's a small system definition (one region, four generators, four timesteps) defined in a handful of lines:

https://github.com/NREL/PRAS/blob/bc95ac2b1b9b139f27ff3e1d0f1b41d00597eef3/test/testsystems.jl#L8-L32

You can see all the individual components separately and then how they combine together to make a SystemModel in the final line.

Also, I wouldn't try running individual files from the test suite, since they might have dependencies to other parts of the test suite that result in confusing errors. Instead I would just copy/paste individual lines of code into the REPL and build up the system interactively.

bobbyaguirre commented 4 months ago

@GordStephen How do you convert .h5 to .pras?

GordStephen commented 4 months ago

No conversion needed actually, .pras file are just HDF5 files in a specific format (see https://github.com/NREL/PRAS/blob/master/SystemModel_HDF5_spec.md)

bobbyaguirre commented 4 months ago
`begin
using PRAS
using TimeZones

#const tz = tz"UTC"

empty_str = String[]
empty_int(x) = Matrix{Int}(undef, 0, x)
empty_float(x) = Matrix{Float64}(undef, 0, x)

## Single-Region System A

gens1 = Generators{4,1,Hour,MW}(
    ["Gen1", "Gen2", "Gen3", "VG"], ["Gens", "Gens", "Gens", "VG"],
    [fill(10, 3, 4); [5 6 7 8]],
    [fill(0.1, 3, 4); fill(0.0, 1, 4)],
    [fill(0.9, 3, 4); fill(1.0, 1, 4)])

emptystors1 = Storages{4,1,Hour,MW,MWh}((empty_str for _ in 1:2)...,
                  (empty_int(4) for _ in 1:3)...,
                  (empty_float(4) for _ in 1:5)...)

emptygenstors1 = GeneratorStorages{4,1,Hour,MW,MWh}(
    (empty_str for _ in 1:2)...,
    (empty_int(4) for _ in 1:3)..., (empty_float(4) for _ in 1:3)...,
    (empty_int(4) for _ in 1:3)..., (empty_float(4) for _ in 1:2)...)

singlenode_a = SystemModel(
    gens1, emptystors1, emptygenstors1,
    DateTime(2010,1,1,0):Hour(1):DateTime(2010,1,1,3),
    [25, 28, 27, 24])

shortfalls = assess(singlenode_a, Convolution(), Shortfall())

lole = LOLE(shortfalls)
eue = EUE(shortfalls)

end

Hello @GordStephen. I am trying to run this sample system, but I keep getting this error ERROR: UndefVarError: Shortfall not defined

bobbyaguirre commented 4 months ago

Also, I am able to use the PRAS format file and get results last week. However, I can't run it now because of the update in PRASBase.

begin

using PRAS
using TimeZones
# Load in a system model from a .pras file.
# This hypothetical system has an hourly time resolution with an
# extent / simulation horizon of one year.
sys = SystemModel("rts2.pras")
# This system has multiple regions and relies on battery storage, so
# run a sequential Monte Carlo analysis:
shortfall, utilization, storage = assess(
sys, SequentialMonteCarlo(samples=100_000, seed=1),
Shortfall(), Utilization(), StorageEnergy())
# Start by checking the overall system adequacy:
lole = LOLE(shortfall) # event-hours per year
eue = EUE(shortfall) # unserved energy per year

end

ERROR: PRAS file format v0.6.0 not supported by this version of PRASBase.

GordStephen commented 4 months ago

Both of those errors are quite odd. My guess is that you have quite an old version of PRAS installed? Can you re-confirm the version you're using? In particular, a version pre-0.6 might explain both errors.