diff --git a/CHANGELOG.md b/CHANGELOG.md index 713224163e..3cc4dbe548 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated README with new instructions for running GenX through Julia REPL terminal (#492) - Fix factor of 0.5 when writing out transmission losses. (#480) - Fix summation error when a set of hours is empty (in thermal_commit.jl). +- Fix access to eELOSSByZone expr before initialization (#541) ### Changed diff --git a/src/model/generate_model.jl b/src/model/generate_model.jl index e7f0b90640..2644bdf615 100644 --- a/src/model/generate_model.jl +++ b/src/model/generate_model.jl @@ -93,9 +93,12 @@ function generate_model(setup::Dict,inputs::Dict,OPTIMIZER::MOI.OptimizerWithAtt # Initialize Objective Function Expression @expression(EP, eObj, 0) - #@expression(EP, :eCO2Cap[cap=1:inputs["NCO2Cap"]], 0) @expression(EP, eGenerationByZone[z=1:Z, t=1:T], 0) + + # Initialize energy losses related to technologies + @expression(EP, eELOSSByZone[z=1:Z], 0) + # Initialize Capacity Reserve Margin Expression if setup["CapacityReserveMargin"] > 0 @expression(EP, eCapResMarBalance[res=1:inputs["NCapacityReserveMargin"], t=1:T], 0) diff --git a/src/model/resources/storage/storage_all.jl b/src/model/resources/storage/storage_all.jl index cb8588898a..534b80dc1d 100644 --- a/src/model/resources/storage/storage_all.jl +++ b/src/model/resources/storage/storage_all.jl @@ -93,10 +93,9 @@ function storage_all!(EP::Model, inputs::Dict, setup::Dict) [y in STOR_ALL, t=1:T], EP[:vP][y,t] <= EP[:vS][y, hoursbefore(hours_per_subperiod,t,1)]*dfGen[y,:Eff_Down] end) end - #From co2 Policy module - @expression(EP, eELOSSByZone[z=1:Z], - sum(EP[:eELOSS][y] for y in intersect(STOR_ALL, dfGen[dfGen[!,:Zone].==z,:R_ID])) - ) + # From co2 Policy module + expr = @expression(EP, [z=1:Z], sum(EP[:eELOSS][y] for y in intersect(STOR_ALL, dfGen[dfGen[!,:Zone].==z,:R_ID]))) + EP[:eELOSSByZone] += expr end function storage_all_reserves!(EP::Model, inputs::Dict)