Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions cases_test.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
,Default Value,Pacific,USA_defaults,Mid_Case,USA_decarb,github_Pacific,github_Everything,github_MA_county_CC,Pacific_CC,Pacific_weks,Pacific_full_year,Interday_storage,Pacific_2020,Pacific_rep15,WY_county,WECC_county,PJM_county_CC,NYVT_mixed,OR_water,MonteCarlo_Random,MonteCarlo_LHS,Everything,Simple,USA_fast,USA_faster,MultiMetricRA,Pacific_DR,Pacific_MGA,Pacific_MGA_RV,Pacific_LoadSite95,MARICTNYNJPAOH_Offshore,R2P
ignore,1,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,Default Value,Pacific,USA,Mid_Case,USA_decarb,github_Pacific,github_Everything,github_MA_county_CC,Pacific_CC,Pacific_weks,Pacific_full_year,Interday_storage,Pacific_2020,Pacific_rep15,WY_county,WECC_county,PJM_county_CC,NYVT_mixed,OR_water,MonteCarlo_Random,MonteCarlo_LHS,Everything,Simple,USA_fast,USA_faster,MultiMetricRA,Pacific_DR,Pacific_MGA,Pacific_MGA_RV,Pacific_LoadSite95,MARICTNYNJPAOH_Offshore,R2P
ignore,1,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
GSw_Region,cendiv/Pacific,,country/USA,country/USA,country/USA,,st/ID.WY.NE.IA.IL,st/MA,,,,,,,st/WY,interconnect/western,transreg/PJM,st/NY.VT,st/OR,st/NE.NY.PA,st/NE.NY.PA,st/ID.WY.NE.IA.IL,st/KS,country/USA,country/USA,st/NY.NJ,,,,,st/MA.RI.CT.NY.NJ.PA.OH,
endyear,2035,,2050,2050,2050,2030,2060,2030,,,,,,,,,,,2035,2030,2030,2060,2035,2050,2050,2050,,,,,,
endyear,2035,,2035,2050,2050,2030,2060,2030,,,,,,,,,,,2035,2030,2030,2060,2035,2050,2050,2050,,,,,,
yearset,,,,,,,2010..2060..10,,,,,,,,,,,,,,,2010..2060..10,2010_2015_2020..2050..3,,2010_2025_2050,,,,,,,
GSw_ZoneSet,,,,,,,z54,z3109,,,,,,,z3109,z3109,z3109,PJMcounty,,,,z54,z134,z54,z48,,,,,,,
GSw_ZoneSet,,,z54,,,,z54,z3109,,,,,,,z3109,z3109,z3109,PJMcounty,,,,z54,z134,z54,z48,,,,,,,
GSw_GasCurve,2,,1,1,,,,,,,,,,,,,,,,,,,,1,1,,,,,,,
GSw_Geothermal,,,,2,,,,,,,,,,,,,,,,,,,0,,0,,,,,,,
GSw_GrowthPenalties,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Expand Down Expand Up @@ -42,8 +42,8 @@ GSw_CO2_Detail,,,,,,,1,,,,,,,,,,,,,,,1,,,,,,,,,,
GSw_DAC,,,,,,,1,,,,,,,,,,,,,,,1,,,,,,,,,,
GSw_NoFossilOffsetCDR,,,,,,,1,,,,,,,,,,,,,,,1,,,,,,,,,,
GSw_Biopower,,,,,,,,,,,,,,,,,,,,,,,0,,0,,,,,,,
GSw_HourlyChunkLengthRep,,,,,,,,,,,,,,,,,,,,,,,6,4,4,,,,,,,
GSw_HourlyChunkLengthStress,,,,,,,,,,,,,,,,,,,,,,,6,4,4,,,,,,,
GSw_HourlyChunkLengthRep,,,2,,,,,,,,,,,,,,,,,,,,6,4,4,,,,,,,
GSw_HourlyChunkLengthStress,,,2,,,,,,,,,,,,,,,,,,,,6,4,4,,,,,,,
GSw_LfillGas,,,,,,,,,,,,,,,,,,,,,,,0,,0,,,,,,,
GSw_Nuclear,,,,,,,,,,,,,,,,,,,,,,,0,,0,,,,,,,
GSw_OpRes,,,,,,,,,,,,,,,,,,,,,,,0,,0,,,,,,,
Expand All @@ -65,3 +65,7 @@ pras_scheduled_outage,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0
pras_unitsize_source,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,r2x
pras_vre_combine,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1
pras_samples,,,,,,10,10,10,,,,,,,,,,,,,,,,10,10,,,,,,,
pcm,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
keep_resource_adequacy_files,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
dump_alldata,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
keep_g00_files,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
23 changes: 20 additions & 3 deletions postprocessing/run_pcm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# %% Imports
import os
import shutil
import subprocess
import sys
import argparse
import json
from glob import glob
Expand All @@ -9,14 +11,15 @@
from pathlib import Path

