From 939080bb2a4db81e2d3163216f5bf575836b2156 Mon Sep 17 00:00:00 2001 From: lbonaldo Date: Thu, 4 Apr 2024 11:03:42 -0400 Subject: [PATCH] Add check on crp w non-zero inv_cost --- CHANGELOG.md | 2 ++ .../configure_multi_stage_inputs.jl | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c372739aaa..6bdeda7065 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/src/multi_stage/configure_multi_stage_inputs.jl b/src/multi_stage/configure_multi_stage_inputs.jl index 0bd5d45928..bbf4bb3431 100644 --- a/src/multi_stage/configure_multi_stage_inputs.jl +++ b/src/multi_stage/configure_multi_stage_inputs.jl @@ -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) @@ -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)