Skip to content

Fix eq_rsc_INVlim infeasibility for geohydro_allkm by not applying geo_discovery to exogenous capacity - #94

Open
Yunzhi-Chen wants to merge 10 commits into
mainfrom
yc/geohydro_debug
Open

Fix eq_rsc_INVlim infeasibility for geohydro_allkm by not applying geo_discovery to exogenous capacity#94
Yunzhi-Chen wants to merge 10 commits into
mainfrom
yc/geohydro_debug

Conversation

@Yunzhi-Chen

@Yunzhi-Chen Yunzhi-Chen commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix eq_rsc_INVlim infeasibility for geohydro_allkm and other technologies that use rsc_capacity_scalar.

Previously, rsc_capacity_scalar was applied to the full resource supply curve capacity:

m_rsc_dat * rsc_capacity_scalar
    >= sum(INV_RSC) + capacity_exog_rsc

For geohydro_allkm, rsc_capacity_scalar is based on geo_discovery and can be less than 1 in early years. This incorrectly applied the discovery factor to exogenous capacity that had already been built and was therefore already discovered.

If exogenous capacity exceeded m_rsc_dat * geo_discovery, eq_rsc_INVlim could become infeasible together with eq_forceprescription_power. This occurred at p35023 in 2015 for geohydro_allkm_9 bin1 in a county-level Western Interconnection case.

The equation is reformulated as:

(m_rsc_dat - capacity_exog_rsc) * rsc_capacity_scalar
    >= sum(INV_RSC)

With this formulation, existing exogenous capacity is treated as already discovered. The capacity scalar is applied only to the remaining resource available for new investment.

For technologies that do not use a capacity scalar, the multiplier is 1 and the reformulated equation is algebraically equivalent to the previous equation. Therefore, behavior is preserved for non-scalar technologies.

Code changes

  1. reeds/core/setup/c_model.gms

Updated eq_rsc_INVlim to:

  • Subtract first-year exogenous capacity from m_rsc_dat before applying rsc_capacity_scalar.
  • Remove exogenous capacity from the investment side of the equation.
  1. reeds/core/solve/3_solve_oneyear.gms

Updated the rhs_eq_rsc_INVlim pre-solve calculation to match the revised model equation. Keeping these two formulations synchronized is necessary because rhs_eq_rsc_INVlim is used to identify very small resource limits and fix the corresponding INV_RSC variables to zero.

Interaction with PR #12

An earlier version of this PR also included a temporary b_inputs.gms change that extended the pcat-based geothermal prescribed-build adjustment to geohydro_allkm.

PR #12 subsequently removed the pcat dependency and reworked prescribed-build handling. The current main branch now:

  • Tracks prescribed builds directly by technology using prescribed_build(i,v,r,t).
  • Ensures that resource supply is sufficient for existing and prescribed capacity.
  • Handles geo_hydro discovery adjustments directly.

As a result, the temporary b_inputs.gms change is no longer needed and is not part of the current PR diff.

Issue resolved

Closes #84.

Validation and testing

The original county-level Western Interconnection reproducer was previously infeasible and solved successfully with this equation change.

The original comparison run used a maximum iteration count of 1 because the default configuration took more than five days for a single solve year due to PRAS convergence difficulties associated with initial transmission capacity. The complete run finished in approximately 70 hours.

Comparison report:
https://github.com/user-attachments/files/28815528/report.2.html

Reference-case report:
https://github.com/user-attachments/files/28815517/report.1.html

After merging the latest main branch and the prescribed-build changes from PR #12:

  • The remaining c_model.gms and 3_solve_oneyear.gms patches are unchanged.
  • The revised b_inputs.gms logic is consistent with the equation change.
  • GitHub documentation checks pass.
  • The original long-running county-level reproducer has not yet been rerun after the merge.

Checklist

Details to double-check

[ ] Charge code provided to reviewers
[x] Included comparison reports for appropriate test cases
[x] Documentation updated if necessary; no user-facing switches or input files changed
[x] Code formatting standardized
[x] Reusable functions used where appropriate

General information

[x] No expected impact on default-case results for technologies without rsc_capacity_scalar
[x] No large data files added or modified
[x] No substantive expected impact on runtime
[x] No substantive expected impact on case folder size
[x] No change to process flow
[x] No change to code organization
[x] No change to package requirements

LLM usage

GitHub Copilot was used to implement the suggested fix and draft the original PR description.

@Yunzhi-Chen Yunzhi-Chen self-assigned this May 14, 2026
@Yunzhi-Chen
Yunzhi-Chen marked this pull request as ready for review June 10, 2026 22:43
@Yunzhi-Chen
Yunzhi-Chen requested a review from wesleyjcole June 10, 2026 23:23
@Yunzhi-Chen Yunzhi-Chen added bug Something isn't working and removed data_changes labels Jun 10, 2026

@wesleyjcole wesleyjcole 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.

This looks good. If Max says we can remove the evmc(i) piece, I think it can be removed entirely, either here or in a separate PR.

Because it has a pcat change, would you coordinate with An on her startyear PR (#12) before merging this in?

Comment thread reeds/core/setup/c_model.gms Outdated
1$[not rsc_capacity_scalar_i(i)] + rsc_capacity_scalar(i,r,t)$rsc_capacity_scalar_i(i))
*capacity indicated by the resource supply curve minus exogenous (pre-start-year)
*capacity (scaled by rsc_capacity_scalar)
(m_rsc_dat(r,i,rscbin,"cap")$[not evmc(i)]

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.

@Max-Vanatta - should this [not evmc(i)] be here? It is the only place where it is used in the entire model.

@atpham88 atpham88 mentioned this pull request Jun 22, 2026
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working model_changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eq_rsc_INVlim infeasibility for geohydro_allkm when exogenous capacity exceeds m_rsc_dat * geo_discovery

2 participants