Skip to content

Fix bugs in run_pcm.py - #251

Draft
aschleif wants to merge 3 commits into
mainfrom
ahs_pcm
Draft

aschleif wants to merge 3 commits into
mainfrom
ahs_pcm

Conversation

@aschleif

@aschleif aschleif commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Running run_pcm.py, whether as part of a ReEDS run with Sw_PCM=1 or just on its own with an existing ReEDS run, throws a few errors, including:

  • inability to import reeds or any functions from reeds (e.g., from reeds.input_processing import hourly_repperiods)
  • relative file paths getting appended because run_pcm.py gets called twice on the HPC
  • compile issues in 2_temporal_params.gms because there is no prm.csv file in the PCM-specific inputs_case/stress0 folder
  • mismatching columns between the CEM cf_vre.csv and the PCM cf_vre.csv

Technical details

Implementation notes

Adding an prm.csv file could look more like...

pd.DataFrame(columns=['rep_period', 'year', 'yperiod', 'actual_period']).to_csv(
os.path.join(stresspath, 'period_szn.csv'),
index=False,
)

instead of...
## 2_temporal_params.gms reads stress{stress_year}/prm.csv even with no stress periods,
## so use the PRM from the stress folder that the restart solve (_t, _iteration) used
prm_src = os.path.join(casepath, 'inputs_case', f'stress{_t}i{_iteration}', 'prm.csv')
if not os.path.isfile(prm_src):
raise FileNotFoundError(f'PRM file for {_t}i{_iteration} not found: {prm_src}')
shutil.copy(prm_src, os.path.join(stresspath, 'prm.csv'))

Validation, testing, and comparison report(s)

Checklist for author

Details to double-check

  • Charge code provided to reviewers
  • Included comparison reports for appropriate test cases
  • Documentation updated if necessary
  • If input data added/modified:
  • Code formatting standardized
  • Reusable functions used where possible instead of copy/pasted code

General information to guide review

  • Zero impact on results of default case
  • No large data file(s) added/modified
  • No substantive impact on runtime for full-US reference case
  • No substantive impact on folder size for full-US reference case
  • No change to process flow (runreeds.py, reeds/core/solve/solve.py)
  • No change to code organization
  • No change to package requirements (environment.yml or Project.toml)

Did you use LLM tools (chatbot or copilot) in the preparation of this PR? If so, describe how

This branch has not been deployed

No deployments
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.

1 participant