Skip to content

Commit

Permalink
add fusion_dwell_avoided_operation function
Browse files Browse the repository at this point in the history
Also retab
  • Loading branch information
cfe316 committed Dec 6, 2023
1 parent 4e016e6 commit 20d785e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 27 deletions.
13 changes: 12 additions & 1 deletion src/model/resources/fusion/fusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,21 @@ function fusion_pulse_thermal_power_generation_constraint!(
@constraint(

Check warning on line 380 in src/model/resources/fusion/fusion.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion.jl#L380

Added line #L380 was not covered by tests
EP,
[t in 1:T],
power_like[y, t] <= ePulseUnderway[t] - dwell_time * ePulseStart[t]
power_like[y, t] <= ePulseUnderway[t] - _fusion_dwell_avoided_operation(dwell_time, ePulseStart[t])
)
end

@doc raw"""
_fusion_dwell_avoided_operation(dwell_time::Float64,
ePulseStart::AffExpr)
dwell_time in fractions of a timestep
ePulseStart is the number of MW starting. Typically component_size * vPulseStart
"""
function _fusion_dwell_avoided_operation(dwell_time::Float64, ePulseStart::AffExpr)
return dwell_time * ePulseStart

Check warning on line 395 in src/model/resources/fusion/fusion.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion.jl#L394-L395

Added lines #L394 - L395 were not covered by tests
end

function fusion_parasitic_power!(

Check warning on line 398 in src/model/resources/fusion/fusion.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion.jl#L398

Added line #L398 was not covered by tests
EP::Model,
inputs::Dict,
Expand Down
2 changes: 1 addition & 1 deletion src/model/resources/fusion/fusion_maintenance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function fusion_maintenance_adjust_parasitic_power!(EP, df::DataFrame)
reactor = FusionReactorData(parasitic_passive_fraction = by_rid(y, :Parasitic_Passive),

Check warning on line 12 in src/model/resources/fusion/fusion_maintenance.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_maintenance.jl#L10-L12

Added lines #L10 - L12 were not covered by tests
eff_down = 1.0,
component_size = by_rid(y, :Cap_Size),
maintenance_remaining_parasitic_power_fraction = float(by_rid(y, :Parasitic_Passive_Maintenance_Remaining)))
maintenance_remaining_parasitic_power_fraction = float(by_rid(y, :Parasitic_Passive_Maintenance_Remaining)))

_fusion_maintenance_parasitic_power_adjustment!(EP, resource_component, reactor)
end

Check warning on line 18 in src/model/resources/fusion/fusion_maintenance.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_maintenance.jl#L17-L18

Added lines #L17 - L18 were not covered by tests
Expand Down
56 changes: 31 additions & 25 deletions src/model/resources/fusion/fusion_policy_adjustments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,44 @@ function _fusion_capacity_reserve_margin_adjustment!(EP::Model,
y::Int)

T = inputs["T"]
timesteps = collect(1:T)
timesteps = collect(1:T)
ncapres = inputs["NCapacityReserveMargin"]

Check warning on line 35 in src/model/resources/fusion/fusion_policy_adjustments.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_policy_adjustments.jl#L33-L35

Added lines #L33 - L35 were not covered by tests

eCapResMarBalance = EP[:eCapResMarBalance]

Check warning on line 37 in src/model/resources/fusion/fusion_policy_adjustments.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_policy_adjustments.jl#L37

Added line #L37 was not covered by tests

for capres_zone in 1:ncapres
adjustment = fusion_capacity_reserve_margin_adjustment(EP, inputs, resource_component, y, capres_zone, timesteps)
add_similar_to_expression!(eCapResMarBalance[capres_zone, :], adjustment)
end
return
for capres_zone in 1:ncapres
adjustment = fusion_capacity_reserve_margin_adjustment(EP, inputs, resource_component, y, capres_zone, timesteps)
add_similar_to_expression!(eCapResMarBalance[capres_zone, :], adjustment)
end
return

Check warning on line 43 in src/model/resources/fusion/fusion_policy_adjustments.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_policy_adjustments.jl#L39-L43

Added lines #L39 - L43 were not covered by tests
end

# Get the amount for one resource component in one CRM zone
function fusion_capacity_reserve_margin_adjustment(EP::Model,

Check warning on line 47 in src/model/resources/fusion/fusion_policy_adjustments.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_policy_adjustments.jl#L47

Added line #L47 was not covered by tests
inputs::Dict,
resource_component::AbstractString,
resource_component::AbstractString,
y::Int,
capres_zone::Int,
timesteps::Vector{Int})
timesteps::Vector{Int})

