Skip to content

Commit

Permalink
Fix eELOSSByZone expr: access before initialization
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Schwartz <[email protected]>
  • Loading branch information
lbonaldo and cfe316 committed Oct 28, 2023
1 parent ae19f20 commit d7de540
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)

Check warning on line 100 in src/model/generate_model.jl

View check run for this annotation

Codecov / codecov/patch

src/model/generate_model.jl#L100

Added line #L100 was not covered by tests

# 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

Check warning on line 98 in src/model/resources/storage/storage_all.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/storage/storage_all.jl#L97-L98

Added lines #L97 - L98 were not covered by tests
end

function storage_all_reserves!(EP::Model, inputs::Dict)
Expand Down

0 comments on commit d7de540

Please sign in to comment.