## Local imports
sys.path.append(str(Path(__file__).parent.parent))
import reeds
from reeds.input_processing import hourly_repperiods
from reeds.input_processing import hourly_writetimeseries
from reeds.core.terminus.report_dump import write_dfdict


# %% Inferred inputs
reeds_path = os.path.dirname(__file__)
reeds_path = Path(__file__).parent.parent

# %% Default inputs
switch_mods_default = {
Expand All @@ -27,6 +30,8 @@
'GSw_HourlyChunkLengthStress': 1,
'GSw_HourlyChunkAggMethod': 1,
'GSw_PRM_CapCredit': 0,
'GSw_H2': 0,
'GSw_H2_PTC': 0
}


Expand Down Expand Up @@ -166,6 +171,7 @@ def main(casepath, t, switch_mods=switch_mods_default, label='', overwrite=False
kwargs: Passed to hourly_reppreiods.main()
"""
# %% Switch to run folder
casepath = os.path.abspath(casepath)
os.chdir(casepath)

# %% Get the run settings
Expand Down Expand Up @@ -227,12 +233,23 @@ def main(casepath, t, switch_mods=switch_mods_default, label='', overwrite=False
restartfile = batch_case
_iteration = 0
elif iteration == 'last':
restartfile = sorted(glob(os.path.join(casepath, 'g00files', f"{batch_case}_{_t}i*")))[-1]
## Sort numerically so i10 comes after i9
restartfile = sorted(
glob(os.path.join(casepath, 'g00files', f"{batch_case}_{_t}i*.g00")),
key=lambda x: int(x[: -len('.g00')].split('i')[-1]),
)[-1]
_iteration = int(restartfile[: -len('.g00')].split('i')[-1])
else:
_iteration = iteration
restartfile = os.path.join(casepath, 'g00files', f"{batch_case}_{_t}i{_iteration}.g00")

## 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'))

cmd_gams = solvestring_pcm(
batch_case=batch_case,
sw=sw_pcm,
Expand Down Expand Up @@ -374,7 +391,7 @@ def main(casepath, t, switch_mods=switch_mods_default, label='', overwrite=False
main(casepath=casepath, t=t, switch_mods=switch_mods, label=label, overwrite=overwrite)
else:
command_string = (
f"python run_pcm.py {casepath} "
f"python {str(os.path.abspath(__file__))} {casepath} "
f"--year={t} "
f"--iteration={iteration} "
f"--switch_mods='{json.dumps(switch_mods)}' "
Expand Down
1 change: 1 addition & 0 deletions reeds/input_processing/hourly_writetimeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,7 @@ def main(sw, reeds_path, inputs_case, periodtype='rep', make_plots=1, logging=Tr
.assign(h=cf_out.h.map(chunkmap))
.groupby(['i','c','r','h'], as_index=False)
.agg(aggmethod, *args)
[['i','c','r','h','cf']]
)

load_long = (
Expand Down
2 changes: 1 addition & 1 deletion runreeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ def write_batch_script(
### Run dispatch mode if desired
if int(caseSwitches['pcm']):
OPATH.writelines(
f"\npython {Path('reeds','postprocessing','run_pcm.py')} {casedir} -b\n\n"
f"\npython {Path(reeds_path,'postprocessing','run_pcm.py')} {casedir} -b\n\n"
)


Expand Down
Loading