Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update configure_multi_stage_inputs.jl #666

Merged
merged 1 commit into from
Apr 4, 2024
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- New settings parameter, StorageVirtualDischarge, to turn storage virtual charging and discharging off if desired by the user (#638).
- Add module to retrofit existing resources with new technologies (#600).
- Formatted the code and added a format check to the CI pipeline (#673).
- Add check when capital recovery period is zero and investment costs are
non-zero in multi-stage GenX (#666)

### Fixed
- Set MUST_RUN=1 for RealSystemExample/small_hydro plants (#517).
Expand Down
22 changes: 16 additions & 6 deletions src/multi_stage/configure_multi_stage_inputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,24 @@ NOTE: The inv\_costs\_yr and crp arrays must be the same length; values with the
returns: array object containing overnight capital costs, the discounted sum of annual investment costs incured within the model horizon.
"""
function compute_overnight_capital_cost(settings_d::Dict,
inv_costs_yr::Array,
crp::Array,
tech_wacc::Array)
inv_costs_yr::Array,
crp::Array,
tech_wacc::Array)

# Check for resources with non-zero investment costs and a Capital_Recovery_Period value of 0 years
if any((crp .== 0) .& (inv_costs_yr .> 0))
msg = "You have some resources with non-zero investment costs and a Capital_Recovery_Period value of 0 years.\n" *
"These resources will have a calculated overnight capital cost of \$0. Correct your inputs if this is a mistake.\n"
error(msg)
end

cur_stage = settings_d["CurStage"] # Current model
num_stages = settings_d["NumStages"] # Total number of model stages
stage_lens = settings_d["StageLengths"]

# 1) For each resource, find the minimum of the capital recovery period and the end of the model horizon
# Total time between the end of the final model stage and the start of the current stage
model_yrs_remaining = sum(stage_lens[cur_stage:end])
model_yrs_remaining = sum(stage_lens[cur_stage:end]; init = 0)

# We will sum annualized costs through the full capital recovery period or the end of planning horizon, whichever comes first
payment_yrs_remaining = min.(crp, model_yrs_remaining)
Expand All @@ -41,8 +49,10 @@ function compute_overnight_capital_cost(settings_d::Dict,
# (Factor to adjust discounting to year 0 for capital cost is included in the discounting coefficient applied to all terms in the objective function value.)
occ = zeros(length(inv_costs_yr))
for i in 1:length(occ)
occ[i] = sum(inv_costs_yr[i] / (1 + tech_wacc[i]) .^ (p)
for p in 1:payment_yrs_remaining[i])
occ[i] = sum(
inv_costs_yr[i] / (1 + tech_wacc[i]) .^ (p)
for p in 1:payment_yrs_remaining[i];
init = 0)
end

# 3) Return the overnight capital cost (discounted sum of annual investment costs incured within the model horizon)
Expand Down
Loading