From 7b07a6912716b9dd9e23a24888822d9616e5154b Mon Sep 17 00:00:00 2001 From: TimSlendebroek <32385057+TimSlendebroek@users.noreply.github.com> Date: Mon, 13 Mar 2023 13:46:03 -0700 Subject: [PATCH 1/7] Creation of ActorPowerNeeds initial commit --- src/FUSE.jl | 1 + .../balance_plant/balance_of_plant_actor.jl | 69 +------- src/actors/balance_plant/power_needs.jl | 150 ++++++++++++++++++ src/parameters_actors.jl | 2 + 4 files changed, 159 insertions(+), 63 deletions(-) create mode 100644 src/actors/balance_plant/power_needs.jl diff --git a/src/FUSE.jl b/src/FUSE.jl index 978ae6760..40c9c5958 100644 --- a/src/FUSE.jl +++ b/src/FUSE.jl @@ -80,6 +80,7 @@ include(joinpath("actors", "limits_actor.jl")) include(joinpath("actors", "balance_plant", "heat_transfer_actor.jl")) include(joinpath("actors", "balance_plant", "thermal_cycle_actor.jl")) +include(joinpath("actors", "balance_plant", "power_needs.jl")) include(joinpath("actors", "balance_plant", "balance_of_plant_actor.jl")) include(joinpath("actors", "balance_plant", "balance_of_plant_plot.jl")) diff --git a/src/actors/balance_plant/balance_of_plant_actor.jl b/src/actors/balance_plant/balance_of_plant_actor.jl index 5e465a8b6..3cc6ba59c 100644 --- a/src/actors/balance_plant/balance_of_plant_actor.jl +++ b/src/actors/balance_plant/balance_of_plant_actor.jl @@ -15,6 +15,7 @@ mutable struct ActorBalanceOfPlant <: FacilityAbstractActor act::ParametersAllActors thermal_cycle_actor::ActorThermalCycle IHTS_actor::ActorHeatTransfer + power_needs_actor::ActorPowerNeeds end """ @@ -47,7 +48,8 @@ function ActorBalanceOfPlant(dd::IMAS.dd, par::FUSEparameters__ActorBalanceOfPla IHTS_actor = ActorHeatTransfer(dd, act; breeder_hi_temp, breeder_low_temp) thermal_cycle_actor = ActorThermalCycle(dd, act; Tmax=cycle_tmax, rp=3.0) - return ActorBalanceOfPlant(dd, par, act, thermal_cycle_actor, IHTS_actor) + power_needs_actor = ActorPowerNeeds(dd, act.ActorPowerNeeds) + return ActorBalanceOfPlant(dd, par, act, thermal_cycle_actor, IHTS_actor, power_needs_actor) end function ihts_specs(power_cycle_type::Symbol) @@ -72,33 +74,11 @@ function _step(actor::ActorBalanceOfPlant) @ddtime(bop_thermal.total_useful_heat_power = @ddtime(bop.heat_transfer.wall.heat_delivered) + @ddtime(bop.heat_transfer.divertor.heat_delivered) + @ddtime(bop.heat_transfer.breeder.heat_delivered)) - bop_electric = bop.power_electric_plant_operation - ## heating and current drive systems - sys = resize!(bop_electric.system, "name" => "H&CD", "index" => 1) - sys.power = zeros(length(bop.time)) - for (idx, hcd_system) in enumerate(intersect([:nbi, :ec_launchers, :ic_antennas, :lh_antennas], keys(dd))) - sub_sys = resize!(sys.subsystem, "name" => string(hcd_system), "index" => idx) - sub_sys.power = electricity(getproperty(dd, hcd_system), bop.time) - sys.power .+= sub_sys.power - end - ## balance of plant systems - if par.needs_model == :gasc - sys = resize!(bop_electric.system, "name" => "BOP_gasc", "index" => 2) - sys.power = 0.07 .* bop_thermal.power_electric_generated - - elseif par.needs_model == :EU_DEMO - # More realistic DEMO numbers - bop_systems = [:cryostat, :tritium_handling, :pumping, :pf_active] # index 2 : 5 - for (idx, system) in enumerate(bop_systems) - sys = resize!(bop_electric.system, "name" => string(system), "index" => (idx + 1)) - sys.power = electricity(system, bop.time) - end - else - error("ActorBalanceOfPlant: par.needs_model = $(par.needs_model) not recognized") - end + ## balance of plant needs + finalize(step_(actor.power_needs_actor)) if par.do_plot core = sys_coords(dd) @@ -184,41 +164,4 @@ function heating_and_current_drive_calc(system_unit, time_array::Vector{<:Real}) power_electric_total .+= IMAS.get_time_array(item_unit.power_launched, :data, time_array, :constant) ./ efficiency end return power_electric_total -end - -function electricity(nbi::IMAS.nbi, time_array::Vector{<:Real}) - return heating_and_current_drive_calc(nbi.unit, time_array) -end - -function electricity(ec_launchers::IMAS.ec_launchers, time_array::Vector{<:Real}) - return heating_and_current_drive_calc(ec_launchers.beam, time_array) -end - -function electricity(ic_antennas::IMAS.ic_antennas, time_array::Vector{<:Real}) - return heating_and_current_drive_calc(ic_antennas.antenna, time_array) -end - -function electricity(lh_antennas::IMAS.lh_antennas, time_array::Vector{<:Real}) - return heating_and_current_drive_calc(lh_antennas.antenna, time_array) -end - -function electricity(symbol::Symbol, time_array::Vector{<:Real}) - return electricity(Val{symbol}, time_array) -end - -# Dummy functions values taken from DEMO 2017 https://iopscience.iop.org/article/10.1088/0029-5515/57/1/016011 -function electricity(::Type{Val{:cryostat}}, time_array::Vector{<:Real}) - return 30e6 .* ones(length(time_array)) # MWe -end - -function electricity(::Type{Val{:tritium_handling}}, time_array::Vector{<:Real}) - return 15e6 .* ones(length(time_array)) # MWe -end - -function electricity(::Type{Val{:pumping}}, time_array::Vector{<:Real}) - return 80e6 .* ones(length(time_array)) # MWe (Note this should not be a constant!) -end - -function electricity(::Type{Val{:pf_active}}, time_array::Vector{<:Real}) - return 0e6 .* ones(length(time_array)) # MWe (Note this should not be a constant!) -end +end \ No newline at end of file diff --git a/src/actors/balance_plant/power_needs.jl b/src/actors/balance_plant/power_needs.jl new file mode 100644 index 000000000..700e3bda5 --- /dev/null +++ b/src/actors/balance_plant/power_needs.jl @@ -0,0 +1,150 @@ +#= =============== =# +# ActorPowerNeeds # +#= =============== =# +Base.@kwdef mutable struct FUSEparameters__ActorPowerNeeds{T} <: ParametersActor where {T<:Real} + _parent::WeakRef = WeakRef(Nothing) + _name::Symbol = :not_set + model::Switch{Symbol} = Switch(Symbol, [:gasc, :EU_DEMO, :FUSE], "-", "Power plant electrical needs model"; default=:FUSE) + do_plot::Entry{Bool} = Entry(Bool, "-", "plot"; default=false) +end + +mutable struct ActorPowerNeeds <: FacilityAbstractActor + dd::IMAS.dd + par::FUSEparameters__ActorPowerNeeds +end + +""" + ActorPowerNeeds(dd::IMAS.dd, act::ParametersAllActors; kw...) + +Power needs actor that calculates the needed power to operate the plant + +* `model = :gasc` simply assumes that the power to balance a plant is 7% of the electricity generated. +* `model = :EU_DEMO` subdivides the power plant electrical needs to [:cryostat, :tritium_handling, :pumping] using EU-DEMO numbers. +* `model = :FUSE` subdivides power plant needs and self-consistently calculates the power needs according to FUSE +!!! note + Stores data in `dd.balance_of_plant.power_electric_plant_operation` +""" +function ActorPowerNeeds(dd::IMAS.dd, act::ParametersAllActors; kw...) + par = act.ActorPowerNeeds(kw...) + actor = ActorPowerNeeds(dd, par, act) + step(actor) + finalize(actor) + return actor +end + +function ActorPowerNeeds(dd::IMAS.dd, par::FUSEparameters__ActorPowerNeeds, act::ParametersAllActors; kw...) + logging_actor_init(ActorPowerNeeds) + par = par(kw...) + return ActorPowerNeeds(dd, par) +end + +function _step(actor::ActorPowerNeeds) + dd = actor.dd + par = actor.par + bop = dd.balance_of_plant + + bop_electric = bop.power_electric_plant_operation + + ## heating and current drive systems + sys = resize!(bop_electric.system, "name" => "H&CD", "index" => 1) + sys.power = zeros(length(bop.time)) + for (idx, hcd_system) in enumerate(intersect([:nbi, :ec_launchers, :ic_antennas, :lh_antennas], keys(dd))) + sub_sys = resize!(sys.subsystem, "name" => string(hcd_system), "index" => idx) + sub_sys.power = electricity(getproperty(dd, hcd_system), bop.time) + sys.power .+= sub_sys.power + end + + ## Other subsytems based on model + if par.model == :gasc + sys = resize!(bop_electric.system, "name" => "BOP_gasc", "index" => 2) + sys.power = 0.07 .* bop_thermal.power_electric_generated + + elseif par.model == :FUSE + + # For now electrical needs same as DEMO but pumping self-consistent + bop_systems = [:cryostat, :tritium_handling, :pf_active] + for (idx, system) in enumerate(bop_systems) + if system == :pf_active + idx += 1 + end + sys = resize!(bop_electric.system, "name" => string(system), "index" => (idx + 1)) + sys.power = electricity(system, bop.time) + end + + sys = resize!(bop_electric.system, "name" => "pumping", "index" => 5) + sys.power = electricity(:electricity, dd.balance_of_plant) + + elseif par.model == :EU_DEMO + # More realistic DEMO numbers + bop_systems = [:cryostat, :tritium_handling, :pumping, :pf_active] # index 2 : 5 + for (idx, system) in enumerate(bop_systems) + sys = resize!(bop_electric.system, "name" => string(system), "index" => (idx + 1)) + sys.power = electricity(system, bop.time) + end + else + error("ActorPowerNeeds: par.model = $(par.model) not recognized") + end + + bop.power_electric_net = (bop_thermal.power_electric_generated - sys.power) .* ones(length(bop.time)) + bop.Q_plant = (bop.power_electric_net ./ bop_electric.total_power) + + return actor +end + +function heating_and_current_drive_calc(system_unit, time_array::Vector{<:Real}) + power_electric_total = zeros(length(time_array)) + for item_unit in system_unit + efficiency = prod([getproperty(item_unit.efficiency, i) for i in keys(item_unit.efficiency)]) + power_electric_total .+= IMAS.get_time_array(item_unit.power_launched, :data, time_array, :constant) ./ efficiency + end + return power_electric_total +end + +function electricity(nbi::IMAS.nbi, time_array::Vector{<:Real}) + return heating_and_current_drive_calc(nbi.unit, time_array) +end + +function electricity(ec_launchers::IMAS.ec_launchers, time_array::Vector{<:Real}) + return heating_and_current_drive_calc(ec_launchers.beam, time_array) +end + +function electricity(ic_antennas::IMAS.ic_antennas, time_array::Vector{<:Real}) + return heating_and_current_drive_calc(ic_antennas.antenna, time_array) +end + +function electricity(lh_antennas::IMAS.lh_antennas, time_array::Vector{<:Real}) + return heating_and_current_drive_calc(lh_antennas.antenna, time_array) +end + +function electricity(symbol::Symbol, time_array::Vector{<:Real}) + return electricity(Val{symbol}, time_array) +end + +#= =================== =# +# EU DEMO electricity # +#= =================== =# + +# Dummy functions values taken from DEMO 2017 https://iopscience.iop.org/article/10.1088/0029-5515/57/1/016011 +function electricity(::Type{Val{:cryostat}}, time_array::Vector{<:Real}) + return 30e6 .* ones(length(time_array)) # MWe +end + +function electricity(::Type{Val{:tritium_handling}}, time_array::Vector{<:Real}) + return 15e6 .* ones(length(time_array)) # MWe +end + +function electricity(::Type{Val{:pumping}}, time_array::Vector{<:Real}) + return 80e6 .* ones(length(time_array)) # MWe (Note this should not be a constant!) +end + +function electricity(::Type{Val{:pf_active}}, time_array::Vector{<:Real}) + return 0e6 .* ones(length(time_array)) # MWe (Note this should not be a constant!) +end + +#= =================== =# +# FUSE electricity # +#= =================== =# + +function electricity(::Type{Val{:pumping}},bop::IMAS.balance_of_plant, time_array::Vector{<:Real}) + return bop.heat_transfer.breeder.circulator_power .+ bop.divertor.breeder.circulator_power .+ bop.heat_transfer.wall.circulator_power +end diff --git a/src/parameters_actors.jl b/src/parameters_actors.jl index 4b2844d5f..fe5ef1865 100644 --- a/src/parameters_actors.jl +++ b/src/parameters_actors.jl @@ -13,6 +13,7 @@ mutable struct ParametersActors{T} <: ParametersAllActors where {T<:Real} ActorPassiveStructures::FUSEparameters__ActorPassiveStructures{T} ActorBlanket::FUSEparameters__ActorBlanket{T} ActorBalanceOfPlant::FUSEparameters__ActorBalanceOfPlant{T} + ActorPowerNeeds::FUSEparameters__ActorPowerNeeds{T} ActorThermalCycle::FUSEparameters__ActorThermalCycle{T} ActorHeatTransfer::FUSEparameters__ActorHeatTransfer{T} ActorQEDcurrent::FUSEparameters__ActorQEDcurrent{T} @@ -51,6 +52,7 @@ function ParametersActors{T}() where {T<:Real} FUSEparameters__ActorPassiveStructures{T}(), FUSEparameters__ActorBlanket{T}(), FUSEparameters__ActorBalanceOfPlant{T}(), + FUSEparameters__ActorPowerNeeds{T}(), FUSEparameters__ActorThermalCycle{T}(), FUSEparameters__ActorHeatTransfer{T}(), FUSEparameters__ActorQEDcurrent{T}(), From 6335f22e2c13e5c779318766fef250edc33a1638 Mon Sep 17 00:00:00 2001 From: TimSlendebroek <32385057+TimSlendebroek@users.noreply.github.com> Date: Mon, 13 Mar 2023 13:53:51 -0700 Subject: [PATCH 2/7] name_actor.. rm bop left overs --- src/FUSE.jl | 2 +- .../balance_plant/balance_of_plant_actor.jl | 19 +------------------ .../{power_needs.jl => power_needs_actor.jl} | 2 +- 3 files changed, 3 insertions(+), 20 deletions(-) rename src/actors/balance_plant/{power_needs.jl => power_needs_actor.jl} (98%) diff --git a/src/FUSE.jl b/src/FUSE.jl index 40c9c5958..14ea9aa85 100644 --- a/src/FUSE.jl +++ b/src/FUSE.jl @@ -80,7 +80,7 @@ include(joinpath("actors", "limits_actor.jl")) include(joinpath("actors", "balance_plant", "heat_transfer_actor.jl")) include(joinpath("actors", "balance_plant", "thermal_cycle_actor.jl")) -include(joinpath("actors", "balance_plant", "power_needs.jl")) +include(joinpath("actors", "balance_plant", "power_needs_actor.jl")) include(joinpath("actors", "balance_plant", "balance_of_plant_actor.jl")) include(joinpath("actors", "balance_plant", "balance_of_plant_plot.jl")) diff --git a/src/actors/balance_plant/balance_of_plant_actor.jl b/src/actors/balance_plant/balance_of_plant_actor.jl index 3cc6ba59c..d58b04b6c 100644 --- a/src/actors/balance_plant/balance_of_plant_actor.jl +++ b/src/actors/balance_plant/balance_of_plant_actor.jl @@ -4,7 +4,6 @@ Base.@kwdef mutable struct FUSEparameters__ActorBalanceOfPlant{T} <: ParametersActor where {T<:Real} _parent::WeakRef = WeakRef(Nothing) _name::Symbol = :not_set - needs_model::Switch{Symbol} = Switch(Symbol, [:gasc, :EU_DEMO], "-", "Power plant electrical needs model"; default=:EU_DEMO) thermal_electric_conversion_efficiency::Entry{T} = Entry(T, "-", "Efficiency of the steam cycle, thermal to electric"; default=0.9) do_plot::Entry{Bool} = Entry(Bool, "-", "plot"; default=false) end @@ -22,10 +21,6 @@ end ActorBalanceOfPlant(dd::IMAS.dd, act::ParametersAllActors; kw...) Balance of plant actor that estimates the net electrical power output by comparing the balance of plant electrical needs with the electricity generated from the thermal cycle. - -* `needs_model = :gasc` simply assumes that the power to balance a plant is 7% of the electricity generated. -* `needs_model = :EU_DEMO` subdivides the power plant electrical needs to [:cryostat, :tritium_handling, :pumping] using EU-DEMO numbers. - !!! note Stores data in `dd.balance_of_plant` """ @@ -74,11 +69,8 @@ function _step(actor::ActorBalanceOfPlant) @ddtime(bop_thermal.total_useful_heat_power = @ddtime(bop.heat_transfer.wall.heat_delivered) + @ddtime(bop.heat_transfer.divertor.heat_delivered) + @ddtime(bop.heat_transfer.breeder.heat_delivered)) - - ## balance of plant needs - - finalize(step_(actor.power_needs_actor)) + finalize(step(actor.power_needs_actor)) if par.do_plot core = sys_coords(dd) @@ -155,13 +147,4 @@ function _step(actor::ActorBalanceOfPlant) end return actor -end - -function heating_and_current_drive_calc(system_unit, time_array::Vector{<:Real}) - power_electric_total = zeros(length(time_array)) - for item_unit in system_unit - efficiency = prod([getproperty(item_unit.efficiency, i) for i in keys(item_unit.efficiency)]) - power_electric_total .+= IMAS.get_time_array(item_unit.power_launched, :data, time_array, :constant) ./ efficiency - end - return power_electric_total end \ No newline at end of file diff --git a/src/actors/balance_plant/power_needs.jl b/src/actors/balance_plant/power_needs_actor.jl similarity index 98% rename from src/actors/balance_plant/power_needs.jl rename to src/actors/balance_plant/power_needs_actor.jl index 700e3bda5..2b869ef35 100644 --- a/src/actors/balance_plant/power_needs.jl +++ b/src/actors/balance_plant/power_needs_actor.jl @@ -145,6 +145,6 @@ end # FUSE electricity # #= =================== =# -function electricity(::Type{Val{:pumping}},bop::IMAS.balance_of_plant, time_array::Vector{<:Real}) +function electricity(::Type{Val{:pumping}}, bop::IMAS.balance_of_plant, time_array::Vector{<:Real}) return bop.heat_transfer.breeder.circulator_power .+ bop.divertor.breeder.circulator_power .+ bop.heat_transfer.wall.circulator_power end From dd5cd000ca4252777b0b005b0bfba58cd43dbe56 Mon Sep 17 00:00:00 2001 From: TimSlendebroek <32385057+TimSlendebroek@users.noreply.github.com> Date: Mon, 13 Mar 2023 17:14:11 -0700 Subject: [PATCH 3/7] only initalizing actors and calling them in bop actor --- .../balance_plant/balance_of_plant_actor.jl | 18 +++++++++------- .../balance_plant/heat_transfer_actor.jl | 21 ++++++++++--------- .../balance_plant/thermal_cycle_actor.jl | 21 ++++++++++--------- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/actors/balance_plant/balance_of_plant_actor.jl b/src/actors/balance_plant/balance_of_plant_actor.jl index d58b04b6c..1208538b3 100644 --- a/src/actors/balance_plant/balance_of_plant_actor.jl +++ b/src/actors/balance_plant/balance_of_plant_actor.jl @@ -4,7 +4,7 @@ Base.@kwdef mutable struct FUSEparameters__ActorBalanceOfPlant{T} <: ParametersActor where {T<:Real} _parent::WeakRef = WeakRef(Nothing) _name::Symbol = :not_set - thermal_electric_conversion_efficiency::Entry{T} = Entry(T, "-", "Efficiency of the steam cycle, thermal to electric"; default=0.9) + generator_conversion_efficiency::Entry{T} = Entry(T, "-", "Efficiency of the generator"; default=0.95) # Appl. Therm. Eng. 76 (2015) 123–133, https://doi.org/10.1016/j.applthermaleng.2014.10.093 do_plot::Entry{Bool} = Entry(Bool, "-", "plot"; default=false) end @@ -41,9 +41,9 @@ function ActorBalanceOfPlant(dd::IMAS.dd, par::FUSEparameters__ActorBalanceOfPla breeder_hi_temp, breeder_low_temp, cycle_tmax = ihts_specs(act.ActorThermalCycle.power_cycle_type) - IHTS_actor = ActorHeatTransfer(dd, act; breeder_hi_temp, breeder_low_temp) - thermal_cycle_actor = ActorThermalCycle(dd, act; Tmax=cycle_tmax, rp=3.0) - power_needs_actor = ActorPowerNeeds(dd, act.ActorPowerNeeds) + IHTS_actor = ActorHeatTransfer(dd, act.ActorHeatTransfer, act; breeder_hi_temp, breeder_low_temp) + thermal_cycle_actor = ActorThermalCycle(dd, act.ActorThermalCycle, act; Tmax=cycle_tmax, rp=3.0) + power_needs_actor = ActorPowerNeeds(dd, act.ActorPowerNeeds, act) return ActorBalanceOfPlant(dd, par, act, thermal_cycle_actor, IHTS_actor, power_needs_actor) end @@ -64,11 +64,15 @@ function _step(actor::ActorBalanceOfPlant) bop = dd.balance_of_plant bop_thermal = bop.thermal_cycle - bop_thermal.thermal_electric_conversion_efficiency = par.thermal_electric_conversion_efficiency .* ones(length(bop.time)) - bop_thermal.power_electric_generated = bop_thermal.net_work .* par.thermal_electric_conversion_efficiency .* ones(length(bop.time)) - + @ddtime(bop_thermal.generator_conversion_efficiency = par.generator_conversion_efficiency) @ddtime(bop_thermal.total_useful_heat_power = @ddtime(bop.heat_transfer.wall.heat_delivered) + @ddtime(bop.heat_transfer.divertor.heat_delivered) + @ddtime(bop.heat_transfer.breeder.heat_delivered)) + # + asdf + finalize(step(acttor.IHTS_actor)) + # + finalize(step(acttor.thermal_cycle_actor)) + ## balance of plant needs finalize(step(actor.power_needs_actor)) diff --git a/src/actors/balance_plant/heat_transfer_actor.jl b/src/actors/balance_plant/heat_transfer_actor.jl index c09724f64..8bc416700 100644 --- a/src/actors/balance_plant/heat_transfer_actor.jl +++ b/src/actors/balance_plant/heat_transfer_actor.jl @@ -3,16 +3,6 @@ #= ================= =# # ACTOR FOR THE INTERMEDIATE HEAT TRANSFER SYSTEM -mutable struct ActorHeatTransfer <: FacilityAbstractActor - dd::IMAS.dd - par::ParametersActor - function ActorHeatTransfer(dd::IMAS.dd, par::ParametersActor; kw...) - logging_actor_init(ActorHeatTransfer) - par = par(kw...) - return new(dd, par) - end -end - const coolant_fluid = [:He, :PbLi] Base.@kwdef mutable struct FUSEparameters__ActorHeatTransfer{T} <: ParametersActor where {T<:Real} @@ -40,6 +30,11 @@ Base.@kwdef mutable struct FUSEparameters__ActorHeatTransfer{T} <: ParametersAct divertor_coolant::Switch{Symbol} = Switch(Symbol, coolant_fluid, "-", "Breeder coolant fluid"; default=:He) end +mutable struct ActorHeatTransfer <: FacilityAbstractActor + dd::IMAS.dd + par::FUSEparameters__ActorHeatTransfer +end + """ ActorHeatTransfer(dd::IMAS.dd, act::ParametersAllActors; kw...) @@ -54,6 +49,12 @@ function ActorHeatTransfer(dd::IMAS.dd, act::ParametersAllActors; kw...) return actor end +function ActorHeatTransfer(dd::IMAS.dd, par::FUSEparameters__ActorHeatTransfer, act::ParametersAllActors; kw...) + logging_actor_init(ActorHeatTransfer) + par = par(kw...) + return ActorHeatTransfer(dd, par) +end + function _step(actor::ActorHeatTransfer) dd = actor.dd par = actor.par diff --git a/src/actors/balance_plant/thermal_cycle_actor.jl b/src/actors/balance_plant/thermal_cycle_actor.jl index e44779ce3..139fd390d 100644 --- a/src/actors/balance_plant/thermal_cycle_actor.jl +++ b/src/actors/balance_plant/thermal_cycle_actor.jl @@ -6,16 +6,6 @@ # SIMPLE rankine # COMBINED BRAYTON RANKINE #= =================== =# -mutable struct ActorThermalCycle <: FacilityAbstractActor - dd::IMAS.dd - par::ParametersActor - act::ParametersAllActors - function ActorThermalCycle(dd::IMAS.dd, par::ParametersActor, act; kw...) - logging_actor_init(ActorThermalCycle) - par = par(kw...) - return new(dd, par, act) - end -end Base.@kwdef mutable struct FUSEparameters__ActorThermalCycle{T} <: ParametersActor where {T<:Real} _parent::WeakRef = WeakRef(Nothing) @@ -31,6 +21,11 @@ Base.@kwdef mutable struct FUSEparameters__ActorThermalCycle{T} <: ParametersAct do_plot::Entry{Bool} = Entry(Bool, "-", "plot"; default=false) end +mutable struct ActorThermalCycle <: FacilityAbstractActor + dd::IMAS.dd + par::FUSEparameters__ActorThermalCycle +end + """ ActorThermalCycle(dd::IMAS.dd, act::ParametersAllActors; kw...) @@ -48,6 +43,12 @@ function ActorThermalCycle(dd::IMAS.dd, act::ParametersAllActors; kw...) return actor end +function ActorThermalCycle(dd::IMAS.dd, par::FUSEparameters__ActorThermalCycle, act::ParametersAllActors; kw...) + logging_actor_init(ActorThermalCycle) + par = par(kw...) + return ActorThermalCycle(dd, par) +end + function _step(actor::ActorThermalCycle) dd = actor.dd par = actor.par From e6d88c1616626e85174d8ae6eb08ef39651c242c Mon Sep 17 00:00:00 2001 From: TimSlendebroek <32385057+TimSlendebroek@users.noreply.github.com> Date: Mon, 13 Mar 2023 17:14:26 -0700 Subject: [PATCH 4/7] Bop act only one global_time timesclice --- src/actors/balance_plant/power_needs_actor.jl | 59 +++++++++---------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/src/actors/balance_plant/power_needs_actor.jl b/src/actors/balance_plant/power_needs_actor.jl index 2b869ef35..f79a02bc8 100644 --- a/src/actors/balance_plant/power_needs_actor.jl +++ b/src/actors/balance_plant/power_needs_actor.jl @@ -50,7 +50,7 @@ function _step(actor::ActorPowerNeeds) sys.power = zeros(length(bop.time)) for (idx, hcd_system) in enumerate(intersect([:nbi, :ec_launchers, :ic_antennas, :lh_antennas], keys(dd))) sub_sys = resize!(sys.subsystem, "name" => string(hcd_system), "index" => idx) - sub_sys.power = electricity(getproperty(dd, hcd_system), bop.time) + sub_sys.power = electricity(getproperty(dd, hcd_system)) sys.power .+= sub_sys.power end @@ -68,7 +68,7 @@ function _step(actor::ActorPowerNeeds) idx += 1 end sys = resize!(bop_electric.system, "name" => string(system), "index" => (idx + 1)) - sys.power = electricity(system, bop.time) + sys.power = electricity(system) end sys = resize!(bop_electric.system, "name" => "pumping", "index" => 5) @@ -79,45 +79,40 @@ function _step(actor::ActorPowerNeeds) bop_systems = [:cryostat, :tritium_handling, :pumping, :pf_active] # index 2 : 5 for (idx, system) in enumerate(bop_systems) sys = resize!(bop_electric.system, "name" => string(system), "index" => (idx + 1)) - sys.power = electricity(system, bop.time) + sys.power = electricity(system) end - else - error("ActorPowerNeeds: par.model = $(par.model) not recognized") end - - bop.power_electric_net = (bop_thermal.power_electric_generated - sys.power) .* ones(length(bop.time)) - bop.Q_plant = (bop.power_electric_net ./ bop_electric.total_power) - return actor end -function heating_and_current_drive_calc(system_unit, time_array::Vector{<:Real}) - power_electric_total = zeros(length(time_array)) +function heating_and_current_drive_calc(system_unit) + power_electric_total = 0.0 for item_unit in system_unit efficiency = prod([getproperty(item_unit.efficiency, i) for i in keys(item_unit.efficiency)]) - power_electric_total .+= IMAS.get_time_array(item_unit.power_launched, :data, time_array, :constant) ./ efficiency + @show item_unit.power_launched + power_electric_total += item_unit.power_launched / efficiency end return power_electric_total end -function electricity(nbi::IMAS.nbi, time_array::Vector{<:Real}) - return heating_and_current_drive_calc(nbi.unit, time_array) +function electricity(nbi::IMAS.nbi) + return heating_and_current_drive_calc(nbi.unit) end -function electricity(ec_launchers::IMAS.ec_launchers, time_array::Vector{<:Real}) - return heating_and_current_drive_calc(ec_launchers.beam, time_array) +function electricity(ec_launchers::IMAS.ec_launchers) + return heating_and_current_drive_calc(ec_launchers.beam) end -function electricity(ic_antennas::IMAS.ic_antennas, time_array::Vector{<:Real}) - return heating_and_current_drive_calc(ic_antennas.antenna, time_array) +function electricity(ic_antennas::IMAS.ic_antennas) + return heating_and_current_drive_calc(ic_antennas.antenna) end -function electricity(lh_antennas::IMAS.lh_antennas, time_array::Vector{<:Real}) - return heating_and_current_drive_calc(lh_antennas.antenna, time_array) +function electricity(lh_antennas::IMAS.lh_antennas) + return heating_and_current_drive_calc(lh_antennas.antenna) end -function electricity(symbol::Symbol, time_array::Vector{<:Real}) - return electricity(Val{symbol}, time_array) +function electricity(symbol::Symbol) + return electricity(Val{symbol}) end #= =================== =# @@ -125,26 +120,26 @@ end #= =================== =# # Dummy functions values taken from DEMO 2017 https://iopscience.iop.org/article/10.1088/0029-5515/57/1/016011 -function electricity(::Type{Val{:cryostat}}, time_array::Vector{<:Real}) - return 30e6 .* ones(length(time_array)) # MWe +function electricity(::Type{Val{:cryostat}}) + return 30e6 # We end -function electricity(::Type{Val{:tritium_handling}}, time_array::Vector{<:Real}) - return 15e6 .* ones(length(time_array)) # MWe +function electricity(::Type{Val{:tritium_handling}}) + return 15e6# We end -function electricity(::Type{Val{:pumping}}, time_array::Vector{<:Real}) - return 80e6 .* ones(length(time_array)) # MWe (Note this should not be a constant!) +function electricity(::Type{Val{:pumping}}) + return 80e6 # We (Note this should not be a constant!) end -function electricity(::Type{Val{:pf_active}}, time_array::Vector{<:Real}) - return 0e6 .* ones(length(time_array)) # MWe (Note this should not be a constant!) +function electricity(::Type{Val{:pf_active}}) + return 0.0 # We (Note this should not be a constant!) end #= =================== =# # FUSE electricity # #= =================== =# -function electricity(::Type{Val{:pumping}}, bop::IMAS.balance_of_plant, time_array::Vector{<:Real}) - return bop.heat_transfer.breeder.circulator_power .+ bop.divertor.breeder.circulator_power .+ bop.heat_transfer.wall.circulator_power +function electricity(::Type{Val{:pumping}}, bop::IMAS.balance_of_plant) + return @ddtime(bop.heat_transfer.breeder.circulator_power) + @ddtime(bop.divertor.breeder.circulator_power) + @ddtime(bop.heat_transfer.wall.circulator_power) end From 0c106bd0cd9a9ea4976fc3bb0aa7d3414cee9095 Mon Sep 17 00:00:00 2001 From: TimSlendebroek <32385057+TimSlendebroek@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:18:23 -0700 Subject: [PATCH 5/7] fixes to bop, works now --- .../balance_plant/balance_of_plant_actor.jl | 10 ++-------- src/actors/balance_plant/power_needs_actor.jl | 15 +++++++++------ src/actors/balance_plant/thermal_cycle_actor.jl | 6 +++--- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/actors/balance_plant/balance_of_plant_actor.jl b/src/actors/balance_plant/balance_of_plant_actor.jl index 1208538b3..989444c27 100644 --- a/src/actors/balance_plant/balance_of_plant_actor.jl +++ b/src/actors/balance_plant/balance_of_plant_actor.jl @@ -65,15 +65,9 @@ function _step(actor::ActorBalanceOfPlant) bop_thermal = bop.thermal_cycle @ddtime(bop_thermal.generator_conversion_efficiency = par.generator_conversion_efficiency) - @ddtime(bop_thermal.total_useful_heat_power = @ddtime(bop.heat_transfer.wall.heat_delivered) + @ddtime(bop.heat_transfer.divertor.heat_delivered) + @ddtime(bop.heat_transfer.breeder.heat_delivered)) - # - asdf - finalize(step(acttor.IHTS_actor)) - # - finalize(step(acttor.thermal_cycle_actor)) - - ## balance of plant needs + finalize(step(actor.IHTS_actor)) + finalize(step(actor.thermal_cycle_actor)) finalize(step(actor.power_needs_actor)) if par.do_plot diff --git a/src/actors/balance_plant/power_needs_actor.jl b/src/actors/balance_plant/power_needs_actor.jl index f79a02bc8..cda7c922d 100644 --- a/src/actors/balance_plant/power_needs_actor.jl +++ b/src/actors/balance_plant/power_needs_actor.jl @@ -50,7 +50,7 @@ function _step(actor::ActorPowerNeeds) sys.power = zeros(length(bop.time)) for (idx, hcd_system) in enumerate(intersect([:nbi, :ec_launchers, :ic_antennas, :lh_antennas], keys(dd))) sub_sys = resize!(sys.subsystem, "name" => string(hcd_system), "index" => idx) - sub_sys.power = electricity(getproperty(dd, hcd_system)) + @ddtime(sub_sys.power = electricity(getproperty(dd, hcd_system))) sys.power .+= sub_sys.power end @@ -68,11 +68,11 @@ function _step(actor::ActorPowerNeeds) idx += 1 end sys = resize!(bop_electric.system, "name" => string(system), "index" => (idx + 1)) - sys.power = electricity(system) + @ddtime(sys.power = electricity(system)) end sys = resize!(bop_electric.system, "name" => "pumping", "index" => 5) - sys.power = electricity(:electricity, dd.balance_of_plant) + @ddtime(sys.power = electricity(:pumping, dd.balance_of_plant)) elseif par.model == :EU_DEMO # More realistic DEMO numbers @@ -89,8 +89,7 @@ function heating_and_current_drive_calc(system_unit) power_electric_total = 0.0 for item_unit in system_unit efficiency = prod([getproperty(item_unit.efficiency, i) for i in keys(item_unit.efficiency)]) - @show item_unit.power_launched - power_electric_total += item_unit.power_launched / efficiency + power_electric_total += @ddtime(item_unit.power_launched.data) / efficiency end return power_electric_total end @@ -141,5 +140,9 @@ end #= =================== =# function electricity(::Type{Val{:pumping}}, bop::IMAS.balance_of_plant) - return @ddtime(bop.heat_transfer.breeder.circulator_power) + @ddtime(bop.divertor.breeder.circulator_power) + @ddtime(bop.heat_transfer.wall.circulator_power) + return @ddtime(bop.heat_transfer.breeder.circulator_power) + @ddtime(bop.heat_transfer.divertor.circulator_power) + @ddtime(bop.heat_transfer.wall.circulator_power) end + +function electricity(symbol::Symbol, bop::IMAS.balance_of_plant) + return electricity(Val{symbol}, bop) +end \ No newline at end of file diff --git a/src/actors/balance_plant/thermal_cycle_actor.jl b/src/actors/balance_plant/thermal_cycle_actor.jl index 139fd390d..6e1aa8b07 100644 --- a/src/actors/balance_plant/thermal_cycle_actor.jl +++ b/src/actors/balance_plant/thermal_cycle_actor.jl @@ -24,6 +24,7 @@ end mutable struct ActorThermalCycle <: FacilityAbstractActor dd::IMAS.dd par::FUSEparameters__ActorThermalCycle + par_ActorHeatTransfer::FUSEparameters__ActorHeatTransfer end """ @@ -46,13 +47,12 @@ end function ActorThermalCycle(dd::IMAS.dd, par::FUSEparameters__ActorThermalCycle, act::ParametersAllActors; kw...) logging_actor_init(ActorThermalCycle) par = par(kw...) - return ActorThermalCycle(dd, par) + return ActorThermalCycle(dd, par,act.ActorHeatTransfer) end function _step(actor::ActorThermalCycle) dd = actor.dd par = actor.par - act = actor.act bop = dd.balance_of_plant ihts = bop.heat_transfer wall = ihts.wall @@ -62,7 +62,7 @@ function _step(actor::ActorThermalCycle) bop.power_cycle_type = string(par.power_cycle_type) bop_thermal = bop.thermal_cycle - ihts_par = act.ActorHeatTransfer + ihts_par = actor.par_ActorHeatTransfer blanket_power = @ddtime(bop.heat_transfer.wall.heat_load) breeder_power = @ddtime(bop.heat_transfer.breeder.heat_load) From 21f40d0c8045372c6de9d07218ddd47cee06dad8 Mon Sep 17 00:00:00 2001 From: TimSlendebroek <32385057+TimSlendebroek@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:18:45 -0700 Subject: [PATCH 6/7] format --- src/actors/balance_plant/heat_transfer_actor.jl | 2 +- src/actors/balance_plant/thermal_cycle_actor.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/actors/balance_plant/heat_transfer_actor.jl b/src/actors/balance_plant/heat_transfer_actor.jl index 8bc416700..7507a0965 100644 --- a/src/actors/balance_plant/heat_transfer_actor.jl +++ b/src/actors/balance_plant/heat_transfer_actor.jl @@ -156,7 +156,7 @@ function pbLi_props(Temperature) return [specific_heat, density] end -function gas_circulator(rp, Tin, effC, mflow, nstages = 1) +function gas_circulator(rp, Tin, effC, mflow, nstages=1) cp = 5.1926e3 cv = 3.1156e3 a1c = (effC * (rp^(1.0 / nstages))^(cv / cp) - (rp^(1.0 / nstages))^(cv / cp) + rp^(1.0 / nstages)) / (effC * (rp^(1.0 / nstages))^(cv / cp)) diff --git a/src/actors/balance_plant/thermal_cycle_actor.jl b/src/actors/balance_plant/thermal_cycle_actor.jl index 6e1aa8b07..bf9c37ae5 100644 --- a/src/actors/balance_plant/thermal_cycle_actor.jl +++ b/src/actors/balance_plant/thermal_cycle_actor.jl @@ -47,7 +47,7 @@ end function ActorThermalCycle(dd::IMAS.dd, par::FUSEparameters__ActorThermalCycle, act::ParametersAllActors; kw...) logging_actor_init(ActorThermalCycle) par = par(kw...) - return ActorThermalCycle(dd, par,act.ActorHeatTransfer) + return ActorThermalCycle(dd, par, act.ActorHeatTransfer) end function _step(actor::ActorThermalCycle) From dcf0b7f57c45118407f5d65a277378bbfd78434b Mon Sep 17 00:00:00 2001 From: TimSlendebroek <32385057+TimSlendebroek@users.noreply.github.com> Date: Thu, 16 Mar 2023 15:41:47 -0700 Subject: [PATCH 7/7] redo ActorThermalCycle constructor --- src/actors/balance_plant/thermal_cycle_actor.jl | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/actors/balance_plant/thermal_cycle_actor.jl b/src/actors/balance_plant/thermal_cycle_actor.jl index bf9c37ae5..3a94aac67 100644 --- a/src/actors/balance_plant/thermal_cycle_actor.jl +++ b/src/actors/balance_plant/thermal_cycle_actor.jl @@ -24,7 +24,12 @@ end mutable struct ActorThermalCycle <: FacilityAbstractActor dd::IMAS.dd par::FUSEparameters__ActorThermalCycle - par_ActorHeatTransfer::FUSEparameters__ActorHeatTransfer + act::ParametersAllActors + function ActorThermalCycle(dd::IMAS.dd, par::FUSEparameters__ActorThermalCycle, act::ParametersAllActors; kw...) + logging_actor_init(ActorThermalCycle) + par = par(kw...) + return new(dd, par, act) + end end """ @@ -44,12 +49,6 @@ function ActorThermalCycle(dd::IMAS.dd, act::ParametersAllActors; kw...) return actor end -function ActorThermalCycle(dd::IMAS.dd, par::FUSEparameters__ActorThermalCycle, act::ParametersAllActors; kw...) - logging_actor_init(ActorThermalCycle) - par = par(kw...) - return ActorThermalCycle(dd, par, act.ActorHeatTransfer) -end - function _step(actor::ActorThermalCycle) dd = actor.dd par = actor.par @@ -62,7 +61,7 @@ function _step(actor::ActorThermalCycle) bop.power_cycle_type = string(par.power_cycle_type) bop_thermal = bop.thermal_cycle - ihts_par = actor.par_ActorHeatTransfer + ihts_par = actor.act.ActorHeatTransfer blanket_power = @ddtime(bop.heat_transfer.wall.heat_load) breeder_power = @ddtime(bop.heat_transfer.breeder.heat_load)