dfGen = inputs["dfGen"]
by_rid(rid, sym) = by_rid_df(rid, sym, dfGen)

Check warning on line 55 in src/model/resources/fusion/fusion_policy_adjustments.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_policy_adjustments.jl#L54-L55

Added lines #L54 - L55 were not covered by tests

capresfactor = dfGen[y, Symbol("CapRes_" * string(capres_zone))]
capresfactor = dfGen[y, Symbol("CapRes_" * string(capres_zone))]

Check warning on line 57 in src/model/resources/fusion/fusion_policy_adjustments.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_policy_adjustments.jl#L57

Added line #L57 was not covered by tests

get_from_model(f::Function) = EP[Symbol(f(resource_component))]

Check warning on line 59 in src/model/resources/fusion/fusion_policy_adjustments.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_policy_adjustments.jl#L59

Added line #L59 was not covered by tests

ePassive = get_from_model(fusion_parasitic_passive_name)
eActive = get_from_model(fusion_parasitic_active_name)
eStartPower = get_from_model(fusion_pulse_start_power_name)

Check warning on line 63 in src/model/resources/fusion/fusion_policy_adjustments.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_policy_adjustments.jl#L61-L63

Added lines #L61 - L63 were not covered by tests

fusion_adj = _fusion_crm_parasitic_adjustment.(capresfactor, ePassive[timesteps], eActive[timesteps], eStartPower[timesteps])
return fusion_adj
dwell_time = Float64(by_rid(y, :Dwell_Time))
component_size = by_rid(y, :Cap_Size)
ePulseStart = component_size * get_from_model(fusion_pulse_start_name)

Check warning on line 67 in src/model/resources/fusion/fusion_policy_adjustments.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_policy_adjustments.jl#L65-L67

Added lines #L65 - L67 were not covered by tests

parasitic_adj = _fusion_crm_parasitic_adjustment.(capresfactor, ePassive[timesteps], eActive[timesteps], eStartPower[timesteps])
dwell_adj = - capresfactor * _fusion_dwell_avoided_operation.(dwell_time, ePulseStart[timesteps])
return parasitic_adj + dwell_adj

Check warning on line 71 in src/model/resources/fusion/fusion_policy_adjustments.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_policy_adjustments.jl#L69-L71

Added lines #L69 - L71 were not covered by tests
end


Expand Down Expand Up @@ -103,19 +109,19 @@ end
#################################

function fusion_parasitic_power_adjust_energy_share_requirement!(EP, inputs)
eESR = EP[:eESR]
nESR = inputs["nESR"]
weights = inputs["omega"]
dfGen = inputs["dfGen"]
FUSION = resources_with_fusion(dfGen)

for y in FUSION, p in 1:nESR
esr_derating = dfGen[y, Symbol("ESR_" * string(p))]
if esr_derating > 0
resource_component = dfGen[y, :Resource]
adjustment = -esr_derating * fusion_annual_parasitic_power(EP, inputs, resource_component)
add_similar_to_expression!(eESR[p], adjustment)
end
end
eESR = EP[:eESR]
nESR = inputs["nESR"]
weights = inputs["omega"]
dfGen = inputs["dfGen"]
FUSION = resources_with_fusion(dfGen)

Check warning on line 116 in src/model/resources/fusion/fusion_policy_adjustments.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_policy_adjustments.jl#L111-L116

Added lines #L111 - L116 were not covered by tests

for y in FUSION, p in 1:nESR
esr_derating = dfGen[y, Symbol("ESR_" * string(p))]
if esr_derating > 0
resource_component = dfGen[y, :Resource]
adjustment = -esr_derating * fusion_annual_parasitic_power(EP, inputs, resource_component)
add_similar_to_expression!(eESR[p], adjustment)

Check warning on line 123 in src/model/resources/fusion/fusion_policy_adjustments.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_policy_adjustments.jl#L118-L123

Added lines #L118 - L123 were not covered by tests
end
end

Check warning on line 125 in src/model/resources/fusion/fusion_policy_adjustments.jl

View check run for this annotation

Codecov / codecov/patch

src/model/resources/fusion/fusion_policy_adjustments.jl#L125

Added line #L125 was not covered by tests
end

0 comments on commit 20d785e

Please sign in to comment.