Skip to content

Jf/set initial param levels#98

Open
juflorez wants to merge 17 commits into
mainfrom
jf/set_initial_param_levels
Open

Jf/set initial param levels#98
juflorez wants to merge 17 commits into
mainfrom
jf/set_initial_param_levels

Conversation

@juflorez

Copy link
Copy Markdown
Collaborator

Creating initial PR now-will update with graphics/analysis on impact in varying param. Core functionality with backwards compat file reading tests is present though

@codecov-commenter

codecov-commenter commented Nov 24, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.13675% with 56 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.30%. Comparing base (fbde94e) to head (3550896).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
PRASFiles.jl/src/Systems/read.jl 45.45% 48 Missing ⚠️
PRASCore.jl/src/Systems/assets.jl 64.70% 6 Missing ⚠️
PRASCore.jl/src/Simulations/Simulations.jl 88.88% 1 Missing ⚠️
PRASFiles.jl/src/Systems/write.jl 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #98      +/-   ##
==========================================
- Coverage   83.13%   81.30%   -1.84%     
==========================================
  Files          45       45              
  Lines        2325     2407      +82     
==========================================
+ Hits         1933     1957      +24     
- Misses        392      450      +58     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 12 changed files in this pull request and generated 23 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PRASCore.jl/src/Systems/assets.jl Outdated
Comment thread PRASCore.jl/src/Systems/assets.jl Outdated
Comment thread docs/src/SystemModel_HDF5_spec.md Outdated
Comment thread docs/src/SystemModel_HDF5_spec.md Outdated
Comment thread PRASCore.jl/src/Systems/assets.jl Outdated
Comment thread docs/src/SystemModel_HDF5_spec.md Outdated
Comment thread PRASFiles.jl/src/Systems/read.jl Outdated
Comment thread PRASFiles.jl/test/runtests.jl Outdated
Comment thread PRASCore.jl/src/Systems/assets.jl Outdated
Comment thread PRASCore.jl/src/Simulations/Simulations.jl Outdated
@juflorez juflorez requested a review from Copilot November 25, 2025 22:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 12 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PRASFiles.jl/test/runtests.jl
Comment thread docs/src/SystemModel_HDF5_spec.md
Comment thread PRASCore.jl/src/Systems/assets.jl
Comment thread PRASFiles.jl/src/Systems/read.jl
Comment thread PRASFiles.jl/src/Systems/read.jl
Comment thread docs/src/SystemModel_HDF5_spec.md
transitions from forced outage to operational during a given simulation
timestep, for each storage unit in each timeperiod. Unitless.

An optional parameter is available to set the initial state of charge for the unit:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a one dimensional array, if so, is it still a dataset, can we qualify it better with info on shape?

initialize_availability!(
rng, state.lines_available, state.lines_nexttransition,
system.lines, N)
if size(system.storages.energy_capacity, 1) > 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to have one function for these 3 blocks?

operational during a given simulation timestep, for each generator-storage unit in each
timeperiod. Unitless.
- `initial_soc`: Optional keyword for initial state of charge as a fraction [0.0, 1.0] of
`energy_capacity` at the first timestep for each storage unit. Default is zero.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

genstor unit*

λ::Matrix{Float64}, μ::Matrix{Float64},
borrowefficiency::Matrix{Float64},paybackefficiency::Matrix{Float64}
λ::Matrix{Float64}, μ::Matrix{Float64};
initial_borrowed_load::Vector{Float64} = zeros(Float64, length(names)),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we keep this as the last argument, much like the others?

"""
Read a SystemModel from a PRAS file in version 0.8.1+ format. Requires initial SOC levels for storages/generator-storages and initial borrowed load/efficiency parameters for demand responses.
"""
function systemmodel_0_8_1(f::File)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're gonna release this with PRASFiles 0.9, so let's call this function.


path = dirname(@__FILE__)
version_0_7_0 = SystemModel(path * "/versioned_toy/toymodel_v0_7_0.pras")
version_0_8_1 = SystemModel(path * "/versioned_toy/toymodel_v0_8_1.pras")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, think this can be 0.9

end


@testset "Read version 0.7.0 to 0.8.1 compatibility" begin

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we trying to test for here? To test backward compatibility of our reader, to ensure if we can read 0.7, 0.8 version etc.? The 0.8.1 (or other newer versions) are written from those, original right?

has_storages = haskey(f, "storages")
has_generatorstorages = haskey(f, "generatorstorages")

if has_storages

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's pull these blocks into 2 functions read_storages() and read_genstorages(), which take the file handle and the version as a symbol and passes 0 for version <0.9, and passes read-in SoC to the asset struct which is sent back to the calling function. We can then call this in core and can do the same thing as before for 0_5 and 0_8. Same deal with read_demandresponses() except we only check for versions 0_8 and 0_9.

load_matrix(f["storages/carryoverefficiency"], region_order, Float64),
load_matrix(f["storages/failureprobability"], region_order, Float64),
load_matrix(f["storages/repairprobability"], region_order, Float64);
initial_soc = load_matrix(f["storages/initialsoc"], region_order, Float64)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not read with read_vector?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants