Skip to content

Commit

Permalink
Experimental use of expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
cfe316 committed Dec 1, 2023
1 parent 8289bf2 commit e843554
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
19 changes: 14 additions & 5 deletions src/model/resources/thermal/thermal_commit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,20 @@ function thermal_maintenance_capacity_reserve_margin_adjustment!(EP::Model,
MAINT = resources_with_maintenance(dfGen)
applicable_resources = intersect(MAINT, THERM_COMMIT)

resource_component(y) = dfGen[y, :Resource]
capresfactor(y, capres) = dfGen[y, Symbol("CapRes_$capres")]
cap_size(y) = dfGen[y, :Cap_Size]
down_var(y) = EP[Symbol(maintenance_down_name(resource_component(y)))]
maint_adj = @expression(EP, [capres in 1:ncapres, t in 1:T],
-sum(capresfactor(y, capres) * down_var(y)[t] * cap_size(y) for y in applicable_resources))
sum(thermal_maintenance_capacity_reserve_margin_adjustment(EP, inputs, y, capres, t) for y in applicable_resources))
add_similar_to_expression!(EP[:eCapResMarBalance], maint_adj)
end

function thermal_maintenance_capacity_reserve_margin_adjustment(EP::Model,
inputs::Dict,
y::Int,
capres::Int,
t)
dfGen = inputs["dfGen"]
resource_component = dfGen[y, :Resource]
capresfactor = dfGen[y, Symbol("CapRes_$capres")]
cap_size = dfGen[y, :Cap_Size]
down_var = EP[Symbol(GenX.maintenance_down_name(resource_component))]
return -capresfactor * down_var[t] * cap_size
end
10 changes: 3 additions & 7 deletions src/write_outputs/capacity_reserve_margin/effective_capacity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,9 @@ function thermal_plant_effective_capacity(
effective_capacity = fill(capresfactor(y, capres_zone) * eTotalCap, length(timesteps))

if has_maintenance(inputs) && y in resources_with_maintenance(dfGen)
resource_component = dfGen[y, :Resource]
cap_size = dfGen[y, :Cap_Size]
down_var = EP[Symbol(maintenance_down_name(resource_component))]
vDOWN = value.(down_var[timesteps])
effective_capacity =
effective_capacity .- capresfactor(y, capres_zone) * vDOWN * cap_size
end
adjustment = thermal_maintenance_capacity_reserve_margin_adjustment(EP, inputs, y, capres_zone, timesteps)
effective_capacity = effective_capacity .+ value.(adjustment)
end

return effective_capacity
end

0 comments on commit e843554

Please sign in to comment.