Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions process/buildings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def run(self, output: bool = False):
# Calculate building areas and volumes

if buildings_variables.i_bldgs_size == 1:
# STEP building estimates
# Updated building estimates
self.bldgs_sizes(output, tf_radial_dim, tf_vertical_dim)

else:
Expand Down Expand Up @@ -831,7 +831,7 @@ def bldgs_sizes(self, output, tf_radial_dim, tf_vertical_dim):
# As proposed by R. Gowland, based on assessment of 18 existing fission power plants:
# turbine hall size is largely independent of plant output power.
# The default footprint used here represents a weighted mean of those plants
# and the design of a Steam Rankine cycle turbine building suitable for STEP,
# and the design of a Steam Rankine cycle turbine building,
# produced by Morsons as part of the Year 1 work.
turbine_hall_area = (
buildings_variables.turbine_hall_l * buildings_variables.turbine_hall_w
Expand Down
9 changes: 2 additions & 7 deletions process/caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,8 @@ def call_models(self, xc):
---- | ------
0 | 1990 costs model
1 | 2015 Kovari model
2 | 2019 STEP model
2 | Custom model
"""
if ft.cost_variables.cost_model == 0:
self.models.costs.run(output=False)
elif ft.cost_variables.cost_model == 1:
self.models.costs_2015.run(output=False)
elif ft.cost_variables.cost_model == 2:
self.models.costs_step.run()
self.models.costs.run()

# FISPACT and LOCA model (not used)- removed
1,312 changes: 607 additions & 705 deletions process/costs.py

Large diffs are not rendered by default.

19 changes: 4 additions & 15 deletions process/costs_2015.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def __init__(self):
self.outfile = constants.nout

# Initialise module variables
self.ip = AnnotatedVariable(float, 0.0, docstring="", units="")
self.ofile = AnnotatedVariable(float, 0.0, docstring="", units="")
self.total_costs = AnnotatedVariable(float, 0.0, docstring="", units="")
self.mean_electric_output = AnnotatedVariable(
Expand All @@ -33,7 +32,6 @@ def __init__(self):
float, 0.0, docstring="", units=""
)
self.maintenance = AnnotatedVariable(float, 0.0, docstring="", units="")
self.ip = AnnotatedVariable(float, 0.0, docstring="", units="")
self.ofile = AnnotatedVariable(float, 0.0, docstring="", units="")
self.total_costs = AnnotatedVariable(float, 0.0, docstring="", units="")

Expand Down Expand Up @@ -85,7 +83,7 @@ def __init__(self):
units="",
)

def run(self, output: bool):
def run(self):
"""
Cost accounting for a fusion power plant
author: J Morris, CCFE, Culham Science Centre
Expand All @@ -94,7 +92,6 @@ def run(self, output: bool):
This routine performs the cost accounting for a fusion power plant.
PROCESS Costs Paper (M. Kovari, J. Morris)
"""
self.ip = int(output)
self.outfile = self.outfile

# ###############################################
Expand Down Expand Up @@ -176,7 +173,7 @@ def run(self, output: bool):
if (abs(cost_variables.concost) > 9.99e99) or (
cost_variables.concost != cost_variables.concost
):
self.write_costs_to_output()
self.output()

for i in range(100):
# noqa: E741
Expand All @@ -196,14 +193,6 @@ def run(self, output: bool):

return

# Output costs #
# ###############

if (self.ip == 0) or (cost_variables.output_costs == 0):
return

self.write_costs_to_output()

def calc_fwbs_costs(self):
"""
Function to calculate the cost of the first wall, blanket and shield
Expand Down Expand Up @@ -232,7 +221,7 @@ def calc_fwbs_costs(self):
tail_li6 = feed_li6 * 0.75e0

# Built-in test
if (self.ip == 1) and (global_variables.run_tests == 1):
if global_variables.run_tests == 1:
product_li6 = 0.3
feed_to_product_mass_ratio = (product_li6 - tail_li6) / (
feed_li6 - tail_li6
Expand Down Expand Up @@ -383,7 +372,7 @@ def calc_fwbs_costs(self):
for j in range(21, 26):
self.s_cost[26] = self.s_cost[26] + self.s_cost[j]

def write_costs_to_output(self):
def output(self):
"""
Function to output the costs calculations
author: J Morris, CCFE, Culham Science Centre
Expand Down
5 changes: 3 additions & 2 deletions process/ife.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def run(self, output: bool):
# write to output file
if output:
# Costs
self.costs.costs(output=True)
self.costs.run()
self.costs.output()

# Plant availability
self.availability.avail(output=True)
Expand Down Expand Up @@ -118,4 +119,4 @@ def run(self, output: bool):
self.availability.avail(output=False)

# Costs
self.costs.costs(output=False)
self.costs.run()
51 changes: 37 additions & 14 deletions process/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
Box file F/MI/PJK/PROCESS and F/PL/PJK/PROCESS (15/01/96 to 24/01/12)
Box file T&M/PKNIGHT/PROCESS (from 24/01/12)
"""

from typing import Protocol
from process import fortran
from process.buildings import Buildings
from process.costs import Costs
Expand Down Expand Up @@ -92,7 +94,6 @@
from process.water_use import WaterUse
from process.sctfcoil import Sctfcoil

from process.fortran import cost_variables

os.environ["PYTHON_PROCESS_ROOT"] = os.path.join(os.path.dirname(__file__))

Expand Down Expand Up @@ -200,7 +201,7 @@ def run_mode(self):
self.run = VaryRun(self.args.varyiterparamsconfig, self.args.solver)
else:
self.run = SingleRun(self.args.input, self.args.solver)
self.run.run()
self.run.run()

def post_process(self):
"""Perform post-run actions, like plotting the mfile."""
Expand Down Expand Up @@ -252,13 +253,11 @@ def __init__(self, config_file, solver="vmcon"):
# Store the absolute path to the config file immediately: various
# dir changes happen in old run_process code
self.config_file = Path(config_file).resolve()
self.run(solver)
self.solver = solver

def run(self, solver):
def run(self):
"""Perform a VaryRun by running multiple SingleRuns.

:param solver: which solver to use, as specified in solver.py
:type solver: str
:raises FileNotFoundError: if input file doesn't exist
"""
# The input path for the varied input file
Expand Down Expand Up @@ -300,7 +299,7 @@ def run(self, solver):
# TODO Don't do this; remove stop statements from Fortran and
# handle error codes
# Run process on an IN.DAT file
config.run_process(input_path, solver)
config.run_process(input_path, self.solver)

check_input_error(wdir=wdir)

Expand Down Expand Up @@ -545,11 +544,18 @@ def validate_user_model(self):
Ensures that the corresponding model variable in Models is defined
and that any relevant switches are set correctly.
"""
# try and get costs model
self.models.costs

if cost_variables.cost_model == 2 and self.models.costs_step is None:
raise NotImplementedError(
f"cost_model = {cost_variables.cost_model} and costs_step = {self.models.costs_step}. Please provide cost model or change switch value."
)

class CostsProtocol(Protocol):
"""Protocol layout for costs models"""

def run(self):
"""Run the model"""

def output(self):
"""write model output"""


class Models:
Expand All @@ -564,7 +570,9 @@ def __init__(self):

This also initialises module variables in the Fortran for that module.
"""
self.costs_step = None
self._costs_custom = None
self._costs_1990 = Costs()
self._costs_2015 = Costs2015()
self.cs_fatigue = CsFatigue()
self.pfcoil = PFCoil(cs_fatigue=self.cs_fatigue)
self.power = Power()
Expand All @@ -579,7 +587,6 @@ def __init__(self):
self.vacuum = Vacuum()
self.water_use = WaterUse()
self.pulse = Pulse()
self.costs = Costs()
self.ife = IFE(availability=self.availability, costs=self.costs)
self.plasma_profile = PlasmaProfile()
self.fw = Fw()
Expand All @@ -596,12 +603,28 @@ def __init__(self):
hcpb=self.ccfe_hcpb,
current_drive=self.current_drive,
)
self.costs_2015 = Costs2015()
self.physics = Physics(
plasma_profile=self.plasma_profile, current_drive=self.current_drive
)
self.dcll = DCLL(blanket_library=self.blanket_library)

@property
def costs(self) -> CostsProtocol:
if fortran.cost_variables.cost_model == 0:
return self._costs_1990
if fortran.cost_variables.cost_model == 1:
return self._costs_2015
if fortran.cost_variables.cost_model == 2:
if self._costs_custom is not None:
return self._costs_custom
raise ValueError("Custom costs model not initialised")
# Probably overkill but makes typing happy
raise ValueError("Unknown costs model")

@costs.setter
def costs(self, value: CostsProtocol):
self._costs_custom = value


def main(args=None):
"""Run Process.
Expand Down
11 changes: 3 additions & 8 deletions process/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@ def write(models, outfile):
# ---- | ------
# 0 | 1990 costs model
# 1 | 2015 Kovari model
# 2 | 2019 STEP model

if ft.cost_variables.cost_model == 0:
models.costs.run(output=True)
elif ft.cost_variables.cost_model == 1:
models.costs_2015.run(output=True)
elif ft.cost_variables.cost_model == 2:
models.costs_step.output()
# 2 | Custom model
models.costs.run()
models.costs.output()

# Availability model
models.availability.run(output=True)
Expand Down
5 changes: 3 additions & 2 deletions process/stellarator.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def run(self, output: bool):
"""

if output:
self.costs.costs(output=True)
self.costs.run()
self.costs.output()
self.availability.run(output=True)
ph.outplas(self.outfile)
self.stigma()
Expand Down Expand Up @@ -154,7 +155,7 @@ def run(self, output: bool):
# TODO: should availability.run be called
# rather than availability.avail?
self.availability.avail(output=False)
self.costs.costs(output=False)
self.costs.run()

if any(numerics.icc == 91):
# This call is comparably time consuming..
Expand Down
28 changes: 14 additions & 14 deletions source/fortran/buildings_variables.f90
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module buildings_variables
!! hazardous waste storage building length, width, height (m)

integer :: i_bldgs_size
!! switch between routines estimating building sizes (0 = default; 1 = STEP-derived)
!! switch between routines estimating building sizes (0 = default; 1 = updated)

integer :: i_bldgs_v
!! switch to select verbose output for buildings (1 = verbose)
Expand Down Expand Up @@ -272,43 +272,43 @@ module buildings_variables


real(dp) :: a_reactor_bldg
!! Floor area of reactor building in m^2, used as GIFA in costs_step
!! Floor area of reactor building in m^2

real(dp) :: a_ee_ps_bldg
!! Floor area of electrical equipment and power supply building in m^2, used as GIFA in costs_step
!! Floor area of electrical equipment and power supply building in m^2

real(dp) :: a_aux_services_bldg
!! Floor area of auxiliary services building in m^2, used as GIFA in costs_step
!! Floor area of auxiliary services building in m^2

real(dp) :: a_hot_cell_bldg
!! Floor area of hot cell building in m^2, used as GIFA in costs_step
!! Floor area of hot cell building in m^2

real(dp) :: a_reactor_service_bldg
!! Floor area of reactor service building in m^2, used as GIFA in costs_step
!! Floor area of reactor service building in m^2

real(dp) :: a_service_water_bldg
!! Floor area of service water building in m^2, used as GIFA in costs_step
!! Floor area of service water building in m^2

real(dp) :: a_fuel_handling_bldg
!! Floor area of fuel handling and storage building in m^2, used as GIFA in costs_step
!! Floor area of fuel handling and storage building in m^2

real(dp) :: a_control_room_bldg
!! Floor area of controlroom building in m^2, used as GIFA in costs_step
!! Floor area of controlroom building in m^2

real(dp) :: a_ac_ps_bldg
!! Floor area of AC power supply building in m^2, used as GIFA in costs_step
!! Floor area of AC power supply building in m^2

real(dp) :: a_admin_bldg
!! Floor area of admin building in m^2, used as GIFA in costs_step
!! Floor area of admin building in m^2

real(dp) :: a_site_service_bldg
!! Floor area of site service building in m^2, used as GIFA in costs_step
!! Floor area of site service building in m^2

real(dp) :: a_cryo_inert_gas_bldg
!! Floor area of cryogenics and inert gas storage building in m^2, used as GIFA in costs_step
!! Floor area of cryogenics and inert gas storage building in m^2

real(dp) :: a_security_bldg
!! Floor area of security building in m^2, used as GIFA in costs_step
!! Floor area of security building in m^2


contains
Expand Down
6 changes: 3 additions & 3 deletions source/fortran/physics_variables.f90
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ module physics_variables
!! high Z ion density (/m3)

real(dp) :: gradient_length_ne
!! Max. normalized gradient length in el. density (ipedestal==0 only)
!! Max. normalized gradient length in el. density (ipedestal==0 only)

real(dp) :: gradient_length_te
!! Max. normalized gradient length in el. temperature (ipedestal==0 only)
Expand Down Expand Up @@ -386,7 +386,7 @@ module physics_variables
integer :: iradloss
!! switch for radiation loss term usage in power balance (see User Guide):
!!
!! - =0 total power lost is scaling power plus radiation
!! - =0 total power lost is scaling power plus radiation
!! - =1 total power lost is scaling power plus core radiation only
!! - =2 total power lost is scaling power only, with no additional
!! allowance for radiation. This is not recommended for power plant models.
Expand Down Expand Up @@ -513,7 +513,7 @@ module physics_variables
!! - =6 use input kappa, triang to calculate 95% values based on MAST scaling (ST)
!! - =7 use input kappa95, triang95 to calculate separatrix values based on fit to FIESTA (ST)
!! - =8 use input kappa, triang to calculate 95% values based on fit to FIESTA (ST)
!! - =9 set kappa to the natural elongation value (PROCESS-STEP issue #70), triang input
!! - =9 set kappa to the natural elongation value, triang input
!! - =10 set kappa to maximum stable value at a given aspect ratio (2.6<A<3.6)), triang input (#1399)
!! - =11 set kappa Menard 2016 aspect-ratio-dependent scaling, triang input (#1439)

Expand Down
Loading