Skip to content

Commit

Permalink
Fix eELOSSByZone expr: access before initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
lbonaldo authored Oct 30, 2023
2 parents ae19f20 + d7de540 commit 73a497c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion src/model/generate_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions src/model/resources/storage/storage_all.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 73a497c

Please sign in to comment.