From e47c5409afe678e29471ecf9418fac2a72103734 Mon Sep 17 00:00:00 2001 From: james <81617086+je-cook@users.noreply.github.com> Date: Fri, 14 Nov 2025 08:59:31 +0000 Subject: [PATCH 1/5] move to modern build system --- .gitignore | 1 + pyproject.toml | 220 +++++++++++++++++++++++++++++++++++++++++++ requirements_dev.txt | 15 --- ruff.toml | 78 --------------- setup.py | 53 ----------- 5 files changed, 221 insertions(+), 146 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements_dev.txt delete mode 100644 ruff.toml delete mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 51e6de487d..fcb3136114 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,4 @@ env-fork !tests/integration/data/large_tokamak_SIG_TF.json *.html !documentation/**/*.html +process/_version.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..1565bf3fb8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,220 @@ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[tool.hatch.version] +source = "vcs" +fallback-version = "0.0.0" + +[tool.hatch.build.hooks.vcs] +version-file = "process/_version.py" + +[tool.hatch.metadata] +allow-direct-references = true # remove after reference published + +[project] +name = "process" +authors = [{ name = "UKAEA" }] +description = "Power Reactor Optimisation Code for Environmental and Safety Studies" +readme = "README.md" +requires-python = ">=3.10" +license = "MIT" +dynamic = ["version"] +dependencies = [ + "numpy>=1.23", + "scipy>=1.10", + "cvxpy~=1.7.3", + "osqp>=1.0", + "pandas>=2.0", + "numba>=0.57", + "PyVMCON>=2.4.0,<2.5.0", + "CoolProp>=6.4", + "matplotlib>=2.1.1", + "seaborn>=0.12.2", + "tabulate", + ] +keywords = [] # TODO +classifiers = [ + "Programming Language :: Python", + "Development Status :: 4 - Beta", + "Natural Language :: English", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Scientific/Engineering :: Physics", +] + +[project.urls] +Homepage = "https://www.ukaea.org/service/process/" +Source = "https://github.com/ukaea/process" +Documentation = "https://ukaea.github.io/PROCESS" +Issues = "https://github.com/ukaea/process/issues" + +[project.optional-dependencies] +test = [ + "pytest>=5.4.1", + "requests>=2.30", + "testbook>=0.4", + "pytest-cov>=3.0.0", + "pytest-xdist>=2.5.0" +] +examples = ["pillow>=5.1.0", "jupyter==1.0.0", "pdf2image==1.16.0"] +plotly = ["plotly>=5.15.0,<6"] +docs = [ + "mkdocs>=1.1", + "mkdocs-material>=4.6.3", + "mkdocs-git-revision-date-localized-plugin >= 1.2", + "mkdocs-glightbox >= 0.3.4", + "pymdown-extensions>=6.3", + "bokeh>=3.4.0,<4", + "mkdocstrings==0.18.0", + "Jinja2>=3.0", + "mkdocs-jupyter>=0.24", +] +lint = ["pre-commit>=2.16.0", "ruff==0.9.3", "ty"] +all = ["process[test,docs,lint,examples,plotly]"] + +[tool.hatch.build.targets.wheel] +artifacts = [ + "process/data/lz_non_corona_14_elements/*.dat", + "process/io/*.png" +] + +[tool.hatch.envs.default] +features = ["dev", "test", "docs", "lint"] + +[tool.hatch.envs.test] +features = ["test"] +[[tool.hatch.envs.test.matrix]] +python = ["3.10", "3.11", "3.12", "3.13"] +[tool.hatch.envs.test.scripts] +tests = "pytest {args:tests}" +tests-cov = "pytest --cov process --cov-report html:htmlcov --cov-report xml {args:tests}" +tests-cov-private = "pytest --private --cov process --cov-report html:htmlcov --cov-report xml {args:tests}" + +[tool.hatch.envs.docs] +features = ["docs"] +[tool.hatch.envs.docs.scripts] +build = "mkdocs build" +serve = "mkdocs serve" +deploy = "mkdocs gh-deploy" + +[tool.hatch.envs.lint] +detached = true # Don't inherit from default (does not download project dependencies) +dependencies = ["pre-commit", "ruff", "ty"] + +[tool.hatch.envs.lint.scripts] +fmt = ["pre-commit run --all-files --hook-stage manual"] + +[tool.coverage.report] +exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"] +"omit" = ["process/_version.py"] + +[tool.pytest.ini_options] +addopts = "--strict-markers -r fEX" + +[tool.ty.terminal] +output-format = "concise" + +[tool.ruff] +target-version = "py310" +line-length = 89 +output-format = "concise" +extend-exclude = ["env", ".env"] + +[tool.ruff.format] +preview = true + +[tool.ruff.lint.per-file-ignores] +# Tests can use magic values, assertions, and relative imports +"tests/**" = ["ARG"] + +[tool.ruff.lint.isort] +known-first-party = ["process"] + +[tool.ruff.lint.flake8-tidy-imports] +ban-relative-imports = "all" + +[tool.ruff.lint.pydocstyle] +convention = "numpy" + +[tool.ruff.lint.flake8-copyright] +notice-rgx = "(?i)# SPDX-FileCopyrightText:\\s\\d{4}(-(\\d{4}|present))*" + +[tool.ruff.lint.mccabe] +max-complexity = 12 + +[tool.ruff.lint.pylint] +# These should be made stricter +max-args = 17 +max-locals = 17 + +[tool.ruff.lint] +preview = true +extend-select = [ + "A", + "ARG", + "ASYNC", + "B", + "BLE", + "C4", + "COM", + "DTZ", + "EXE", + "F", + "FA", + "FLY", + "FURB", + "G", + "I", + "ICN", + "INT", + "ISC", + "LOG", + "N", + "NPY", + "PD", + "PERF", + "PGH", + "PIE", + "PYI", + "Q", + "RET", + "RSE", + "RUF", + "SIM", + "SLF", + "SLOT", + "T10", + "TID", + "UP", + "W", + "YTT", +] +ignore = ["COM812", "FBT", "G004", "PD901"] + +[tool.ruff.lint.pep8-naming] +ignore-names = [ + "*PROCESS*", + "*Bt*", + "*Bp*", + "*keV*", + "*MPa*", + "*H*", + "*T*", + "*D*", + "*He*", + "*Be*", + "C", + "N", + "O", + "Ne", + "Si", + "Ar", + "Fe", + "Ni", + "Kr", + "Xe", + "W", +] diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index 4864998084..0000000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,15 +0,0 @@ -# requirements_dev.txt includes the dependencies for running scripts on the CI -# e.g. documentation building and quality assurance (pre-commit). - -pre-commit>=2.16.0 -pytest-cov>=3.0.0 -pytest-xdist>=2.5.0 -mkdocs>=1.1 -mkdocs-material>=4.6.3 -mkdocs-git-revision-date-localized-plugin >= 1.2 -mkdocs-glightbox >= 0.3.4 -pymdown-extensions>=6.3 -bokeh>=3.4.0,<4 -mkdocstrings==0.18.0 -Jinja2>=3.0 -mkdocs-jupyter>=0.24 diff --git a/ruff.toml b/ruff.toml deleted file mode 100644 index 9db7a11a87..0000000000 --- a/ruff.toml +++ /dev/null @@ -1,78 +0,0 @@ -extend-exclude = ["env", ".env"] -target-version = "py310" - -[lint] -extend-select = [ - "A", - "ARG", - "ASYNC", - "B", - "BLE", - "C4", - "COM", - "DTZ", - "EXE", - "F", - "FA", - "FLY", - "FURB", - "G", - "I", - "ICN", - "INT", - "ISC", - "LOG", - "N", - "NPY", - "PD", - "PERF", - "PGH", - "PIE", - "PYI", - "Q", - "RET", - "RSE", - "RUF", - "SIM", - "SLF", - "SLOT", - "T10", - "TID", - "UP", - "W", - "YTT", -] - -ignore = ["COM812", "FBT", "G004", "PD901"] - -[lint.per-file-ignores] -"tests/*" = ["ARG"] - -[lint.pep8-naming] -ignore-names = [ - "*PROCESS*", - "*Bt*", - "*Bp*", - "*keV*", - "*MPa*", - "*H*", - "*T*", - "*D*", - "*He*", - "*Be*", - "C", - "N", - "O", - "Ne", - "Si", - "Ar", - "Fe", - "Ni", - "Kr", - "Xe", - "W", -] - - -[format] -preview = true diff --git a/setup.py b/setup.py deleted file mode 100644 index 12a10b6379..0000000000 --- a/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -import os -import platform -import site - -from setuptools import find_packages, setup - -MODULE_NAME = "process" -_install_loc = os.path.join(site.getsitepackages()[0], MODULE_NAME) -EXTRA_ARGS = [] -if platform.system() == "Darwin": - EXTRA_ARGS = ["-Wl,-rpath," + os.path.join(_install_loc, "lib")] - -setup_kwargs = { - "name": MODULE_NAME, - "version": "3.2.1", - "description": ( - "Power Reactor Optimisation Code for Environmental and Safety Studies" - ), - "url": "https://ccfe.ukaea.uk/resources/process/", - "author": "UKAEA", - "packages": find_packages(), - "package_dir": {"process": "process"}, - "package_data": { - "process": ["data/lz_non_corona_14_elements/*"], - "process.data.impuritydata": ["*"], - "process.io": ["*.png"], - }, - "test_suite": "pytest", - "python_requires": ">=3.10", - "install_requires": [ - "numpy>=1.23", - "scipy>=1.10", - "cvxpy~=1.7.3", - "osqp>=1.0", - "pandas>=2.0", - "numba>=0.57", - "PyVMCON>=2.4.0,<2.5.0", - "CoolProp>=6.4", - "matplotlib>=2.1.1", - "seaborn>=0.12.2", - "tabulate", - ], - "extras_require": { - "test": ["pytest>=5.4.1", "requests>=2.30", "testbook>=0.4"], - "examples": ["pillow>=5.1.0", "jupyter==1.0.0", "pdf2image==1.16.0"], - "plotly": ["plotly>=5.15.0,<6"], - }, - "entry_points": {"console_scripts": ["process=process.main:main"]}, - "extra_link_args": EXTRA_ARGS, -} - -if __name__ == "__main__": - setup(**setup_kwargs) From b4a499cc15091204bde8fe7155fa03a958666fa3 Mon Sep 17 00:00:00 2001 From: james <81617086+je-cook@users.noreply.github.com> Date: Fri, 14 Nov 2025 09:01:54 +0000 Subject: [PATCH 2/5] remove references to requirements.txt --- .github/workflows/process.yml | 26 ++++++++----------------- documentation/development/pre-commit.md | 2 +- documentation/development/testing.md | 2 +- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/.github/workflows/process.yml b/.github/workflows/process.yml index 97e8785560..77117a597c 100644 --- a/.github/workflows/process.yml +++ b/.github/workflows/process.yml @@ -21,8 +21,7 @@ jobs: - name: Install PROCESS # Editable install to match default install run: | - pip install -e '.[test, examples]' - pip install -r requirements_dev.txt + pip install -e '.[lint, test, examples]' - name: Run unit tests run: | pytest --cov=process tests/unit -v \ @@ -44,8 +43,7 @@ jobs: - name: Install PROCESS # Editable install to match default install run: | - pip install -e '.[test]' - pip install -r requirements_dev.txt + pip install -e '.[docs, test, lint]' - name: Install poppler run: | sudo apt update @@ -63,8 +61,7 @@ jobs: - name: Install PROCESS # Editable install to match default install run: | - pip install -e '.[test, examples]' - pip install -r requirements_dev.txt + pip install -e '.[docs, test, lint, examples]' - name: Install poppler run: | sudo apt update @@ -91,8 +88,7 @@ jobs: - name: Install PROCESS # Editable install to match default install run: | - pip install -e '.[test]' - pip install -r requirements_dev.txt + pip install -e '.[docs, test, lint]' - name: Allow git commands to be run run: git config --global --add safe.directory '*' - name: Run regression tests @@ -107,9 +103,7 @@ jobs: with: python-version: '3.10' - name: Install PROCESS - run: pip install -e . - - name: Install dev dependencies - run: pip install -r requirements_dev.txt + run: pip install -e '.[lint, docs, test]' - name: Run regression input files run: python tracking/run_tracking_inputs.py run tests/regression/input_files - name: Move other files @@ -133,7 +127,7 @@ jobs: with: python-version: '3.10' - name: Install dev dependencies - run: pip install -r requirements_dev.txt + run: pip install '.[lint]' - name: Run pre-commit run: pre-commit run --all-files @@ -152,9 +146,7 @@ jobs: with: python-version: '3.10' - name: Install PROCESS - run: pip install -e . - - name: Install dev dependencies - run: pip install -r requirements_dev.txt + run: pip install -e '.[test, docs, lint]' - name: Setup SSH identity uses: webfactory/ssh-agent@v0.7.0 with: @@ -205,9 +197,7 @@ jobs: with: python-version: '3.10' - name: Install PROCESS - run: pip install -e . - - name: Install dev dependencies - run: pip install -r requirements_dev.txt + run: pip install -e '.[test, lint, docs]' - run: python scripts/vardes.py - run: git config --global --add safe.directory '*' - name: Download STF_TF.json files diff --git a/documentation/development/pre-commit.md b/documentation/development/pre-commit.md index 9a5d78d3f0..bb677bc027 100755 --- a/documentation/development/pre-commit.md +++ b/documentation/development/pre-commit.md @@ -43,7 +43,7 @@ pre-commit -h If pre-commit is not installed, then it can be installed by running: ```bash -pip install -r requirements_dev.txt +pip install '.[lint]' ``` in your environment, which will install all development dependencies including pre-commit. diff --git a/documentation/development/testing.md b/documentation/development/testing.md index 056287eb93..9eb2a91f8e 100644 --- a/documentation/development/testing.md +++ b/documentation/development/testing.md @@ -98,7 +98,7 @@ For a guide on contributing code to PROCESS, see `CONTRIBUTING.md`. Running the entire test suite can be time consuming, as by default it runs on a single core. `pytest-xdist` allows `pytest` tests to be distributed across multiple cores to speed up testing. -`pytest-xdist` should be installed already (included in `requirements.txt`), but if not it can be installed manually with: +`pytest-xdist` should be installed already (included in `test` extras; `pip install ".[test]"`), but if not it can be installed manually with: ```bash pip install pytest-xdist From 1311a0d2d2a89a081e56fa36f47802b22bca658e Mon Sep 17 00:00:00 2001 From: james <81617086+je-cook@users.noreply.github.com> Date: Fri, 14 Nov 2025 10:37:48 +0000 Subject: [PATCH 3/5] forgot entry point --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 1565bf3fb8..5e2a0544aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,6 +75,9 @@ docs = [ lint = ["pre-commit>=2.16.0", "ruff==0.9.3", "ty"] all = ["process[test,docs,lint,examples,plotly]"] +[project.scripts] +process = "process.main:main" + [tool.hatch.build.targets.wheel] artifacts = [ "process/data/lz_non_corona_14_elements/*.dat", From e4f86472fd4f987bd69d92422479ccf00c06f6b6 Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Thu, 18 Dec 2025 11:17:28 +0000 Subject: [PATCH 4/5] change setup.py to pyproject.toml --- process/data_structure/__init__.py | 2 +- pyproject.toml | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/process/data_structure/__init__.py b/process/data_structure/__init__.py index 034764b200..b84550ac61 100644 --- a/process/data_structure/__init__.py +++ b/process/data_structure/__init__.py @@ -1,4 +1,4 @@ -from . import ( +from process.data_structure import ( blanket_library, build_variables, buildings_variables, diff --git a/pyproject.toml b/pyproject.toml index 5e2a0544aa..a732b79fb2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,9 +9,6 @@ fallback-version = "0.0.0" [tool.hatch.build.hooks.vcs] version-file = "process/_version.py" -[tool.hatch.metadata] -allow-direct-references = true # remove after reference published - [project] name = "process" authors = [{ name = "UKAEA" }] @@ -33,7 +30,7 @@ dependencies = [ "seaborn>=0.12.2", "tabulate", ] -keywords = [] # TODO +keywords = ['fusion', 'optimisation'] classifiers = [ "Programming Language :: Python", "Development Status :: 4 - Beta", @@ -59,7 +56,7 @@ test = [ "pytest-cov>=3.0.0", "pytest-xdist>=2.5.0" ] -examples = ["pillow>=5.1.0", "jupyter==1.0.0", "pdf2image==1.16.0"] +examples = ["jupyter==1.0.0"] plotly = ["plotly>=5.15.0,<6"] docs = [ "mkdocs>=1.1", From 12dd4f2e0f194521eb0bc6f995775534414be7eb Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Tue, 16 Dec 2025 10:27:52 +0000 Subject: [PATCH 5/5] pre-commit changes --- .../2nd_gen_rebco_critical_surface.py | 4 +- .../bi_2212_critical_surface.py | 4 +- .../plotting_scripts/d_shaped_fw_area.py | 12 +- .../durham_nbti_critical_surface.py | 4 +- .../durham_rebco_critical_surface.py | 4 +- .../eutf4_nb3sn_critical_surface.py | 4 +- .../hazelton_zhai_rebco_critical_surface.py | 4 +- .../old_empirical_nbti_critical_surface.py | 4 +- .../plotting_scripts/profile_pedestal_plot.py | 4 +- .../western_nb3sn_critical_surface.py | 4 +- process/availability.py | 4 +- process/blanket_library.py | 76 +-- process/build.py | 17 +- process/buildings.py | 21 +- process/confinement_time.py | 8 +- process/constants.py | 3 +- process/constraints.py | 9 +- process/costs.py | 11 +- process/costs_2015.py | 40 +- process/current_drive.py | 14 +- process/data_structure/blanket_library.py | 101 ++-- process/data_structure/build_variables.py | 189 +++--- process/data_structure/buildings_variables.py | 307 +++++----- process/data_structure/ccfe_hcpb_module.py | 31 +- .../data_structure/constraint_variables.py | 171 +++--- process/data_structure/cost_variables.py | 313 +++++----- .../data_structure/current_drive_variables.py | 169 +++--- process/data_structure/dcll_variables.py | 67 +- process/data_structure/divertor_variables.py | 37 +- process/data_structure/fwbs_variables.py | 391 ++++++------ process/data_structure/global_variables.py | 27 +- .../heat_transport_variables.py | 101 ++-- process/data_structure/ife_variables.py | 229 +++---- .../impurity_radiation_module.py | 27 +- .../data_structure/neoclassics_variables.py | 47 +- process/data_structure/numerics.py | 87 +-- process/data_structure/pf_power_variables.py | 23 +- process/data_structure/pfcoil_variables.py | 242 ++++---- process/data_structure/physics_variables.py | 572 +++++++++--------- .../primary_pumping_variables.py | 23 +- process/data_structure/pulse_variables.py | 6 +- process/data_structure/rebco_variables.py | 45 +- process/data_structure/reinke_variables.py | 6 +- process/data_structure/scan_variables.py | 19 +- .../data_structure/stellarator_variables.py | 55 +- process/data_structure/structure_variables.py | 6 +- .../superconducting_tf_coil_variables.py | 119 ++-- process/data_structure/tfcoil_variables.py | 433 ++++++------- process/data_structure/times_variables.py | 31 +- process/data_structure/vacuum_variables.py | 41 +- .../data_structure/water_usage_variables.py | 27 +- process/dcll.py | 12 +- process/final.py | 6 +- process/fusion_reactions.py | 9 +- process/fw.py | 4 +- process/geometry/plasma_geometry.py | 3 +- process/geometry/shield_geometry.py | 16 +- process/geometry/tfcoil_geometry.py | 30 +- process/ife.py | 172 ++---- process/impurity_radiation.py | 8 +- process/init.py | 23 +- process/input.py | 92 +-- process/io/configuration.py | 4 +- process/io/costs_bar.py | 8 +- process/io/data_structure_dicts.py | 7 +- process/io/mfile.py | 9 +- process/io/mfile2dict.py | 201 +++--- process/io/mfile_to_csv.py | 6 +- process/io/plot_plotly_sankey.py | 4 +- process/io/plot_proc.py | 290 ++++----- process/io/plot_radial_build.py | 4 - process/io/plot_scans.py | 42 +- process/io/plot_solutions.py | 8 +- process/io/plot_stress_tf.py | 48 +- process/io/process_config.py | 6 +- process/io/sankey_funcs.py | 13 +- process/io/variable_metadata.py | 4 +- process/io/write_new_in_dat.py | 4 +- process/iteration_variables.py | 28 +- process/main.py | 4 +- process/pfcoil.py | 69 +-- process/physics.py | 29 +- process/plasma_geometry.py | 16 +- process/power.py | 11 +- process/profiles.py | 3 +- process/quench.py | 4 +- process/resistive_tf_coil.py | 17 +- process/scan.py | 8 +- process/solver.py | 2 +- process/stellarator.py | 145 ++--- process/structure.py | 4 +- process/superconducting_tf_coil.py | 17 +- process/superconductors.py | 18 +- process/tf_coil.py | 33 +- process/vacuum.py | 34 +- scripts/vardes.py | 8 +- tests/integration/test_pfcoil_int.py | 8 +- tests/regression/regression_test_assets.py | 5 +- tests/unit/test_blanket_library.py | 8 +- tests/unit/test_buildings.py | 4 +- tests/unit/test_ccfe_hcpb.py | 20 +- tests/unit/test_coolprop_interface.py | 3 +- tests/unit/test_costs_1990.py | 4 +- tests/unit/test_costs_2015.py | 4 +- tests/unit/test_cryostat.py | 4 +- tests/unit/test_current_drive.py | 28 +- tests/unit/test_dcll.py | 40 +- tests/unit/test_fusion_reactions.py | 8 +- tests/unit/test_ife.py | 8 +- tests/unit/test_input.py | 5 +- tests/unit/test_mfile2dict.py | 24 +- tests/unit/test_neoclassics.py | 4 +- tests/unit/test_pfcoil.py | 12 +- tests/unit/test_physics.py | 38 +- tests/unit/test_plasma_profiles.py | 4 +- tests/unit/test_power.py | 8 +- tests/unit/test_pulse.py | 4 +- tests/unit/test_resistive_tf_coil.py | 4 +- tests/unit/test_sctfcoil.py | 6 +- tests/unit/test_stellarator.py | 4 +- tests/unit/test_superconductors.py | 4 +- tests/unit/test_tfcoil.py | 10 +- tests/unit/test_water_usage.py | 8 +- tracking/tracking_data.py | 4 +- 124 files changed, 2657 insertions(+), 3302 deletions(-) diff --git a/documentation/scripts/plotting_scripts/2nd_gen_rebco_critical_surface.py b/documentation/scripts/plotting_scripts/2nd_gen_rebco_critical_surface.py index 8d0456b667..89d45279de 100644 --- a/documentation/scripts/plotting_scripts/2nd_gen_rebco_critical_surface.py +++ b/documentation/scripts/plotting_scripts/2nd_gen_rebco_critical_surface.py @@ -46,9 +46,7 @@ # Convert the data to a format suitable for Plotly fig_plotly = go.Figure( - data=[ - go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis") - ] + data=[go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis")] ) # Update layout for better visualization diff --git a/documentation/scripts/plotting_scripts/bi_2212_critical_surface.py b/documentation/scripts/plotting_scripts/bi_2212_critical_surface.py index ec3694c094..fba4635c4f 100644 --- a/documentation/scripts/plotting_scripts/bi_2212_critical_surface.py +++ b/documentation/scripts/plotting_scripts/bi_2212_critical_surface.py @@ -45,9 +45,7 @@ # Convert the data to a format suitable for Plotly fig_plotly = go.Figure( - data=[ - go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis") - ] + data=[go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis")] ) # Update layout for better visualization diff --git a/documentation/scripts/plotting_scripts/d_shaped_fw_area.py b/documentation/scripts/plotting_scripts/d_shaped_fw_area.py index 590deea344..e66ce15b9b 100644 --- a/documentation/scripts/plotting_scripts/d_shaped_fw_area.py +++ b/documentation/scripts/plotting_scripts/d_shaped_fw_area.py @@ -140,16 +140,8 @@ "y": [ -(kappa.value * a.value + plasma_divertor_gap.value), -(kappa.value * a.value + plasma_divertor_gap.value), - -( - kappa.value * a.value - + plasma_divertor_gap.value - + divertor_height.value - ), - -( - kappa.value * a.value - + plasma_divertor_gap.value - + divertor_height.value - ), + -(kappa.value * a.value + plasma_divertor_gap.value + divertor_height.value), + -(kappa.value * a.value + plasma_divertor_gap.value + divertor_height.value), ], } ) diff --git a/documentation/scripts/plotting_scripts/durham_nbti_critical_surface.py b/documentation/scripts/plotting_scripts/durham_nbti_critical_surface.py index 477c3b4a17..728dc5d5be 100644 --- a/documentation/scripts/plotting_scripts/durham_nbti_critical_surface.py +++ b/documentation/scripts/plotting_scripts/durham_nbti_critical_surface.py @@ -47,9 +47,7 @@ # Convert the data to a format suitable for Plotly fig_plotly = go.Figure( - data=[ - go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis") - ] + data=[go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis")] ) # Update layout for better visualization diff --git a/documentation/scripts/plotting_scripts/durham_rebco_critical_surface.py b/documentation/scripts/plotting_scripts/durham_rebco_critical_surface.py index fa895a166b..9b1f69b0d5 100644 --- a/documentation/scripts/plotting_scripts/durham_rebco_critical_surface.py +++ b/documentation/scripts/plotting_scripts/durham_rebco_critical_surface.py @@ -47,9 +47,7 @@ # Convert the data to a format suitable for Plotly fig_plotly = go.Figure( - data=[ - go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis") - ] + data=[go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis")] ) # Update layout for better visualization diff --git a/documentation/scripts/plotting_scripts/eutf4_nb3sn_critical_surface.py b/documentation/scripts/plotting_scripts/eutf4_nb3sn_critical_surface.py index 41a5e61b73..8f2b9ad199 100644 --- a/documentation/scripts/plotting_scripts/eutf4_nb3sn_critical_surface.py +++ b/documentation/scripts/plotting_scripts/eutf4_nb3sn_critical_surface.py @@ -45,9 +45,7 @@ # Convert the data to a format suitable for Plotly fig_plotly = go.Figure( - data=[ - go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis") - ] + data=[go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis")] ) # Update layout for better visualization diff --git a/documentation/scripts/plotting_scripts/hazelton_zhai_rebco_critical_surface.py b/documentation/scripts/plotting_scripts/hazelton_zhai_rebco_critical_surface.py index 6241896819..65851f46af 100644 --- a/documentation/scripts/plotting_scripts/hazelton_zhai_rebco_critical_surface.py +++ b/documentation/scripts/plotting_scripts/hazelton_zhai_rebco_critical_surface.py @@ -49,9 +49,7 @@ # Convert the data to a format suitable for Plotly fig_plotly = go.Figure( - data=[ - go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis") - ] + data=[go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis")] ) # Update layout for better visualization diff --git a/documentation/scripts/plotting_scripts/old_empirical_nbti_critical_surface.py b/documentation/scripts/plotting_scripts/old_empirical_nbti_critical_surface.py index c68e8d953e..4d029acc2c 100644 --- a/documentation/scripts/plotting_scripts/old_empirical_nbti_critical_surface.py +++ b/documentation/scripts/plotting_scripts/old_empirical_nbti_critical_surface.py @@ -46,9 +46,7 @@ # Convert the data to a format suitable for Plotly fig_plotly = go.Figure( - data=[ - go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis") - ] + data=[go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis")] ) # Update layout for better visualization diff --git a/documentation/scripts/plotting_scripts/profile_pedestal_plot.py b/documentation/scripts/plotting_scripts/profile_pedestal_plot.py index 2c53fc89a2..e31b6f88e5 100644 --- a/documentation/scripts/plotting_scripts/profile_pedestal_plot.py +++ b/documentation/scripts/plotting_scripts/profile_pedestal_plot.py @@ -4,9 +4,7 @@ from bokeh.plotting import figure, output_file, save T0 = Slider(start=0.1, end=10, value=10.0, step=0.1, title="Plasma centre value | T0") -alpha = Slider( - start=0.01, end=10, value=2.0, step=0.01, title="Profile Index | alphan" -) +alpha = Slider(start=0.01, end=10, value=2.0, step=0.01, title="Profile Index | alphan") Trho = Slider(start=0.1, end=1, value=0.9, step=0.01, title="Pedestal position | Trho") Tped = Slider(start=0.01, end=10, value=2.0, step=0.01, title="Pedestal value | Tped") Tsep = Slider(start=0.1, end=10, value=0.5, step=0.1, title="Separatrix value | Tsep") diff --git a/documentation/scripts/plotting_scripts/western_nb3sn_critical_surface.py b/documentation/scripts/plotting_scripts/western_nb3sn_critical_surface.py index c83333e914..3844e95887 100644 --- a/documentation/scripts/plotting_scripts/western_nb3sn_critical_surface.py +++ b/documentation/scripts/plotting_scripts/western_nb3sn_critical_surface.py @@ -47,9 +47,7 @@ # Convert the data to a format suitable for Plotly fig_plotly = go.Figure( - data=[ - go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis") - ] + data=[go.Surface(z=j_scaling, x=temp_conductor, y=b_conductor, colorscale="Viridis")] ) # Update layout for better visualization diff --git a/process/availability.py b/process/availability.py index 6dd2259842..4caa6dc290 100644 --- a/process/availability.py +++ b/process/availability.py @@ -1356,9 +1356,7 @@ def cp_lifetime(): # Rem : only the TF maximum fluence is considered for now if tfv.i_tf_sup == 1: cplife = min( - ( - ctv.nflutfmax / (np.asarray(fwbsv.neut_flux_cp) * YEAR_SECONDS) - ).item(), + (ctv.nflutfmax / (np.asarray(fwbsv.neut_flux_cp) * YEAR_SECONDS)).item(), cv.life_plant, ) diff --git a/process/blanket_library.py b/process/blanket_library.py index fc16881d13..c43637a4f4 100644 --- a/process/blanket_library.py +++ b/process/blanket_library.py @@ -109,9 +109,7 @@ def component_half_height(self, icomponent: int): - build_variables.dz_vv_lower ) else: - raise ProcessValueError( - f"{icomponent=} is invalid, it must be either 0,1,2" - ) + raise ProcessValueError(f"{icomponent=} is invalid, it must be either 0,1,2") # Calculate component internal upper half-height (m) # If a double null machine then symmetric @@ -256,9 +254,7 @@ def elliptical_component(self, icomponent: int): r3 = r3 - build_variables.dr_shld_outboard # ... blanket (m) if icomponent == 0: - r3 = ( - r3 - build_variables.dr_shld_outboard - build_variables.dr_blkt_outboard - ) + r3 = r3 - build_variables.dr_shld_outboard - build_variables.dr_blkt_outboard # Calculate surface area, assuming 100% coverage if icomponent == 0: @@ -1782,8 +1778,8 @@ def thermo_hydraulic_model(self, output: bool): ) ( blanket_library.temp_fw_outboard_peak, - cf, - rhof, + _cf, + _rhof, blanket_library.mflow_fw_outboard_coolant_channel, ) = self.fw.fw_temp( output, @@ -2013,21 +2009,19 @@ def thermo_hydraulic_model(self, output: bool): ) # Mechanical pumping power for the blanket (MW) - heat_transport_variables.p_blkt_coolant_pump_mw = ( - self.coolant_pumping_power( - output=output, - i_liquid_breeder=1, - temp_coolant_pump_outlet=fwbs_variables.temp_blkt_coolant_in, - temp_coolant_pump_inlet=fwbs_variables.temp_blkt_coolant_out, - pres_coolant_pump_inlet=fwbs_variables.pres_blkt_coolant, - dpres_coolant=deltap_blkt, - mflow_coolant_total=blanket_library.mflow_blkt_coolant_total, - primary_coolant_switch=( - "Helium" if fwbs_variables.i_blkt_coolant_type == 1 else "Water" - ), - den_coolant=fwbs_variables.den_blkt_coolant, - label="Blanket", - ) + heat_transport_variables.p_blkt_coolant_pump_mw = self.coolant_pumping_power( + output=output, + i_liquid_breeder=1, + temp_coolant_pump_outlet=fwbs_variables.temp_blkt_coolant_in, + temp_coolant_pump_inlet=fwbs_variables.temp_blkt_coolant_out, + pres_coolant_pump_inlet=fwbs_variables.pres_blkt_coolant, + dpres_coolant=deltap_blkt, + mflow_coolant_total=blanket_library.mflow_blkt_coolant_total, + primary_coolant_switch=( + "Helium" if fwbs_variables.i_blkt_coolant_type == 1 else "Water" + ), + den_coolant=fwbs_variables.den_blkt_coolant, + label="Blanket", ) # Total mechanical pumping power (MW) @@ -2052,21 +2046,19 @@ def thermo_hydraulic_model(self, output: bool): ) # Mechanical pumping power for the blanket (MW) - heat_transport_variables.p_blkt_breeder_pump_mw = ( - self.coolant_pumping_power( - output=output, - i_liquid_breeder=2, - temp_coolant_pump_outlet=fwbs_variables.inlet_temp_liq, - temp_coolant_pump_inlet=fwbs_variables.outlet_temp_liq, - pres_coolant_pump_inlet=fwbs_variables.blpressure_liq, - dpres_coolant=deltap_bl_liq, - mflow_coolant_total=blanket_library.mfblkt_liq, - primary_coolant_switch=( - "Helium" if fwbs_variables.i_blkt_coolant_type == 1 else "Water" - ), - den_coolant=fwbs_variables.den_liq, - label="Liquid Metal Breeder/Coolant", - ) + heat_transport_variables.p_blkt_breeder_pump_mw = self.coolant_pumping_power( + output=output, + i_liquid_breeder=2, + temp_coolant_pump_outlet=fwbs_variables.inlet_temp_liq, + temp_coolant_pump_inlet=fwbs_variables.outlet_temp_liq, + pres_coolant_pump_inlet=fwbs_variables.blpressure_liq, + dpres_coolant=deltap_bl_liq, + mflow_coolant_total=blanket_library.mfblkt_liq, + primary_coolant_switch=( + "Helium" if fwbs_variables.i_blkt_coolant_type == 1 else "Water" + ), + den_coolant=fwbs_variables.den_liq, + label="Liquid Metal Breeder/Coolant", ) heat_transport_variables.htpmw_blkt_tot = ( @@ -2075,9 +2067,7 @@ def thermo_hydraulic_model(self, output: bool): ) if output: - po.oheadr( - self.outfile, "Summary of first wall and blanket thermohydraulics" - ) + po.oheadr(self.outfile, "Summary of first wall and blanket thermohydraulics") # FW po.osubhd(self.outfile, "First wall: ") @@ -2214,9 +2204,7 @@ def thermo_hydraulic_model(self, output: bool): fwbs_variables.i_blkt_liquid_breeder_type, ) if fwbs_variables.i_blkt_dual_coolant == 2: - po.ocmmnt( - self.outfile, "Dual-coolant BB, i.e. self-cooled breeder." - ) + po.ocmmnt(self.outfile, "Dual-coolant BB, i.e. self-cooled breeder.") po.ovarrf( self.outfile, "Inlet temperature of blanket liquid breeder (K)", diff --git a/process/build.py b/process/build.py index 0317324e3c..4a0bd4c859 100644 --- a/process/build.py +++ b/process/build.py @@ -388,9 +388,7 @@ def calculate_vertical_build(self, output: bool) -> None: vertical_build_upper - build_variables.dz_shld_lower ) - vertical_build_upper = ( - vertical_build_upper - build_variables.dz_vv_lower - ) + vertical_build_upper = vertical_build_upper - build_variables.dz_vv_lower po.obuild( self.outfile, "Vacuum vessel (and shielding)", @@ -2099,9 +2097,8 @@ def calculate_radial_build(self, output: bool) -> None: - fwbs_variables.f_a_fw_outboard_hcd ) ) - build_variables.a_fw_inboard = ( - build_variables.a_fw_inboard_full_coverage - * (1.0e0 - 2.0e0 * fwbs_variables.f_ster_div_single) + build_variables.a_fw_inboard = build_variables.a_fw_inboard_full_coverage * ( + 1.0e0 - 2.0e0 * fwbs_variables.f_ster_div_single ) else: # Single null configuration @@ -2113,9 +2110,8 @@ def calculate_radial_build(self, output: bool) -> None: - fwbs_variables.f_a_fw_outboard_hcd ) ) - build_variables.a_fw_inboard = ( - build_variables.a_fw_inboard_full_coverage - * (1.0e0 - fwbs_variables.f_ster_div_single) + build_variables.a_fw_inboard = build_variables.a_fw_inboard_full_coverage * ( + 1.0e0 - fwbs_variables.f_ster_div_single ) build_variables.a_fw_total = ( @@ -2224,8 +2220,7 @@ def calculate_radial_build(self, output: bool) -> None: radius, ]) elif ( - build_variables.i_tf_inside_cs == 1 - and tfcoil_variables.i_tf_bucking < 2 + build_variables.i_tf_inside_cs == 1 and tfcoil_variables.i_tf_bucking < 2 ): radius = radius + build_variables.dr_bore radial_build_data.append([ diff --git a/process/buildings.py b/process/buildings.py index 7fd186b3c6..7eec10e530 100644 --- a/process/buildings.py +++ b/process/buildings.py @@ -41,9 +41,7 @@ def run(self, output: bool = False): build_variables.dr_tf_outboard * 0.5e0 ) # inboard edge: inboard mid-leg radial position - half-thickness of inboard leg - tfri = build_variables.r_tf_inboard_mid - ( - build_variables.dr_tf_inboard * 0.5e0 - ) + tfri = build_variables.r_tf_inboard_mid - (build_variables.dr_tf_inboard * 0.5e0) # Find width, in radial dimension, of TF coil (m) tf_radial_dim = tfro - tfri @@ -318,9 +316,7 @@ def bldgs( buildings_variables.convol = buildings_variables.conv # Total volume of nuclear buildings - buildings_variables.volnucb = ( - vrci + rmbv + wsv + buildings_variables.triv + cryv - ) + buildings_variables.volnucb = vrci + rmbv + wsv + buildings_variables.triv + cryv # Output ! # !!!!!!!!! @@ -680,9 +676,9 @@ def bldgs_sizes(self, output, tf_radial_dim, tf_vertical_dim): hotcell_w = hotcell_l # external dimensions include same wall and roof thicknesses as reactor building - hotcell_area_ext = ( - hotcell_l + 2.0e0 * buildings_variables.reactor_wall_thk - ) * (hotcell_w + 2.0e0 * buildings_variables.reactor_wall_thk) + hotcell_area_ext = (hotcell_l + 2.0e0 * buildings_variables.reactor_wall_thk) * ( + hotcell_w + 2.0e0 * buildings_variables.reactor_wall_thk + ) hotcell_vol_ext = hotcell_area_ext * ( buildings_variables.hotcell_h + buildings_variables.reactor_roof_thk @@ -736,9 +732,7 @@ def bldgs_sizes(self, output, tf_radial_dim, tf_vertical_dim): magnet_pulse_vol = magnet_pulse_area * buildings_variables.magnet_pulse_h # Total power buildings areas and volumes - power_buildings_area = ( - hcd_building_area + magnet_trains_area + magnet_pulse_area - ) + power_buildings_area = hcd_building_area + magnet_trains_area + magnet_pulse_area power_buildings_vol = hcd_building_vol + magnet_trains_vol + magnet_pulse_vol buildings_total_vol = buildings_total_vol + power_buildings_vol @@ -925,8 +919,7 @@ def bldgs_sizes(self, output, tf_radial_dim, tf_vertical_dim): # Respiratory Protective Equipment cleaning; industrial drains & sewage # process and discharge; these values amalgamate multiple individual buildings. water_buildings_area = ( - buildings_variables.water_buildings_l - * buildings_variables.water_buildings_w + buildings_variables.water_buildings_l * buildings_variables.water_buildings_w ) water_buildings_vol = ( water_buildings_area * buildings_variables.water_buildings_h diff --git a/process/confinement_time.py b/process/confinement_time.py index 108cdafff8..28ee76fd54 100644 --- a/process/confinement_time.py +++ b/process/confinement_time.py @@ -168,11 +168,7 @@ def kaye_goldston_confinement_time( * n20**0.26e0 * rmajor**1.65e0 * np.sqrt(afuel / 1.5e0) - / ( - b_plasma_toroidal_on_axis**0.09e0 - * rminor**0.49e0 - * p_plasma_loss_mw**0.58e0 - ) + / (b_plasma_toroidal_on_axis**0.09e0 * rminor**0.49e0 * p_plasma_loss_mw**0.58e0) ) @@ -877,7 +873,7 @@ def gyro_reduced_bohm_confinement_time( Notes: References: - - Goldston, R. J., H. Biglari, and G. W. Hammett. "E x B/B 2 vs. µ B/B as the Cause of Transport in Tokamaks." + - Goldston, R. J., H. Biglari, and G. W. Hammett. "E x B/B 2 vs. μ B/B as the Cause of Transport in Tokamaks." Bull. Am. Phys. Soc 34 (1989): 1964. """ return ( diff --git a/process/constants.py b/process/constants.py index 0f853ad282..98025ec20b 100644 --- a/process/constants.py +++ b/process/constants.py @@ -308,8 +308,7 @@ def init_constants(): - global den_copper - global den_aluminium + global den_copper, den_aluminium den_copper = 8900.0 den_aluminium = 2700.0 diff --git a/process/constraints.py b/process/constraints.py index 154ef31006..2a5d373676 100644 --- a/process/constraints.py +++ b/process/constraints.py @@ -439,9 +439,7 @@ def constraint_equation_7(): nd_beam_ions: hot beam ion density, variable (/m3) """ if data_structure.physics_variables.i_plasma_ignited == 1: - raise ProcessValueError( - "Do not use constraint equation 7 if i_plasma_ignited=1" - ) + raise ProcessValueError("Do not use constraint equation 7 if i_plasma_ignited=1") cc = ( 1.0 @@ -1950,10 +1948,7 @@ def constraint_equation_76(): 5.9 * data_structure.physics_variables.alpha_crit * (data_structure.physics_variables.aspect ** (-2.0 / 7.0)) - * ( - ((1.0 + (data_structure.physics_variables.kappa**2.0)) / 2.0) - ** (-6.0 / 7.0) - ) + * (((1.0 + (data_structure.physics_variables.kappa**2.0)) / 2.0) ** (-6.0 / 7.0)) * ( (data_structure.physics_variables.p_plasma_separatrix_mw * 1.0e6) ** (-11.0 / 70.0) diff --git a/process/costs.py b/process/costs.py index 560addecdd..f1aa09dc79 100644 --- a/process/costs.py +++ b/process/costs.py @@ -199,9 +199,7 @@ def output(self): "(fkind)", cost_variables.fkind, ) - po.ovarin( - self.outfile, "Level of Safety Assurance", "(lsa)", cost_variables.lsa - ) + po.ovarin(self.outfile, "Level of Safety Assurance", "(lsa)", cost_variables.lsa) po.oblnkl(self.outfile) po.oshead(self.outfile, "Structures and Site Facilities") po.ocosts( @@ -1949,8 +1947,7 @@ def acc223(self): cost_variables.c2231 = ( 1.0e-6 * cost_variables.ucech - * (1.0e6 * current_drive_variables.p_hcd_ecrh_injected_total_mw) - ** exprf + * (1.0e6 * current_drive_variables.p_hcd_ecrh_injected_total_mw) ** exprf ) if cost_variables.ifueltyp == 1: @@ -2879,9 +2876,7 @@ def coelc(self): # Interest on construction costs - cost_variables.moneyint = cost_variables.concost * ( - cost_variables.fcap0 - 1.0e0 - ) + cost_variables.moneyint = cost_variables.concost * (cost_variables.fcap0 - 1.0e0) # Capital costs diff --git a/process/costs_2015.py b/process/costs_2015.py index 6f2a6c1e3f..ecc081f6a1 100644 --- a/process/costs_2015.py +++ b/process/costs_2015.py @@ -109,9 +109,7 @@ def run(self): # Levelized cost of electricity (LCOE) ($/MWh) if cost_2015_variables.annual_electric_output > 0.00001: - cost_variables.coe = ( - 1.0e0 / cost_2015_variables.annual_electric_output - ) * ( + cost_variables.coe = (1.0e0 / cost_2015_variables.annual_electric_output) * ( cost_2015_variables.total_costs / cost_variables.amortization + cost_2015_variables.maintenance ) @@ -169,19 +167,13 @@ def calc_fwbs_costs(self): # Built-in test if global_variables.run_tests == 1: product_li6 = 0.3 - feed_to_product_mass_ratio = (product_li6 - tail_li6) / ( - feed_li6 - tail_li6 - ) - tail_to_product_mass_ratio = (product_li6 - feed_li6) / ( - feed_li6 - tail_li6 - ) + feed_to_product_mass_ratio = (product_li6 - tail_li6) / (feed_li6 - tail_li6) + tail_to_product_mass_ratio = (product_li6 - feed_li6) / (feed_li6 - tail_li6) p_v = self.value_function(product_li6) t_v = self.value_function(tail_li6) f_v = self.value_function(feed_li6) swu = ( - p_v - + tail_to_product_mass_ratio * t_v - - feed_to_product_mass_ratio * f_v + p_v + tail_to_product_mass_ratio * t_v - feed_to_product_mass_ratio * f_v ) if abs(swu - 2.66e0) < 2.0e-2: po.ocmmnt( @@ -222,14 +214,10 @@ def calc_fwbs_costs(self): # SWU will be calculated for a unit mass of product (P=1) # Feed to product mass ratio - feed_to_product_mass_ratio = (product_li6 - tail_li6) / ( - feed_li6 - tail_li6 - ) + feed_to_product_mass_ratio = (product_li6 - tail_li6) / (feed_li6 - tail_li6) # Tail to product mass ratio - tail_to_product_mass_ratio = (product_li6 - feed_li6) / ( - feed_li6 - tail_li6 - ) + tail_to_product_mass_ratio = (product_li6 - feed_li6) / (feed_li6 - tail_li6) # Calculate value functions p_v = self.value_function(product_li6) @@ -238,9 +226,7 @@ def calc_fwbs_costs(self): # Calculate separative work units per kg swu = ( - p_v - + tail_to_product_mass_ratio * t_v - - feed_to_product_mass_ratio * f_v + p_v + tail_to_product_mass_ratio * t_v - feed_to_product_mass_ratio * f_v ) # Mass of lithium (kg). Lithium orthosilicate is 22% lithium by mass. @@ -900,9 +886,7 @@ def calc_n_plant_and_vv_costs(self): ** cost_variables.costexp ) - cost_2015_variables.s_label[33] = ( - "Total liquid nitrogen plant and vacuum vessel" - ) + cost_2015_variables.s_label[33] = "Total liquid nitrogen plant and vacuum vessel" cost_2015_variables.s_cost[33] = 0.0e0 for j in range(31, 33): cost_2015_variables.s_cost[33] = ( @@ -1148,9 +1132,7 @@ def calc_remaining_subsystems(self): # For ITER value see # K:\Power Plant Physics and Technology\PROCESS\PROCESS documentation papers\resistive diffusion time.xmcd or pdf cost_2015_variables.s_k[51] = ( - pf_power_variables.ensxpfm - * 1.0e6 - / physics_variables.t_plasma_res_diffusion + pf_power_variables.ensxpfm * 1.0e6 / physics_variables.t_plasma_res_diffusion ) cost_2015_variables.s_kref[51] = 8.0e9 / 953.0e0 cost_2015_variables.s_cost[51] = ( @@ -1160,9 +1142,7 @@ def calc_remaining_subsystems(self): ** cost_variables.costexp ) - cost_2015_variables.s_label[52] = ( - "Neutral beam heating and current drive system" - ) + cost_2015_variables.s_label[52] = "Neutral beam heating and current drive system" # Cost of ITER NB H and CD cost_2015_variables.s_cref[52] = 814.0e6 # Scale with total auxiliary injected power (MW) diff --git a/process/current_drive.py b/process/current_drive.py index faebea1f70..48f1213fe4 100644 --- a/process/current_drive.py +++ b/process/current_drive.py @@ -937,8 +937,7 @@ def ion_cyclotron_ipdg89( """ return ( - (0.63e0 * 0.1e0 * temp_plasma_electron_density_weighted_kev) - / (2.0e0 + zeff) + (0.63e0 * 0.1e0 * temp_plasma_electron_density_weighted_kev) / (2.0e0 + zeff) ) / (rmajor * dene20) @@ -1500,8 +1499,7 @@ def cudriv(self) -> None: rmajor=physics_variables.rmajor, temp_plasma_electron_vol_avg_kev=physics_variables.temp_plasma_electron_vol_avg_kev, c_hcd_driven=current_drive_variables.c_hcd_primary_driven, - p_hcd_injected=current_drive_variables.p_hcd_primary_injected_mw - * 1.0e6, + p_hcd_injected=current_drive_variables.p_hcd_primary_injected_mw * 1.0e6, ) if current_drive_variables.p_hcd_secondary_injected_mw > 0.0: @@ -1547,7 +1545,7 @@ def cudriv(self) -> None: # ========================================================== # Ion cyclotron cases - if current_drive_variables.i_hcd_secondary in [2]: + if current_drive_variables.i_hcd_secondary == 2: # Injected power p_hcd_secondary_ions_mw = ( current_drive_variables.p_hcd_secondary_injected_mw @@ -1599,7 +1597,7 @@ def cudriv(self) -> None: # ========================================================== # Electron berstein cases - if current_drive_variables.i_hcd_secondary in [12]: + if current_drive_variables.i_hcd_secondary == 12: # Injected power p_hcd_secondary_electrons_mw = ( current_drive_variables.p_hcd_secondary_injected_mw @@ -1736,7 +1734,7 @@ def cudriv(self) -> None: # =========================================================== # Ion cyclotron cases - if current_drive_variables.i_hcd_primary in [2]: + if current_drive_variables.i_hcd_primary == 2: p_hcd_primary_ions_mw = ( current_drive_variables.p_hcd_primary_injected_mw + current_drive_variables.p_hcd_primary_extra_heat_mw @@ -1799,7 +1797,7 @@ def cudriv(self) -> None: # Electron bernstein cases - if current_drive_variables.i_hcd_primary in [12]: + if current_drive_variables.i_hcd_primary == 12: p_hcd_primary_electrons_mw = ( current_drive_variables.p_ebw_injected_mw + current_drive_variables.p_hcd_primary_extra_heat_mw diff --git a/process/data_structure/blanket_library.py b/process/data_structure/blanket_library.py index 12df702245..b4e240243a 100644 --- a/process/data_structure/blanket_library.py +++ b/process/data_structure/blanket_library.py @@ -238,56 +238,57 @@ def init_blanket_library(): - global dz_blkt_half - global dz_shld_half - global dz_pf_cryostat - global dz_vv_half - global vol_shld_inboard - global vol_shld_outboard - global vol_vv_inboard - global vol_vv_outboard - global len_blkt_inboard_coolant_channel_radial - global len_blkt_outboard_coolant_channel_radial - global len_blkt_inboard_segment_toroidal - global len_blkt_outboard_segment_toroidal - global len_blkt_inboard_segment_poloidal - global len_blkt_outboard_segment_poloidal - global len_blkt_inboard_channel_total - global bzfllengi_liq - global bzfllengo_liq - global len_blkt_outboard_channel_total - global p_fw_inboard_nuclear_heat_mw - global p_fw_outboard_nuclear_heat_mw - global temp_fw_inboard_peak - global temp_fw_outboard_peak - global mflow_fw_inboard_coolant_total - global mflow_fw_outboard_coolant_total - global mflow_fw_coolant_total - global n_fw_inboard_channels - global n_fw_outboard_channels - global mflow_fw_inboard_coolant_channel - global mflow_fw_outboard_coolant_channel - global p_blkt_nuclear_heat_inboard_mw - global p_blkt_nuclear_heat_outboard_mw - global mflow_blkt_inboard_coolant - global mflow_blkt_outboard_coolant - global mfblkti_liq - global mfblkto_liq - global mfblkt_liq - global mflow_blkt_coolant_total - global mftotal - global n_blkt_inboard_channels - global n_blkt_outboard_channels - global mfblktpi - global mfblktpo - global vel_blkt_inboard_coolant - global vel_blkt_outboard_coolant - global htpmw_fwi - global htpmw_fwo - global htpmw_blkti - global htpmw_blkto - global vfblkti - global vfblkto + global \ + dz_blkt_half, \ + dz_shld_half, \ + dz_pf_cryostat, \ + dz_vv_half, \ + vol_shld_inboard, \ + vol_shld_outboard, \ + vol_vv_inboard, \ + vol_vv_outboard, \ + len_blkt_inboard_coolant_channel_radial, \ + len_blkt_outboard_coolant_channel_radial, \ + len_blkt_inboard_segment_toroidal, \ + len_blkt_outboard_segment_toroidal, \ + len_blkt_inboard_segment_poloidal, \ + len_blkt_outboard_segment_poloidal, \ + len_blkt_inboard_channel_total, \ + bzfllengi_liq, \ + bzfllengo_liq, \ + len_blkt_outboard_channel_total, \ + p_fw_inboard_nuclear_heat_mw, \ + p_fw_outboard_nuclear_heat_mw, \ + temp_fw_inboard_peak, \ + temp_fw_outboard_peak, \ + mflow_fw_inboard_coolant_total, \ + mflow_fw_outboard_coolant_total, \ + mflow_fw_coolant_total, \ + n_fw_inboard_channels, \ + n_fw_outboard_channels, \ + mflow_fw_inboard_coolant_channel, \ + mflow_fw_outboard_coolant_channel, \ + p_blkt_nuclear_heat_inboard_mw, \ + p_blkt_nuclear_heat_outboard_mw, \ + mflow_blkt_inboard_coolant, \ + mflow_blkt_outboard_coolant, \ + mfblkti_liq, \ + mfblkto_liq, \ + mfblkt_liq, \ + mflow_blkt_coolant_total, \ + mftotal, \ + n_blkt_inboard_channels, \ + n_blkt_outboard_channels, \ + mfblktpi, \ + mfblktpo, \ + vel_blkt_inboard_coolant, \ + vel_blkt_outboard_coolant, \ + htpmw_fwi, \ + htpmw_fwo, \ + htpmw_blkti, \ + htpmw_blkto, \ + vfblkti, \ + vfblkto dz_blkt_half = 0.0 dz_shld_half = 0.0 diff --git a/process/data_structure/build_variables.py b/process/data_structure/build_variables.py index 4a75fe5b51..6baf84627f 100644 --- a/process/data_structure/build_variables.py +++ b/process/data_structure/build_variables.py @@ -403,100 +403,101 @@ def init_build_variables(): - global ripflag - global aplasmin - global available_radial_space - global a_blkt_total_surface - global a_blkt_inboard_surface - global a_blkt_outboard_surface - global blbmith - global blbmoth - global blbpith - global blbpoth - global blbuith - global blbuoth - global dr_blkt_inboard - global dr_blkt_outboard - global dz_blkt_upper - global dz_fw_upper - global dr_bore - global f_z_cryostat - global dr_cryostat - global dr_vv_inboard - global dr_vv_outboard - global dz_vv_upper - global dz_vv_lower - global dr_vv_shells - global f_avspace - global fcspc - global fseppc - global a_fw_total_full_coverage - global a_fw_inboard_full_coverage - global a_fw_outboard_full_coverage - global a_fw_total - global a_fw_inboard - global a_fw_outboard - global dr_fw_inboard - global dr_fw_outboard - global dr_shld_vv_gap_inboard - global dr_cs_tf_gap - global gapomin - global dr_shld_vv_gap_outboard - global z_tf_inside_half - global dz_tf_upper_lower_midplane - global z_tf_top - global hr1 - global iohcl - global i_cs_precomp - global i_tf_inside_cs - global dr_cs - global dr_cs_precomp - global rbld - global required_radial_space - global rinboard - global rsldi - global rsldo - global r_vv_inboard_out - global r_sh_inboard_in - global r_sh_inboard_out - global r_tf_inboard_in - global r_tf_inboard_mid - global r_tf_inboard_out - global r_tf_outboard_mid - global i_r_cp_top - global r_cp_top - global f_r_cp - global dr_tf_inner_bore - global dh_tf_inner_bore - global dr_fw_plasma_gap_inboard - global dr_fw_plasma_gap_outboard - global a_shld_total_surface - global a_shld_inboard_surface - global a_shld_outboard_surface - global dr_shld_inboard - global dz_shld_lower - global dr_shld_outboard - global dz_shld_upper - global sigallpc - global dr_tf_inboard - global dz_tf_plasma_centre_offset - global f_dr_tf_outboard_inboard - global dr_tf_outboard - global dr_tf_shld_gap - global dr_shld_thermal_inboard - global dr_shld_thermal_outboard - global dz_shld_thermal - global dz_shld_vv_gap - global dz_xpoint_divertor - global dz_fw_plasma_gap - global dr_shld_blkt_gap - global plleni - global plleno - global plsepi - global plsepo - global rspo - global z_plasma_xpoint_upper - global z_plasma_xpoint_lower + global \ + ripflag, \ + aplasmin, \ + available_radial_space, \ + a_blkt_total_surface, \ + a_blkt_inboard_surface, \ + a_blkt_outboard_surface, \ + blbmith, \ + blbmoth, \ + blbpith, \ + blbpoth, \ + blbuith, \ + blbuoth, \ + dr_blkt_inboard, \ + dr_blkt_outboard, \ + dz_blkt_upper, \ + dz_fw_upper, \ + dr_bore, \ + f_z_cryostat, \ + dr_cryostat, \ + dr_vv_inboard, \ + dr_vv_outboard, \ + dz_vv_upper, \ + dz_vv_lower, \ + dr_vv_shells, \ + f_avspace, \ + fcspc, \ + fseppc, \ + a_fw_total_full_coverage, \ + a_fw_inboard_full_coverage, \ + a_fw_outboard_full_coverage, \ + a_fw_total, \ + a_fw_inboard, \ + a_fw_outboard, \ + dr_fw_inboard, \ + dr_fw_outboard, \ + dr_shld_vv_gap_inboard, \ + dr_cs_tf_gap, \ + gapomin, \ + dr_shld_vv_gap_outboard, \ + z_tf_inside_half, \ + dz_tf_upper_lower_midplane, \ + z_tf_top, \ + hr1, \ + iohcl, \ + i_cs_precomp, \ + i_tf_inside_cs, \ + dr_cs, \ + dr_cs_precomp, \ + rbld, \ + required_radial_space, \ + rinboard, \ + rsldi, \ + rsldo, \ + r_vv_inboard_out, \ + r_sh_inboard_in, \ + r_sh_inboard_out, \ + r_tf_inboard_in, \ + r_tf_inboard_mid, \ + r_tf_inboard_out, \ + r_tf_outboard_mid, \ + i_r_cp_top, \ + r_cp_top, \ + f_r_cp, \ + dr_tf_inner_bore, \ + dh_tf_inner_bore, \ + dr_fw_plasma_gap_inboard, \ + dr_fw_plasma_gap_outboard, \ + a_shld_total_surface, \ + a_shld_inboard_surface, \ + a_shld_outboard_surface, \ + dr_shld_inboard, \ + dz_shld_lower, \ + dr_shld_outboard, \ + dz_shld_upper, \ + sigallpc, \ + dr_tf_inboard, \ + dz_tf_plasma_centre_offset, \ + f_dr_tf_outboard_inboard, \ + dr_tf_outboard, \ + dr_tf_shld_gap, \ + dr_shld_thermal_inboard, \ + dr_shld_thermal_outboard, \ + dz_shld_thermal, \ + dz_shld_vv_gap, \ + dz_xpoint_divertor, \ + dz_fw_plasma_gap, \ + dr_shld_blkt_gap, \ + plleni, \ + plleno, \ + plsepi, \ + plsepo, \ + rspo, \ + z_plasma_xpoint_upper, \ + z_plasma_xpoint_lower ripflag = 0 aplasmin = 0.25 diff --git a/process/data_structure/buildings_variables.py b/process/data_structure/buildings_variables.py index 2003024133..b27b5f6f33 100644 --- a/process/data_structure/buildings_variables.py +++ b/process/data_structure/buildings_variables.py @@ -611,159 +611,160 @@ def init_buildings_variables(): - global admv - global admvol - global aux_build_l - global aux_build_w - global aux_build_h - global auxcool_l - global auxcool_w - global auxcool_h - global bioshld_thk - global chemlab_l - global chemlab_w - global chemlab_h - global dz_tf_cryostat - global clh2 - global control_buildings_l - global control_buildings_w - global control_buildings_h - global conv - global convol - global crane_arm_h - global crane_clrnc_h - global crane_clrnc_v - global cryomag_l - global cryomag_w - global cryomag_h - global cryostore_l - global cryostore_w - global cryostore_h - global cryostat_clrnc - global cryvol - global a_plant_floor_effective - global elecdist_l - global elecdist_w - global elecdist_h - global elecload_l - global elecload_w - global elecload_h - global elecstore_l - global elecstore_w - global elecstore_h - global elevol - global esbldgm3 - global fc_building_l - global fc_building_w - global fndt - global gas_buildings_l - global gas_buildings_w - global gas_buildings_h - global ground_clrnc - global hcd_building_l - global hcd_building_w - global hcd_building_h - global hccl - global hcwt - global heat_sink_l - global heat_sink_w - global heat_sink_h - global hot_sepdist - global hotcell_h - global hw_storage_l - global hw_storage_w - global hw_storage_h - global i_bldgs_size - global i_bldgs_v - global ilw_smelter_l - global ilw_smelter_w - global ilw_smelter_h - global ilw_storage_l - global ilw_storage_w - global ilw_storage_h - global llw_storage_l - global llw_storage_w - global llw_storage_h - global magnet_pulse_l - global magnet_pulse_w - global magnet_pulse_h - global magnet_trains_l - global magnet_trains_w - global magnet_trains_h - global maint_cont_l - global maint_cont_w - global maint_cont_h - global mbvfac - global nbi_sys_l - global nbi_sys_w - global pfbldgm3 - global pibv - global qnty_sfty_fac - global rbvfac - global rbrt - global rbvol - global rbwt - global reactor_clrnc - global reactor_fndtn_thk - global reactor_hall_l - global reactor_hall_w - global reactor_hall_h - global reactor_roof_thk - global reactor_wall_thk - global rmbvol - global robotics_l - global robotics_w - global robotics_h - global row - global rxcl - global sec_buildings_l - global sec_buildings_w - global sec_buildings_h - global shmf - global shov - global shovol - global staff_buildings_area - global staff_buildings_h - global stcl - global tfcbv - global transp_clrnc - global trcl - global triv - global turbine_hall_l - global turbine_hall_w - global turbine_hall_h - global tw_storage_l - global tw_storage_w - global tw_storage_h - global volrci - global volnucb - global warm_shop_l - global warm_shop_w - global warm_shop_h - global water_buildings_l - global water_buildings_w - global water_buildings_h - global wgt - global wgt2 - global workshop_l - global workshop_w - global workshop_h - global wrbi - global wsvol - global wsvfac - global a_reactor_bldg - global a_ee_ps_bldg - global a_aux_services_bldg - global a_hot_cell_bldg - global a_reactor_service_bldg - global a_service_water_bldg - global a_fuel_handling_bldg - global a_control_room_bldg - global a_ac_ps_bldg - global a_admin_bldg - global a_site_service_bldg - global a_cryo_inert_gas_bldg - global a_security_bldg + global \ + admv, \ + admvol, \ + aux_build_l, \ + aux_build_w, \ + aux_build_h, \ + auxcool_l, \ + auxcool_w, \ + auxcool_h, \ + bioshld_thk, \ + chemlab_l, \ + chemlab_w, \ + chemlab_h, \ + dz_tf_cryostat, \ + clh2, \ + control_buildings_l, \ + control_buildings_w, \ + control_buildings_h, \ + conv, \ + convol, \ + crane_arm_h, \ + crane_clrnc_h, \ + crane_clrnc_v, \ + cryomag_l, \ + cryomag_w, \ + cryomag_h, \ + cryostore_l, \ + cryostore_w, \ + cryostore_h, \ + cryostat_clrnc, \ + cryvol, \ + a_plant_floor_effective, \ + elecdist_l, \ + elecdist_w, \ + elecdist_h, \ + elecload_l, \ + elecload_w, \ + elecload_h, \ + elecstore_l, \ + elecstore_w, \ + elecstore_h, \ + elevol, \ + esbldgm3, \ + fc_building_l, \ + fc_building_w, \ + fndt, \ + gas_buildings_l, \ + gas_buildings_w, \ + gas_buildings_h, \ + ground_clrnc, \ + hcd_building_l, \ + hcd_building_w, \ + hcd_building_h, \ + hccl, \ + hcwt, \ + heat_sink_l, \ + heat_sink_w, \ + heat_sink_h, \ + hot_sepdist, \ + hotcell_h, \ + hw_storage_l, \ + hw_storage_w, \ + hw_storage_h, \ + i_bldgs_size, \ + i_bldgs_v, \ + ilw_smelter_l, \ + ilw_smelter_w, \ + ilw_smelter_h, \ + ilw_storage_l, \ + ilw_storage_w, \ + ilw_storage_h, \ + llw_storage_l, \ + llw_storage_w, \ + llw_storage_h, \ + magnet_pulse_l, \ + magnet_pulse_w, \ + magnet_pulse_h, \ + magnet_trains_l, \ + magnet_trains_w, \ + magnet_trains_h, \ + maint_cont_l, \ + maint_cont_w, \ + maint_cont_h, \ + mbvfac, \ + nbi_sys_l, \ + nbi_sys_w, \ + pfbldgm3, \ + pibv, \ + qnty_sfty_fac, \ + rbvfac, \ + rbrt, \ + rbvol, \ + rbwt, \ + reactor_clrnc, \ + reactor_fndtn_thk, \ + reactor_hall_l, \ + reactor_hall_w, \ + reactor_hall_h, \ + reactor_roof_thk, \ + reactor_wall_thk, \ + rmbvol, \ + robotics_l, \ + robotics_w, \ + robotics_h, \ + row, \ + rxcl, \ + sec_buildings_l, \ + sec_buildings_w, \ + sec_buildings_h, \ + shmf, \ + shov, \ + shovol, \ + staff_buildings_area, \ + staff_buildings_h, \ + stcl, \ + tfcbv, \ + transp_clrnc, \ + trcl, \ + triv, \ + turbine_hall_l, \ + turbine_hall_w, \ + turbine_hall_h, \ + tw_storage_l, \ + tw_storage_w, \ + tw_storage_h, \ + volrci, \ + volnucb, \ + warm_shop_l, \ + warm_shop_w, \ + warm_shop_h, \ + water_buildings_l, \ + water_buildings_w, \ + water_buildings_h, \ + wgt, \ + wgt2, \ + workshop_l, \ + workshop_w, \ + workshop_h, \ + wrbi, \ + wsvol, \ + wsvfac, \ + a_reactor_bldg, \ + a_ee_ps_bldg, \ + a_aux_services_bldg, \ + a_hot_cell_bldg, \ + a_reactor_service_bldg, \ + a_service_water_bldg, \ + a_fuel_handling_bldg, \ + a_control_room_bldg, \ + a_ac_ps_bldg, \ + a_admin_bldg, \ + a_site_service_bldg, \ + a_cryo_inert_gas_bldg, \ + a_security_bldg admv = 1.0e5 admvol = 0.0 diff --git a/process/data_structure/ccfe_hcpb_module.py b/process/data_structure/ccfe_hcpb_module.py index aafb6bd2aa..3d9e9d0737 100644 --- a/process/data_structure/ccfe_hcpb_module.py +++ b/process/data_structure/ccfe_hcpb_module.py @@ -65,21 +65,22 @@ def init_ccfe_hcpb_module(): - global iso_fortran_env - global armour_density - global fw_density - global blanket_density - global shield_density - global vv_density - global x_blanket - global x_shield - global tfc_nuc_heating - global fw_armour_u_nuc_heating - global shld_u_nuc_heating - global pnuc_tot_blk_sector - global exp_blanket - global exp_shield1 - global exp_shield2 + global \ + iso_fortran_env, \ + armour_density, \ + fw_density, \ + blanket_density, \ + shield_density, \ + vv_density, \ + x_blanket, \ + x_shield, \ + tfc_nuc_heating, \ + fw_armour_u_nuc_heating, \ + shld_u_nuc_heating, \ + pnuc_tot_blk_sector, \ + exp_blanket, \ + exp_shield1, \ + exp_shield2 armour_density = 0.0 fw_density = 0.0 diff --git a/process/data_structure/constraint_variables.py b/process/data_structure/constraint_variables.py index 267c86c9ad..9d852b350e 100644 --- a/process/data_structure/constraint_variables.py +++ b/process/data_structure/constraint_variables.py @@ -405,91 +405,92 @@ def init_constraint_variables(): """Initialise the constraint variables""" - global p_hcd_injected_min_mw - global beta_poloidal_max - global big_q_plasma_min - global b_tf_inboard_max - global fp_hcd_injected_min_mw - global fbeta_poloidal_eps - global fbeta_poloidal - global fbeta_max - global fbeta_min - global fc_tf_turn_max - global fr_conducting_wall - global fdene - global fdtmp - global fecrh_ignition - global fflutf - global fp_fusion_total_max_mw - global feta_cd_norm_hcd_primary_max - global fpflux_div_heat_load_mw - global fiooic - global fipir - global q95_fixed - global fjohc - global fjohc0 - global fjprot - global fl_h_threshold - global fmva - global fnbshinef - global fncycle - global fnesep - global foh_stress - global fb_tf_inboard_max - global fp_hcd_injected_max - global fp_plant_electric_net_required_mw - global fradius_beam_tangency - global fpsepbqar - global fpsepr - global fptemp - global fptfnuc - global fq95_min - global fbig_q_plasma_min - global fradpwr - global fpflux_fw_rad_max - global freinke - global frminor - global fstrcase - global fstrcond - global fstr_wp - global fmaxvvstress - global ftbr - global ft_burn_min - global ft_cycle_min - global ftmargoh - global ftmargtf - global ft_current_ramp_up - global ftemp_fw_max - global fvdump - global fvs_plasma_total_required - global fvvhe - global fpflux_fw_neutron_max_mw - global fzeff_max - global eta_cd_norm_hcd_primary_max - global i_q95_fixed - global pflux_fw_rad_max - global mvalim - global f_p_beam_shine_through_max - global nflutfmax - global p_plasma_separatrix_min_mw - global f_fw_rad_max - global pflux_fw_rad_max_mw - global p_plant_electric_net_required_mw - global p_fusion_total_max_mw - global psepbqarmax - global pseprmax - global ptfnucmax - global tbrmin - global t_burn_min - global t_cycle_min - global t_current_ramp_up_min - global pflux_fw_neutron_max_mw - global f_alpha_energy_confinement_min - global falpha_energy_confinement - global fniterpump - global zeff_max - global fpoloidalpower - global ftemp_croco_quench_max + global \ + p_hcd_injected_min_mw, \ + beta_poloidal_max, \ + big_q_plasma_min, \ + b_tf_inboard_max, \ + fp_hcd_injected_min_mw, \ + fbeta_poloidal_eps, \ + fbeta_poloidal, \ + fbeta_max, \ + fbeta_min, \ + fc_tf_turn_max, \ + fr_conducting_wall, \ + fdene, \ + fdtmp, \ + fecrh_ignition, \ + fflutf, \ + fp_fusion_total_max_mw, \ + feta_cd_norm_hcd_primary_max, \ + fpflux_div_heat_load_mw, \ + fiooic, \ + fipir, \ + q95_fixed, \ + fjohc, \ + fjohc0, \ + fjprot, \ + fl_h_threshold, \ + fmva, \ + fnbshinef, \ + fncycle, \ + fnesep, \ + foh_stress, \ + fb_tf_inboard_max, \ + fp_hcd_injected_max, \ + fp_plant_electric_net_required_mw, \ + fradius_beam_tangency, \ + fpsepbqar, \ + fpsepr, \ + fptemp, \ + fptfnuc, \ + fq95_min, \ + fbig_q_plasma_min, \ + fradpwr, \ + fpflux_fw_rad_max, \ + freinke, \ + frminor, \ + fstrcase, \ + fstrcond, \ + fstr_wp, \ + fmaxvvstress, \ + ftbr, \ + ft_burn_min, \ + ft_cycle_min, \ + ftmargoh, \ + ftmargtf, \ + ft_current_ramp_up, \ + ftemp_fw_max, \ + fvdump, \ + fvs_plasma_total_required, \ + fvvhe, \ + fpflux_fw_neutron_max_mw, \ + fzeff_max, \ + eta_cd_norm_hcd_primary_max, \ + i_q95_fixed, \ + pflux_fw_rad_max, \ + mvalim, \ + f_p_beam_shine_through_max, \ + nflutfmax, \ + p_plasma_separatrix_min_mw, \ + f_fw_rad_max, \ + pflux_fw_rad_max_mw, \ + p_plant_electric_net_required_mw, \ + p_fusion_total_max_mw, \ + psepbqarmax, \ + pseprmax, \ + ptfnucmax, \ + tbrmin, \ + t_burn_min, \ + t_cycle_min, \ + t_current_ramp_up_min, \ + pflux_fw_neutron_max_mw, \ + f_alpha_energy_confinement_min, \ + falpha_energy_confinement, \ + fniterpump, \ + zeff_max, \ + fpoloidalpower, \ + ftemp_croco_quench_max p_hcd_injected_min_mw = 0.1 beta_poloidal_max = 0.19 diff --git a/process/data_structure/cost_variables.py b/process/data_structure/cost_variables.py index ca5b93130c..4060e20f33 100644 --- a/process/data_structure/cost_variables.py +++ b/process/data_structure/cost_variables.py @@ -1274,162 +1274,163 @@ def init_cost_variables(): global c22128 c22128 = 0.0 - global abktflnc - global adivflnc - global blkcst - global c221 - global c222 - global capcost - global cconfix - global cconshpf - global cconshtf - global cdcost - global cdirt - global life_hcd_fpy - global cdrlife_cal - global f_t_plant_available - global cpfact - global cfind - global cland - global coe - global coecap - global coefuelt - global coeoam - global concost - global costexp - global costexp_pebbles - global cost_factor_buildings - global cost_factor_land - global cost_factor_tf_coils - global cost_factor_fwbs - global cost_factor_rh - global cost_factor_vv - global cost_factor_bop - global cost_factor_misc - global maintenance_fwbs - global maintenance_gen - global amortization - global cost_model - global i_cp_lifetime - global cowner - global cplife_input - global cplife - global cplife_cal - global cpstcst - global cpstflnc - global crctcore - global csi - global cturbb - global decomf - global dintrt - global divcst - global life_div_fpy - global life_div - global dtlife - global fcap0 - global fcap0cp - global fcdfuel - global fcontng - global fcr0 - global fkind - global fwallcst - global i_plant_availability - global ibkt_life - global life_dpa - global bktcycles - global avail_min - global tok_build_cost_per_vol - global light_build_cost_per_vol - global favail - global num_rh_systems - global conf_mag - global div_prob_fail - global div_umain_time - global div_nref - global div_nu - global fwbs_nref - global fwbs_nu - global fwbs_prob_fail - global fwbs_umain_time - global redun_vacp - global redun_vac - global t_plant_operational_total_yrs - global t_blkt_replace_yrs - global tcomrepl - global t_div_replace_yrs - global uubop - global uucd - global uudiv - global uufuel - global uufw - global uumag - global uuves - global ifueltyp - global ipnet - global ireactor - global lsa - global moneyint - global output_costs - global discount_rate - global startupratio - global startuppwr - global supercond_cost_model - global life_plant - global tmain - global u_unplanned_cp - global ucblbe - global ucblbreed - global ucblli - global ucblli2o - global ucbllipb - global ucblss - global ucblvd - global ucbus - global uccase - global uccpcl1 - global uccpclb - global uccry - global uccryo - global uccu - global ucdiv - global ucech - global uces1 - global uces2 - global ucf1 - global ucfnc - global ucfuel - global uche3 - global uchrs - global uchts - global uciac - global ucich - global uclh - global ucme - global ucmisc - global ucnbi - global ucoam - global ucpens - global ucpfb - global ucpfbk - global ucpfbs - global ucpfcb - global ucpfdr1 - global ucpfps - global ucrb - global ucsc - global sc_mat_cost_0 - global ucshld - global uctfbr - global uctfbus - global uctfps - global uctfsw - global uctpmp - global ucturb - global ucwindpf - global ucwindtf - global ucws - global ucwst - global ucpfic + global \ + abktflnc, \ + adivflnc, \ + blkcst, \ + c221, \ + c222, \ + capcost, \ + cconfix, \ + cconshpf, \ + cconshtf, \ + cdcost, \ + cdirt, \ + life_hcd_fpy, \ + cdrlife_cal, \ + f_t_plant_available, \ + cpfact, \ + cfind, \ + cland, \ + coe, \ + coecap, \ + coefuelt, \ + coeoam, \ + concost, \ + costexp, \ + costexp_pebbles, \ + cost_factor_buildings, \ + cost_factor_land, \ + cost_factor_tf_coils, \ + cost_factor_fwbs, \ + cost_factor_rh, \ + cost_factor_vv, \ + cost_factor_bop, \ + cost_factor_misc, \ + maintenance_fwbs, \ + maintenance_gen, \ + amortization, \ + cost_model, \ + i_cp_lifetime, \ + cowner, \ + cplife_input, \ + cplife, \ + cplife_cal, \ + cpstcst, \ + cpstflnc, \ + crctcore, \ + csi, \ + cturbb, \ + decomf, \ + dintrt, \ + divcst, \ + life_div_fpy, \ + life_div, \ + dtlife, \ + fcap0, \ + fcap0cp, \ + fcdfuel, \ + fcontng, \ + fcr0, \ + fkind, \ + fwallcst, \ + i_plant_availability, \ + ibkt_life, \ + life_dpa, \ + bktcycles, \ + avail_min, \ + tok_build_cost_per_vol, \ + light_build_cost_per_vol, \ + favail, \ + num_rh_systems, \ + conf_mag, \ + div_prob_fail, \ + div_umain_time, \ + div_nref, \ + div_nu, \ + fwbs_nref, \ + fwbs_nu, \ + fwbs_prob_fail, \ + fwbs_umain_time, \ + redun_vacp, \ + redun_vac, \ + t_plant_operational_total_yrs, \ + t_blkt_replace_yrs, \ + tcomrepl, \ + t_div_replace_yrs, \ + uubop, \ + uucd, \ + uudiv, \ + uufuel, \ + uufw, \ + uumag, \ + uuves, \ + ifueltyp, \ + ipnet, \ + ireactor, \ + lsa, \ + moneyint, \ + output_costs, \ + discount_rate, \ + startupratio, \ + startuppwr, \ + supercond_cost_model, \ + life_plant, \ + tmain, \ + u_unplanned_cp, \ + ucblbe, \ + ucblbreed, \ + ucblli, \ + ucblli2o, \ + ucbllipb, \ + ucblss, \ + ucblvd, \ + ucbus, \ + uccase, \ + uccpcl1, \ + uccpclb, \ + uccry, \ + uccryo, \ + uccu, \ + ucdiv, \ + ucech, \ + uces1, \ + uces2, \ + ucf1, \ + ucfnc, \ + ucfuel, \ + uche3, \ + uchrs, \ + uchts, \ + uciac, \ + ucich, \ + uclh, \ + ucme, \ + ucmisc, \ + ucnbi, \ + ucoam, \ + ucpens, \ + ucpfb, \ + ucpfbk, \ + ucpfbs, \ + ucpfcb, \ + ucpfdr1, \ + ucpfps, \ + ucrb, \ + ucsc, \ + sc_mat_cost_0, \ + ucshld, \ + uctfbr, \ + uctfbus, \ + uctfps, \ + uctfsw, \ + uctpmp, \ + ucturb, \ + ucwindpf, \ + ucwindtf, \ + ucws, \ + ucwst, \ + ucpfic abktflnc = 5.0 adivflnc = 7.0 diff --git a/process/data_structure/current_drive_variables.py b/process/data_structure/current_drive_variables.py index e7c3718978..9fc62d5001 100644 --- a/process/data_structure/current_drive_variables.py +++ b/process/data_structure/current_drive_variables.py @@ -379,90 +379,91 @@ def init_current_drive_variables(): """Initialise current drive variables""" - global dx_beam_duct - global big_q_plasma - global f_c_plasma_bootstrap - global f_c_plasma_bootstrap_max - global f_c_plasma_bootstrap_iter89 - global f_c_plasma_bootstrap_nevins - global f_c_plasma_bootstrap_sauter - global f_c_plasma_bootstrap_wilson - global f_c_plasma_bootstrap_sakai - global f_c_plasma_bootstrap_aries - global f_c_plasma_bootstrap_andrade - global f_c_plasma_bootstrap_hoang - global f_c_plasma_bootstrap_wong - global bscf_gi_i - global bscf_gi_ii - global f_c_plasma_bootstrap_sugiyama_l - global f_c_plasma_bootstrap_sugiyama_h - global cboot - global c_beam_total - global f_c_plasma_diamagnetic_hender - global f_c_plasma_diamagnetic_scene - global f_c_plasma_diamagnetic - global p_hcd_ecrh_injected_total_mw - global p_ebw_injected_mw - global p_hcd_ecrh_electric_mw - global p_hcd_ebw_electric_mw - global eta_cd_hcd_primary - global eta_cd_hcd_secondary - global c_hcd_primary_driven - global c_hcd_secondary_driven - global f_c_plasma_hcd_primary - global f_c_plasma_hcd_secondary - global n_ecrh_harmonic - global i_ecrh_wave_mode - global e_beam_kev - global eta_hcd_primary_injector_wall_plug - global eta_hcd_secondary_injector_wall_plug - global eta_ecrh_injector_wall_plug - global eta_lowhyb_injector_wall_plug - global eta_icrh_injector_wall_plug - global eta_ebw_injector_wall_plug - global eta_beam_injector_wall_plug - global f_p_beam_injected_ions - global p_beam_injected_mw - global f_c_plasma_pfirsch_schluter_scene - global p_beam_shine_through_mw - global feffcd - global f_p_beam_orbit_loss - global f_radius_beam_tangency_rmajor - global f_beam_tritium - global eta_cd_norm_hcd_primary - global eta_cd_dimensionless_hcd_primary - global eta_cd_norm_hcd_secondary - global eta_cd_dimensionless_hcd_secondary - global eta_cd_norm_ecrh - global xi_ebw - global i_hcd_primary - global i_hcd_secondary - global i_hcd_calculations - global f_p_beam_shine_through - global dx_beam_shield - global p_hcd_primary_extra_heat_mw - global p_hcd_secondary_extra_heat_mw - global p_hcd_injected_max - global p_hcd_injected_electrons_mw - global p_hcd_injected_ions_mw - global p_hcd_injected_total_mw - global p_hcd_injected_current_total_mw - global p_hcd_secondary_injected_mw - global p_hcd_primary_injected_mw - global f_c_plasma_internal - global p_hcd_lowhyb_injected_total_mw - global p_hcd_icrh_injected_total_mw - global p_hcd_ebw_injected_total_mw - global p_beam_plasma_coupled_mw - global p_hcd_beam_injected_total_mw - global p_beam_orbit_loss_mw - global f_c_plasma_pfirsch_schluter - global p_hcd_lowhyb_electric_mw - global pwpnb - global radius_beam_tangency - global radius_beam_tangency_max - global n_beam_decay_lengths_core - global n_beam_decay_lengths_core_required + global \ + dx_beam_duct, \ + big_q_plasma, \ + f_c_plasma_bootstrap, \ + f_c_plasma_bootstrap_max, \ + f_c_plasma_bootstrap_iter89, \ + f_c_plasma_bootstrap_nevins, \ + f_c_plasma_bootstrap_sauter, \ + f_c_plasma_bootstrap_wilson, \ + f_c_plasma_bootstrap_sakai, \ + f_c_plasma_bootstrap_aries, \ + f_c_plasma_bootstrap_andrade, \ + f_c_plasma_bootstrap_hoang, \ + f_c_plasma_bootstrap_wong, \ + bscf_gi_i, \ + bscf_gi_ii, \ + f_c_plasma_bootstrap_sugiyama_l, \ + f_c_plasma_bootstrap_sugiyama_h, \ + cboot, \ + c_beam_total, \ + f_c_plasma_diamagnetic_hender, \ + f_c_plasma_diamagnetic_scene, \ + f_c_plasma_diamagnetic, \ + p_hcd_ecrh_injected_total_mw, \ + p_ebw_injected_mw, \ + p_hcd_ecrh_electric_mw, \ + p_hcd_ebw_electric_mw, \ + eta_cd_hcd_primary, \ + eta_cd_hcd_secondary, \ + c_hcd_primary_driven, \ + c_hcd_secondary_driven, \ + f_c_plasma_hcd_primary, \ + f_c_plasma_hcd_secondary, \ + n_ecrh_harmonic, \ + i_ecrh_wave_mode, \ + e_beam_kev, \ + eta_hcd_primary_injector_wall_plug, \ + eta_hcd_secondary_injector_wall_plug, \ + eta_ecrh_injector_wall_plug, \ + eta_lowhyb_injector_wall_plug, \ + eta_icrh_injector_wall_plug, \ + eta_ebw_injector_wall_plug, \ + eta_beam_injector_wall_plug, \ + f_p_beam_injected_ions, \ + p_beam_injected_mw, \ + f_c_plasma_pfirsch_schluter_scene, \ + p_beam_shine_through_mw, \ + feffcd, \ + f_p_beam_orbit_loss, \ + f_radius_beam_tangency_rmajor, \ + f_beam_tritium, \ + eta_cd_norm_hcd_primary, \ + eta_cd_dimensionless_hcd_primary, \ + eta_cd_norm_hcd_secondary, \ + eta_cd_dimensionless_hcd_secondary, \ + eta_cd_norm_ecrh, \ + xi_ebw, \ + i_hcd_primary, \ + i_hcd_secondary, \ + i_hcd_calculations, \ + f_p_beam_shine_through, \ + dx_beam_shield, \ + p_hcd_primary_extra_heat_mw, \ + p_hcd_secondary_extra_heat_mw, \ + p_hcd_injected_max, \ + p_hcd_injected_electrons_mw, \ + p_hcd_injected_ions_mw, \ + p_hcd_injected_total_mw, \ + p_hcd_injected_current_total_mw, \ + p_hcd_secondary_injected_mw, \ + p_hcd_primary_injected_mw, \ + f_c_plasma_internal, \ + p_hcd_lowhyb_injected_total_mw, \ + p_hcd_icrh_injected_total_mw, \ + p_hcd_ebw_injected_total_mw, \ + p_beam_plasma_coupled_mw, \ + p_hcd_beam_injected_total_mw, \ + p_beam_orbit_loss_mw, \ + f_c_plasma_pfirsch_schluter, \ + p_hcd_lowhyb_electric_mw, \ + pwpnb, \ + radius_beam_tangency, \ + radius_beam_tangency_max, \ + n_beam_decay_lengths_core, \ + n_beam_decay_lengths_core_required dx_beam_duct = 0.58 big_q_plasma = 0.0 diff --git a/process/data_structure/dcll_variables.py b/process/data_structure/dcll_variables.py index 799b50b7b7..57dd20c3ff 100644 --- a/process/data_structure/dcll_variables.py +++ b/process/data_structure/dcll_variables.py @@ -170,39 +170,40 @@ def init_dcll_module(): - global r_fci - global r_backwall - global bz_r_ib - global bz_r_ob - global f_vol_stff_plates - global f_vol_stl_bz_struct - global f_vol_stl_back_wall - global f_vol_stl_fw - global f_vol_mfbss_stl - global f_vol_mfbss_he - global f_vol_mfbss_pbli - global vol_fci - global vol_bz_struct - global vol_bz_liq - global vol_bz_liq_ib - global vol_bz_liq_ob - global vol_bw - global vol_bss - global wht_cer - global wht_stl_struct - global wht_cool_struct - global wht_bw_stl - global wht_bw_cool - global wht_mfbss_stl - global wht_mfbss_cool - global wht_mfbss_pbli - global fwmass_stl - global fwmass_cool - global mass_cool_blanket - global mass_liq_blanket - global mass_stl_blanket - global mass_segm_ib - global mass_segm_ob + global \ + r_fci, \ + r_backwall, \ + bz_r_ib, \ + bz_r_ob, \ + f_vol_stff_plates, \ + f_vol_stl_bz_struct, \ + f_vol_stl_back_wall, \ + f_vol_stl_fw, \ + f_vol_mfbss_stl, \ + f_vol_mfbss_he, \ + f_vol_mfbss_pbli, \ + vol_fci, \ + vol_bz_struct, \ + vol_bz_liq, \ + vol_bz_liq_ib, \ + vol_bz_liq_ob, \ + vol_bw, \ + vol_bss, \ + wht_cer, \ + wht_stl_struct, \ + wht_cool_struct, \ + wht_bw_stl, \ + wht_bw_cool, \ + wht_mfbss_stl, \ + wht_mfbss_cool, \ + wht_mfbss_pbli, \ + fwmass_stl, \ + fwmass_cool, \ + mass_cool_blanket, \ + mass_liq_blanket, \ + mass_stl_blanket, \ + mass_segm_ib, \ + mass_segm_ob r_fci = 0.0 r_backwall = 0.0 diff --git a/process/data_structure/divertor_variables.py b/process/data_structure/divertor_variables.py index 091932a04b..8b3ba77b74 100644 --- a/process/data_structure/divertor_variables.py +++ b/process/data_structure/divertor_variables.py @@ -58,24 +58,25 @@ def init_divertor_variables(): - global anginc - global deg_div_field_plate - global betai - global betao - global f_vol_div_coolant - global den_div_structure - global dz_divertor - global m_div_plate - global dx_div_plate - global a_div_surface_total - global fdiva - global f_div_flux_expansion - global pflux_div_heat_load_mw - global i_div_heat_load - global pflux_div_heat_load_max_mw - global prn1 - global tdiv - global xpertin + global \ + anginc, \ + deg_div_field_plate, \ + betai, \ + betao, \ + f_vol_div_coolant, \ + den_div_structure, \ + dz_divertor, \ + m_div_plate, \ + dx_div_plate, \ + a_div_surface_total, \ + fdiva, \ + f_div_flux_expansion, \ + pflux_div_heat_load_mw, \ + i_div_heat_load, \ + pflux_div_heat_load_max_mw, \ + prn1, \ + tdiv, \ + xpertin anginc = 0.262 deg_div_field_plate = 1.0 diff --git a/process/data_structure/fwbs_variables.py b/process/data_structure/fwbs_variables.py index 89e664dfc8..7d23654c44 100644 --- a/process/data_structure/fwbs_variables.py +++ b/process/data_structure/fwbs_variables.py @@ -901,201 +901,202 @@ def init_fwbs_variables(): """Initialise FWBS variables""" - global life_blkt_fpy - global life_blkt - global m_fw_blkt_div_coolant_total - global m_vv - global den_steel - global denwc - global dewmkg - global f_p_blkt_multiplication - global p_blkt_multiplication_mw - global fblss - global f_ster_div_single - global f_a_fw_outboard_hcd - global fhole - global i_fw_blkt_vv_shape - global life_fw_fpy - global m_fw_total - global fw_armour_mass - global fw_armour_thickness - global fw_armour_vol - global i_blanket_type - global i_blkt_inboard - global inuclear - global qnuc - global f_blkt_li6_enrichment - global p_blkt_nuclear_heat_total_mw - global pnuc_cp - global p_cp_shield_nuclear_heat_mw - global pnuc_cp_tf - global p_div_nuclear_heat_total_mw - global p_fw_nuclear_heat_total_mw - global p_fw_hcd_nuclear_heat_mw - global pnucloss - global pnucvvplus - global p_shld_nuclear_heat_mw - global m_blkt_total - global m_blkt_steel_total - global armour_fw_bl_mass - global breeder_f - global breeder_multiplier - global vfcblkt - global vfpblkt - global m_blkt_li4sio4 - global m_blkt_tibe12 - global neut_flux_cp - global f_neut_shield - global f_a_fw_coolant_inboard - global f_a_fw_coolant_outboard - global psurffwi - global psurffwo - global vol_fw_total - global f_vol_blkt_steel - global f_vol_blkt_li4sio4 - global f_vol_blkt_tibe12 - global breedmat - global densbreed - global fblbe - global fblbreed - global fblhebmi - global fblhebmo - global fblhebpi - global fblhebpo - global hcdportsize - global nflutf - global npdiv - global nphcdin - global nphcdout - global tbr - global tritprate - global wallpf - global whtblbreed - global m_blkt_beryllium - global i_p_coolant_pumping - global i_shield_mat - global i_thermal_electric_conversion - global secondary_cycle_liq - global i_blkt_coolant_type - global i_fw_coolant_type - global dr_fw_wall - global radius_fw_channel - global dx_fw_module - global temp_fw_coolant_in - global temp_fw_coolant_out - global pres_fw_coolant - global temp_fw_peak - global roughness_fw_channel - global len_fw_channel - global f_fw_peak - global pres_blkt_coolant - global temp_blkt_coolant_in - global temp_blkt_coolant_out - global coolp - global n_blkt_outboard_modules_poloidal - global n_blkt_inboard_modules_poloidal - global n_blkt_outboard_modules_toroidal - global n_blkt_inboard_modules_toroidal - global temp_fw_max - global fw_th_conductivity - global fvoldw - global fvolsi - global fvolso - global fwclfr - global p_div_rad_total_mw - global p_fw_rad_total_mw - global p_fw_hcd_rad_total_mw - global pradloss - global p_tf_nuclear_heat_mw - global ptfnucpm3 - global r_cryostat_inboard - global z_cryostat_half_inside - global dr_pf_cryostat - global vol_cryostat - global vol_cryostat_internal - global vol_vv - global vfshld - global vol_blkt_total - global vol_blkt_inboard - global vol_blkt_outboard - global vol_shld_total - global whtshld - global wpenshld - global wtshldi - global wtshldo - global irefprop - global fblli - global fblli2o - global fbllipb - global fblvd - global m_blkt_li2o - global wtbllipb - global m_blkt_vanadium - global m_blkt_lithium - global f_a_blkt_cooling_channels - global blktmodel - global declblkt - global declfw - global declshld - global blkttype - global etaiso - global eta_coolant_pump_electric - global i_fw_blkt_shared_coolant - global i_blkt_liquid_breeder_type - global i_blkt_dual_coolant - global i_blkt_liquid_breeder_channel_type - global i_blkt_module_segmentation - global n_liq_recirc - global r_f_liq_ib - global r_f_liq_ob - global w_f_liq_ib - global w_f_liq_ob - global den_ceramic - global th_wall_secondary - global bz_channel_conduct_liq - global a_bz_liq - global b_bz_liq - global nopol - global nopipes - global den_liq - global wht_liq - global wht_liq_ib - global wht_liq_ob - global specific_heat_liq - global thermal_conductivity_liq - global dynamic_viscosity_liq - global electrical_conductivity_liq - global hartmann_liq - global b_mag_blkt - global etaiso_liq - global blpressure_liq - global inlet_temp_liq - global outlet_temp_liq - global den_fw_coolant - global visc_fw_coolant - global den_blkt_coolant - global visc_blkt_coolant - global cp_fw - global cv_fw - global cp_bl - global cv_bl - global f_nuc_pow_bz_struct - global f_nuc_pow_bz_liq - global pnuc_fw_ratio_dcll - global pnuc_blkt_ratio_dcll - global n_blkt_inboard_module_coolant_sections_radial - global n_blkt_inboard_module_coolant_sections_poloidal - global n_blkt_outboard_module_coolant_sections_radial - global n_blkt_outboard_module_coolant_sections_poloidal - global bzfllengi_n_rad_liq - global bzfllengi_n_pol_liq - global bzfllengo_n_rad_liq - global bzfllengo_n_pol_liq - global radius_blkt_channel - global radius_fw_channel_90_bend - global radius_fw_channel_180_bend - global radius_blkt_channel_90_bend - global radius_blkt_channel_180_bend + global \ + life_blkt_fpy, \ + life_blkt, \ + m_fw_blkt_div_coolant_total, \ + m_vv, \ + den_steel, \ + denwc, \ + dewmkg, \ + f_p_blkt_multiplication, \ + p_blkt_multiplication_mw, \ + fblss, \ + f_ster_div_single, \ + f_a_fw_outboard_hcd, \ + fhole, \ + i_fw_blkt_vv_shape, \ + life_fw_fpy, \ + m_fw_total, \ + fw_armour_mass, \ + fw_armour_thickness, \ + fw_armour_vol, \ + i_blanket_type, \ + i_blkt_inboard, \ + inuclear, \ + qnuc, \ + f_blkt_li6_enrichment, \ + p_blkt_nuclear_heat_total_mw, \ + pnuc_cp, \ + p_cp_shield_nuclear_heat_mw, \ + pnuc_cp_tf, \ + p_div_nuclear_heat_total_mw, \ + p_fw_nuclear_heat_total_mw, \ + p_fw_hcd_nuclear_heat_mw, \ + pnucloss, \ + pnucvvplus, \ + p_shld_nuclear_heat_mw, \ + m_blkt_total, \ + m_blkt_steel_total, \ + armour_fw_bl_mass, \ + breeder_f, \ + breeder_multiplier, \ + vfcblkt, \ + vfpblkt, \ + m_blkt_li4sio4, \ + m_blkt_tibe12, \ + neut_flux_cp, \ + f_neut_shield, \ + f_a_fw_coolant_inboard, \ + f_a_fw_coolant_outboard, \ + psurffwi, \ + psurffwo, \ + vol_fw_total, \ + f_vol_blkt_steel, \ + f_vol_blkt_li4sio4, \ + f_vol_blkt_tibe12, \ + breedmat, \ + densbreed, \ + fblbe, \ + fblbreed, \ + fblhebmi, \ + fblhebmo, \ + fblhebpi, \ + fblhebpo, \ + hcdportsize, \ + nflutf, \ + npdiv, \ + nphcdin, \ + nphcdout, \ + tbr, \ + tritprate, \ + wallpf, \ + whtblbreed, \ + m_blkt_beryllium, \ + i_p_coolant_pumping, \ + i_shield_mat, \ + i_thermal_electric_conversion, \ + secondary_cycle_liq, \ + i_blkt_coolant_type, \ + i_fw_coolant_type, \ + dr_fw_wall, \ + radius_fw_channel, \ + dx_fw_module, \ + temp_fw_coolant_in, \ + temp_fw_coolant_out, \ + pres_fw_coolant, \ + temp_fw_peak, \ + roughness_fw_channel, \ + len_fw_channel, \ + f_fw_peak, \ + pres_blkt_coolant, \ + temp_blkt_coolant_in, \ + temp_blkt_coolant_out, \ + coolp, \ + n_blkt_outboard_modules_poloidal, \ + n_blkt_inboard_modules_poloidal, \ + n_blkt_outboard_modules_toroidal, \ + n_blkt_inboard_modules_toroidal, \ + temp_fw_max, \ + fw_th_conductivity, \ + fvoldw, \ + fvolsi, \ + fvolso, \ + fwclfr, \ + p_div_rad_total_mw, \ + p_fw_rad_total_mw, \ + p_fw_hcd_rad_total_mw, \ + pradloss, \ + p_tf_nuclear_heat_mw, \ + ptfnucpm3, \ + r_cryostat_inboard, \ + z_cryostat_half_inside, \ + dr_pf_cryostat, \ + vol_cryostat, \ + vol_cryostat_internal, \ + vol_vv, \ + vfshld, \ + vol_blkt_total, \ + vol_blkt_inboard, \ + vol_blkt_outboard, \ + vol_shld_total, \ + whtshld, \ + wpenshld, \ + wtshldi, \ + wtshldo, \ + irefprop, \ + fblli, \ + fblli2o, \ + fbllipb, \ + fblvd, \ + m_blkt_li2o, \ + wtbllipb, \ + m_blkt_vanadium, \ + m_blkt_lithium, \ + f_a_blkt_cooling_channels, \ + blktmodel, \ + declblkt, \ + declfw, \ + declshld, \ + blkttype, \ + etaiso, \ + eta_coolant_pump_electric, \ + i_fw_blkt_shared_coolant, \ + i_blkt_liquid_breeder_type, \ + i_blkt_dual_coolant, \ + i_blkt_liquid_breeder_channel_type, \ + i_blkt_module_segmentation, \ + n_liq_recirc, \ + r_f_liq_ib, \ + r_f_liq_ob, \ + w_f_liq_ib, \ + w_f_liq_ob, \ + den_ceramic, \ + th_wall_secondary, \ + bz_channel_conduct_liq, \ + a_bz_liq, \ + b_bz_liq, \ + nopol, \ + nopipes, \ + den_liq, \ + wht_liq, \ + wht_liq_ib, \ + wht_liq_ob, \ + specific_heat_liq, \ + thermal_conductivity_liq, \ + dynamic_viscosity_liq, \ + electrical_conductivity_liq, \ + hartmann_liq, \ + b_mag_blkt, \ + etaiso_liq, \ + blpressure_liq, \ + inlet_temp_liq, \ + outlet_temp_liq, \ + den_fw_coolant, \ + visc_fw_coolant, \ + den_blkt_coolant, \ + visc_blkt_coolant, \ + cp_fw, \ + cv_fw, \ + cp_bl, \ + cv_bl, \ + f_nuc_pow_bz_struct, \ + f_nuc_pow_bz_liq, \ + pnuc_fw_ratio_dcll, \ + pnuc_blkt_ratio_dcll, \ + n_blkt_inboard_module_coolant_sections_radial, \ + n_blkt_inboard_module_coolant_sections_poloidal, \ + n_blkt_outboard_module_coolant_sections_radial, \ + n_blkt_outboard_module_coolant_sections_poloidal, \ + bzfllengi_n_rad_liq, \ + bzfllengi_n_pol_liq, \ + bzfllengo_n_rad_liq, \ + bzfllengo_n_pol_liq, \ + radius_blkt_channel, \ + radius_fw_channel_90_bend, \ + radius_fw_channel_180_bend, \ + radius_blkt_channel_90_bend, \ + radius_blkt_channel_180_bend life_blkt_fpy = 0.0 life_blkt = 0.0 diff --git a/process/data_structure/global_variables.py b/process/data_structure/global_variables.py index e961ce3a66..57e36bdf7e 100644 --- a/process/data_structure/global_variables.py +++ b/process/data_structure/global_variables.py @@ -36,19 +36,20 @@ def init_global_variables(): - global icase - global runtitle - global run_tests - global verbose - global maxcal - global fileprefix - global output_prefix - global xlabel - global vlabel - global xlabel_2 - global vlabel_2 - global iscan_global - global convergence_parameter + global \ + icase, \ + runtitle, \ + run_tests, \ + verbose, \ + maxcal, \ + fileprefix, \ + output_prefix, \ + xlabel, \ + vlabel, \ + xlabel_2, \ + vlabel_2, \ + iscan_global, \ + convergence_parameter icase = "Steady-state tokamak model" runtitle = "Run Title (change this line using input variable 'runtitle')" diff --git a/process/data_structure/heat_transport_variables.py b/process/data_structure/heat_transport_variables.py index b8820eadef..4f4a0c89f1 100644 --- a/process/data_structure/heat_transport_variables.py +++ b/process/data_structure/heat_transport_variables.py @@ -230,56 +230,57 @@ def init_heat_transport_variables(): """Initialise heat transport variables""" - global p_plant_electric_base - global p_cryo_plant_electric_mw - global p_cryo_plant_electric_max_mw - global f_crypmw - global etatf - global eta_turbine - global etath_liq - global fachtmw - global p_plant_electric_base_total_mw - global fgrosbop - global fmgdmw - global f_p_blkt_coolant_pump_total_heat - global f_p_div_coolant_pump_total_heat - global f_p_fw_coolant_pump_total_heat - global f_p_shld_coolant_pump_total_heat - global helpow - global helpow_cryal - global p_coolant_pump_elec_total_mw - global p_blkt_coolant_pump_mw - global p_blkt_breeder_pump_mw - global htpmw_blkt_tot - global p_div_coolant_pump_mw - global p_fw_coolant_pump_mw - global p_shld_coolant_pump_mw - global p_coolant_pump_loss_total_mw - global ipowerflow - global i_shld_primary_heat - global n_primary_heat_exchangers - global pacpmw - global peakmva - global p_fw_div_heat_deposited_mw - global p_plant_electric_gross_mw - global p_hcd_electric_loss_mw - global p_hcd_electric_total_mw - global p_hcd_secondary_electric_mw - global p_plant_electric_net_mw - global p_plant_electric_recirc_mw - global priheat - global p_div_secondary_heat_mw - global p_hcd_secondary_heat_mw - global p_plant_secondary_heat_mw - global p_shld_secondary_heat_mw - global p_plant_primary_heat_mw - global pflux_plant_floor_electric - global p_tf_electric_supplies_mw - global tlvpmw - global p_tritium_plant_electric_mw - global temp_turbine_coolant_in - global vachtmw - global f_p_plant_electric_recirc + global \ + p_plant_electric_base, \ + p_cryo_plant_electric_mw, \ + p_cryo_plant_electric_max_mw, \ + f_crypmw, \ + etatf, \ + eta_turbine, \ + etath_liq, \ + fachtmw, \ + p_plant_electric_base_total_mw, \ + fgrosbop, \ + fmgdmw, \ + f_p_blkt_coolant_pump_total_heat, \ + f_p_div_coolant_pump_total_heat, \ + f_p_fw_coolant_pump_total_heat, \ + f_p_shld_coolant_pump_total_heat, \ + helpow, \ + helpow_cryal, \ + p_coolant_pump_elec_total_mw, \ + p_blkt_coolant_pump_mw, \ + p_blkt_breeder_pump_mw, \ + htpmw_blkt_tot, \ + p_div_coolant_pump_mw, \ + p_fw_coolant_pump_mw, \ + p_shld_coolant_pump_mw, \ + p_coolant_pump_loss_total_mw, \ + ipowerflow, \ + i_shld_primary_heat, \ + n_primary_heat_exchangers, \ + pacpmw, \ + peakmva, \ + p_fw_div_heat_deposited_mw, \ + p_plant_electric_gross_mw, \ + p_hcd_electric_loss_mw, \ + p_hcd_electric_total_mw, \ + p_hcd_secondary_electric_mw, \ + p_plant_electric_net_mw, \ + p_plant_electric_recirc_mw, \ + priheat, \ + p_div_secondary_heat_mw, \ + p_hcd_secondary_heat_mw, \ + p_plant_secondary_heat_mw, \ + p_shld_secondary_heat_mw, \ + p_plant_primary_heat_mw, \ + pflux_plant_floor_electric, \ + p_tf_electric_supplies_mw, \ + tlvpmw, \ + p_tritium_plant_electric_mw, \ + temp_turbine_coolant_in, \ + vachtmw, \ + f_p_plant_electric_recirc p_plant_electric_base = 5.0e6 p_cryo_plant_electric_mw = 0.0 diff --git a/process/data_structure/ife_variables.py b/process/data_structure/ife_variables.py index aa4dc18d98..261ce4a3f5 100644 --- a/process/data_structure/ife_variables.py +++ b/process/data_structure/ife_variables.py @@ -496,120 +496,121 @@ def init_ife_variables(): - global bldr - global bldrc - global bldzl - global bldzu - global blmatf - global blmatm - global blmatv - global blvol - global cdriv0 - global cdriv1 - global cdriv2 - global cdriv3 - global chdzl - global chdzu - global chmatf - global chmatm - global chmatv - global chrad - global chvol - global dcdrv0 - global dcdrv1 - global dcdrv2 - global drveff - global edrive - global etadrv - global etali - global etave - global fauxbop - global fbreed - global fburn - global flirad - global frrmax - global fwdr - global fwdzl - global fwdzu - global fwmatf - global fwmatm - global fwmatv - global fwvol - global gain - global gainve - global htpmw_ife - global ife - global ifedrv - global ifetyp - global lipmw - global mcdriv - global mflibe - global pdrive - global pfusife - global pifecr - global ptargf - global r1 - global r2 - global r3 - global r4 - global r5 - global r6 - global r7 - global reprat - global rrin - global rrmax - global shdr - global shdzl - global shdzu - global shmatf - global shmatm - global shmatv - global shvol - global sombdr - global somtdr - global taufall - global tdspmw - global tfacmw - global tgain - global uccarb - global ucconc - global ucflib - global uctarg - global v1dr - global v1dzl - global v1dzu - global v1matf - global v1matm - global v1matv - global v1vol - global v2dr - global v2dzl - global v2dzu - global v2matf - global v2matm - global v2matv - global v2vol - global v3dr - global v3dzl - global v3dzu - global v3matf - global v3matm - global v3matv - global v3vol - global zl1 - global zl2 - global zl3 - global zl4 - global zl5 - global zl6 - global zl7 - global zu1 - global zu2 - global zu3 - global zu4 - global zu5 - global zu6 - global zu7 + global \ + bldr, \ + bldrc, \ + bldzl, \ + bldzu, \ + blmatf, \ + blmatm, \ + blmatv, \ + blvol, \ + cdriv0, \ + cdriv1, \ + cdriv2, \ + cdriv3, \ + chdzl, \ + chdzu, \ + chmatf, \ + chmatm, \ + chmatv, \ + chrad, \ + chvol, \ + dcdrv0, \ + dcdrv1, \ + dcdrv2, \ + drveff, \ + edrive, \ + etadrv, \ + etali, \ + etave, \ + fauxbop, \ + fbreed, \ + fburn, \ + flirad, \ + frrmax, \ + fwdr, \ + fwdzl, \ + fwdzu, \ + fwmatf, \ + fwmatm, \ + fwmatv, \ + fwvol, \ + gain, \ + gainve, \ + htpmw_ife, \ + ife, \ + ifedrv, \ + ifetyp, \ + lipmw, \ + mcdriv, \ + mflibe, \ + pdrive, \ + pfusife, \ + pifecr, \ + ptargf, \ + r1, \ + r2, \ + r3, \ + r4, \ + r5, \ + r6, \ + r7, \ + reprat, \ + rrin, \ + rrmax, \ + shdr, \ + shdzl, \ + shdzu, \ + shmatf, \ + shmatm, \ + shmatv, \ + shvol, \ + sombdr, \ + somtdr, \ + taufall, \ + tdspmw, \ + tfacmw, \ + tgain, \ + uccarb, \ + ucconc, \ + ucflib, \ + uctarg, \ + v1dr, \ + v1dzl, \ + v1dzu, \ + v1matf, \ + v1matm, \ + v1matv, \ + v1vol, \ + v2dr, \ + v2dzl, \ + v2dzu, \ + v2matf, \ + v2matm, \ + v2matv, \ + v2vol, \ + v3dr, \ + v3dzl, \ + v3dzu, \ + v3matf, \ + v3matm, \ + v3matv, \ + v3vol, \ + zl1, \ + zl2, \ + zl3, \ + zl4, \ + zl5, \ + zl6, \ + zl7, \ + zu1, \ + zu2, \ + zu3, \ + zu4, \ + zu5, \ + zu6, \ + zu7 """Initialise IFE variables""" bldr = 1.0 diff --git a/process/data_structure/impurity_radiation_module.py b/process/data_structure/impurity_radiation_module.py index b54522e300..c5e0c6787f 100644 --- a/process/data_structure/impurity_radiation_module.py +++ b/process/data_structure/impurity_radiation_module.py @@ -53,19 +53,20 @@ def init_impurity_radiation_module(): - global radius_plasma_core_norm - global f_p_plasma_core_rad_reduction - global f_nd_impurity_electrons - global n_charge_impurity_profile - global imp_label - global impurity_arr_label - global impurity_arr_z - global m_impurity_amu_array - global f_nd_impurity_electron_array - global impurity_arr_len_tab - global temp_impurity_keV_array - global pden_impurity_lz_nd_temp_array - global impurity_arr_zav + global \ + radius_plasma_core_norm, \ + f_p_plasma_core_rad_reduction, \ + f_nd_impurity_electrons, \ + n_charge_impurity_profile, \ + imp_label, \ + impurity_arr_label, \ + impurity_arr_z, \ + m_impurity_amu_array, \ + f_nd_impurity_electron_array, \ + impurity_arr_len_tab, \ + temp_impurity_keV_array, \ + pden_impurity_lz_nd_temp_array, \ + impurity_arr_zav radius_plasma_core_norm = 0.6 f_p_plasma_core_rad_reduction = 1.0 diff --git a/process/data_structure/neoclassics_variables.py b/process/data_structure/neoclassics_variables.py index eb9c2119d1..b1ec8a9a74 100644 --- a/process/data_structure/neoclassics_variables.py +++ b/process/data_structure/neoclassics_variables.py @@ -81,29 +81,30 @@ def init_neoclassics_variables(): - global densities - global temperatures - global dr_densities - global dr_temperatures - global roots - global weights - global nu - global nu_star - global nu_star_averaged - global vd - global kt - global er - global iota - global d11_mono - global d11_plateau - global d111 - global d112 - global d113 - global q_flux - global gamma_flux - global d31_mono - global eps_eff - global r_eff + global \ + densities, \ + temperatures, \ + dr_densities, \ + dr_temperatures, \ + roots, \ + weights, \ + nu, \ + nu_star, \ + nu_star_averaged, \ + vd, \ + kt, \ + er, \ + iota, \ + d11_mono, \ + d11_plateau, \ + d111, \ + d112, \ + d113, \ + q_flux, \ + gamma_flux, \ + d31_mono, \ + eps_eff, \ + r_eff densities = np.zeros(4) temperatures = np.zeros(4) diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index 4bf548f81c..e01694754b 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -448,49 +448,50 @@ def init_numerics(): - global ipnvars - global ipeqns - global ipnfoms - global ipvlam - global iptnt - global ipvp1 - global ioptimz - global minmax - global lablmm - global n_constraints - global ncalls - global neqns - global nfev1 - global nfev2 - global nineqns - global nvar - global nviter - global icc - global active_constraints - global lablcc - global ixc - global lablxc - global name_xc - global sqsumsq - global objf_name - global norm_objf - global epsfcn - global epsvmc - global factor - global ftol - global boundl - global boundu - global itv_scaled_lower_bounds - global itv_scaled_upper_bounds - global rcm - global resdl - global scafc - global scale - global xcm - global xcs - global vlam - global force_vmcon_inequality_satisfication - global force_vmcon_inequality_tolerance + global \ + ipnvars, \ + ipeqns, \ + ipnfoms, \ + ipvlam, \ + iptnt, \ + ipvp1, \ + ioptimz, \ + minmax, \ + lablmm, \ + n_constraints, \ + ncalls, \ + neqns, \ + nfev1, \ + nfev2, \ + nineqns, \ + nvar, \ + nviter, \ + icc, \ + active_constraints, \ + lablcc, \ + ixc, \ + lablxc, \ + name_xc, \ + sqsumsq, \ + objf_name, \ + norm_objf, \ + epsfcn, \ + epsvmc, \ + factor, \ + ftol, \ + boundl, \ + boundu, \ + itv_scaled_lower_bounds, \ + itv_scaled_upper_bounds, \ + rcm, \ + resdl, \ + scafc, \ + scale, \ + xcm, \ + xcs, \ + vlam, \ + force_vmcon_inequality_satisfication, \ + force_vmcon_inequality_tolerance """Initialise module variables""" ioptimz = 1 diff --git a/process/data_structure/pf_power_variables.py b/process/data_structure/pf_power_variables.py index a3ddd0f5ae..4151c1a566 100644 --- a/process/data_structure/pf_power_variables.py +++ b/process/data_structure/pf_power_variables.py @@ -45,17 +45,18 @@ def init_pf_power_variables(): """Initialise PF coil power variables""" - global acptmax - global ensxpfm - global i_pf_energy_storage_source - global pfckts - global spfbusl - global spsmva - global srcktpm - global vpfskv - global peakpoloidalpower - global maxpoloidalpower - global poloidalpower + global \ + acptmax, \ + ensxpfm, \ + i_pf_energy_storage_source, \ + pfckts, \ + spfbusl, \ + spsmva, \ + srcktpm, \ + vpfskv, \ + peakpoloidalpower, \ + maxpoloidalpower, \ + poloidalpower acptmax = 0.0 ensxpfm = 0.0 diff --git a/process/data_structure/pfcoil_variables.py b/process/data_structure/pfcoil_variables.py index 63be3d2f58..3640bb4069 100644 --- a/process/data_structure/pfcoil_variables.py +++ b/process/data_structure/pfcoil_variables.py @@ -563,25 +563,26 @@ def init_pfcoil_module(): - global first_call - global cslimit - global nef - global nfxf - global ricpf - global ssq0 - global stress_z_cs_self_peak_midplane - global sig_hoop - global forc_z_cs_self_peak_midplane - global r_pf_cs_current_filaments - global z_pf_cs_current_filaments - global c_pf_cs_current_filaments - global xind - global r_pf_coil_middle_group_array - global z_pf_coil_middle_group_array - global ccls - global ccl0 - global bpf2 - global vsdum + global \ + first_call, \ + cslimit, \ + nef, \ + nfxf, \ + ricpf, \ + ssq0, \ + stress_z_cs_self_peak_midplane, \ + sig_hoop, \ + forc_z_cs_self_peak_midplane, \ + r_pf_cs_current_filaments, \ + z_pf_cs_current_filaments, \ + c_pf_cs_current_filaments, \ + xind, \ + r_pf_coil_middle_group_array, \ + z_pf_coil_middle_group_array, \ + ccls, \ + ccl0, \ + bpf2, \ + vsdum first_call = True cslimit = False @@ -607,107 +608,108 @@ def init_pfcoil_module(): def init_pfcoil_variables(): """Initialise the PF coil variables""" - global alfapf - global alstroh - global i_cs_stress - global a_cs_poloidal - global a_cs_turn - global awpoh - global b_cs_peak_flat_top_end - global b_cs_peak_pulse_start - global b_pf_coil_peak - global ccl0_ma - global ccls_ma - global j_cs_pulse_start - global j_cs_flat_top_end - global c_pf_coil_turn - global c_pf_coil_turn_peak_input - global c_pf_cs_coil_pulse_start_ma - global c_pf_cs_coil_flat_top_ma - global c_pf_cs_coil_pulse_end_ma - global etapsu - global f_j_cs_start_end_flat_top - global f_j_cs_start_pulse_end_flat_top - global fcuohsu - global fcupfsu - global fvs_cs_pf_total_ramp - global i_pf_location - global i_pf_conductor - global itr_sum - global i_cs_superconductor - global i_pf_superconductor - global j_crit_str_cs - global j_crit_str_pf - global i_pf_current - global i_r_pf_outside_tf_placement - global j_cs_conductor_critical_pulse_start - global j_cs_conductor_critical_flat_top_end - global jcableoh_bop - global jcableoh_eof - global n_pf_cs_plasma_circuits - global n_pf_coils_in_group - global n_cs_current_filaments - global n_pf_coil_groups - global n_cs_pf_coils - global f_z_cs_tf_internal - global f_a_cs_turn_steel - global pf_current_safety_factor - global pfcaseth - global rho_pf_coil - global rhopfbus - global m_pf_coil_max - global r_pf_coil_outer_max - global p_pf_electric_supplies_mw - global p_cs_resistive_flat_top - global p_pf_coil_resistive_total_flat_top - global r_pf_coil_inner - global r_pf_coil_outer - global c_pf_cs_coils_peak_ma - global j_pf_coil_wp_peak - global j_cs_critical_flat_top_end - global j_cs_critical_pulse_start - global j_pf_wp_critical - global r_cs_middle - global dz_cs_full - global dr_pf_tf_outboard_out_offset - global r_pf_coil_middle - global dr_pf_cs_middle_offset - global rpf2 - global rref - global s_shear_cs_peak - global sigpfcalw - global sigpfcf - global ind_pf_cs_plasma_mutual - global temp_cs_superconductor_margin - global n_pf_coil_turns - global f_a_pf_coil_void - global f_a_cs_void - global vs_cs_pf_total_burn - global vs_pf_coils_total_burn - global vs_pf_coils_total_ramp - global vs_pf_coils_total_pulse - global vs_cs_total_pulse - global vs_cs_burn - global vs_cs_ramp - global vs_cs_pf_total_ramp - global vs_cs_pf_total_pulse - global f_c_pf_cs_peak_time_array - global m_pf_coil_conductor_total - global m_pf_coil_structure_total - global m_pf_coil_conductor - global m_pf_coil_structure - global z_pf_coil_upper - global z_pf_coil_lower - global z_pf_coil_middle - global zref - global b_cs_limit_max - global fb_cs_limit_max - global f_dr_dz_cs_turn - global dr_cs_turn - global dr_cs_full - global dz_cs_turn - global radius_cs_turn_corners - global radius_cs_turn_cable_space + global \ + alfapf, \ + alstroh, \ + i_cs_stress, \ + a_cs_poloidal, \ + a_cs_turn, \ + awpoh, \ + b_cs_peak_flat_top_end, \ + b_cs_peak_pulse_start, \ + b_pf_coil_peak, \ + ccl0_ma, \ + ccls_ma, \ + j_cs_pulse_start, \ + j_cs_flat_top_end, \ + c_pf_coil_turn, \ + c_pf_coil_turn_peak_input, \ + c_pf_cs_coil_pulse_start_ma, \ + c_pf_cs_coil_flat_top_ma, \ + c_pf_cs_coil_pulse_end_ma, \ + etapsu, \ + f_j_cs_start_end_flat_top, \ + f_j_cs_start_pulse_end_flat_top, \ + fcuohsu, \ + fcupfsu, \ + fvs_cs_pf_total_ramp, \ + i_pf_location, \ + i_pf_conductor, \ + itr_sum, \ + i_cs_superconductor, \ + i_pf_superconductor, \ + j_crit_str_cs, \ + j_crit_str_pf, \ + i_pf_current, \ + i_r_pf_outside_tf_placement, \ + j_cs_conductor_critical_pulse_start, \ + j_cs_conductor_critical_flat_top_end, \ + jcableoh_bop, \ + jcableoh_eof, \ + n_pf_cs_plasma_circuits, \ + n_pf_coils_in_group, \ + n_cs_current_filaments, \ + n_pf_coil_groups, \ + n_cs_pf_coils, \ + f_z_cs_tf_internal, \ + f_a_cs_turn_steel, \ + pf_current_safety_factor, \ + pfcaseth, \ + rho_pf_coil, \ + rhopfbus, \ + m_pf_coil_max, \ + r_pf_coil_outer_max, \ + p_pf_electric_supplies_mw, \ + p_cs_resistive_flat_top, \ + p_pf_coil_resistive_total_flat_top, \ + r_pf_coil_inner, \ + r_pf_coil_outer, \ + c_pf_cs_coils_peak_ma, \ + j_pf_coil_wp_peak, \ + j_cs_critical_flat_top_end, \ + j_cs_critical_pulse_start, \ + j_pf_wp_critical, \ + r_cs_middle, \ + dz_cs_full, \ + dr_pf_tf_outboard_out_offset, \ + r_pf_coil_middle, \ + dr_pf_cs_middle_offset, \ + rpf2, \ + rref, \ + s_shear_cs_peak, \ + sigpfcalw, \ + sigpfcf, \ + ind_pf_cs_plasma_mutual, \ + temp_cs_superconductor_margin, \ + n_pf_coil_turns, \ + f_a_pf_coil_void, \ + f_a_cs_void, \ + vs_cs_pf_total_burn, \ + vs_pf_coils_total_burn, \ + vs_pf_coils_total_ramp, \ + vs_pf_coils_total_pulse, \ + vs_cs_total_pulse, \ + vs_cs_burn, \ + vs_cs_ramp, \ + vs_cs_pf_total_ramp, \ + vs_cs_pf_total_pulse, \ + f_c_pf_cs_peak_time_array, \ + m_pf_coil_conductor_total, \ + m_pf_coil_structure_total, \ + m_pf_coil_conductor, \ + m_pf_coil_structure, \ + z_pf_coil_upper, \ + z_pf_coil_lower, \ + z_pf_coil_middle, \ + zref, \ + b_cs_limit_max, \ + fb_cs_limit_max, \ + f_dr_dz_cs_turn, \ + dr_cs_turn, \ + dr_cs_full, \ + dz_cs_turn, \ + radius_cs_turn_corners, \ + radius_cs_turn_cable_space alfapf = 5e-10 alstroh = 4.0e8 diff --git a/process/data_structure/physics_variables.py b/process/data_structure/physics_variables.py index ef365893bc..e14f132539 100644 --- a/process/data_structure/physics_variables.py +++ b/process/data_structure/physics_variables.py @@ -1323,32 +1323,33 @@ def init_physics_module(): """Initialise the physics module""" - global first_call - global iscz - global err242 - global err243 - global f_p_plasma_separatrix_rad - global e_plasma_beta - global p_plasma_heating_total_mw - global t_energy_confinement_beta - global ptarmw - global lambdaio - global drsep - global fio - global fli - global flo - global fui - global fuo - global plimw - global plomw - global puimw - global puomw - global rho_star - global rho_ne_max - global rho_te_max - global nu_star - global beta_mcdonald - global itart_r + global \ + first_call, \ + iscz, \ + err242, \ + err243, \ + f_p_plasma_separatrix_rad, \ + e_plasma_beta, \ + p_plasma_heating_total_mw, \ + t_energy_confinement_beta, \ + ptarmw, \ + lambdaio, \ + drsep, \ + fio, \ + fli, \ + flo, \ + fui, \ + fuo, \ + plimw, \ + plomw, \ + puimw, \ + puomw, \ + rho_star, \ + rho_ne_max, \ + rho_te_max, \ + nu_star, \ + beta_mcdonald, \ + itart_r first_call = 1 iscz = 0 @@ -1379,265 +1380,266 @@ def init_physics_module(): def init_physics_variables(): - global m_beam_amu - global m_fuel_amu - global m_ions_total_amu - global m_plasma_fuel_ions - global m_plasma_ions_total - global m_plasma_alpha - global m_plasma_electron - global m_plasma - global alphaj - global i_alphaj - global alphan - global alphap - global fusden_alpha_total - global fusden_plasma_alpha - global alphat - global aspect - global beamfus0 - global beta_total_vol_avg - global beta_fast_alpha - global beta_vol_avg_max - global beta_vol_avg_min - global beta_beam - global beta_poloidal_vol_avg - global beta_poloidal_eps - global beta_toroidal_vol_avg - global beta_thermal_toroidal_profile - global beta_thermal_vol_avg - global beta_thermal_poloidal_vol_avg - global beta_thermal_toroidal_vol_avg - global beta_norm_total - global beta_norm_thermal - global beta_norm_poloidal - global e_plasma_beta_thermal - global beta_norm_toroidal - global betbm0 - global b_plasma_poloidal_average - global b_plasma_toroidal_on_axis - global b_plasma_toroidal_inboard - global b_plasma_toroidal_outboard - global b_plasma_toroidal_profile - global b_plasma_total - global e_plasma_magnetic_stored - global burnup - global burnup_in - global b_plasma_vertical_required - global c_beta - global csawth - global f_vol_plasma - global f_r_conducting_wall - global nd_plasma_electrons_vol_avg - global nd_plasma_fuel_ions_vol_avg - global dlamee - global dlamie - global nd_plasma_electron_max_array - global nd_plasma_alphas_vol_avg - global nd_beam_ions - global nd_beam_ions_out - global beta_norm_max - global beta_norm_max_wesson - global beta_norm_max_menard - global beta_norm_max_original_scaling - global beta_norm_max_tholerus - global beta_norm_max_stambaugh - global nd_plasma_electrons_max - global nd_plasma_ions_total_vol_avg - global nd_plasma_electron_line - global nd_plasma_protons_vol_avg - global ntau - global nTtau - global nd_plasma_impurities_vol_avg - global beta_poloidal_eps_max - global eps - global f_c_plasma_auxiliary - global f_c_plasma_inductive - global f_alpha_electron - global f_p_alpha_plasma_deposited - global f_alpha_ion - global f_plasma_fuel_deuterium - global f_p_div_lower - global ffwal - global f_nd_plasma_pedestal_greenwald - global f_nd_plasma_separatrix_greenwald - global f_plasma_fuel_helium3 - global figmer - global fkzohm - global fplhsep - global fp_plasma_separatrix_min_mw - global fne0 - global f_plasma_fuel_tritium - global fusden_total - global fusrat_total - global fusrat_plasma_dt_profile - global fusrat_plasma_dd_triton_profile - global fusrat_plasma_dd_helion_profile - global fusrat_plasma_dhe3_profile - global fusden_plasma - global f_c_plasma_non_inductive - global ejima_coeff - global f_beta_alpha_beam_thermal - global hfac - global hfact - global t_plasma_energy_confinement_max - global i_bootstrap_current - global i_beta_component - global i_plasma_current - global i_diamagnetic_current - global i_density_limit - global n_divertors - global i_beta_fast_alpha - global i_plasma_ignited - global i_plasma_pedestal - global i_pfirsch_schluter_current - global nd_plasma_pedestal_electron - global nd_plasma_separatrix_electron - global alpha_crit - global nd_plasma_separatrix_electron_eich_max - global plasma_res_factor - global radius_plasma_pedestal_density_norm - global radius_plasma_pedestal_temp_norm - global tbeta - global temp_plasma_pedestal_kev - global temp_plasma_separatrix_kev - global i_beta_norm_max - global i_rad_loss - global i_confinement_time - global i_plasma_wall_gap - global i_plasma_geometry - global i_plasma_shape - global itart - global itartpf - global i_pflux_fw_neutron - global plasma_square - global kappa - global kappa95 - global kappa_ipb - global nd_plasma_electron_on_axis - global nd_plasma_ions_on_axis - global m_s_limit - global pres_plasma_thermal_on_axis - global pres_plasma_thermal_total_profile - global pres_plasma_electron_profile - global pres_plasma_ion_total_profile - global pres_plasma_fuel_profile - global j_plasma_on_axis - global j_plasma_bootstrap_sauter_profile - global n_plasma_profile_elements - global f_dd_branching_trit - global pden_plasma_alpha_mw - global pden_alpha_total_mw - global f_pden_alpha_electron_mw - global p_fw_alpha_mw - global f_pden_alpha_ions_mw - global p_alpha_total_mw - global p_plasma_alpha_mw - global p_beam_alpha_mw - global p_beam_neutron_mw - global p_beam_dt_mw - global p_non_alpha_charged_mw - global pden_non_alpha_charged_mw - global f_temp_plasma_electron_density_vol_avg - global p_plasma_inner_rad_mw - global pden_plasma_core_rad_mw - global p_dd_total_mw - global p_dhe3_total_mw - global p_plasma_separatrix_mw - global p_div_lower_separatrix_mw - global p_div_upper_separatrix_mw - global p_div_separatrix_max_mw - global p_dt_total_mw - global p_plasma_dt_mw - global p_plasma_outer_rad_mw - global pden_plasma_outer_rad_mw - global p_charged_particle_mw - global vs_plasma_internal - global pflux_fw_rad_mw - global pden_ion_electron_equilibration_mw - global plasma_current - global p_plasma_neutron_mw - global p_neutron_total_mw - global pden_neutron_total_mw - global pden_plasma_neutron_mw - global p_plasma_ohmic_mw - global pden_plasma_ohmic_mw - global p_plasma_loss_mw - global p_fusion_total_mw - global len_plasma_poloidal - global p_plasma_rad_mw - global pden_plasma_rad_mw - global pradsolmw - global proton_rate_density - global psolradmw - global pden_plasma_sync_mw - global p_plasma_sync_mw - global i_l_h_threshold - global p_l_h_threshold_mw - global l_h_threshold_powers - global p_electron_transport_loss_mw - global pden_electron_transport_loss_mw - global p_ion_transport_loss_mw - global pscalingmw - global pden_ion_transport_loss_mw - global q0 - global q95 - global molflow_plasma_fuelling_required - global tauratio - global q95_min - global qstar - global rad_fraction_sol - global rad_fraction_total - global f_nd_alpha_electron - global f_nd_protium_electrons - global ind_plasma_internal_norm - global ind_plasma_internal_norm_wesson - global ind_plasma_internal_norm_menard - global ind_plasma_internal_norm_iter_3 - global i_ind_plasma_internal_norm - global ind_plasma - global rmajor - global rminor - global f_nd_beam_electron - global f_nd_plasma_carbon_electron - global rndfuel - global f_nd_plasma_iron_argon_electron - global f_nd_plasma_oxygen_electron - global f_res_plasma_neo - global res_plasma - global t_plasma_res_diffusion - global a_plasma_surface - global a_plasma_surface_outboard - global i_single_null - global f_sync_reflect - global t_electron_energy_confinement - global tauee_in - global t_energy_confinement - global t_ion_energy_confinement - global t_alpha_confinement - global f_alpha_energy_confinement - global temp_plasma_electron_vol_avg_kev - global temp_plasma_electron_on_axis_kev - global temp_plasma_electron_density_weighted_kev - global temp_plasma_ion_vol_avg_kev - global temp_plasma_ion_on_axis_kev - global temp_plasma_ion_density_weighted_kev - global f_temp_plasma_ion_electron - global triang - global triang95 - global vol_plasma - global vs_plasma_burn_required - global vs_plasma_ramp_required - global v_plasma_loop_burn - global vs_plasma_ind_ramp - global vs_plasma_res_ramp - global vs_plasma_total_required - global pflux_fw_neutron_mw - global wtgpd - global a_plasma_poloidal - global n_charge_plasma_effective_vol_avg - global n_charge_plasma_effective_profile - global n_charge_plasma_effective_mass_weighted_vol_avg + global \ + m_beam_amu, \ + m_fuel_amu, \ + m_ions_total_amu, \ + m_plasma_fuel_ions, \ + m_plasma_ions_total, \ + m_plasma_alpha, \ + m_plasma_electron, \ + m_plasma, \ + alphaj, \ + i_alphaj, \ + alphan, \ + alphap, \ + fusden_alpha_total, \ + fusden_plasma_alpha, \ + alphat, \ + aspect, \ + beamfus0, \ + beta_total_vol_avg, \ + beta_fast_alpha, \ + beta_vol_avg_max, \ + beta_vol_avg_min, \ + beta_beam, \ + beta_poloidal_vol_avg, \ + beta_poloidal_eps, \ + beta_toroidal_vol_avg, \ + beta_thermal_toroidal_profile, \ + beta_thermal_vol_avg, \ + beta_thermal_poloidal_vol_avg, \ + beta_thermal_toroidal_vol_avg, \ + beta_norm_total, \ + beta_norm_thermal, \ + beta_norm_poloidal, \ + e_plasma_beta_thermal, \ + beta_norm_toroidal, \ + betbm0, \ + b_plasma_poloidal_average, \ + b_plasma_toroidal_on_axis, \ + b_plasma_toroidal_inboard, \ + b_plasma_toroidal_outboard, \ + b_plasma_toroidal_profile, \ + b_plasma_total, \ + e_plasma_magnetic_stored, \ + burnup, \ + burnup_in, \ + b_plasma_vertical_required, \ + c_beta, \ + csawth, \ + f_vol_plasma, \ + f_r_conducting_wall, \ + nd_plasma_electrons_vol_avg, \ + nd_plasma_fuel_ions_vol_avg, \ + dlamee, \ + dlamie, \ + nd_plasma_electron_max_array, \ + nd_plasma_alphas_vol_avg, \ + nd_beam_ions, \ + nd_beam_ions_out, \ + beta_norm_max, \ + beta_norm_max_wesson, \ + beta_norm_max_menard, \ + beta_norm_max_original_scaling, \ + beta_norm_max_tholerus, \ + beta_norm_max_stambaugh, \ + nd_plasma_electrons_max, \ + nd_plasma_ions_total_vol_avg, \ + nd_plasma_electron_line, \ + nd_plasma_protons_vol_avg, \ + ntau, \ + nTtau, \ + nd_plasma_impurities_vol_avg, \ + beta_poloidal_eps_max, \ + eps, \ + f_c_plasma_auxiliary, \ + f_c_plasma_inductive, \ + f_alpha_electron, \ + f_p_alpha_plasma_deposited, \ + f_alpha_ion, \ + f_plasma_fuel_deuterium, \ + f_p_div_lower, \ + ffwal, \ + f_nd_plasma_pedestal_greenwald, \ + f_nd_plasma_separatrix_greenwald, \ + f_plasma_fuel_helium3, \ + figmer, \ + fkzohm, \ + fplhsep, \ + fp_plasma_separatrix_min_mw, \ + fne0, \ + f_plasma_fuel_tritium, \ + fusden_total, \ + fusrat_total, \ + fusrat_plasma_dt_profile, \ + fusrat_plasma_dd_triton_profile, \ + fusrat_plasma_dd_helion_profile, \ + fusrat_plasma_dhe3_profile, \ + fusden_plasma, \ + f_c_plasma_non_inductive, \ + ejima_coeff, \ + f_beta_alpha_beam_thermal, \ + hfac, \ + hfact, \ + t_plasma_energy_confinement_max, \ + i_bootstrap_current, \ + i_beta_component, \ + i_plasma_current, \ + i_diamagnetic_current, \ + i_density_limit, \ + n_divertors, \ + i_beta_fast_alpha, \ + i_plasma_ignited, \ + i_plasma_pedestal, \ + i_pfirsch_schluter_current, \ + nd_plasma_pedestal_electron, \ + nd_plasma_separatrix_electron, \ + alpha_crit, \ + nd_plasma_separatrix_electron_eich_max, \ + plasma_res_factor, \ + radius_plasma_pedestal_density_norm, \ + radius_plasma_pedestal_temp_norm, \ + tbeta, \ + temp_plasma_pedestal_kev, \ + temp_plasma_separatrix_kev, \ + i_beta_norm_max, \ + i_rad_loss, \ + i_confinement_time, \ + i_plasma_wall_gap, \ + i_plasma_geometry, \ + i_plasma_shape, \ + itart, \ + itartpf, \ + i_pflux_fw_neutron, \ + plasma_square, \ + kappa, \ + kappa95, \ + kappa_ipb, \ + nd_plasma_electron_on_axis, \ + nd_plasma_ions_on_axis, \ + m_s_limit, \ + pres_plasma_thermal_on_axis, \ + pres_plasma_thermal_total_profile, \ + pres_plasma_electron_profile, \ + pres_plasma_ion_total_profile, \ + pres_plasma_fuel_profile, \ + j_plasma_on_axis, \ + j_plasma_bootstrap_sauter_profile, \ + n_plasma_profile_elements, \ + f_dd_branching_trit, \ + pden_plasma_alpha_mw, \ + pden_alpha_total_mw, \ + f_pden_alpha_electron_mw, \ + p_fw_alpha_mw, \ + f_pden_alpha_ions_mw, \ + p_alpha_total_mw, \ + p_plasma_alpha_mw, \ + p_beam_alpha_mw, \ + p_beam_neutron_mw, \ + p_beam_dt_mw, \ + p_non_alpha_charged_mw, \ + pden_non_alpha_charged_mw, \ + f_temp_plasma_electron_density_vol_avg, \ + p_plasma_inner_rad_mw, \ + pden_plasma_core_rad_mw, \ + p_dd_total_mw, \ + p_dhe3_total_mw, \ + p_plasma_separatrix_mw, \ + p_div_lower_separatrix_mw, \ + p_div_upper_separatrix_mw, \ + p_div_separatrix_max_mw, \ + p_dt_total_mw, \ + p_plasma_dt_mw, \ + p_plasma_outer_rad_mw, \ + pden_plasma_outer_rad_mw, \ + p_charged_particle_mw, \ + vs_plasma_internal, \ + pflux_fw_rad_mw, \ + pden_ion_electron_equilibration_mw, \ + plasma_current, \ + p_plasma_neutron_mw, \ + p_neutron_total_mw, \ + pden_neutron_total_mw, \ + pden_plasma_neutron_mw, \ + p_plasma_ohmic_mw, \ + pden_plasma_ohmic_mw, \ + p_plasma_loss_mw, \ + p_fusion_total_mw, \ + len_plasma_poloidal, \ + p_plasma_rad_mw, \ + pden_plasma_rad_mw, \ + pradsolmw, \ + proton_rate_density, \ + psolradmw, \ + pden_plasma_sync_mw, \ + p_plasma_sync_mw, \ + i_l_h_threshold, \ + p_l_h_threshold_mw, \ + l_h_threshold_powers, \ + p_electron_transport_loss_mw, \ + pden_electron_transport_loss_mw, \ + p_ion_transport_loss_mw, \ + pscalingmw, \ + pden_ion_transport_loss_mw, \ + q0, \ + q95, \ + molflow_plasma_fuelling_required, \ + tauratio, \ + q95_min, \ + qstar, \ + rad_fraction_sol, \ + rad_fraction_total, \ + f_nd_alpha_electron, \ + f_nd_protium_electrons, \ + ind_plasma_internal_norm, \ + ind_plasma_internal_norm_wesson, \ + ind_plasma_internal_norm_menard, \ + ind_plasma_internal_norm_iter_3, \ + i_ind_plasma_internal_norm, \ + ind_plasma, \ + rmajor, \ + rminor, \ + f_nd_beam_electron, \ + f_nd_plasma_carbon_electron, \ + rndfuel, \ + f_nd_plasma_iron_argon_electron, \ + f_nd_plasma_oxygen_electron, \ + f_res_plasma_neo, \ + res_plasma, \ + t_plasma_res_diffusion, \ + a_plasma_surface, \ + a_plasma_surface_outboard, \ + i_single_null, \ + f_sync_reflect, \ + t_electron_energy_confinement, \ + tauee_in, \ + t_energy_confinement, \ + t_ion_energy_confinement, \ + t_alpha_confinement, \ + f_alpha_energy_confinement, \ + temp_plasma_electron_vol_avg_kev, \ + temp_plasma_electron_on_axis_kev, \ + temp_plasma_electron_density_weighted_kev, \ + temp_plasma_ion_vol_avg_kev, \ + temp_plasma_ion_on_axis_kev, \ + temp_plasma_ion_density_weighted_kev, \ + f_temp_plasma_ion_electron, \ + triang, \ + triang95, \ + vol_plasma, \ + vs_plasma_burn_required, \ + vs_plasma_ramp_required, \ + v_plasma_loop_burn, \ + vs_plasma_ind_ramp, \ + vs_plasma_res_ramp, \ + vs_plasma_total_required, \ + pflux_fw_neutron_mw, \ + wtgpd, \ + a_plasma_poloidal, \ + n_charge_plasma_effective_vol_avg, \ + n_charge_plasma_effective_profile, \ + n_charge_plasma_effective_mass_weighted_vol_avg m_beam_amu = 0.0 m_fuel_amu = 0.0 diff --git a/process/data_structure/primary_pumping_variables.py b/process/data_structure/primary_pumping_variables.py index 24783e16ac..fb0c9f21ca 100644 --- a/process/data_structure/primary_pumping_variables.py +++ b/process/data_structure/primary_pumping_variables.py @@ -36,17 +36,18 @@ def init_primary_pumping_variables(): """Initialise primary pumping variables""" - global gamma_he - global t_in_bb - global t_out_bb - global p_he - global dp_he - global dp_fw_blkt - global dp_fw - global dp_blkt - global dp_liq - global p_fw_blkt_coolant_pump_mw - global f_p_fw_blkt_pump + global \ + gamma_he, \ + t_in_bb, \ + t_out_bb, \ + p_he, \ + dp_he, \ + dp_fw_blkt, \ + dp_fw, \ + dp_blkt, \ + dp_liq, \ + p_fw_blkt_coolant_pump_mw, \ + f_p_fw_blkt_pump gamma_he = 1.667 # Ratio of specific heats Helium t_in_bb = 573.13 # K diff --git a/process/data_structure/pulse_variables.py b/process/data_structure/pulse_variables.py index 3b5e3e6982..144271ea03 100644 --- a/process/data_structure/pulse_variables.py +++ b/process/data_structure/pulse_variables.py @@ -27,11 +27,7 @@ def init_pulse_variables(): """Initialise the pulse variables""" - global bctmp - global dtstor - global istore - global itcycl - global i_pulsed_plant + global bctmp, dtstor, istore, itcycl, i_pulsed_plant bctmp = 320.0 dtstor = 300.0 diff --git a/process/data_structure/rebco_variables.py b/process/data_structure/rebco_variables.py index 420999564d..0a4941358e 100644 --- a/process/data_structure/rebco_variables.py +++ b/process/data_structure/rebco_variables.py @@ -67,28 +67,29 @@ def init_rebco_variables(): """Initialise the REBCO variables""" - global dx_hts_tape_rebco - global dx_hts_tape_copper - global dx_hts_tape_hastelloy - global dr_hts_tape - global dia_croco_strand - global dia_croco_strand_tape_region - global dx_croco_strand_copper - global copper_rrr - global coppera_m2_max - global f_coppera_m2 - global dx_hts_tape_total - global dx_croco_strand_tape_stack - global n_croco_strand_hts_tapes - global a_croco_strand_rebco - global a_croco_strand_copper_total - global a_croco_strand_hastelloy - global a_croco_strand_solder - global a_croco_strand - global copperA_m2 - global copperaoh_m2_max - global f_copperaoh_m2 - global copperaoh_m2 + global \ + dx_hts_tape_rebco, \ + dx_hts_tape_copper, \ + dx_hts_tape_hastelloy, \ + dr_hts_tape, \ + dia_croco_strand, \ + dia_croco_strand_tape_region, \ + dx_croco_strand_copper, \ + copper_rrr, \ + coppera_m2_max, \ + f_coppera_m2, \ + dx_hts_tape_total, \ + dx_croco_strand_tape_stack, \ + n_croco_strand_hts_tapes, \ + a_croco_strand_rebco, \ + a_croco_strand_copper_total, \ + a_croco_strand_hastelloy, \ + a_croco_strand_solder, \ + a_croco_strand, \ + copperA_m2, \ + copperaoh_m2_max, \ + f_copperaoh_m2, \ + copperaoh_m2 dx_hts_tape_rebco = 1.0e-6 dx_hts_tape_copper = 100.0e-6 diff --git a/process/data_structure/reinke_variables.py b/process/data_structure/reinke_variables.py index 3973c28626..2ee9b84e78 100644 --- a/process/data_structure/reinke_variables.py +++ b/process/data_structure/reinke_variables.py @@ -23,11 +23,7 @@ def init_reinke_variables(): """Initialise Reinke criterion variables""" - global impvardiv - global lhat - global fzmin - global fzactual - global reinke_mode + global impvardiv, lhat, fzmin, fzactual, reinke_mode impvardiv = 9 lhat = 4.33 diff --git a/process/data_structure/scan_variables.py b/process/data_structure/scan_variables.py index c9467cccbf..8a696ba8c7 100644 --- a/process/data_structure/scan_variables.py +++ b/process/data_structure/scan_variables.py @@ -138,15 +138,16 @@ def init_scan_variables(): """Initialise the scan module""" - global scan_dim - global isweep - global isweep_2 - global nsweep - global nsweep_2 - global sweep - global sweep_2 - global first_call_1d - global first_call_2d + global \ + scan_dim, \ + isweep, \ + isweep_2, \ + nsweep, \ + nsweep_2, \ + sweep, \ + sweep_2, \ + first_call_1d, \ + first_call_2d scan_dim = 1 isweep = 0 diff --git a/process/data_structure/stellarator_variables.py b/process/data_structure/stellarator_variables.py index 0fd7eeb161..bda58050b3 100644 --- a/process/data_structure/stellarator_variables.py +++ b/process/data_structure/stellarator_variables.py @@ -94,33 +94,34 @@ def init_stellarator_variables(): - global first_call - global first_call_stfwbs - global f_n - global f_r - global f_a - global f_b - global f_i - global istell - global bmn - global f_asym - global f_rad - global f_w - global fdivwet - global flpitch - global hportamax - global hportpmax - global hporttmax - global iotabar - global isthtr - global m_res - global n_res - global shear - global vportamax - global vportpmax - global vporttmax - global max_gyrotron_frequency - global te0_ecrh_achievable + global \ + first_call, \ + first_call_stfwbs, \ + f_n, \ + f_r, \ + f_a, \ + f_b, \ + f_i, \ + istell, \ + bmn, \ + f_asym, \ + f_rad, \ + f_w, \ + fdivwet, \ + flpitch, \ + hportamax, \ + hportpmax, \ + hporttmax, \ + iotabar, \ + isthtr, \ + m_res, \ + n_res, \ + shear, \ + vportamax, \ + vportpmax, \ + vporttmax, \ + max_gyrotron_frequency, \ + te0_ecrh_achievable first_call = True first_call_stfwbs = True diff --git a/process/data_structure/structure_variables.py b/process/data_structure/structure_variables.py index debae9099a..b975409714 100644 --- a/process/data_structure/structure_variables.py +++ b/process/data_structure/structure_variables.py @@ -16,11 +16,7 @@ def init_structure_variables(): """Initialise structure variables""" - global aintmass - global clgsmass - global coldmass - global fncmass - global gsmass + global aintmass, clgsmass, coldmass, fncmass, gsmass aintmass = 0.0 clgsmass = 0.0 diff --git a/process/data_structure/superconducting_tf_coil_variables.py b/process/data_structure/superconducting_tf_coil_variables.py index af280c4243..1391289251 100644 --- a/process/data_structure/superconducting_tf_coil_variables.py +++ b/process/data_structure/superconducting_tf_coil_variables.py @@ -261,65 +261,66 @@ def init_superconducting_tf_coil_variables(): - global is_leg_cp_temp_same - global tf_fit_t - global tf_fit_z - global f_b_tf_inboard_peak_ripple_symmetric - global c_tf_coil - global a_tf_wp_with_insulation - global a_tf_wp_no_insulation - global a_tf_coil_inboard_steel - global a_tf_coil_inboard_insulation - global f_a_tf_coil_inboard_steel - global f_a_tf_coil_inboard_insulation - global z_cp_top - global r_tf_outboard_in - global r_tf_outboard_out - global r_tf_wp_inboard_inner - global r_tf_wp_inboard_outer - global r_tf_wp_inboard_centre - global dr_tf_wp_top - global vol_ins_cp - global vol_gr_ins_cp - global vol_case_cp - global dx_tf_wp_toroidal_min - global dx_tf_wp_toroidal_average - global dx_tf_side_case_average - global a_tf_plasma_case - global a_tf_coil_nose_case - global a_tf_wp_ground_insulation - global a_leg_ins - global a_leg_gr_ins - global a_leg_cond - global rad_tf_coil_inboard_toroidal_half - global tan_theta_coil - global t_conductor_radial - global t_conductor_toroidal - global dr_tf_turn_cable_space - global dx_tf_turn_cable_space - global dr_tf_turn - global dx_tf_turn - global dx_tf_turn_cable_space_average - global vforce_inboard_tot - global t1 - global time2 - global tau2 - global e_tf_magnetic_stored_total - global radius_tf_turn_cable_space_corners - global a_tf_turn_cable_space_effective - global dr_tf_wp_no_insulation - global dia_tf_turn_superconducting_cable - global n_tf_turn_superconducting_cables - global len_tf_coil_superconductor - global len_tf_superconductor_total - global j_tf_superconductor_critical - global f_c_tf_turn_operating_critical - global j_tf_coil_turn - global b_tf_superconductor_critical_zero_temp_strain - global temp_tf_superconductor_critical_zero_field_strain - global f_a_tf_turn_cable_space_cooling - global c_tf_turn_cables_critical - global j_tf_superconductor + global \ + is_leg_cp_temp_same, \ + tf_fit_t, \ + tf_fit_z, \ + f_b_tf_inboard_peak_ripple_symmetric, \ + c_tf_coil, \ + a_tf_wp_with_insulation, \ + a_tf_wp_no_insulation, \ + a_tf_coil_inboard_steel, \ + a_tf_coil_inboard_insulation, \ + f_a_tf_coil_inboard_steel, \ + f_a_tf_coil_inboard_insulation, \ + z_cp_top, \ + r_tf_outboard_in, \ + r_tf_outboard_out, \ + r_tf_wp_inboard_inner, \ + r_tf_wp_inboard_outer, \ + r_tf_wp_inboard_centre, \ + dr_tf_wp_top, \ + vol_ins_cp, \ + vol_gr_ins_cp, \ + vol_case_cp, \ + dx_tf_wp_toroidal_min, \ + dx_tf_wp_toroidal_average, \ + dx_tf_side_case_average, \ + a_tf_plasma_case, \ + a_tf_coil_nose_case, \ + a_tf_wp_ground_insulation, \ + a_leg_ins, \ + a_leg_gr_ins, \ + a_leg_cond, \ + rad_tf_coil_inboard_toroidal_half, \ + tan_theta_coil, \ + t_conductor_radial, \ + t_conductor_toroidal, \ + dr_tf_turn_cable_space, \ + dx_tf_turn_cable_space, \ + dr_tf_turn, \ + dx_tf_turn, \ + dx_tf_turn_cable_space_average, \ + vforce_inboard_tot, \ + t1, \ + time2, \ + tau2, \ + e_tf_magnetic_stored_total, \ + radius_tf_turn_cable_space_corners, \ + a_tf_turn_cable_space_effective, \ + dr_tf_wp_no_insulation, \ + dia_tf_turn_superconducting_cable, \ + n_tf_turn_superconducting_cables, \ + len_tf_coil_superconductor, \ + len_tf_superconductor_total, \ + j_tf_superconductor_critical, \ + f_c_tf_turn_operating_critical, \ + j_tf_coil_turn, \ + b_tf_superconductor_critical_zero_temp_strain, \ + temp_tf_superconductor_critical_zero_field_strain, \ + f_a_tf_turn_cable_space_cooling, \ + c_tf_turn_cables_critical, \ + j_tf_superconductor is_leg_cp_temp_same = 0 tf_fit_t = 0.0 diff --git a/process/data_structure/tfcoil_variables.py b/process/data_structure/tfcoil_variables.py index d1d56ed36f..bb44041dbc 100644 --- a/process/data_structure/tfcoil_variables.py +++ b/process/data_structure/tfcoil_variables.py @@ -1087,222 +1087,223 @@ def init_tfcoil_variables(): - global a_tf_coil_inboard_case - global a_tf_coil_outboard_case - global a_tf_turn_steel - global a_tf_wp_conductor - global a_res_tf_coil_conductor - global a_tf_turn_cable_space_no_void - global a_tf_turn_insulation - global a_tf_coil_wp_turn_insulation - global sig_tf_case_max - global sig_tf_wp_max - global a_tf_leg_outboard - global a_tf_wp_steel - global a_tf_wp_extra_void - global a_tf_wp_coolant_channels - global bcritsc - global b_tf_inboard_peak_symmetric - global b_tf_inboard_peak_with_ripple - global casestr - global dr_tf_plasma_case - global f_dr_tf_plasma_case - global i_f_dr_tf_plasma_case - global dx_tf_side_case_min - global dx_tf_side_case_peak - global casths_fraction - global tfc_sidewall_is_fraction - global t_conductor - global dx_tf_turn_general - global i_dx_tf_turn_general_input - global f_t_turn_tf - global t_turn_tf_max - global dx_tf_turn_cable_space_general - global i_dx_tf_turn_cable_space_general_input - global acs - global cdtfleg - global cforce - global cplen - global c_tf_turn - global c_tf_turn_max - global den_tf_coil_case - global dcond - global den_tf_wp_turn_insulation - global dia_tf_turn_coolant_channel - global e_tf_magnetic_stored_total_gj - global e_tf_coil_magnetic_stored - global b_crit_upper_nbti - global t_crit_nbti - global max_force_density - global f_a_tf_turn_cable_copper - global fhts - global insstrain - global i_tf_stress_model - global i_tf_tresca - global i_tf_wp_geom - global i_tf_case_geom - global i_tf_turns_integer - global i_tf_sc_mat - global i_tf_sup - global i_tf_shape - global i_tf_cond_eyoung_axial - global i_tf_cond_eyoung_trans - global n_tf_wp_pancakes - global n_tf_wp_layers - global n_rad_per_layer - global i_tf_bucking - global n_tf_graded_layers - global n_tf_stress_layers - global n_tf_wp_stress_layers - global j_tf_bus - global j_crit_str_tf - global j_crit_str_0 - global j_tf_wp_critical - global j_tf_wp_quench_heat_max - global j_tf_wp - global oacdcp - global eyoung_ins - global eyoung_steel - global eyoung_cond_axial - global eyoung_cond_trans - global eyoung_res_tf_buck - global eyoung_copper - global eyoung_al - global poisson_steel - global poisson_copper - global poisson_al - global poisson_ins - global poisson_cond_axial - global poisson_cond_trans - global r_b_tf_inboard_peak - global res_tf_leg - global toroidalgap - global ftoroidalgap - global ripple_b_tf_plasma_edge_max - global ripple_b_tf_plasma_edge - global c_tf_total - global radial_array - global sig_tf_r - global sig_tf_t - global deflect - global sig_tf_z - global sig_tf_vmises - global s_shear_tf - global sig_tf_cs_bucked - global sig_tf_case - global sig_tf_wp - global str_cs_con_res - global str_pf_con_res - global str_tf_con_res - global str_wp - global str_wp_max - global i_str_wp - global quench_model - global time1 - global tcritsc - global t_tf_superconductor_quench - global a_tf_inboard_total - global len_tf_bus - global m_tf_bus - global tfckw - global tfcmw - global p_cp_resistive_mw - global p_tf_joints_resistive_mw - global tfcryoarea - global tficrn - global ind_tf_coil - global dx_tf_wp_insertion_gap - global p_tf_leg_resistive_mw - global rho_cp - global rho_tf_leg - global rho_tf_bus - global frhocp - global frholeg - global i_cp_joints - global rho_tf_joints - global n_tf_joints_contact - global n_tf_joints - global th_joint_contact - global p_tf_joints_resistive - global len_tf_coil - global eff_tf_cryo - global n_tf_coils - global tfocrn - global tfsai - global tfsao - global tftmp - global dx_tf_inboard_out_toroidal - global dx_tf_turn_insulation - global layer_ins - global dr_tf_nose_case - global dr_tf_wp_with_insulation - global dx_tf_turn_steel - global dx_tf_wp_insulation - global temp_tf_superconductor_margin_min - global temp_cs_superconductor_margin_min - global tmargmin - global temp_margin - global temp_tf_superconductor_margin - global temp_tf_conductor_quench_max - global temp_croco_quench_max - global temp_croco_quench - global temp_tf_cryo - global n_tf_coil_turns - global v_tf_coil_dump_quench_max_kv - global vforce - global f_vforce_inboard - global vforce_outboard - global f_a_tf_turn_cable_space_extra_void - global voltfleg - global vtfkv - global v_tf_coil_dump_quench_kv - global m_tf_coil_case - global m_tf_coil_conductor - global m_tf_coil_copper - global whtconal - global m_tf_coil_wp_turn_insulation - global m_tf_coil_superconductor - global m_tf_wp_steel_conduit - global m_tf_coil_wp_insulation - global m_tf_coils_total - global dx_tf_wp_primary_toroidal - global dx_tf_wp_secondary_toroidal - global dthet - global radctf - global r_tf_arc - global xctfc - global z_tf_arc - global yctfc - global tfa - global tfb - global drtop - global dztop - global etapump - global fcoolcp - global f_a_tf_cool_outboard - global a_cp_cool - global ncool - global p_cp_coolant_pump_elec - global p_cp_resistive - global p_tf_leg_resistive - global temp_cp_max - global rcool - global tcoolin - global dtiocool - global temp_cp_average - global tcpav2 - global temp_tf_legs_outboard - global temp_cp_peak - global vcool - global vol_cond_cp - global whtcp - global whttflgs - global cryo_cool_req - global theta1_coil - global theta1_vv - global max_vv_stress - global t_tf_quench_detection - global rrr_tf_cu + global \ + a_tf_coil_inboard_case, \ + a_tf_coil_outboard_case, \ + a_tf_turn_steel, \ + a_tf_wp_conductor, \ + a_res_tf_coil_conductor, \ + a_tf_turn_cable_space_no_void, \ + a_tf_turn_insulation, \ + a_tf_coil_wp_turn_insulation, \ + sig_tf_case_max, \ + sig_tf_wp_max, \ + a_tf_leg_outboard, \ + a_tf_wp_steel, \ + a_tf_wp_extra_void, \ + a_tf_wp_coolant_channels, \ + bcritsc, \ + b_tf_inboard_peak_symmetric, \ + b_tf_inboard_peak_with_ripple, \ + casestr, \ + dr_tf_plasma_case, \ + f_dr_tf_plasma_case, \ + i_f_dr_tf_plasma_case, \ + dx_tf_side_case_min, \ + dx_tf_side_case_peak, \ + casths_fraction, \ + tfc_sidewall_is_fraction, \ + t_conductor, \ + dx_tf_turn_general, \ + i_dx_tf_turn_general_input, \ + f_t_turn_tf, \ + t_turn_tf_max, \ + dx_tf_turn_cable_space_general, \ + i_dx_tf_turn_cable_space_general_input, \ + acs, \ + cdtfleg, \ + cforce, \ + cplen, \ + c_tf_turn, \ + c_tf_turn_max, \ + den_tf_coil_case, \ + dcond, \ + den_tf_wp_turn_insulation, \ + dia_tf_turn_coolant_channel, \ + e_tf_magnetic_stored_total_gj, \ + e_tf_coil_magnetic_stored, \ + b_crit_upper_nbti, \ + t_crit_nbti, \ + max_force_density, \ + f_a_tf_turn_cable_copper, \ + fhts, \ + insstrain, \ + i_tf_stress_model, \ + i_tf_tresca, \ + i_tf_wp_geom, \ + i_tf_case_geom, \ + i_tf_turns_integer, \ + i_tf_sc_mat, \ + i_tf_sup, \ + i_tf_shape, \ + i_tf_cond_eyoung_axial, \ + i_tf_cond_eyoung_trans, \ + n_tf_wp_pancakes, \ + n_tf_wp_layers, \ + n_rad_per_layer, \ + i_tf_bucking, \ + n_tf_graded_layers, \ + n_tf_stress_layers, \ + n_tf_wp_stress_layers, \ + j_tf_bus, \ + j_crit_str_tf, \ + j_crit_str_0, \ + j_tf_wp_critical, \ + j_tf_wp_quench_heat_max, \ + j_tf_wp, \ + oacdcp, \ + eyoung_ins, \ + eyoung_steel, \ + eyoung_cond_axial, \ + eyoung_cond_trans, \ + eyoung_res_tf_buck, \ + eyoung_copper, \ + eyoung_al, \ + poisson_steel, \ + poisson_copper, \ + poisson_al, \ + poisson_ins, \ + poisson_cond_axial, \ + poisson_cond_trans, \ + r_b_tf_inboard_peak, \ + res_tf_leg, \ + toroidalgap, \ + ftoroidalgap, \ + ripple_b_tf_plasma_edge_max, \ + ripple_b_tf_plasma_edge, \ + c_tf_total, \ + radial_array, \ + sig_tf_r, \ + sig_tf_t, \ + deflect, \ + sig_tf_z, \ + sig_tf_vmises, \ + s_shear_tf, \ + sig_tf_cs_bucked, \ + sig_tf_case, \ + sig_tf_wp, \ + str_cs_con_res, \ + str_pf_con_res, \ + str_tf_con_res, \ + str_wp, \ + str_wp_max, \ + i_str_wp, \ + quench_model, \ + time1, \ + tcritsc, \ + t_tf_superconductor_quench, \ + a_tf_inboard_total, \ + len_tf_bus, \ + m_tf_bus, \ + tfckw, \ + tfcmw, \ + p_cp_resistive_mw, \ + p_tf_joints_resistive_mw, \ + tfcryoarea, \ + tficrn, \ + ind_tf_coil, \ + dx_tf_wp_insertion_gap, \ + p_tf_leg_resistive_mw, \ + rho_cp, \ + rho_tf_leg, \ + rho_tf_bus, \ + frhocp, \ + frholeg, \ + i_cp_joints, \ + rho_tf_joints, \ + n_tf_joints_contact, \ + n_tf_joints, \ + th_joint_contact, \ + p_tf_joints_resistive, \ + len_tf_coil, \ + eff_tf_cryo, \ + n_tf_coils, \ + tfocrn, \ + tfsai, \ + tfsao, \ + tftmp, \ + dx_tf_inboard_out_toroidal, \ + dx_tf_turn_insulation, \ + layer_ins, \ + dr_tf_nose_case, \ + dr_tf_wp_with_insulation, \ + dx_tf_turn_steel, \ + dx_tf_wp_insulation, \ + temp_tf_superconductor_margin_min, \ + temp_cs_superconductor_margin_min, \ + tmargmin, \ + temp_margin, \ + temp_tf_superconductor_margin, \ + temp_tf_conductor_quench_max, \ + temp_croco_quench_max, \ + temp_croco_quench, \ + temp_tf_cryo, \ + n_tf_coil_turns, \ + v_tf_coil_dump_quench_max_kv, \ + vforce, \ + f_vforce_inboard, \ + vforce_outboard, \ + f_a_tf_turn_cable_space_extra_void, \ + voltfleg, \ + vtfkv, \ + v_tf_coil_dump_quench_kv, \ + m_tf_coil_case, \ + m_tf_coil_conductor, \ + m_tf_coil_copper, \ + whtconal, \ + m_tf_coil_wp_turn_insulation, \ + m_tf_coil_superconductor, \ + m_tf_wp_steel_conduit, \ + m_tf_coil_wp_insulation, \ + m_tf_coils_total, \ + dx_tf_wp_primary_toroidal, \ + dx_tf_wp_secondary_toroidal, \ + dthet, \ + radctf, \ + r_tf_arc, \ + xctfc, \ + z_tf_arc, \ + yctfc, \ + tfa, \ + tfb, \ + drtop, \ + dztop, \ + etapump, \ + fcoolcp, \ + f_a_tf_cool_outboard, \ + a_cp_cool, \ + ncool, \ + p_cp_coolant_pump_elec, \ + p_cp_resistive, \ + p_tf_leg_resistive, \ + temp_cp_max, \ + rcool, \ + tcoolin, \ + dtiocool, \ + temp_cp_average, \ + tcpav2, \ + temp_tf_legs_outboard, \ + temp_cp_peak, \ + vcool, \ + vol_cond_cp, \ + whtcp, \ + whttflgs, \ + cryo_cool_req, \ + theta1_coil, \ + theta1_vv, \ + max_vv_stress, \ + t_tf_quench_detection, \ + rrr_tf_cu a_tf_coil_inboard_case = 0.0 a_tf_coil_outboard_case = 0.0 diff --git a/process/data_structure/times_variables.py b/process/data_structure/times_variables.py index 73ceafa791..2a93f889d3 100644 --- a/process/data_structure/times_variables.py +++ b/process/data_structure/times_variables.py @@ -55,21 +55,22 @@ def init_times_variables(): """Initialise plasma pulse timing variables""" - global pulsetimings - global t_plant_pulse_burn - global t_burn_0 - global t_plant_pulse_total - global t_plant_pulse_no_burn - global t_plant_pulse_dwell - global t_plant_pulse_fusion_ramp - global t_pulse_cumulative - global timelabel - global intervallabel - global t_plant_pulse_plasma_current_ramp_up - global i_t_current_ramp_up - global t_plant_pulse_plasma_present - global t_plant_pulse_plasma_current_ramp_down - global t_plant_pulse_coil_precharge + global \ + pulsetimings, \ + t_plant_pulse_burn, \ + t_burn_0, \ + t_plant_pulse_total, \ + t_plant_pulse_no_burn, \ + t_plant_pulse_dwell, \ + t_plant_pulse_fusion_ramp, \ + t_pulse_cumulative, \ + timelabel, \ + intervallabel, \ + t_plant_pulse_plasma_current_ramp_up, \ + i_t_current_ramp_up, \ + t_plant_pulse_plasma_present, \ + t_plant_pulse_plasma_current_ramp_down, \ + t_plant_pulse_coil_precharge pulsetimings = 1.0 t_plant_pulse_burn = np.array(1000.0, dtype=np.float64) diff --git a/process/data_structure/vacuum_variables.py b/process/data_structure/vacuum_variables.py index bd7eaad2c5..c938b7b56b 100644 --- a/process/data_structure/vacuum_variables.py +++ b/process/data_structure/vacuum_variables.py @@ -83,26 +83,27 @@ def init_vacuum_variables(): """Initialise Vacuum variables""" - global i_vacuum_pumping - global n_iter_vacuum_pumps - global i_vacuum_pump_type - global n_vv_vacuum_ducts - global dlscal - global pres_vv_chamber_base - global pres_div_chamber_burn - global molflow_vac_pumps - global outgrat_fw - global temp_vv_chamber_gas_burn_end - global m_vv_vacuum_duct_shield - global dia_vv_vacuum_ducts - global n_vac_pumps_high - global i_vac_pump_dwell - global f_a_vac_pump_port_plasma_surface - global volflow_vac_pumps_max - global f_volflow_vac_pumps_impedance - global pres_vv_chamber_dwell_start - global outgasindex - global outgasfactor + global \ + i_vacuum_pumping, \ + n_iter_vacuum_pumps, \ + i_vacuum_pump_type, \ + n_vv_vacuum_ducts, \ + dlscal, \ + pres_vv_chamber_base, \ + pres_div_chamber_burn, \ + molflow_vac_pumps, \ + outgrat_fw, \ + temp_vv_chamber_gas_burn_end, \ + m_vv_vacuum_duct_shield, \ + dia_vv_vacuum_ducts, \ + n_vac_pumps_high, \ + i_vac_pump_dwell, \ + f_a_vac_pump_port_plasma_surface, \ + volflow_vac_pumps_max, \ + f_volflow_vac_pumps_impedance, \ + pres_vv_chamber_dwell_start, \ + outgasindex, \ + outgasfactor i_vacuum_pumping = "old" n_iter_vacuum_pumps = 0.0 diff --git a/process/data_structure/water_usage_variables.py b/process/data_structure/water_usage_variables.py index 19e25a0f8d..955c057071 100644 --- a/process/data_structure/water_usage_variables.py +++ b/process/data_structure/water_usage_variables.py @@ -54,19 +54,20 @@ def init_watuse_variables(): """Initialise water variables""" - global airtemp - global watertemp - global windspeed - global waterdens - global latentheat - global volheat - global evapratio - global evapvol - global energypervol - global volperenergy - global waterusetower - global wateruserecirc - global wateruseonethru + global \ + airtemp, \ + watertemp, \ + windspeed, \ + waterdens, \ + latentheat, \ + volheat, \ + evapratio, \ + evapvol, \ + energypervol, \ + volperenergy, \ + waterusetower, \ + wateruserecirc, \ + wateruseonethru airtemp = 15.0 watertemp = 5.0 diff --git a/process/dcll.py b/process/dcll.py index 8f1198c5af..b7c490540f 100644 --- a/process/dcll.py +++ b/process/dcll.py @@ -129,9 +129,7 @@ def dcll_neutronics_and_power(self, output: bool): else: # Single null configuration covf = ( - 1 - - fwbs_variables.f_ster_div_single - - fwbs_variables.f_a_fw_outboard_hcd + 1 - fwbs_variables.f_ster_div_single - fwbs_variables.f_a_fw_outboard_hcd ) # Nuclear heating in the first wall (MW) @@ -642,12 +640,8 @@ def dcll_masses(self, output: bool): * dcll_variables.vol_bz_struct ) fwbs_variables.wht_liq = fwbs_variables.den_liq * dcll_variables.vol_bz_liq - fwbs_variables.wht_liq_ib = ( - fwbs_variables.den_liq * dcll_variables.vol_bz_liq_ib - ) - fwbs_variables.wht_liq_ob = ( - fwbs_variables.den_liq * dcll_variables.vol_bz_liq_ob - ) + fwbs_variables.wht_liq_ib = fwbs_variables.den_liq * dcll_variables.vol_bz_liq_ib + fwbs_variables.wht_liq_ob = fwbs_variables.den_liq * dcll_variables.vol_bz_liq_ob dcll_variables.wht_cer = fwbs_variables.den_ceramic * dcll_variables.vol_fci # Back Wall dcll_variables.wht_bw_stl = ( diff --git a/process/final.py b/process/final.py index e25503d693..9295730f13 100644 --- a/process/final.py +++ b/process/final.py @@ -10,7 +10,7 @@ from process.objectives import objective_function -def finalise(models, ifail: int, non_idempotent_msg: None | str = None): +def finalise(models, ifail: int, non_idempotent_msg: str | None = None): """Routine to print out the final point in the scan. Writes to OUT.DAT and MFILE.DAT. @@ -48,9 +48,7 @@ def output_evaluation(): # Evaluate objective function norm_objf = objective_function(numerics.minmax) - po.ovarre( - constants.MFILE, "Normalised objective function", "(norm_objf)", norm_objf - ) + po.ovarre(constants.MFILE, "Normalised objective function", "(norm_objf)", norm_objf) # Print the residuals of the constraint equations diff --git a/process/fusion_reactions.py b/process/fusion_reactions.py index 08150f322f..26da81726a 100644 --- a/process/fusion_reactions.py +++ b/process/fusion_reactions.py @@ -749,10 +749,7 @@ def bosch_hale_reactivity( * ( reaction_constants.cc2 + ion_temperature_profile - * ( - reaction_constants.cc4 - + ion_temperature_profile * reaction_constants.cc6 - ) + * (reaction_constants.cc4 + ion_temperature_profile * reaction_constants.cc6) ) / ( 1.0 @@ -1362,9 +1359,7 @@ def beam_reaction_rate( ) relative_velocity = beam_velocity / critical_velocity - integral_coefficient = ( - 3.0 * critical_velocity / np.log(1.0 + (relative_velocity**3)) - ) + integral_coefficient = 3.0 * critical_velocity / np.log(1.0 + (relative_velocity**3)) fusion_integral = integrate.quad( _hot_beam_fusion_reaction_rate_integrand, diff --git a/process/fw.py b/process/fw.py index cda8910b08..ceaed70689 100644 --- a/process/fw.py +++ b/process/fw.py @@ -220,9 +220,7 @@ def fw_temp( # This heat starts off spread over width = 'dx_fw_module'. # It ends up spread over one half the circumference. # Use the mean of these values. - mean_width = ( - fwbs_variables.dx_fw_module + np.pi * radius_fw_channel - ) / 2 # (m) + mean_width = (fwbs_variables.dx_fw_module + np.pi * radius_fw_channel) / 2 # (m) # As before, use a combined load 'onedload' # Temperature drop in first-wall material (K) diff --git a/process/geometry/plasma_geometry.py b/process/geometry/plasma_geometry.py index bb922245ba..f6f338c657 100644 --- a/process/geometry/plasma_geometry.py +++ b/process/geometry/plasma_geometry.py @@ -102,8 +102,7 @@ def plasma_geometry( # Sauter return PlasmaGeometry( - rs=rmajor - + rminor * np.cos(x + triang * np.sin(x) - square * np.sin(2 * x)), + rs=rmajor + rminor * np.cos(x + triang * np.sin(x) - square * np.sin(2 * x)), zs=kappa * rminor * np.sin(x + square * np.sin(2 * x)), kappa=kappa, ) diff --git a/process/geometry/shield_geometry.py b/process/geometry/shield_geometry.py index 40d4e5d4e8..8d2dd056bd 100644 --- a/process/geometry/shield_geometry.py +++ b/process/geometry/shield_geometry.py @@ -39,15 +39,11 @@ def shield_geometry_single_null( # Upper shield # Side furthest from plasma kapx = cumulative_upper["dz_shld_upper"] / rminx_far - rs_upper_outboard, zs_upper_outboard = dh_vertices( - radx_far, rminx_far, triang, kapx - ) + rs_upper_outboard, zs_upper_outboard = dh_vertices(radx_far, rminx_far, triang, kapx) # Side nearest to plasma kapx = (cumulative_upper["dr_shld_blkt_gap"]) / rminx_near - rs_upper_inboard, zs_upper_inboard = dh_vertices( - radx_near, rminx_near, triang, kapx - ) + rs_upper_inboard, zs_upper_inboard = dh_vertices(radx_near, rminx_near, triang, kapx) # Lower shield ( @@ -109,15 +105,11 @@ def shield_geometry_lower( """ # Side furthest from plasma kapx = cumulative_lower["dz_shld_lower"] / rminx_far - rs_lower_outboard, zs_lower_outboard = dh_vertices( - radx_far, rminx_far, triang, kapx - ) + rs_lower_outboard, zs_lower_outboard = dh_vertices(radx_far, rminx_far, triang, kapx) # Side nearest to plasma kapx = (cumulative_lower["dz_divertor"]) / rminx_near - rs_lower_inboard, zs_lower_inboard = dh_vertices( - radx_near, rminx_near, triang, kapx - ) + rs_lower_inboard, zs_lower_inboard = dh_vertices(radx_near, rminx_near, triang, kapx) return rs_lower_outboard, zs_lower_outboard, rs_lower_inboard, zs_lower_inboard diff --git a/process/geometry/tfcoil_geometry.py b/process/geometry/tfcoil_geometry.py index 4e94f7a471..adbc1c7000 100644 --- a/process/geometry/tfcoil_geometry.py +++ b/process/geometry/tfcoil_geometry.py @@ -44,44 +44,34 @@ def tfcoil_geometry_rectangular_shape( :return: list of RectangleGeometry - dataclass returning rectangular geometry parameters :rtype: List[RectangleGeometry] """ - return_rects = [] # In this geometry, the tf coil is represented by 4 rectangular sections as follows: - - # rectangle representing the inboard part of the tf coil - return_rects.append( + return [ + # rectangle representing the inboard part of the tf coil RectangleGeometry( anchor_x=x5 - dr_tf_inboard + offset_in, anchor_z=y5 - dr_tf_inboard, width=dr_tf_inboard, height=(y1 - y5 + 2.0 * dr_tf_inboard), - ) - ) - # rectangle representing the outboard part of the tf coil - return_rects.append( + ), + # rectangle representing the outboard part of the tf coil RectangleGeometry( anchor_x=x4 - offset_in, anchor_z=y4 - dr_tf_inboard, width=dr_tf_inboard, height=(y2 - y4 + 2.0 * dr_tf_inboard), - ) - ) - # rectangle representing the lower horizontal part of the tf coil - return_rects.append( + ), + # rectangle representing the lower horizontal part of the tf coil RectangleGeometry( anchor_x=x5, anchor_z=y5 - dr_tf_inboard + offset_in, width=x4 - x5, height=dr_tf_inboard, - ) - ) - # rectangle representing the upper horizontal part of the tf coil - return_rects.append( + ), + # rectangle representing the upper horizontal part of the tf coil RectangleGeometry( anchor_x=x1, anchor_z=y1 - offset_in, width=(x2 - x1), height=dr_tf_inboard - ) - ) - - return return_rects + ), + ] def tfcoil_geometry_d_shape( diff --git a/process/ife.py b/process/ife.py index 2d5097579d..ee3d1fe0f6 100644 --- a/process/ife.py +++ b/process/ife.py @@ -337,10 +337,7 @@ def sombld(self): # First wall ife_variables.fwvol[0] = ( np.pi - * ( - ife_variables.r2 * ife_variables.r2 - - ife_variables.r1 * ife_variables.r1 - ) + * (ife_variables.r2 * ife_variables.r2 - ife_variables.r1 * ife_variables.r1) * chcylh ) ife_variables.fwvol[1] = ( @@ -367,10 +364,7 @@ def sombld(self): # First void ife_variables.v1vol[0] = ( np.pi - * ( - ife_variables.r3 * ife_variables.r3 - - ife_variables.r2 * ife_variables.r2 - ) + * (ife_variables.r3 * ife_variables.r3 - ife_variables.r2 * ife_variables.r2) * chcylh ) ife_variables.v1vol[1] = ( @@ -405,10 +399,7 @@ def sombld(self): ife_variables.blvol[0] = ( np.pi - * ( - ife_variables.r4 * ife_variables.r4 - - ife_variables.r3 * ife_variables.r3 - ) + * (ife_variables.r4 * ife_variables.r4 - ife_variables.r3 * ife_variables.r3) * chcylh ) @@ -445,12 +436,7 @@ def sombld(self): * ife_variables.somtdr ) dvol = ( - 2.0 - * (1.0 / 3.0) - * np.pi - * ife_variables.somtdr - * ife_variables.somtdr - * ddz + 2.0 * (1.0 / 3.0) * np.pi * ife_variables.somtdr * ife_variables.somtdr * ddz ) ife_variables.blvol[1] = ife_variables.blvol[1] + dvol @@ -490,12 +476,7 @@ def sombld(self): * ife_variables.sombdr ) dvol = ( - 2.0 - * (1.0 / 3.0) - * np.pi - * ife_variables.sombdr - * ife_variables.sombdr - * ddz + 2.0 * (1.0 / 3.0) * np.pi * ife_variables.sombdr * ife_variables.sombdr * ddz ) ife_variables.blvol[2] = ife_variables.blvol[2] + dvol @@ -503,10 +484,7 @@ def sombld(self): # Second void ife_variables.v2vol[0] = ( np.pi - * ( - ife_variables.r5 * ife_variables.r5 - - ife_variables.r4 * ife_variables.r4 - ) + * (ife_variables.r5 * ife_variables.r5 - ife_variables.r4 * ife_variables.r4) * chcylh ) ife_variables.v2vol[1] = np.pi * ife_variables.r5 * ife_variables.r5 * ( @@ -541,10 +519,7 @@ def sombld(self): # Shield ife_variables.shvol[0] = ( np.pi - * ( - ife_variables.r6 * ife_variables.r6 - - ife_variables.r5 * ife_variables.r5 - ) + * (ife_variables.r6 * ife_variables.r6 - ife_variables.r5 * ife_variables.r5) * (ife_variables.zu6 + ife_variables.zl6) ) ife_variables.shvol[1] = ( @@ -563,10 +538,7 @@ def sombld(self): # Third void ife_variables.v3vol[0] = ( np.pi - * ( - ife_variables.r7 * ife_variables.r7 - - ife_variables.r6 * ife_variables.r6 - ) + * (ife_variables.r7 * ife_variables.r7 - ife_variables.r6 * ife_variables.r6) * (ife_variables.zu7 + ife_variables.zl7) ) ife_variables.v3vol[1] = ( @@ -612,10 +584,7 @@ def sombld(self): 2.0 * np.pi * ife_variables.r1 - * ( - (ife_variables.zu1 + ife_variables.zl1) - + ife_variables.r1 * np.sqrt(2.0) - ) + * ((ife_variables.zu1 + ife_variables.zl1) + ife_variables.r1 * np.sqrt(2.0)) ) def hylbld(self): @@ -669,10 +638,7 @@ def hylbld(self): # FLIRAD is the radius of the Flibe inlet ife_variables.fwvol[0] = ( np.pi - * ( - ife_variables.r2 * ife_variables.r2 - - ife_variables.r1 * ife_variables.r1 - ) + * (ife_variables.r2 * ife_variables.r2 - ife_variables.r1 * ife_variables.r1) * (ife_variables.zu2 + ife_variables.zl5) ) ife_variables.fwvol[1] = ( @@ -699,10 +665,7 @@ def hylbld(self): # First void ife_variables.v1vol[0] = ( np.pi - * ( - ife_variables.r3 * ife_variables.r3 - - ife_variables.r2 * ife_variables.r2 - ) + * (ife_variables.r3 * ife_variables.r3 - ife_variables.r2 * ife_variables.r2) * (ife_variables.zu2 + ife_variables.zl3) ) ife_variables.v1vol[1] = ( @@ -724,10 +687,7 @@ def hylbld(self): # Blanket ife_variables.blvol[0] = ( np.pi - * ( - ife_variables.r4 * ife_variables.r4 - - ife_variables.r3 * ife_variables.r3 - ) + * (ife_variables.r4 * ife_variables.r4 - ife_variables.r3 * ife_variables.r3) * (ife_variables.zu2 + ife_variables.zl3) ) ife_variables.blvol[1] = ( @@ -748,10 +708,7 @@ def hylbld(self): # Second void ife_variables.v2vol[0] = ( np.pi - * ( - ife_variables.r5 * ife_variables.r5 - - ife_variables.r4 * ife_variables.r4 - ) + * (ife_variables.r5 * ife_variables.r5 - ife_variables.r4 * ife_variables.r4) * (ife_variables.zu4 + ife_variables.zl4) ) ife_variables.v2vol[1] = ( @@ -772,10 +729,7 @@ def hylbld(self): # Shield ife_variables.shvol[0] = ( np.pi - * ( - ife_variables.r6 * ife_variables.r6 - - ife_variables.r5 * ife_variables.r5 - ) + * (ife_variables.r6 * ife_variables.r6 - ife_variables.r5 * ife_variables.r5) * (ife_variables.zu5 + ife_variables.zl5) ) ife_variables.shvol[1] = ( @@ -794,10 +748,7 @@ def hylbld(self): # Third void ife_variables.v3vol[0] = ( np.pi - * ( - ife_variables.r7 * ife_variables.r7 - - ife_variables.r6 * ife_variables.r6 - ) + * (ife_variables.r7 * ife_variables.r7 - ife_variables.r6 * ife_variables.r6) * (ife_variables.zu6 + ife_variables.zl6) ) ife_variables.v3vol[1] = ( @@ -870,19 +821,11 @@ def bld2019(self): # Check input if ife_variables.fwdr > 0 or ife_variables.v1dr > 0: raise ProcessValueError("fwdr and v1dr should be zero for 2019 IFE build") - if ( - ife_variables.fwdzu > 0 - or ife_variables.v1dzu > 0 - or ife_variables.v2dzu > 0 - ): + if ife_variables.fwdzu > 0 or ife_variables.v1dzu > 0 or ife_variables.v2dzu > 0: raise ProcessValueError( "fwdzu, v1dzu and v2dzu should be zero for 2019 IFE build" ) - if ( - ife_variables.fwdzl > 0 - or ife_variables.v1dzl > 0 - or ife_variables.v2dzu > 0 - ): + if ife_variables.fwdzl > 0 or ife_variables.v1dzl > 0 or ife_variables.v2dzu > 0: raise ProcessValueError( "fwdzl, v1dzl and v2dzl should be zero for 2019 IFE build" ) @@ -928,9 +871,7 @@ def bld2019(self): # Fall Time ife_variables.taufall = ( - 2.0 - * (ife_variables.chdzl + ife_variables.chdzu + ife_variables.bldzu) - / vel + 2.0 * (ife_variables.chdzl + ife_variables.chdzu + ife_variables.bldzu) / vel ) ife_variables.rrmax = 1.0 / ife_variables.taufall @@ -1013,10 +954,7 @@ def bld2019(self): ife_variables.fwvol[0] = ( np.pi - * ( - ife_variables.r2 * ife_variables.r2 - - ife_variables.r1 * ife_variables.r1 - ) + * (ife_variables.r2 * ife_variables.r2 - ife_variables.r1 * ife_variables.r1) * (ife_variables.zu1 + ife_variables.zl1) ) ife_variables.fwvol[1] = ( @@ -1036,10 +974,7 @@ def bld2019(self): ife_variables.v1vol[0] = ( np.pi - * ( - ife_variables.r3 * ife_variables.r3 - - ife_variables.r2 * ife_variables.r2 - ) + * (ife_variables.r3 * ife_variables.r3 - ife_variables.r2 * ife_variables.r2) * (ife_variables.zu2 + ife_variables.zl2) ) ife_variables.v1vol[1] = ( @@ -1059,20 +994,14 @@ def bld2019(self): # Radial Blanket - between void 2 and chamber ife_variables.blvol[0] = ( np.pi - * ( - ife_variables.r4 * ife_variables.r4 - - ife_variables.r3 * ife_variables.r3 - ) + * (ife_variables.r4 * ife_variables.r4 - ife_variables.r3 * ife_variables.r3) * (ife_variables.zu3 + ife_variables.zl3) ) # Upper Blanket - Pool radially between shield and # chamber of input height. ife_variables.blvol[1] = ( np.pi - * ( - ife_variables.r5 * ife_variables.r5 - - ife_variables.r3 * ife_variables.r3 - ) + * (ife_variables.r5 * ife_variables.r5 - ife_variables.r3 * ife_variables.r3) * ife_variables.bldzu ) # Lower Blanket - Pool filling base of device @@ -1087,10 +1016,7 @@ def bld2019(self): ife_variables.v2vol[0] = ( np.pi - * ( - ife_variables.r5 * ife_variables.r5 - - ife_variables.r4 * ife_variables.r4 - ) + * (ife_variables.r5 * ife_variables.r5 - ife_variables.r4 * ife_variables.r4) * (ife_variables.chdzl + ife_variables.chdzu) ) ife_variables.v2vol[1] = 0.0 @@ -1099,10 +1025,7 @@ def bld2019(self): # Shield ife_variables.shvol[0] = ( np.pi - * ( - ife_variables.r6 * ife_variables.r6 - - ife_variables.r5 * ife_variables.r5 - ) + * (ife_variables.r6 * ife_variables.r6 - ife_variables.r5 * ife_variables.r5) * (ife_variables.zu5 + ife_variables.zl5) ) # Top Section is in three parts to account for the dip at @@ -1144,10 +1067,7 @@ def bld2019(self): ife_variables.v3vol[0] = ( np.pi - * ( - ife_variables.r7 * ife_variables.r7 - - ife_variables.r6 * ife_variables.r6 - ) + * (ife_variables.r7 * ife_variables.r7 - ife_variables.r6 * ife_variables.r6) * (ife_variables.zu6 + ife_variables.zl6) ) ife_variables.v3vol[1] = ( @@ -1264,10 +1184,7 @@ def genbld(self): ife_variables.fwvol[0] = ( np.pi - * ( - ife_variables.r2 * ife_variables.r2 - - ife_variables.r1 * ife_variables.r1 - ) + * (ife_variables.r2 * ife_variables.r2 - ife_variables.r1 * ife_variables.r1) * (ife_variables.zu1 + ife_variables.zl1) ) ife_variables.fwvol[1] = ( @@ -1287,10 +1204,7 @@ def genbld(self): ife_variables.v1vol[0] = ( np.pi - * ( - ife_variables.r3 * ife_variables.r3 - - ife_variables.r2 * ife_variables.r2 - ) + * (ife_variables.r3 * ife_variables.r3 - ife_variables.r2 * ife_variables.r2) * (ife_variables.zu2 + ife_variables.zl2) ) ife_variables.v1vol[1] = ( @@ -1310,10 +1224,7 @@ def genbld(self): ife_variables.blvol[0] = ( np.pi - * ( - ife_variables.r4 * ife_variables.r4 - - ife_variables.r3 * ife_variables.r3 - ) + * (ife_variables.r4 * ife_variables.r4 - ife_variables.r3 * ife_variables.r3) * (ife_variables.zu3 + ife_variables.zl3) ) ife_variables.blvol[1] = ( @@ -1333,10 +1244,7 @@ def genbld(self): ife_variables.v2vol[0] = ( np.pi - * ( - ife_variables.r5 * ife_variables.r5 - - ife_variables.r4 * ife_variables.r4 - ) + * (ife_variables.r5 * ife_variables.r5 - ife_variables.r4 * ife_variables.r4) * (ife_variables.zu4 + ife_variables.zl4) ) ife_variables.v2vol[1] = ( @@ -1356,10 +1264,7 @@ def genbld(self): ife_variables.shvol[0] = ( np.pi - * ( - ife_variables.r6 * ife_variables.r6 - - ife_variables.r5 * ife_variables.r5 - ) + * (ife_variables.r6 * ife_variables.r6 - ife_variables.r5 * ife_variables.r5) * (ife_variables.zu5 + ife_variables.zl5) ) ife_variables.shvol[1] = ( @@ -1379,10 +1284,7 @@ def genbld(self): ife_variables.v3vol[0] = ( np.pi - * ( - ife_variables.r7 * ife_variables.r7 - - ife_variables.r6 * ife_variables.r6 - ) + * (ife_variables.r7 * ife_variables.r7 - ife_variables.r6 * ife_variables.r6) * (ife_variables.zu6 + ife_variables.zl6) ) ife_variables.v3vol[1] = ( @@ -1733,9 +1635,7 @@ def ifetgt(self): # Target factory power (MWe) # Assumed to scale with repetition rate (not quite linearly) - ife_variables.tfacmw = ( - ife_variables.ptargf * (ife_variables.reprat / 6.0) ** 0.7 - ) + ife_variables.tfacmw = ife_variables.ptargf * (ife_variables.reprat / 6.0) ** 0.7 def ifefbs(self, output: bool = False): """Routine to calculate the first wall, blanket and shield volumes, @@ -2438,9 +2338,7 @@ def ifebdg(self, output: bool = False): # Total volume of nuclear buildings - buildings_variables.volnucb = ( - vrci + rmbv + wsv + buildings_variables.triv + cryv - ) + buildings_variables.volnucb = vrci + rmbv + wsv + buildings_variables.triv + cryv if not output: return @@ -2461,9 +2359,7 @@ def ifebdg(self, output: bool = False): "(a_plant_floor_effective)", buildings_variables.a_plant_floor_effective, ) - process_output.ovarre( - self.outfile, "Reactor building volume (m3)", "(rbv)", rbv - ) + process_output.ovarre(self.outfile, "Reactor building volume (m3)", "(rbv)", rbv) process_output.ovarre( self.outfile, "Reactor maintenance building volume (m3)", "(rmbv)", rmbv ) diff --git a/process/impurity_radiation.py b/process/impurity_radiation.py index 7267ce3791..de0de2d26a 100644 --- a/process/impurity_radiation.py +++ b/process/impurity_radiation.py @@ -325,12 +325,8 @@ def init_imp_element( f"Cannot locate Zav for infinite confinement data in {z_file}" ) - impurity_radiation_module.temp_impurity_keV_array[n_species_index - 1, :] = ( - Te * 1e-3 - ) - impurity_radiation_module.pden_impurity_lz_nd_temp_array[n_species_index - 1, :] = ( - lz - ) + impurity_radiation_module.temp_impurity_keV_array[n_species_index - 1, :] = Te * 1e-3 + impurity_radiation_module.pden_impurity_lz_nd_temp_array[n_species_index - 1, :] = lz impurity_radiation_module.impurity_arr_zav[n_species_index - 1, :] = zav diff --git a/process/init.py b/process/init.py index 15b7598cc0..e0ae6d0fdb 100644 --- a/process/init.py +++ b/process/init.py @@ -749,9 +749,7 @@ def check_process(inputs): # noqa: ARG001 # Checking the CP TF top radius if ( abs(data_structure.build_variables.r_cp_top) > 0 - or ( - data_structure.numerics.ixc[: data_structure.numerics.nvar] == 174 - ).any() + or (data_structure.numerics.ixc[: data_structure.numerics.nvar] == 174).any() ) and data_structure.build_variables.i_r_cp_top != 1: raise ProcessValidationError( "To set the TF CP top value, you must use i_r_cp_top = 1" @@ -826,9 +824,7 @@ def check_process(inputs): # noqa: ARG001 if ( ( not ( - ( - data_structure.numerics.ixc[: data_structure.numerics.nvar] == 16 - ).any() + (data_structure.numerics.ixc[: data_structure.numerics.nvar] == 16).any() or ( data_structure.numerics.ixc[: data_structure.numerics.nvar] == 29 ).any() @@ -1021,14 +1017,11 @@ def check_process(inputs): # noqa: ARG001 ) # Steel conduit thickness (can be an iteration variable) - if ( - data_structure.numerics.ixc[: data_structure.numerics.nvar] == 58 - ).any(): + if (data_structure.numerics.ixc[: data_structure.numerics.nvar] == 58).any(): dr_tf_wp_min = dr_tf_wp_min + 2.0 * data_structure.numerics.boundl[57] else: dr_tf_wp_min = ( - dr_tf_wp_min - + 2.0 * data_structure.tfcoil_variables.dx_tf_turn_steel + dr_tf_wp_min + 2.0 * data_structure.tfcoil_variables.dx_tf_turn_steel ) # Minimal conductor layer thickness @@ -1253,13 +1246,9 @@ def set_active_constraints(): if data_structure.numerics.neqns == 0: # The value of neqns has not been set in the input file. Default = 0. - data_structure.numerics.neqns = ( - num_constraints - data_structure.numerics.nineqns - ) + data_structure.numerics.neqns = num_constraints - data_structure.numerics.nineqns else: - data_structure.numerics.nineqns = ( - num_constraints - data_structure.numerics.neqns - ) + data_structure.numerics.nineqns = num_constraints - data_structure.numerics.neqns def set_device_type(): diff --git a/process/input.py b/process/input.py index 022b7715ef..a82fea6757 100644 --- a/process/input.py +++ b/process/input.py @@ -200,9 +200,7 @@ def __post_init__(self): "anginc": InputVariable( data_structure.divertor_variables, float, range=(0.0, 1.5707) ), - "aplasmin": InputVariable( - data_structure.build_variables, float, range=(0.01, 10.0) - ), + "aplasmin": InputVariable(data_structure.build_variables, float, range=(0.01, 10.0)), "aux_build_h": InputVariable( data_structure.buildings_variables, float, range=(1.0, 100.0) ), @@ -231,9 +229,7 @@ def __post_init__(self): "p_plant_electric_base": InputVariable( data_structure.heat_transport_variables, float, range=(1000000.0, 10000000000.0) ), - "bcritsc": InputVariable( - data_structure.tfcoil_variables, float, range=(10.0, 50.0) - ), + "bcritsc": InputVariable(data_structure.tfcoil_variables, float, range=(10.0, 50.0)), "bctmp": InputVariable(data_structure.pulse_variables, float, range=(1.0, 800.0)), "e_beam_kev": InputVariable( data_structure.current_drive_variables, float, range=(1.0, 1000000.0) @@ -316,12 +312,8 @@ def __post_init__(self): data_structure.current_drive_variables, float, range=(0.0, 10.0) ), "cconfix": InputVariable(data_structure.cost_variables, float, range=(50.0, 200.0)), - "cconshpf": InputVariable( - data_structure.cost_variables, float, range=(50.0, 200.0) - ), - "cconshtf": InputVariable( - data_structure.cost_variables, float, range=(50.0, 200.0) - ), + "cconshpf": InputVariable(data_structure.cost_variables, float, range=(50.0, 200.0)), + "cconshtf": InputVariable(data_structure.cost_variables, float, range=(50.0, 200.0)), "cdriv0": InputVariable(data_structure.ife_variables, float, range=(50.0, 500.0)), "cdriv1": InputVariable(data_structure.ife_variables, float, range=(50.0, 500.0)), "cdriv2": InputVariable(data_structure.ife_variables, float, range=(50.0, 500.0)), @@ -449,9 +441,7 @@ def __post_init__(self): data_structure.heat_transport_variables, float, range=(0.01, 200.0) ), "csi": InputVariable(data_structure.cost_variables, float, range=(1.0, 100.0)), - "cturbb": InputVariable( - data_structure.cost_variables, float, range=(100.0, 1000.0) - ), + "cturbb": InputVariable(data_structure.cost_variables, float, range=(100.0, 1000.0)), "dz_vv_lower": InputVariable( data_structure.build_variables, float, range=(0.0, 10.0) ), @@ -659,9 +649,7 @@ def __post_init__(self): "eta_turbine": InputVariable( data_structure.heat_transport_variables, float, range=(0.0, 1.0) ), - "eyoung_al": InputVariable( - data_structure.tfcoil_variables, float, range=(0.0, 1.0) - ), + "eyoung_al": InputVariable(data_structure.tfcoil_variables, float, range=(0.0, 1.0)), "eyoung_cond_axial": InputVariable( data_structure.tfcoil_variables, float, range=(0.0, 10000000000000.0) ), @@ -698,9 +686,7 @@ def __post_init__(self): "f_crypmw": InputVariable( data_structure.heat_transport_variables, float, range=(0.0, 100.0) ), - "f_fw_peak": InputVariable( - data_structure.fwbs_variables, float, range=(1.0, 100.0) - ), + "f_fw_peak": InputVariable(data_structure.fwbs_variables, float, range=(1.0, 100.0)), "f_fw_rad_max": InputVariable( data_structure.constraint_variables, float, range=(0.1, 10) ), @@ -1115,9 +1101,7 @@ def __post_init__(self): "p_fw_coolant_pump_mw": InputVariable( data_structure.heat_transport_variables, float, range=(0.0, 1000.0) ), - "htpmw_ife": InputVariable( - data_structure.ife_variables, float, range=(0.0, 1000.0) - ), + "htpmw_ife": InputVariable(data_structure.ife_variables, float, range=(0.0, 1000.0)), "p_shld_coolant_pump_mw": InputVariable( data_structure.heat_transport_variables, float, range=(0.0, 1000.0) ), @@ -1167,12 +1151,8 @@ def __post_init__(self): data_structure.tfcoil_variables, float, range=(10000.0, 100000000.0) ), "kappa": InputVariable(data_structure.physics_variables, float, range=(0.99, 5.0)), - "kappa95": InputVariable( - data_structure.physics_variables, float, range=(0.99, 5.0) - ), - "layer_ins": InputVariable( - data_structure.tfcoil_variables, float, range=(0.0, 0.1) - ), + "kappa95": InputVariable(data_structure.physics_variables, float, range=(0.99, 5.0)), + "layer_ins": InputVariable(data_structure.tfcoil_variables, float, range=(0.0, 0.1)), "f_dr_dz_cs_turn": InputVariable( data_structure.pfcoil_variables, float, range=(0.0, 5.0) ), @@ -1186,9 +1166,7 @@ def __post_init__(self): "f_blkt_li6_enrichment": InputVariable( data_structure.fwbs_variables, float, range=(7.4, 100.0) ), - "life_dpa": InputVariable( - data_structure.cost_variables, float, range=(10.0, 100.0) - ), + "life_dpa": InputVariable(data_structure.cost_variables, float, range=(10.0, 100.0)), "llw_storage_h": InputVariable( data_structure.buildings_variables, float, range=(1.0, 100.0) ), @@ -1248,9 +1226,7 @@ def __post_init__(self): "pflux_fw_rad_max": InputVariable( data_structure.constraint_variables, float, range=(0.1, 10.0) ), - "mbvfac": InputVariable( - data_structure.buildings_variables, float, range=(0.9, 3.0) - ), + "mbvfac": InputVariable(data_structure.buildings_variables, float, range=(0.9, 3.0)), "mcdriv": InputVariable(data_structure.ife_variables, float, range=(0.1, 10.0)), "mvalim": InputVariable( data_structure.constraint_variables, float, range=(0.0, 1000.0) @@ -1435,9 +1411,7 @@ def __post_init__(self): data_structure.vacuum_variables, float, range=(1e-10, 1e-06) ), "rbrt": InputVariable(data_structure.buildings_variables, float, range=(0.0, 10.0)), - "rbvfac": InputVariable( - data_structure.buildings_variables, float, range=(0.9, 3.0) - ), + "rbvfac": InputVariable(data_structure.buildings_variables, float, range=(0.9, 3.0)), "rbwt": InputVariable(data_structure.buildings_variables, float, range=(0.0, 10.0)), "rcool": InputVariable(data_structure.tfcoil_variables, float, range=(1e-06, 1.0)), "reactor_clrnc": InputVariable( @@ -1681,9 +1655,7 @@ def __post_init__(self): "tcoolin": InputVariable( data_structure.tfcoil_variables, float, range=(4.0, 373.15) ), - "tcritsc": InputVariable( - data_structure.tfcoil_variables, float, range=(1.0, 300.0) - ), + "tcritsc": InputVariable(data_structure.tfcoil_variables, float, range=(1.0, 300.0)), "t_cycle_min": InputVariable( data_structure.constraint_variables, float, range=(0.001, 2000000.0) ), @@ -1760,9 +1732,7 @@ def __post_init__(self): data_structure.cost_variables, float, range=(1.0, 100.0) ), "tmain": InputVariable(data_structure.cost_variables, float, range=(0.0, 100.0)), - "tmargmin": InputVariable( - data_structure.tfcoil_variables, float, range=(0.0, 20.0) - ), + "tmargmin": InputVariable(data_structure.tfcoil_variables, float, range=(0.0, 20.0)), "temp_cs_superconductor_margin_min": InputVariable( data_structure.tfcoil_variables, float, range=(0.0, 20.0) ), @@ -1792,9 +1762,7 @@ def __post_init__(self): ), "trcl": InputVariable(data_structure.buildings_variables, float, range=(0.0, 10.0)), "triang": InputVariable(data_structure.physics_variables, float, range=(-1.0, 1.0)), - "triang95": InputVariable( - data_structure.physics_variables, float, range=(0.0, 1.0) - ), + "triang95": InputVariable(data_structure.physics_variables, float, range=(0.0, 1.0)), "p_tritium_plant_electric_mw": InputVariable( data_structure.heat_transport_variables, float, range=(0.0, 100.0) ), @@ -1826,9 +1794,7 @@ def __post_init__(self): "ucblbreed": InputVariable( data_structure.cost_variables, float, range=(1.0, 1000.0) ), - "ucblli": InputVariable( - data_structure.cost_variables, float, range=(10.0, 10000.0) - ), + "ucblli": InputVariable(data_structure.cost_variables, float, range=(10.0, 10000.0)), "ucblli2o": InputVariable( data_structure.cost_variables, float, range=(100.0, 10000.0) ), @@ -1836,9 +1802,7 @@ def __post_init__(self): data_structure.cost_variables, float, range=(100.0, 10000.0) ), "ucblss": InputVariable(data_structure.cost_variables, float, range=(10.0, 1000.0)), - "ucblvd": InputVariable( - data_structure.cost_variables, float, range=(100.0, 1000.0) - ), + "ucblvd": InputVariable(data_structure.cost_variables, float, range=(100.0, 1000.0)), "ucbus": InputVariable(data_structure.cost_variables, float, range=(0.01, 10.0)), "uccarb": InputVariable(data_structure.ife_variables, float, range=(10.0, 1000.0)), "uccase": InputVariable(data_structure.cost_variables, float, range=(1.0, 1000.0)), @@ -1928,9 +1892,7 @@ def __post_init__(self): "vachtmw": InputVariable( data_structure.heat_transport_variables, float, range=(0.0, 100.0) ), - "vcool": InputVariable( - data_structure.tfcoil_variables, float, range=(0.001, 100.0) - ), + "vcool": InputVariable(data_structure.tfcoil_variables, float, range=(0.001, 100.0)), "v_tf_coil_dump_quench_max_kv": InputVariable( data_structure.tfcoil_variables, float, range=(0.0, 100.0) ), @@ -2001,9 +1963,7 @@ def __post_init__(self): "workshop_w": InputVariable( data_structure.buildings_variables, float, range=(10.0, 1000.0) ), - "wsvfac": InputVariable( - data_structure.buildings_variables, float, range=(0.9, 3.0) - ), + "wsvfac": InputVariable(data_structure.buildings_variables, float, range=(0.9, 3.0)), "xi_ebw": InputVariable( data_structure.current_drive_variables, float, range=(0.0, 1.0) ), @@ -2087,9 +2047,7 @@ def __post_init__(self): "i_plasma_wall_gap": InputVariable( data_structure.physics_variables, int, choices=[0, 1] ), - "i_pulsed_plant": InputVariable( - data_structure.pulse_variables, int, choices=[0, 1] - ), + "i_pulsed_plant": InputVariable(data_structure.pulse_variables, int, choices=[0, 1]), "i_q95_fixed": InputVariable( data_structure.constraint_variables, int, choices=[0, 1] ), @@ -2116,9 +2074,7 @@ def __post_init__(self): data_structure.tfcoil_variables, int, choices=[0, 1] ), "i_tf_sc_mat": InputVariable(data_structure.tfcoil_variables, int, range=(1, 9)), - "i_tf_shape": InputVariable( - data_structure.tfcoil_variables, int, choices=[0, 1, 2] - ), + "i_tf_shape": InputVariable(data_structure.tfcoil_variables, int, choices=[0, 1, 2]), "i_tf_stress_model": InputVariable( data_structure.tfcoil_variables, int, choices=[0, 1, 2] ), @@ -2258,9 +2214,7 @@ def __post_init__(self): "supercond_cost_model": InputVariable( data_structure.cost_variables, int, choices=[0, 1] ), - "i_tf_inside_cs": InputVariable( - data_structure.build_variables, int, choices=[0, 1] - ), + "i_tf_inside_cs": InputVariable(data_structure.build_variables, int, choices=[0, 1]), "i_ecrh_wave_mode": InputVariable( data_structure.current_drive_variables, int, choices=[0, 1] ), diff --git a/process/io/configuration.py b/process/io/configuration.py index 13e9cfc3d0..d9818775d3 100644 --- a/process/io/configuration.py +++ b/process/io/configuration.py @@ -65,9 +65,7 @@ def _lowercase(self, objekt): if isinstance(objekt, list): return [self._lowercase(item) for item in objekt] if isinstance(objekt, dict): - return { - key.lower(): self._lowercase(value) for key, value in objekt.items() - } + return {key.lower(): self._lowercase(value) for key, value in objekt.items()} return objekt def _search_config_for(self, config, *keys): diff --git a/process/io/costs_bar.py b/process/io/costs_bar.py index dc3fa919ce..90d25343c8 100644 --- a/process/io/costs_bar.py +++ b/process/io/costs_bar.py @@ -104,9 +104,7 @@ def comp_orig(args, mfile_list: list[str], inflate: float) -> None: # Plot bar charts ax.bar(index + identity * bar_width, sizes, bar_width, label=args.f[identity]) - ax2.bar( - index2 + identity * bar_width, sizes2, bar_width, label=args.f[identity] - ) + ax2.bar(index2 + identity * bar_width, sizes2, bar_width, label=args.f[identity]) # Plot labels ax.set_xticks(index + (len(mfile_list) - 1) * 0.5 * bar_width) @@ -165,9 +163,7 @@ def comp_new(args, mfile_list: list[str], inflate: float): cost[1] = item.data["s13"].get_scan(-1) # Land cost[2] = item.data["s21"].get_scan(-1) # TF Coils cost[3] = item.data["s27"].get_scan(-1) # First wall and blanket - cost[4] = item.data["s31"].get_scan( - -1 - ) # Active maintenance and remote handling + cost[4] = item.data["s31"].get_scan(-1) # Active maintenance and remote handling cost[5] = item.data["s34"].get_scan( -1 ) # Vacuum vessel and liquid nitrogen plant diff --git a/process/io/data_structure_dicts.py b/process/io/data_structure_dicts.py index 72fd4f1765..0dbff28738 100644 --- a/process/io/data_structure_dicts.py +++ b/process/io/data_structure_dicts.py @@ -28,6 +28,7 @@ "feffcd", "f_a_tf_turn_cable_copper", ] +logger = logging.getLogger(__name__) output_dict = {} # Dict of nested dicts e.g. output_dict['DICT_DESCRIPTIONS'] = @@ -131,7 +132,7 @@ def grep(file, regexp, flags=re.UNICODE): lines = [line for line in file_open if re.search(regexp, line, flags)] except OSError: - logging.warning("File : %s not found\n", file) + logger.warning("File : %s not found\n", file) return lines @@ -158,7 +159,7 @@ def slice_file(file, re1, re2): start = i break if start is None: - logging.warning("Could not match %s in file %s\n", re1, file) + logger.warning("Could not match %s in file %s\n", re1, file) return "" end = None for i in range(start, len(filetext)): @@ -167,7 +168,7 @@ def slice_file(file, re1, re2): end = i break if end is None: - logging.warning("Could not match %s in file %s\n", re2, file) + logger.warning("Could not match %s in file %s\n", re2, file) return "" # return slice return filetext[start : end + 1] diff --git a/process/io/mfile.py b/process/io/mfile.py index 2133c828dc..cf648341a9 100644 --- a/process/io/mfile.py +++ b/process/io/mfile.py @@ -33,7 +33,7 @@ logger = logging.getLogger(__name__) -class MFileVariable(dict): +class MFileVariable(dict): # noqa: FURB189 """Class for containing a single mfile variable""" def __init__( @@ -269,7 +269,7 @@ def add_to_mfile_variable(self, des, name, value, unit, flag, scan=None): var_key = des.lower().replace("_", " ") if name == "" else name.lower() if var_key in self.data: - scan_num = scan if scan else (self.data[var_key].get_number_of_scans() + 1) + scan_num = scan or (self.data[var_key].get_number_of_scans() + 1) # Check for duplicate entries per scan point if there are scans and no scans a = len(self.data[var_key].get_scans()) @@ -301,10 +301,7 @@ def write_to_json(self, keys_to_write=None, scan=-1, verbose=False): for i in range(self.data["rmajor"].get_number_of_scans()): sub_dict = {} for item in keys_to_write: - if self.data[item].get_number_of_scans() == 1: - dat_key = -1 - else: - dat_key = i + 1 + dat_key = -1 if self.data[item].get_number_of_scans() == 1 else i + 1 data = self.data[item].get_scan(dat_key) des = self.data[item].var_description.replace("_", " ") entry = {"value": data, "description": des} if verbose else data diff --git a/process/io/mfile2dict.py b/process/io/mfile2dict.py index 70f31ad1ed..b14c2c5197 100644 --- a/process/io/mfile2dict.py +++ b/process/io/mfile2dict.py @@ -15,6 +15,7 @@ import os import re from collections import OrderedDict, abc +from pathlib import Path from typing import Any MFILE_END = "# Copy of PROCESS Input Follows #" @@ -42,7 +43,7 @@ def __iter__(self): yield from self._mfile_data[group] def __len__(self): - return sum([len(self._mfile_data[g]) for g in self._mfile_data]) + return sum(len(self._mfile_data[g]) for g in self._mfile_data) def items(self): for group in self._mfile_data: @@ -145,65 +146,63 @@ def _get_values(self, lines: list[str]) -> dict[str, Any]: """ # Compile regex for converting underscores which are spaces into # a space character - _space_re = r"(\_{5,})" - _var_re = r"(\([a-z0-9\-\+\*\/\_\%\]\[]+\))" - + space_re = r"(\_{5,})" + var_re = r"(\([a-z0-9\-\+\*\/\_\%\]\[]+\))" + # TODO remove underscores # Extract lines from the given line set that follow the variable # statement convention of 'desc_______(varname)________ value' - _lines = [line for line in lines if re.findall(_var_re, line)] + lines_ = [line for line in lines if re.findall(var_re, line)] # Remove extra symbols such as quotation marks and split line into # the three required components using regex - _lines = [ + lines_ = [ [ i.replace('"', "").replace("`", "").strip() - for i in re.split(_space_re, line) - if not (re.findall(_space_re, i)) and i.strip() + for i in re.split(space_re, line) + if not (re.findall(space_re, i)) and i.strip() ] - for line in _lines + for line in lines_ ] # If there are not three components in a given line, try splitting # the components present by ' ' instead and append - for i, line in enumerate(_lines): + for i, line in enumerate(lines_): if len(line) != 3: - _new_line = [] + new_line = [] for element in line: if " " in element: - _new_line += element.split(" ") + new_line += element.split(" ") else: - _new_line += element - _lines[i] = _new_line[:3] + new_line += element + lines_[i] = new_line[:3] # Use an ordered dictionary to match ordering in MFILE - _vars_dict = OrderedDict() + vars_dict = OrderedDict() # Iterate through the resultant line sets and tidy them a little # finally creating a dictionary entry for each with the required # information - for line in _lines: - _var_key = line[1][1:-1] - _var_key = _var_key.replace("%", ".") - if not _var_key: + for line in lines_: + var_key = line[1][1:-1] + var_key = var_key.replace("%", ".") + if not var_key: continue - _value = line[2] - _desc = line[0].replace("_-_", "-").replace("_", " ") - _desc = _desc.title().strip() - _desc = _desc.replace('"', "") - _desc = re.sub(r"\s{2,}", " ", _desc) - if _var_key in _vars_dict: - if not isinstance(_vars_dict[_var_key], list): - _vars_dict[_var_key]["value"] = [_vars_dict[_var_key]["value"]] - _vars_dict[_var_key]["value"].append( - self._find_var_val_from_str(_value) - ) + value = line[2] + desc = line[0].replace("_-_", "-").replace("_", " ") + desc = desc.title().strip() + desc = desc.replace('"', "") + desc = re.sub(r"\s{2,}", " ", desc) + if var_key in vars_dict: + if not isinstance(vars_dict[var_key], list): + vars_dict[var_key]["value"] = [vars_dict[var_key]["value"]] + vars_dict[var_key]["value"].append(self._find_var_val_from_str(value)) else: - _vars_dict[_var_key] = { - "description": _desc, - "value": self._find_var_val_from_str(_value), + vars_dict[var_key] = { + "description": desc, + "value": self._find_var_val_from_str(value), } - return _vars_dict + return vars_dict def parse(self, mfile_addr: str) -> dict: """Parse an MFILE and extract output values. @@ -231,81 +230,80 @@ def parse(self, mfile_addr: str) -> dict: self._logger.info("Parsing MFILE: %s", mfile_addr) with open(mfile_addr) as f: - _lines = f.readlines() + lines = f.readlines() - _end_of_output = self._line_string_search(_lines, MFILE_END)[0] + end_of_output = self._line_string_search(lines, MFILE_END)[0] self._logger.info("Extracting file headers") - _header_indexes = [ - i for i, line in enumerate(_lines) if line.strip() and i < _end_of_output + header_indexes = [ + i for i, line in enumerate(lines) if line.strip() and i < end_of_output ] - _header_indexes = [ + header_indexes = [ i - for i in _header_indexes - if _lines[i].strip()[0] == "#" - and not any(k in _lines[i] for k in VETO_LIST) + for i in header_indexes + if lines[i].strip()[0] == "#" and not any(k in lines[i] for k in VETO_LIST) ] # Gets rid of multi-headers, taking the last one - _header_indexes = [i for i in _header_indexes if i + 1 not in _header_indexes] + header_indexes = [i for i in header_indexes if i + 1 not in header_indexes] self._logger.info("Retrieving output variable values") # Iterate through the file headers processing the "block" between them # extracting variable values. Where duplicate headers are found assume # that a parameter sweep is occuring and append values in lists - for i in range(len(_header_indexes) - 1): - _key = _lines[_header_indexes[i]].replace("#", "").strip() + for i in range(len(header_indexes) - 1): + key = lines[header_indexes[i]].replace("#", "").strip() - _new_vals = self._get_values( - _lines[_header_indexes[i] + 1 : _header_indexes[i + 1]] + new_vals = self._get_values( + lines[header_indexes[i] + 1 : header_indexes[i + 1]] ) # The iscan variable is always present at start of sweep # no matter what the first header in an iteration is # need to move it into metadata - _first_key = _lines[_header_indexes[0]] - _check_iscan = self._mfile_data and "iscan" in _new_vals - _check_iscan = _check_iscan and _key != _first_key - if _check_iscan: - _first_key = _first_key.replace("#", "").strip() - _iscan_var = self._mfile_data[_first_key]["iscan"]["value"] - if not isinstance(_iscan_var, list): - self._mfile_data[_first_key]["iscan"]["value"] = [_iscan_var] - self._mfile_data[_first_key]["iscan"]["value"].append( - _new_vals["iscan"]["value"] + first_key = lines[header_indexes[0]] + check_iscan = self._mfile_data and "iscan" in new_vals + check_iscan = check_iscan and key != first_key + if check_iscan: + first_key = first_key.replace("#", "").strip() + iscan_var = self._mfile_data[first_key]["iscan"]["value"] + if not isinstance(iscan_var, list): + self._mfile_data[first_key]["iscan"]["value"] = [iscan_var] + self._mfile_data[first_key]["iscan"]["value"].append( + new_vals["iscan"]["value"] ) - del _new_vals["iscan"] + del new_vals["iscan"] # Add header to dictionary of not present - if _key not in self._mfile_data: - self._mfile_data[_key] = _new_vals + if key not in self._mfile_data: + self._mfile_data[key] = new_vals # If header already present, iterate through member parameters # appending the new values to each else: - for param, var_dict in self._mfile_data[_key].items(): - if param not in _new_vals: + for param, var_dict in self._mfile_data[key].items(): + if param not in new_vals: self._logger.warning( f"Expected parameter '{param}' in sweep, " "but could not find entry" " for this iteration" ) continue - _value = _new_vals[param]["value"] + value = new_vals[param]["value"] if not isinstance(var_dict["value"], list): - self._mfile_data[_key][param]["value"] = [ - self._mfile_data[_key][param]["value"], - _value, + self._mfile_data[key][param]["value"] = [ + self._mfile_data[key][param]["value"], + value, ] else: # Need to check if the find variables function # returned a single value for the parameter or multiple # and handle the cases - if not isinstance(_new_vals[param]["value"], list): - self._mfile_data[_key][param]["value"].append(_value) + if not isinstance(new_vals[param]["value"], list): + self._mfile_data[key][param]["value"].append(value) else: - self._mfile_data[_key][param]["value"] += _value + self._mfile_data[key][param]["value"] += value self._logger.info("Creating output dictionaries") # Remove any cases where there are no parameters under a given header @@ -313,11 +311,11 @@ def parse(self, mfile_addr: str) -> dict: # Use underscore keys and tidy them to be more computationally friendly def _key_update(key): - _key = key.lower() - _key = _key.replace(" ", "_") + key_ = key.lower() + key_ = key_.replace(" ", "_") for sym in [":", "(", ")", "/"]: - _key = _key.replace(sym, "") - return _key.replace("__", "_") + key_ = key_.replace(sym, "") + return key_.replace("__", "_") # Apply header mappings and tidy headers self._mfile_data = { @@ -330,16 +328,16 @@ def _key_update(key): # Only run iscan check if iscan exists try: - _first_key = next(iter(self._mfile_data.keys())) - _second_key = list(self._mfile_data.keys())[1] - _second_key_fp = list(self._mfile_data[_second_key])[8] - _iscan_arr = self._mfile_data[_first_key]["iscan"]["value"] - _test_param = self._mfile_data[_second_key][_second_key_fp]["value"] - if len(_test_param) != _iscan_arr[-1]: - print(_test_param) + first_key = next(iter(self._mfile_data.keys())) + second_key = list(self._mfile_data.keys())[1] + second_key_fp = list(self._mfile_data[second_key])[8] + iscan_arr = self._mfile_data[first_key]["iscan"]["value"] + test_param = self._mfile_data[second_key][second_key_fp]["value"] + if len(test_param) != iscan_arr[-1]: + print(test_param) raise AssertionError( "Failed to retrieve all parameter sweep values, " - f"expected {_iscan_arr[-1]} values for '{_second_key}:{_second_key_fp}' and got {len(_test_param)}" + f"expected {iscan_arr[-1]} values for '{second_key}:{second_key_fp}' and got {len(test_param)}" ) except KeyError: pass @@ -358,9 +356,9 @@ def write(self, output_filename: str) -> None: """ self._logger.info("Writing to output file '%s'", output_filename) - _suffix = os.path.splitext(output_filename)[1].lower() + suffix = os.path.splitext(output_filename)[1].lower() - if _suffix == ".toml": + if suffix == ".toml": self._logger.info("Output will be TOML file.") try: import tomlkit @@ -378,44 +376,43 @@ def write(self, output_filename: str) -> None: # If TOMLKit is present, write TOML file as normal but add in # descriptions as docstrings instead and format - _doc = tomlkit.document() - _doc.add(tomlkit.comment("PROCESS Run Output")) + doc = tomlkit.document() + doc.add(tomlkit.comment("PROCESS Run Output")) for group_name, data in self._mfile_data.items(): - _new_dict = {} + new_dict = {} for var_name, var_data in data.items(): - _new_dict[var_name] = var_data["value"] - _header = group_name.replace("_", " ").title() - _ls = int((75 - len(_header)) / 2) - _rs = 75 - len(_header) - _ls - _header = _ls * "-" + " " + _header + " " + _rs * "-" - _doc.add(tomlkit.comment(_header)) - _doc.add(group_name, _new_dict) - _doc.add(tomlkit.nl()) - _doc.add(tomlkit.nl()) + new_dict[var_name] = var_data["value"] + header = group_name.replace("_", " ").title() + ls = int((75 - len(header)) / 2) + rs = 75 - len(header) - ls + header = ls * "-" + " " + header + " " + rs * "-" + doc.add(tomlkit.comment(header)) + doc.add(group_name, new_dict) + doc.add(tomlkit.nl()) + doc.add(tomlkit.nl()) for group_name, data in self._mfile_data.items(): for var_name in data: - _doc[group_name][var_name].comment( + doc[group_name][var_name].comment( self._mfile_data[group_name][var_name]["description"] ) - with open(output_filename, "w") as f: - f.write(tomlkit.dumps(_doc)) - elif _suffix == ".json": + Path(output_filename).write_text(tomlkit.dumps(doc)) + elif suffix == ".json": # If file suffix is JSON self._logger.info("Output will be JSON file.") import json with open(output_filename, "w") as file: json.dump(self._mfile_data, file) - elif _suffix in [".yml", ".yaml"]: + elif suffix in [".yml", ".yaml"]: self._logger.info("Output will be YAML file.") # If file suffix is YAML import yaml with open(output_filename, "w") as file: yaml.dump(self._mfile_data, file) - elif _suffix == ".pckl": + elif suffix == ".pckl": self._logger.info("Output will be Pickle file.") # If file suffix is Pickle import pickle @@ -423,7 +420,7 @@ def write(self, output_filename: str) -> None: with open(output_filename, "wb") as file: pickle.dump(self._mfile_data, file) else: - raise RuntimeError(f"Unrecognised file format '{_suffix}'") + raise RuntimeError(f"Unrecognised file format '{suffix}'") self._logger.info("File was written successfully.") diff --git a/process/io/mfile_to_csv.py b/process/io/mfile_to_csv.py index b7e74094e3..55f7abe3fd 100644 --- a/process/io/mfile_to_csv.py +++ b/process/io/mfile_to_csv.py @@ -69,11 +69,7 @@ def get_vars(vfile="mfile_to_csv_vars.json"): """ print("Fetching list of variables from", vfile) - with open(vfile) as varfile: - data = varfile.read() - obj = json.loads(data) - - return obj["vars"] + return json.loads(Path(vfile).read_text())["vars"] def read_mfile(mfilename="MFILE.DAT", variables=None): diff --git a/process/io/plot_plotly_sankey.py b/process/io/plot_plotly_sankey.py index f960d03e89..7379707ca4 100644 --- a/process/io/plot_plotly_sankey.py +++ b/process/io/plot_plotly_sankey.py @@ -302,9 +302,7 @@ def plot_power_balance_sankey(m_file): m_file.data["p_div_secondary_heat_mw"].get_scan( -1 ), # 53 Divertor secondary heat, - m_file.data["p_shld_secondary_heat_mw"].get_scan( - -1 - ), # 54 Shield secondary heat + m_file.data["p_shld_secondary_heat_mw"].get_scan(-1), # 54 Shield secondary heat m_file.data["p_fw_hcd_nuclear_heat_mw"].get_scan( -1 ), # 55 Neutron power to H&CD & Diagnostics diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 9b951603a2..204b3b90a7 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -415,8 +415,7 @@ def plot_main_power_flow( axis.text( 0.22, 0.75, - "$P_{{fus}}$\n" - f"{mfile_data.data['p_fusion_total_mw'].get_scan(scan):.2f} MW", + f"$P_{{{{fus}}}}$\n{mfile_data.data['p_fusion_total_mw'].get_scan(scan):.2f} MW", transform=fig.transFigure, horizontalalignment="left", verticalalignment="bottom", @@ -666,9 +665,7 @@ def plot_main_power_flow( ) new_ax.imshow(hcd_injector_1) new_ax.axis("off") - new_ax = axis.inset_axes( - [-0.2, 0.5, 0.15, 0.5], transform=axis.transAxes, zorder=10 - ) + new_ax = axis.inset_axes([-0.2, 0.5, 0.15, 0.5], transform=axis.transAxes, zorder=10) new_ax.imshow(hcd_injector_2) new_ax.axis("off") @@ -931,9 +928,7 @@ def plot_main_power_flow( turbine = mpimg.imread(img_path.open("rb")) # Display the turbine image over the figure, not the axes - new_ax = axis.inset_axes( - [1.1, 0.0, 0.15, 0.15], transform=axis.transAxes, zorder=10 - ) + new_ax = axis.inset_axes([1.1, 0.0, 0.15, 0.15], transform=axis.transAxes, zorder=10) new_ax.imshow(turbine) new_ax.axis("off") @@ -1267,9 +1262,7 @@ def plot_main_power_flow( fw = mpimg.imread(img_path.open("rb")) # Display the first wall image over the figure, not the axes - new_ax = axis.inset_axes( - [0.4, 0.625, 0.4, 0.4], transform=axis.transAxes, zorder=10 - ) + new_ax = axis.inset_axes([0.4, 0.625, 0.4, 0.4], transform=axis.transAxes, zorder=10) new_ax.imshow(fw) new_ax.axis("off") @@ -2784,9 +2777,7 @@ def plot_main_plasma_information( # ========================================= # Load the neutron image - with resources.path( - "process.io", "alpha_particle.png" - ) as alpha_particle_image_path: + with resources.path("process.io", "alpha_particle.png") as alpha_particle_image_path: # Use importlib.resources to locate the image alpha_particle = mpimg.imread(alpha_particle_image_path.open("rb")) @@ -3262,9 +3253,9 @@ def plot_system_power_profiles_over_time( """ t_precharge = mfile_data.data["t_plant_pulse_coil_precharge"].get_scan(scan) - t_current_ramp_up = mfile_data.data[ - "t_plant_pulse_plasma_current_ramp_up" - ].get_scan(scan) + t_current_ramp_up = mfile_data.data["t_plant_pulse_plasma_current_ramp_up"].get_scan( + scan + ) t_fusion_ramp = mfile_data.data["t_plant_pulse_fusion_ramp"].get_scan(scan) t_burn = mfile_data.data["t_plant_pulse_burn"].get_scan(scan) t_ramp_down = mfile_data.data["t_plant_pulse_plasma_current_ramp_down"].get_scan( @@ -3476,8 +3467,10 @@ def color_key(axis, mfile_data, scan, colour_scheme): if (mfile_data.data["i_hcd_primary"].get_scan(scan) in [5, 8]) or ( mfile_data.data["i_hcd_secondary"].get_scan(scan) in [5, 8] ): - labels.append(("NB duct shield", NBSHIELD_COLOUR[colour_scheme - 1])) - labels.append(("Cryostat", CRYOSTAT_COLOUR[colour_scheme - 1])) + labels.extend(( + ("NB duct shield", NBSHIELD_COLOUR[colour_scheme - 1]), + ("Cryostat", CRYOSTAT_COLOUR[colour_scheme - 1]), + )) else: labels.append(("Cryostat", CRYOSTAT_COLOUR[colour_scheme - 1])) @@ -3583,8 +3576,8 @@ def toroidal_cross_section(axis, mfile_data, scan, demo_ranges, colour_scheme): ang = i * spacing angl = ang - spacing / 2 angu = ang + spacing / 2 - r1, null = cumulative_radial_build2("dr_cs_tf_gap", mfile_data, scan) - r2, null = cumulative_radial_build2("dr_tf_inboard", mfile_data, scan) + r1, _null = cumulative_radial_build2("dr_cs_tf_gap", mfile_data, scan) + r2, _null = cumulative_radial_build2("dr_tf_inboard", mfile_data, scan) r4, r3 = cumulative_radial_build2("dr_tf_outboard", mfile_data, scan) # Coil width @@ -3867,7 +3860,7 @@ def plot_n_profiles(prof, demo_ranges, mfile_data, scan): ) # make legend use multiple columns (up to 4) and place it to the right to avoid overlapping the plots - handles, labels = prof.get_legend_handles_labels() + _handles, labels = prof.get_legend_handles_labels() ncol = min(4, max(1, len(labels))) prof.legend(loc="upper center", bbox_to_anchor=(0.5, -0.1), ncol=ncol) @@ -5315,9 +5308,7 @@ def plot_tf_coils(axis, mfile_data, scan, colour_scheme): x5 = mfile_data.data["r_tf_arc(5)"].get_scan(scan) y5 = mfile_data.data["z_tf_arc(5)"].get_scan(scan) dr_shld_thermal_inboard = mfile_data.data["dr_shld_thermal_inboard"].get_scan(scan) - dr_shld_thermal_outboard = mfile_data.data["dr_shld_thermal_outboard"].get_scan( - scan - ) + dr_shld_thermal_outboard = mfile_data.data["dr_shld_thermal_outboard"].get_scan(scan) dr_tf_shld_gap = mfile_data.data["dr_tf_shld_gap"].get_scan(scan) if y3 != 0: print("TF coil geometry: The value of z_tf_arc(3) is not zero, but should be.") @@ -5418,9 +5409,7 @@ def plot_superconducting_tf_wp(axis, mfile_data, scan: int, fig) -> None: dx_tf_wp_secondary_toroidal = mfile_data.data[ "dx_tf_wp_secondary_toroidal" ].get_scan(scan) - dr_tf_wp_with_insulation = mfile_data.data["dr_tf_wp_with_insulation"].get_scan( - scan - ) + dr_tf_wp_with_insulation = mfile_data.data["dr_tf_wp_with_insulation"].get_scan(scan) r_tf_wp_inboard_inner = mfile_data.data["r_tf_wp_inboard_inner"].get_scan(scan) dx_tf_wp_insulation = mfile_data.data["dx_tf_wp_insulation"].get_scan(scan) n_tf_coil_turns = round(mfile_data.data["n_tf_coil_turns"].get_scan(scan)) @@ -6710,10 +6699,7 @@ def _pack_strands_rectangular_with_obstacles( candidate_y = y_pos # Check if within bounds - if ( - candidate_x > x + width - radius - or candidate_y > y + height - radius - ): + if candidate_x > x + width - radius or candidate_y > y + height - radius: continue # Check collision with cooling pipe @@ -6778,8 +6764,7 @@ def _pack_strands_rectangular_with_obstacles( collision = False for existing_x, existing_y in placed_strands: distance = np.sqrt( - (candidate_x - existing_x) ** 2 - + (candidate_y - existing_y) ** 2 + (candidate_x - existing_x) ** 2 + (candidate_y - existing_y) ** 2 ) if distance < strand_diameter: collision = True @@ -6846,9 +6831,7 @@ def _pack_strands_rectangular_with_obstacles( "radius_tf_turn_cable_space_corners" ].get_scan(scan) - a_tf_wp_coolant_channels = mfile_data.data["a_tf_wp_coolant_channels"].get_scan( - scan - ) + a_tf_wp_coolant_channels = mfile_data.data["a_tf_wp_coolant_channels"].get_scan(scan) f_a_tf_turn_cable_space_extra_void = mfile_data.data[ "f_a_tf_turn_cable_space_extra_void" @@ -6941,7 +6924,7 @@ def _pack_strands_rectangular_with_obstacles( # Pack strands if significant void fraction if void_fraction > 0.001: - n_strands, attempts = _pack_strands_rectangular_with_obstacles( + _n_strands, _attempts = _pack_strands_rectangular_with_obstacles( cable_space_bounds=cable_bounds, pipe_center=( turn_width / 2, @@ -7246,9 +7229,7 @@ def plot_cable_in_conduit_cable(axis, fig, mfile_data, scan: int) -> None: dia_tf_turn_superconducting_cable = mfile_data.data[ "dia_tf_turn_superconducting_cable" ].get_scan(scan) - f_a_tf_turn_cable_copper = mfile_data.data["f_a_tf_turn_cable_copper"].get_scan( - scan - ) + f_a_tf_turn_cable_copper = mfile_data.data["f_a_tf_turn_cable_copper"].get_scan(scan) # Convert to mm dia_mm = dia_tf_turn_superconducting_cable * 1000 @@ -7626,9 +7607,9 @@ def plot_geometry_info(axis, mfile_data, scan): axis.set_autoscaley_on(False) axis.set_autoscalex_on(False) - in_blanket_thk = mfile_data.data["dr_shld_inboard"].get_scan( - scan - ) + mfile_data.data["dr_blkt_inboard"].get_scan(scan) + in_blanket_thk = mfile_data.data["dr_shld_inboard"].get_scan(scan) + mfile_data.data[ + "dr_blkt_inboard" + ].get_scan(scan) out_blanket_thk = mfile_data.data["dr_shld_outboard"].get_scan( scan ) + mfile_data.data["dr_blkt_outboard"].get_scan(scan) @@ -7802,9 +7783,9 @@ def plot_magnetics_info(axis, mfile_data, scan): sig_case = 1.0e-6 * mfile_data.data[f"s_shear_tf_peak({i_tf_bucking})"].get_scan( scan ) - sig_cond = 1.0e-6 * mfile_data.data[ - f"s_shear_tf_peak({i_tf_bucking + 1})" - ].get_scan(scan) + sig_cond = 1.0e-6 * mfile_data.data[f"s_shear_tf_peak({i_tf_bucking + 1})"].get_scan( + scan + ) if i_tf_sup == 1: data = [ @@ -7924,9 +7905,7 @@ def plot_power_info(axis, mfile_data, scan): ped_height = ("", "No pedestal model used", "") ped_pos = ("", "", "") - p_cryo_plant_electric_mw = mfile_data.data["p_cryo_plant_electric_mw"].get_scan( - scan - ) + p_cryo_plant_electric_mw = mfile_data.data["p_cryo_plant_electric_mw"].get_scan(scan) data = [ ("pflux_fw_neutron_mw", "Nominal neutron wall load", "MW m$^{-2}$"), @@ -10387,14 +10366,10 @@ def plot_tf_stress(axis): sig_file_data["Von-Mises stress (MPa)"][(ii + 1) * n_radial_array_layer - 1] ) bound_tresca_stress.append( - sig_file_data["CEA Tresca stress (MPa)"][ - (ii + 1) * n_radial_array_layer - 1 - ] + sig_file_data["CEA Tresca stress (MPa)"][(ii + 1) * n_radial_array_layer - 1] ) bound_cea_tresca_stress.append( - sig_file_data["CEA Tresca stress (MPa)"][ - (ii + 1) * n_radial_array_layer - 1 - ] + sig_file_data["CEA Tresca stress (MPa)"][(ii + 1) * n_radial_array_layer - 1] ) bound_radial_displacement.append( sig_file_data["rad. displacement (mm)"][(ii + 1) * n_radial_array_layer - 1] @@ -10404,17 +10379,16 @@ def plot_tf_stress(axis): for ii in range(n_layers): tresca_smeared_stress.append([]) - bound_tresca_smeared_stress.append( + bound_tresca_smeared_stress.extend([ max(abs(radial_smeared_stress[ii][0]), abs(toroidal_smeared_stress[ii][0])) - + vertical_smeared_stress[ii][0] - ) - bound_tresca_smeared_stress.append( + + vertical_smeared_stress[ii][0], max( abs(radial_smeared_stress[ii][n_radial_array_layer - 1]), abs(toroidal_smeared_stress[ii][n_radial_array_layer - 1]), ) - + vertical_smeared_stress[ii][n_radial_array_layer - 1] - ) + + vertical_smeared_stress[ii][n_radial_array_layer - 1], + ]) + for jj in range(n_radial_array_layer): tresca_smeared_stress[ii].append( max( @@ -10431,24 +10405,19 @@ def plot_tf_stress(axis): toroidal_strain.append([]) vertical_strain.append([]) - bound_radial_strain.append( - sig_file_data["Radial strain"][ii * n_radial_array_layer] - ) - bound_toroidal_strain.append( - sig_file_data["Toroidal strain"][ii * n_radial_array_layer] - ) - bound_vertical_strain.append( - sig_file_data["Vertical strain"][ii * n_radial_array_layer] - ) - bound_radial_strain.append( - sig_file_data["Radial strain"][(ii + 1) * n_radial_array_layer - 1] - ) - bound_toroidal_strain.append( - sig_file_data["Toroidal strain"][(ii + 1) * n_radial_array_layer - 1] - ) - bound_vertical_strain.append( - sig_file_data["Vertical strain"][(ii + 1) * n_radial_array_layer - 1] - ) + bound_radial_strain.extend([ + sig_file_data["Radial strain"][ii * n_radial_array_layer], + sig_file_data["Radial strain"][(ii + 1) * n_radial_array_layer - 1], + ]) + bound_toroidal_strain.extend([ + sig_file_data["Toroidal strain"][ii * n_radial_array_layer], + sig_file_data["Toroidal strain"][(ii + 1) * n_radial_array_layer - 1], + ]) + bound_vertical_strain.extend([ + sig_file_data["Vertical strain"][ii * n_radial_array_layer], + sig_file_data["Vertical strain"][(ii + 1) * n_radial_array_layer - 1], + ]) + for jj in range(n_radial_array_layer): radial_strain[ii].append( sig_file_data["Radial strain"][ii * n_radial_array_layer + jj] @@ -10567,9 +10536,7 @@ def plot_tf_stress(axis): markersize=mark_size, color="crimson", ) - ax.plot( - bound_radius, bound_vm_stress, "|", markersize=mark_size, color="darkviolet" - ) + ax.plot(bound_radius, bound_vm_stress, "|", markersize=mark_size, color="darkviolet") ax.grid(True) ax.set_ylabel(r"$\sigma$ [$MPa$]", fontsize=axis_tick_size) ax.set_title("Structure Stress Summary") @@ -11546,9 +11513,7 @@ def plot_plasma_poloidal_pressure_contours( ] # Convert pressure to kPa - pres_plasma_electron_profile_kpa = [ - p / 1000.0 for p in pres_plasma_electron_profile - ] + pres_plasma_electron_profile_kpa = [p / 1000.0 for p in pres_plasma_electron_profile] pres_plasma_profile_ion_kpa = [p / 1000.0 for p in pres_plasma_profile_ion] pres_plasma_profile = [ e + i @@ -11831,9 +11796,7 @@ def plot_fusion_rate_contours( ) # enable minor ticks and grid for clearer reading dt_axes.minorticks_on() - dt_axes.grid( - True, which="major", linestyle="--", linewidth=0.8, alpha=0.7, zorder=1 - ) + dt_axes.grid(True, which="major", linestyle="--", linewidth=0.8, alpha=0.7, zorder=1) dt_axes.grid(True, which="minor", linestyle=":", linewidth=0.4, alpha=0.5, zorder=1) # make minor ticks visible on all sides and draw ticks inward for compact look dt_axes.tick_params(which="both", direction="in", top=True, right=True) @@ -12673,9 +12636,7 @@ def plot_ebw_ecrh_coupling_graph(axis, mfile_data, scan): ) eta_ecrh_omode = ecrg.electron_cyclotron_freethy( te=mfile_data.data["temp_plasma_electron_vol_avg_kev"].get_scan(scan), - zeff=mfile_data.data["n_charge_plasma_effective_vol_avg"].get_scan( - scan - ), + zeff=mfile_data.data["n_charge_plasma_effective_vol_avg"].get_scan(scan), rmajor=mfile_data.data["rmajor"].get_scan(scan), nd_plasma_electrons_vol_avg=mfile_data.data[ "nd_plasma_electrons_vol_avg" @@ -12686,9 +12647,7 @@ def plot_ebw_ecrh_coupling_graph(axis, mfile_data, scan): ) eta_ecrh_xmode = ecrg.electron_cyclotron_freethy( te=mfile_data.data["temp_plasma_electron_vol_avg_kev"].get_scan(scan), - zeff=mfile_data.data["n_charge_plasma_effective_vol_avg"].get_scan( - scan - ), + zeff=mfile_data.data["n_charge_plasma_effective_vol_avg"].get_scan(scan), rmajor=mfile_data.data["rmajor"].get_scan(scan), nd_plasma_electrons_vol_avg=mfile_data.data[ "nd_plasma_electrons_vol_avg" @@ -13073,7 +13032,7 @@ def main(args=None): global m_file_name m_file_name = args.f if args.f != "" else "MFILE.DAT" - scan = args.n if args.n else -1 + scan = args.n or -1 demo_ranges = bool(args.DEMO_ranges) @@ -13089,29 +13048,30 @@ def main(args=None): else: i_tf_wp_geom = 0 - global dr_bore - global dr_cs - global dr_cs_tf_gap - global dr_tf_inboard - global dr_shld_vv_gap_inboard - global ddwi - global dr_shld_inboard - global dr_blkt_inboard - global dr_fw_inboard - global dr_fw_plasma_gap_inboard - global rmajor - global rminor - global dr_fw_plasma_gap_outboard - global dr_fw_outboard - global dr_blkt_outboard - global dr_shld_outboard - global ddwi - global dr_shld_vv_gap_outboard - global dr_tf_outboard - global r_cryostat_inboard - global z_cryostat_half_inside - global dr_cryostat - global j_plasma_0 + global \ + dr_bore, \ + dr_cs, \ + dr_cs_tf_gap, \ + dr_tf_inboard, \ + dr_shld_vv_gap_inboard, \ + ddwi, \ + dr_shld_inboard, \ + dr_blkt_inboard, \ + dr_fw_inboard, \ + dr_fw_plasma_gap_inboard, \ + rmajor, \ + rminor, \ + dr_fw_plasma_gap_outboard, \ + dr_fw_outboard, \ + dr_blkt_outboard, \ + dr_shld_outboard, \ + ddwi, \ + dr_shld_vv_gap_outboard, \ + dr_tf_outboard, \ + r_cryostat_inboard, \ + z_cryostat_half_inside, \ + dr_cryostat, \ + j_plasma_0 dr_bore = m_file.data["dr_bore"].get_scan(scan) dr_cs = m_file.data["dr_cs"].get_scan(scan) @@ -13136,13 +13096,14 @@ def main(args=None): j_plasma_0 = m_file.data["j_plasma_on_axis"].get_scan(scan) # Magnets related - global n_tf_coils - global dx_tf_wp_primary_toroidal - global dx_tf_wp_secondary_toroidal - global dr_tf_wp_with_insulation - global dx_tf_wp_insulation - global dr_tf_nose_case - global dr_tf_plasma_case + global \ + n_tf_coils, \ + dx_tf_wp_primary_toroidal, \ + dx_tf_wp_secondary_toroidal, \ + dr_tf_wp_with_insulation, \ + dx_tf_wp_insulation, \ + dr_tf_nose_case, \ + dr_tf_plasma_case n_tf_coils = m_file.data["n_tf_coils"].get_scan(scan) if i_tf_sup == 1: # If superconducting magnets @@ -13153,19 +13114,14 @@ def main(args=None): dx_tf_wp_secondary_toroidal = m_file.data[ "dx_tf_wp_secondary_toroidal" ].get_scan(scan) - dr_tf_wp_with_insulation = m_file.data["dr_tf_wp_with_insulation"].get_scan( - scan - ) + dr_tf_wp_with_insulation = m_file.data["dr_tf_wp_with_insulation"].get_scan(scan) dx_tf_wp_insulation = m_file.data["dx_tf_wp_insulation"].get_scan(scan) dr_tf_nose_case = m_file.data["dr_tf_nose_case"].get_scan(scan) # To be re-inergrated to resistives when in-plane stresses is integrated dr_tf_plasma_case = m_file.data["dr_tf_plasma_case"].get_scan(scan) - global dx_beam_shield - global radius_beam_tangency - global radius_beam_tangency_max - global dx_beam_duct + global dx_beam_shield, radius_beam_tangency, radius_beam_tangency_max, dx_beam_duct i_hcd_primary = int(m_file.data["i_hcd_primary"].get_scan(scan)) i_hcd_secondary = int(m_file.data["i_hcd_secondary"].get_scan(scan)) @@ -13173,9 +13129,7 @@ def main(args=None): if (i_hcd_primary in [5, 8]) or (i_hcd_secondary in [5, 8]): dx_beam_shield = m_file.data["dx_beam_shield"].get_scan(scan) radius_beam_tangency = m_file.data["radius_beam_tangency"].get_scan(scan) - radius_beam_tangency_max = m_file.data["radius_beam_tangency_max"].get_scan( - scan - ) + radius_beam_tangency_max = m_file.data["radius_beam_tangency_max"].get_scan(scan) dx_beam_duct = m_file.data["dx_beam_duct"].get_scan(scan) else: dx_beam_shield = radius_beam_tangency = radius_beam_tangency_max = ( @@ -13183,25 +13137,26 @@ def main(args=None): ) = 0.0 # Pedestal profile parameters - global i_plasma_pedestal - global nd_plasma_pedestal_electron - global nd_plasma_separatrix_electron - global radius_plasma_pedestal_density_norm - global radius_plasma_pedestal_temp_norm - global tbeta - global temp_plasma_pedestal_kev - global temp_plasma_separatrix_kev - global alphan - global alphat - global ne0 - global nd_plasma_fuel_ions_vol_avg - global nd_plasma_electrons_vol_avg - global te0 - global ti - global te - global fgwped_out - global fgwsep_out - global f_temp_plasma_ion_electron + global \ + i_plasma_pedestal, \ + nd_plasma_pedestal_electron, \ + nd_plasma_separatrix_electron, \ + radius_plasma_pedestal_density_norm, \ + radius_plasma_pedestal_temp_norm, \ + tbeta, \ + temp_plasma_pedestal_kev, \ + temp_plasma_separatrix_kev, \ + alphan, \ + alphat, \ + ne0, \ + nd_plasma_fuel_ions_vol_avg, \ + nd_plasma_electrons_vol_avg, \ + te0, \ + ti, \ + te, \ + fgwped_out, \ + fgwsep_out, \ + f_temp_plasma_ion_electron i_plasma_pedestal = m_file.data["i_plasma_pedestal"].get_scan(scan) nd_plasma_pedestal_electron = m_file.data["nd_plasma_pedestal_electron"].get_scan( @@ -13218,9 +13173,7 @@ def main(args=None): ].get_scan(scan) tbeta = m_file.data["tbeta"].get_scan(scan) temp_plasma_pedestal_kev = m_file.data["temp_plasma_pedestal_kev"].get_scan(scan) - temp_plasma_separatrix_kev = m_file.data["temp_plasma_separatrix_kev"].get_scan( - scan - ) + temp_plasma_separatrix_kev = m_file.data["temp_plasma_separatrix_kev"].get_scan(scan) alphan = m_file.data["alphan"].get_scan(scan) alphat = m_file.data["alphat"].get_scan(scan) ne0 = m_file.data["nd_plasma_electron_on_axis"].get_scan(scan) @@ -13235,17 +13188,10 @@ def main(args=None): te = m_file.data["temp_plasma_electron_vol_avg_kev"].get_scan(scan) fgwped_out = m_file.data["fgwped_out"].get_scan(scan) fgwsep_out = m_file.data["fgwsep_out"].get_scan(scan) - f_temp_plasma_ion_electron = m_file.data["f_temp_plasma_ion_electron"].get_scan( - scan - ) + f_temp_plasma_ion_electron = m_file.data["f_temp_plasma_ion_electron"].get_scan(scan) # Plasma - global triang - global alphaj - global q0 - global q95 - global plasma_current_MA - global a_plasma_poloidal + global triang, alphaj, q0, q95, plasma_current_MA, a_plasma_poloidal triang = m_file.data["triang95"].get_scan(scan) alphaj = m_file.data["alphaj"].get_scan(scan) @@ -13272,9 +13218,7 @@ def main(args=None): # Ion dens(10^19 m^-3) -- 15 # Poloidal flux (Wb) -- 16 # rad profile - global f_sync_reflect - global b_plasma_toroidal_on_axis - global vol_plasma + global f_sync_reflect, b_plasma_toroidal_on_axis, vol_plasma f_sync_reflect = m_file.data["f_sync_reflect"].get_scan(scan) b_plasma_toroidal_on_axis = m_file.data["b_plasma_toroidal_on_axis"].get_scan(scan) vol_plasma = m_file.data["vol_plasma"].get_scan(scan) @@ -13327,8 +13271,7 @@ def main(args=None): subtotal += build cumulative_radial[item] = subtotal - global upper - global cumulative_upper + global upper, cumulative_upper upper = {} cumulative_upper = {} subtotal = 0 @@ -13337,8 +13280,7 @@ def main(args=None): subtotal += upper[item] cumulative_upper[item] = subtotal - global lower - global cumulative_lower + global lower, cumulative_lower lower = {} cumulative_lower = {} subtotal = 0 diff --git a/process/io/plot_radial_build.py b/process/io/plot_radial_build.py index 8a63b1e1e4..293e17eed3 100644 --- a/process/io/plot_radial_build.py +++ b/process/io/plot_radial_build.py @@ -72,8 +72,6 @@ def get_radial_build(m_file): isweep = int(m_file.data["isweep"].get_scan(-1)) if isweep == 0: isweep = 1 - else: - pass radial_labels = [ "dr_bore", @@ -325,8 +323,6 @@ def main(args=None): axis_font_size = 16 if scan_var_name != "Null": ind = [y for y, _ in enumerate(scan_points)] - else: - pass end_scan = radial_labels.index("Plasma") if args.inboard else len(radial_build) plt.figure(figsize=(8, 6)) for kk in range(len(radial_build[:end_scan, 0])): diff --git a/process/io/plot_scans.py b/process/io/plot_scans.py index cab9099f24..75c3f78a44 100644 --- a/process/io/plot_scans.py +++ b/process/io/plot_scans.py @@ -718,9 +718,7 @@ def main(args=None): axs[output_names.index(output_name)].set_ylim( y_range[0], y_range[1] ) - axs[ - output_names.index(output_name) - ].yaxis.set_major_locator( + axs[output_names.index(output_name)].yaxis.set_major_locator( mtick.MultipleLocator(y_divisions) ) if x_axis_range != []: @@ -744,9 +742,7 @@ def main(args=None): if x_axis_percentage is False: x_range = x_axis_range plt.xlim(x_range[0], x_range[1]) - axs[ - output_names.index(output_name) - ].xaxis.set_major_locator( + axs[output_names.index(output_name)].xaxis.set_major_locator( mtick.MultipleLocator(x_divisions) ) plt.rc("xtick", labelsize=axis_tick_size) @@ -911,17 +907,11 @@ def main(args=None): plt.tight_layout() ymin, ymax = axs[output_names.index(output_name)].get_ylim() if ymin < 0 and ymax > 0: - axs[output_names.index(output_name)].set_ylim( - ymin * 1.1, ymax * 1.1 - ) + axs[output_names.index(output_name)].set_ylim(ymin * 1.1, ymax * 1.1) elif ymin >= 0: - axs[output_names.index(output_name)].set_ylim( - ymin * 0.9, ymax * 1.1 - ) + axs[output_names.index(output_name)].set_ylim(ymin * 0.9, ymax * 1.1) else: - axs[output_names.index(output_name)].set_ylim( - ymin * 1.1, ymax * 0.9 - ) + axs[output_names.index(output_name)].set_ylim(ymin * 1.1, ymax * 0.9) else: plt.grid(True) plt.ylabel( @@ -1018,8 +1008,7 @@ def main(args=None): if two_dimensional_contour: output_contour_z = np.zeros((n_scan_1, n_scan_2)) x_contour = [ - m_file.data[scan_2_var_name].get_scan(i + 1) - for i in range(n_scan_2) + m_file.data[scan_2_var_name].get_scan(i + 1) for i in range(n_scan_2) ] y_contour = [ m_file.data[scan_var_name].get_scan(i + 1) @@ -1080,9 +1069,7 @@ def main(args=None): y_max[index] = max(np.abs(y_contour)) yticks = mtick.PercentFormatter(y_max[index]) if y_axis_range != []: - y_divisions = ( - 5 * math.ceil(y_divisions / 5) * y_max[index] / 100 - ) + y_divisions = 5 * math.ceil(y_divisions / 5) * y_max[index] / 100 y_range = ( y_axis_range[0] * y_max[index] / 100, y_axis_range[1] * y_max[index] / 100, @@ -1100,9 +1087,7 @@ def main(args=None): x_max[index] = max(np.abs(x_contour)) xticks = mtick.PercentFormatter(x_max[index]) if x_axis_range != []: - x_divisions = ( - 5 * math.ceil(x_divisions / 5) * x_max[index] / 100 - ) + x_divisions = 5 * math.ceil(x_divisions / 5) * x_max[index] / 100 x_range = ( x_axis_range[0] * x_max[index] / 100, x_axis_range[1] * x_max[index] / 100, @@ -1176,9 +1161,7 @@ def main(args=None): y_max[index] = max(np.abs(y_data)) yticks = mtick.PercentFormatter(y_max[index]) if y_axis_range != []: - y_divisions = ( - 5 * math.ceil(y_divisions / 5) * y_max[index] / 100 - ) + y_divisions = 5 * math.ceil(y_divisions / 5) * y_max[index] / 100 y_range = ( y_axis_range[0] * y_max[index] / 100, y_axis_range[1] * y_max[index] / 100, @@ -1190,8 +1173,7 @@ def main(args=None): ax.set_ylim(y_range[0], y_range[1]) ax.yaxis.set_major_locator(mtick.MultipleLocator(y_divisions)) x_data = [ - m_file.data[scan_2_var_name].get_scan(i + 1) - for i in range(n_scan_2) + m_file.data[scan_2_var_name].get_scan(i + 1) for i in range(n_scan_2) ] if x_axis_range != []: x_divisions = (x_axis_range[1] - x_axis_range[0]) / 10 @@ -1200,9 +1182,7 @@ def main(args=None): x_max[index] = max(np.abs(x_data)) xticks = mtick.PercentFormatter(x_max[index]) if x_axis_range != []: - x_divisions = ( - 5 * math.ceil(x_divisions / 5) * x_max[index] / 100 - ) + x_divisions = 5 * math.ceil(x_divisions / 5) * x_max[index] / 100 x_range = ( x_axis_range[0] * x_max[index] / 100, x_axis_range[1] * x_max[index] / 100, diff --git a/process/io/plot_solutions.py b/process/io/plot_solutions.py index ead89cb876..3b9c1f7bca 100644 --- a/process/io/plot_solutions.py +++ b/process/io/plot_solutions.py @@ -215,9 +215,7 @@ def _create_df_from_run_metadata(runs_metadata: Sequence[RunMetadata]) -> pd.Dat if Path(run_metadata.mfile_path).exists(): mfile_data = _extract_mfile_data(run_metadata.mfile_path) else: - raise FileNotFoundError( - f"The MFILE {run_metadata.mfile_path} doesn't exist" - ) + raise FileNotFoundError(f"The MFILE {run_metadata.mfile_path} doesn't exist") # Merge each run's metadata and results into one dict results.append({**asdict(run_metadata), **mfile_data}) @@ -416,9 +414,7 @@ def _plot_solutions( objf_name = str(objf_list[0]) # Now separate optimisation parameter values from their names - opt_params_values_df = opt_params_df.filter( - regex=f"{opt_param_value_pattern}|{TAG}" - ) + opt_params_values_df = opt_params_df.filter(regex=f"{opt_param_value_pattern}|{TAG}") opt_params_names_df = opt_params_df.filter(regex=NORM_OPT_PARAM_NAME_REGEX) # Replace xcm--- optimisation parameter column headers with actual var names diff --git a/process/io/plot_stress_tf.py b/process/io/plot_stress_tf.py index 1e5d4e056d..bedef5d0ae 100644 --- a/process/io/plot_stress_tf.py +++ b/process/io/plot_stress_tf.py @@ -265,14 +265,10 @@ def main(args=None): sig_file_data["Von-Mises stress (MPa)"][(ii + 1) * n_radial_array_layer - 1] ) bound_tresca_stress.append( - sig_file_data["CEA Tresca stress (MPa)"][ - (ii + 1) * n_radial_array_layer - 1 - ] + sig_file_data["CEA Tresca stress (MPa)"][(ii + 1) * n_radial_array_layer - 1] ) bound_cea_tresca_stress.append( - sig_file_data["CEA Tresca stress (MPa)"][ - (ii + 1) * n_radial_array_layer - 1 - ] + sig_file_data["CEA Tresca stress (MPa)"][(ii + 1) * n_radial_array_layer - 1] ) bound_radial_displacement.append( sig_file_data["rad. displacement (mm)"][(ii + 1) * n_radial_array_layer - 1] @@ -282,17 +278,15 @@ def main(args=None): for ii in range(n_layers): tresca_smeared_stress.append([]) - bound_tresca_smeared_stress.append( + bound_tresca_smeared_stress.extend([ max(abs(radial_smeared_stress[ii][0]), abs(toroidal_smeared_stress[ii][0])) - + vertical_smeared_stress[ii][0] - ) - bound_tresca_smeared_stress.append( + + vertical_smeared_stress[ii][0], max( abs(radial_smeared_stress[ii][n_radial_array_layer - 1]), abs(toroidal_smeared_stress[ii][n_radial_array_layer - 1]), ) - + vertical_smeared_stress[ii][n_radial_array_layer - 1] - ) + + vertical_smeared_stress[ii][n_radial_array_layer - 1], + ]) for jj in range(n_radial_array_layer): tresca_smeared_stress[ii].append( max( @@ -309,24 +303,18 @@ def main(args=None): toroidal_strain.append([]) vertical_strain.append([]) - bound_radial_strain.append( - sig_file_data["Radial strain"][ii * n_radial_array_layer] - ) - bound_toroidal_strain.append( - sig_file_data["Toroidal strain"][ii * n_radial_array_layer] - ) - bound_vertical_strain.append( - sig_file_data["Vertical strain"][ii * n_radial_array_layer] - ) - bound_radial_strain.append( - sig_file_data["Radial strain"][(ii + 1) * n_radial_array_layer - 1] - ) - bound_toroidal_strain.append( - sig_file_data["Toroidal strain"][(ii + 1) * n_radial_array_layer - 1] - ) - bound_vertical_strain.append( - sig_file_data["Vertical strain"][(ii + 1) * n_radial_array_layer - 1] - ) + bound_radial_strain.extend([ + sig_file_data["Radial strain"][ii * n_radial_array_layer], + sig_file_data["Radial strain"][(ii + 1) * n_radial_array_layer - 1], + ]) + bound_toroidal_strain.extend([ + sig_file_data["Toroidal strain"][ii * n_radial_array_layer], + sig_file_data["Toroidal strain"][(ii + 1) * n_radial_array_layer - 1], + ]) + bound_vertical_strain.extend([ + sig_file_data["Vertical strain"][ii * n_radial_array_layer], + sig_file_data["Vertical strain"][(ii + 1) * n_radial_array_layer - 1], + ]) for jj in range(n_radial_array_layer): radial_strain[ii].append( sig_file_data["Radial strain"][ii * n_radial_array_layer + jj] diff --git a/process/io/process_config.py b/process/io/process_config.py index 467cecb458..daa0b5cfa2 100644 --- a/process/io/process_config.py +++ b/process/io/process_config.py @@ -111,8 +111,7 @@ def create_readme(self, directory="."): """creates README.txt containing comment""" if self.comment != "": - with open(directory + "/README.txt", "w") as readme: - readme.write(self.comment) + Path(directory + "/README.txt").write_text(self.comment) def error_status2readme(self, directory="."): """appends PROCESS outcome to README.txt""" @@ -129,8 +128,7 @@ def error_status2readme(self, directory="."): with open(directory + "/README.txt", "a") as readme: readme.write(error_status) else: - with open(directory + "/README.txt", "w") as readme: - readme.write(error_status) + Path(directory + "/README.txt").write_text(error_status) def modify_in_dat(self): """modifies the original IN.DAT file""" diff --git a/process/io/sankey_funcs.py b/process/io/sankey_funcs.py index c576f3a66f..db8d16505c 100644 --- a/process/io/sankey_funcs.py +++ b/process/io/sankey_funcs.py @@ -537,9 +537,7 @@ def plot_sankey(mfilename="MFILE.DAT"): # Plot simplified power flow Sankey Dia fdiv_2 = m_file.data["2*f_ster_div_single"].get_scan( -1 ) # Area fraction taken up by double null divertor - if ( - fdiv_2 > 0 - ): # Takes into account old MFILE representation of double null divertor + if fdiv_2 > 0: # Takes into account old MFILE representation of double null divertor f_ster_div_single = fdiv_2 p_div_rad_total_mw = ( p_plasma_rad_mw * f_ster_div_single @@ -581,9 +579,7 @@ def plot_sankey(mfilename="MFILE.DAT"): # Plot simplified power flow Sankey Dia p_fw_alpha_mw = p_alpha_total_mw * ( 1 - f_p_alpha_plasma_deposited ) # Alpha power hitting 1st wall (MW) - itart = m_file.data["itart"].get_scan( - -1 - ) # switch for spherical tokamak (ST) models + itart = m_file.data["itart"].get_scan(-1) # switch for spherical tokamak (ST) models # Power deposited on divertor (MW) totaldivetc = ( @@ -928,9 +924,6 @@ def plot_sankey(mfilename="MFILE.DAT"): # Plot simplified power flow Sankey Dia pos[0] + 0.15, pos[1] - 0.5 - * ( - (p_hcd_electric_total_mw - p_hcd_injected_total_mw) - / totalplasma - ) + * ((p_hcd_electric_total_mw - p_hcd_injected_total_mw) / totalplasma) - 0.2, )) diff --git a/process/io/variable_metadata.py b/process/io/variable_metadata.py index 58bcb3a061..3e9dfd5d20 100644 --- a/process/io/variable_metadata.py +++ b/process/io/variable_metadata.py @@ -149,9 +149,7 @@ class VariableMetadata: description="Maximum divertor heat load", units="MW.m^{-2}", ), - "hfact": VariableMetadata( - latex=r"$f_\mathrm{H}$", description="H-factor", units="" - ), + "hfact": VariableMetadata(latex=r"$f_\mathrm{H}$", description="H-factor", units=""), "kappa": VariableMetadata( latex=r"$\kappa_\mathrm{sep}$", description="Elongation", units="" ), diff --git a/process/io/write_new_in_dat.py b/process/io/write_new_in_dat.py index ff7c814321..abf1cd0a54 100644 --- a/process/io/write_new_in_dat.py +++ b/process/io/write_new_in_dat.py @@ -99,9 +99,7 @@ def replace_iteration_variables(iteration_vars, in_data): if (match := re.search(r"([a-zA-Z0-9_]+)\(([0-9]+)\)", variable_name)) is None: in_data.add_parameter(variable_name.lower(), variable_value) else: - in_data.change_array( - match.group(1), int(match.group(2)) - 1, variable_value - ) + in_data.change_array(match.group(1), int(match.group(2)) - 1, variable_value) return in_data diff --git a/process/iteration_variables.py b/process/iteration_variables.py index 3214f3ffec..c725fbe667 100644 --- a/process/iteration_variables.py +++ b/process/iteration_variables.py @@ -138,9 +138,7 @@ class IterationVariable: 56: IterationVariable( "t_tf_superconductor_quench", data_structure.tfcoil_variables, 0.1, 100.0 ), - 57: IterationVariable( - "dr_tf_nose_case", data_structure.tfcoil_variables, 0.05, 1.0 - ), + 57: IterationVariable("dr_tf_nose_case", data_structure.tfcoil_variables, 0.05, 1.0), 58: IterationVariable( "dx_tf_turn_steel", data_structure.tfcoil_variables, 0.001, 0.1 ), @@ -213,9 +211,7 @@ class IterationVariable: "fl_h_threshold", data_structure.constraint_variables, 0.001, 1.0 ), 104: IterationVariable("fcwr", data_structure.constraint_variables, 0.001, 1.0), - 105: IterationVariable( - "fnbshinef", data_structure.constraint_variables, 0.001, 1.0 - ), + 105: IterationVariable("fnbshinef", data_structure.constraint_variables, 0.001, 1.0), 106: IterationVariable("ftmargoh", data_structure.constraint_variables, 0.001, 1.0), 107: IterationVariable("favail", data_structure.cost_variables, 0.001, 1.0), 108: IterationVariable("breeder_f", data_structure.fwbs_variables, 0.060, 1.0), @@ -228,9 +224,7 @@ class IterationVariable: 111: IterationVariable( "fniterpump", data_structure.constraint_variables, 0.001, 1.0 ), - 112: IterationVariable( - "fzeff_max", data_structure.constraint_variables, 0.001, 1.0 - ), + 112: IterationVariable("fzeff_max", data_structure.constraint_variables, 0.001, 1.0), 113: IterationVariable( "fmaxvvstress", data_structure.constraint_variables, 0.001, 1.0 ), @@ -243,9 +237,7 @@ class IterationVariable: 116: IterationVariable( "fpflux_fw_rad_max", data_structure.constraint_variables, 0.001, 1.0 ), - 117: IterationVariable( - "fpsepbqar", data_structure.constraint_variables, 0.001, 1.0 - ), + 117: IterationVariable("fpsepbqar", data_structure.constraint_variables, 0.001, 1.0), 119: IterationVariable( "temp_plasma_separatrix_kev", data_structure.physics_variables, 0.0, 1.0e1 ), @@ -397,13 +389,9 @@ class IterationVariable: 158: IterationVariable( "dx_croco_strand_copper", data_structure.rebco_variables, 1.0e-3, 1.0e-1 ), - 159: IterationVariable( - "ftoroidalgap", data_structure.tfcoil_variables, 1.0e-4, 1.0 - ), + 159: IterationVariable("ftoroidalgap", data_structure.tfcoil_variables, 1.0e-4, 1.0), 160: IterationVariable("f_avspace", data_structure.build_variables, 0.010, 1.0), - 161: IterationVariable( - "fbeta_min", data_structure.constraint_variables, 0.010, 1.0 - ), + 161: IterationVariable("fbeta_min", data_structure.constraint_variables, 0.010, 1.0), 162: IterationVariable("r_cp_top", data_structure.build_variables, 0.0010, 10.0), 163: IterationVariable( "f_t_turn_tf", data_structure.tfcoil_variables, 0.0010, 1000.0 @@ -412,9 +400,7 @@ class IterationVariable: "f_crypmw", data_structure.heat_transport_variables, 0.001, 1.0 ), 165: IterationVariable("fstr_wp", data_structure.constraint_variables, 1.0e-9, 1.0), - 166: IterationVariable( - "f_copperaoh_m2", data_structure.rebco_variables, 0.001, 1.0 - ), + 166: IterationVariable("f_copperaoh_m2", data_structure.rebco_variables, 0.001, 1.0), 167: IterationVariable("fncycle", data_structure.constraint_variables, 1.0e-8, 1.0), 168: IterationVariable( "fecrh_ignition", data_structure.constraint_variables, 0.010, 2.0 diff --git a/process/main.py b/process/main.py index 2b0c1028bd..e16b7f2109 100644 --- a/process/main.py +++ b/process/main.py @@ -307,14 +307,14 @@ def run(self): init.init_all_module_vars() init.init_process() - neqns, itervars = get_neqns_itervars() + _neqns, itervars = get_neqns_itervars() lbs, ubs = get_variable_range(itervars, config.factor) # If config file contains WDIR, use that. Otherwise, use the directory # containing the config file (used when running regression tests in # temp dirs) # TODO Not sure this is required any more - wdir = config.wdir if config.wdir else Path(self.config_file).parent + wdir = config.wdir or Path(self.config_file).parent # Check IN.DAT exists if not input_path.exists(): diff --git a/process/pfcoil.py b/process/pfcoil.py index 6c9f138ecf..8e6cb723b0 100644 --- a/process/pfcoil.py +++ b/process/pfcoil.py @@ -545,7 +545,7 @@ def pfcoil(self): pv.b_plasma_vertical_required = bzin[0] - ssqef, pfcoil_variables.ccls0 = self.efc( + _ssqef, pfcoil_variables.ccls0 = self.efc( npts0, rpts, zpts, @@ -822,7 +822,7 @@ def pfcoil(self): if ij == 0: # Index args +1ed - bri, bro, bzi, bzo = peak_b_field_at_pf_coil( + _bri, _bro, _bzi, _bzo = peak_b_field_at_pf_coil( n_coil=i + 1, n_coil_group=iii + 1, t_b_field_peak=it ) # returns b_pf_coil_peak, bpf2 @@ -834,7 +834,7 @@ def pfcoil(self): abs(pfcoil_variables.bpf2[i]), ) - pfcoil_variables.j_pf_wp_critical[i], jstrand, jsc, tmarg = ( + pfcoil_variables.j_pf_wp_critical[i], _jstrand, jsc, _tmarg = ( superconpf( bmax, pfcoil_variables.f_a_pf_coil_void[i], @@ -1262,9 +1262,7 @@ def place_pf_outside_tf( ) # Coil radius is constant / stacked for picture frame TF or if placement switch is set if i_tf_shape == 2 or i_r_pf_outside_tf_placement == 1: - r_pf_coil_middle_group_array[n_pf_group, coil] = ( - r_pf_outside_tf_midplane - ) + r_pf_coil_middle_group_array[n_pf_group, coil] = r_pf_outside_tf_midplane else: # Coil radius follows TF coil curve for TF (D-shape) r_pf_coil_middle_group_array[n_pf_group, coil] = math.sqrt( @@ -1452,7 +1450,7 @@ def efc( ) # Calculate the norm of the residual vectors - brssq, brnrm, bzssq, bznrm, ssq = rsid( + _brssq, _brnrm, _bzssq, _bznrm, ssq = rsid( npts, brin, bzin, nfix, int(n_pf_coil_groups), ccls, bfix, gmat ) @@ -1683,9 +1681,9 @@ def induct(self, output): nohmax = 200 nplas = 1 - br = 0.0 - bz = 0.0 - psi = 0.0 + _br = 0.0 + _bz = 0.0 + _psi = 0.0 rc = np.zeros(pfcoil_variables.NGC2 + nohmax) zc = np.zeros(pfcoil_variables.NGC2 + nohmax) xc = np.zeros(pfcoil_variables.NGC2 + nohmax) @@ -1703,16 +1701,12 @@ def induct(self, output): # than each segment is tall, i.e. the segments are pancake-like, # for the benefit of the mutual inductance calculations later - noh = int( - math.ceil( - 2.0e0 - * pfcoil_variables.z_pf_coil_upper[pfcoil_variables.n_cs_pf_coils - 1] - / ( - pfcoil_variables.r_pf_coil_outer[pfcoil_variables.n_cs_pf_coils - 1] - - pfcoil_variables.r_pf_coil_inner[ - pfcoil_variables.n_cs_pf_coils - 1 - ] - ) + noh = math.ceil( + 2.0e0 + * pfcoil_variables.z_pf_coil_upper[pfcoil_variables.n_cs_pf_coils - 1] + / ( + pfcoil_variables.r_pf_coil_outer[pfcoil_variables.n_cs_pf_coils - 1] + - pfcoil_variables.r_pf_coil_inner[pfcoil_variables.n_cs_pf_coils - 1] ) ) @@ -1777,14 +1771,14 @@ def induct(self, output): reqv = rp * (1.0e0 + delzoh**2 / (24.0e0 * rp**2)) - xcin, br, bz, psi = calculate_b_field_at_point( + xcin, _br, _bz, _psi = calculate_b_field_at_point( r_current_loop=rc, z_current_loop=zc, c_current_loop=cc, r_test_point=reqv - deltar, z_test_point=zp, ) - xcout, br, bz, psi = calculate_b_field_at_point( + xcout, _br, _bz, _psi = calculate_b_field_at_point( r_current_loop=rc, z_current_loop=zc, c_current_loop=cc, @@ -1826,7 +1820,7 @@ def induct(self, output): ncoils = ncoils + pfcoil_variables.n_pf_coils_in_group[i] rp = pfcoil_variables.r_pf_coil_middle[ncoils - 1] zp = pfcoil_variables.z_pf_coil_middle[ncoils - 1] - xc, br, bz, psi = calculate_b_field_at_point( + xc, _br, _bz, _psi = calculate_b_field_at_point( r_current_loop=rc, z_current_loop=zc, c_current_loop=cc, @@ -1878,7 +1872,7 @@ def induct(self, output): ncoils = ncoils + pfcoil_variables.n_pf_coils_in_group[i] rp = pfcoil_variables.r_pf_coil_middle[ncoils - 1] zp = pfcoil_variables.z_pf_coil_middle[ncoils - 1] - xc, br, bz, psi = calculate_b_field_at_point( + xc, _br, _bz, _psi = calculate_b_field_at_point( r_current_loop=rc, z_current_loop=zc, c_current_loop=cc, @@ -1921,7 +1915,7 @@ def induct(self, output): rp = pfcoil_variables.r_pf_coil_middle[i] zp = pfcoil_variables.z_pf_coil_middle[i] - xc, br, bz, psi = calculate_b_field_at_point( + xc, _br, _bz, _psi = calculate_b_field_at_point( r_current_loop=rc, z_current_loop=zc, c_current_loop=cc, @@ -2365,8 +2359,7 @@ def outpf(self): abs(pfcoil_variables.j_cs_flat_top_end) > 0.99e0 * abs( - numerics.boundu[37] - * pfcoil_variables.j_cs_critical_flat_top_end + numerics.boundu[37] * pfcoil_variables.j_cs_critical_flat_top_end ) ) or ( abs(pfcoil_variables.j_cs_pulse_start) @@ -3285,7 +3278,7 @@ def ohcalc(self): # Peak field due to other PF coils plus plasma timepoint = 5 - bri, bro, bzi, bzo = peak_b_field_at_pf_coil( + _bri, _bro, bzi, bzo = peak_b_field_at_pf_coil( n_coil=pfcoil_variables.n_cs_pf_coils, n_coil_group=99, t_b_field_peak=timepoint, @@ -3314,7 +3307,7 @@ def ohcalc(self): ) ) timepoint = 2 - bri, bro, bzi, bzo = peak_b_field_at_pf_coil( + _bri, _bro, bzi, bzo = peak_b_field_at_pf_coil( n_coil=pfcoil_variables.n_cs_pf_coils, n_coil_group=99, t_b_field_peak=timepoint, @@ -3377,9 +3370,7 @@ def ohcalc(self): # equation is used for Central Solenoid stress # Area of steel in Central Solenoid - areaspf = ( - pfcoil_variables.f_a_cs_turn_steel * pfcoil_variables.a_cs_poloidal - ) + areaspf = pfcoil_variables.f_a_cs_turn_steel * pfcoil_variables.a_cs_poloidal if pfcoil_variables.i_cs_stress == 1: pfcoil_variables.s_shear_cs_peak = max( @@ -3907,8 +3898,7 @@ def peak_b_field_at_pf_coil( else: sgn = ( 1.0 - if pfcoil_variables.j_cs_pulse_start - > pfcoil_variables.j_cs_flat_top_end + if pfcoil_variables.j_cs_pulse_start > pfcoil_variables.j_cs_flat_top_end else -1.0 ) @@ -4025,7 +4015,7 @@ def peak_b_field_at_pf_coil( # Calculate the field at the inner and outer edges # of the coil of interest - pfcoil_variables.xind[:kk], b_pf_inner_radial, b_pf_inner_vertical, psi = ( + pfcoil_variables.xind[:kk], b_pf_inner_radial, b_pf_inner_vertical, _psi = ( calculate_b_field_at_point( r_current_loop=pfcoil_variables.r_pf_cs_current_filaments[:kk], z_current_loop=pfcoil_variables.z_pf_cs_current_filaments[:kk], @@ -4034,7 +4024,7 @@ def peak_b_field_at_pf_coil( z_test_point=pfcoil_variables.z_pf_coil_middle[n_coil - 1], ) ) - pfcoil_variables.xind[:kk], b_pf_outer_radial, b_pf_outer_vertical, psi = ( + pfcoil_variables.xind[:kk], b_pf_outer_radial, b_pf_outer_vertical, _psi = ( calculate_b_field_at_point( r_current_loop=pfcoil_variables.r_pf_cs_current_filaments[:kk], z_current_loop=pfcoil_variables.z_pf_cs_current_filaments[:kk], @@ -4248,7 +4238,7 @@ def superconpf(bmax, fhe, fcu, jwp, isumat, fhts, strain, thelium, bcritsc, tcri arguments = (isumat, jsc, bmax, strain, bc20m, tc0m) another_estimate = 2 * thelium - t_zero_margin, root_result = optimize.newton( + t_zero_margin, _root_result = optimize.newton( superconductors.superconductor_current_density_margin, thelium, fprime=None, @@ -4378,10 +4368,7 @@ def calculate_b_field_at_point( * c_current_loop[i] * dz / (2 * np.pi * r_test_point * sd) - * ( - -xk - + (r_current_loop[i] ** 2 + r_test_point**2 + zs) / (dr**2 + zs) * xe - ) + * (-xk + (r_current_loop[i] ** 2 + r_test_point**2 + zs) / (dr**2 + zs) * xe) ) bzx = ( constants.RMU0 diff --git a/process/physics.py b/process/physics.py index 3227317fa1..727859b55b 100644 --- a/process/physics.py +++ b/process/physics.py @@ -819,9 +819,7 @@ def _coulomb_logarithm_sauter( pp. 1-32, Jan. 1976, doi: https://doi.org/10.1103/revmodphys.48.1. """ return ( - 15.9 - - 0.5 * np.log(ne[radial_elements - 1]) - + np.log(tempe[radial_elements - 1]) + 15.9 - 0.5 * np.log(ne[radial_elements - 1]) + np.log(tempe[radial_elements - 1]) ) @@ -2680,12 +2678,10 @@ def physics(self): ) # E. Tholerus scaling law - physics_variables.beta_norm_max_thloreus = ( - self.calculate_beta_norm_max_thloreus( - c_beta=physics_variables.c_beta, - pres_plasma_on_axis=physics_variables.pres_plasma_thermal_on_axis, - pres_plasma_vol_avg=physics_variables.pres_plasma_thermal_vol_avg, - ) + physics_variables.beta_norm_max_thloreus = self.calculate_beta_norm_max_thloreus( + c_beta=physics_variables.c_beta, + pres_plasma_on_axis=physics_variables.pres_plasma_thermal_on_axis, + pres_plasma_vol_avg=physics_variables.pres_plasma_thermal_vol_avg, ) # R. D. Stambaugh scaling law @@ -2868,8 +2864,7 @@ def physics(self): * physics_variables.rad_fraction_sol ) physics_variables.pradsolmw = ( - physics_variables.rad_fraction_sol - * physics_variables.p_plasma_separatrix_mw + physics_variables.rad_fraction_sol * physics_variables.p_plasma_separatrix_mw ) if 78 in numerics.icc: @@ -4163,9 +4158,7 @@ def outplas(self): po.osubhd(self.outfile, "Classic PROCESS plasma shape model is used :") elif physics_variables.i_plasma_shape == 1: po.osubhd(self.outfile, "Sauter plasma shape model is used :") - po.ovarrf( - self.outfile, "Major radius (m)", "(rmajor)", physics_variables.rmajor - ) + po.ovarrf(self.outfile, "Major radius (m)", "(rmajor)", physics_variables.rmajor) po.ovarrf( self.outfile, "Minor radius (m)", @@ -5880,9 +5873,7 @@ def outplas(self): po.ocmmnt( self.outfile, " BEWARE: possible problem with high radiation power" ) - po.ocmmnt( - self.outfile, " Power into divertor zone is unrealistic;" - ) + po.ocmmnt(self.outfile, " Power into divertor zone is unrealistic;") po.ocmmnt(self.outfile, " divertor calculations will be nonsense#") po.ocmmnt( self.outfile, " Set constraint 17 (Radiation fraction upper limit)." @@ -6538,9 +6529,7 @@ def outplas(self): current_drive_variables.f_c_plasma_bootstrap_sauter, "OP ", ) - for point in range( - len(physics_variables.j_plasma_bootstrap_sauter_profile) - ): + for point in range(len(physics_variables.j_plasma_bootstrap_sauter_profile)): po.ovarrf( self.mfile, f"Sauter et al bootstrap current density profile at point {point}", diff --git a/process/plasma_geometry.py b/process/plasma_geometry.py index 7fa8a02a24..18b0d064e5 100644 --- a/process/plasma_geometry.py +++ b/process/plasma_geometry.py @@ -123,9 +123,7 @@ def plasma_geometry(self) -> None: ): # Use input kappa95, physics_variables.triang95 values # Fit to MAST data (Issue #1086) physics_variables.kappa = 0.91300e0 * physics_variables.kappa95 + 0.38654e0 - physics_variables.triang = ( - 0.77394e0 * physics_variables.triang95 + 0.18515e0 - ) + physics_variables.triang = 0.77394e0 * physics_variables.triang95 + 0.18515e0 # ====================================================================== @@ -133,9 +131,7 @@ def plasma_geometry(self) -> None: physics_variables.i_plasma_geometry == 6 ): # Use input kappa, physics_variables.triang values # Fit to MAST data (Issue #1086) - physics_variables.kappa95 = ( - physics_variables.kappa - 0.38654e0 - ) / 0.91300e0 + physics_variables.kappa95 = (physics_variables.kappa - 0.38654e0) / 0.91300e0 physics_variables.triang95 = ( physics_variables.triang - 0.18515e0 ) / 0.77394e0 @@ -147,9 +143,7 @@ def plasma_geometry(self) -> None: ): # Use input kappa95, physics_variables.triang95 values # Fit to FIESTA (Issue #1086) physics_variables.kappa = 0.90698e0 * physics_variables.kappa95 + 0.39467e0 - physics_variables.triang = ( - 1.3799e0 * physics_variables.triang95 + 0.048306e0 - ) + physics_variables.triang = 1.3799e0 * physics_variables.triang95 + 0.048306e0 # ====================================================================== @@ -157,9 +151,7 @@ def plasma_geometry(self) -> None: physics_variables.i_plasma_geometry == 8 ): # Use input kappa, physics_variables.triang values # Fit to FIESTA (Issue #1086) - physics_variables.kappa95 = ( - physics_variables.kappa - 0.39467e0 - ) / 0.90698e0 + physics_variables.kappa95 = (physics_variables.kappa - 0.39467e0) / 0.90698e0 physics_variables.triang95 = ( physics_variables.triang - 0.048306e0 ) / 1.3799e0 diff --git a/process/power.py b/process/power.py index 936d1de535..910e23211f 100644 --- a/process/power.py +++ b/process/power.py @@ -249,8 +249,7 @@ def pfpwr(self, output: bool): # Mean power dissipated # The flat top duration (time 4 to 5) is the denominator, as this is the time when electricity is generated. if ( - times_variables.t_pulse_cumulative[4] - - times_variables.t_pulse_cumulative[3] + times_variables.t_pulse_cumulative[4] - times_variables.t_pulse_cumulative[3] > 1.0e0 ): pfpower = sum(pfdissipation[:]) / ( @@ -462,9 +461,7 @@ def acpow(self, output: bool): # po.oheadr(self.outfile,'AC Power') po.oheadr(self.outfile, "Electric Power Requirements") po.ovarre(self.outfile, "Divertor coil power supplies (MW)", "(bdvmw)", bdvmw) - po.ovarre( - self.outfile, "Cryoplant electric power (MW)", "(crymw)", crymw, "OP " - ) + po.ovarre(self.outfile, "Cryoplant electric power (MW)", "(crymw)", crymw, "OP ") # po.ovarre(self.outfile,'Heat removed from cryogenic coils (MWth)','(helpow/1.0e6)',helpow/1.0e6) # po.ovarre(self.outfile,'MGF (motor-generator flywheel) units (MW)', '(fmgdmw)',fmgdmw) # po.ovarin(self.outfile,'Primary coolant pumps (MW)', '(i_blkt_coolant_type)',i_blkt_coolant_type) @@ -2402,9 +2399,7 @@ def power_profiles_over_time( # Integrate net electric power over the pulse to get total energy produced (MJ) # Assume t_steps in seconds, power in MW, so energy in MJ - energy_made_mj = sp.integrate.trapezoid( - p_plant_electric_net_profile_mw, t_steps - ) + energy_made_mj = sp.integrate.trapezoid(p_plant_electric_net_profile_mw, t_steps) energy_made_kwh = energy_made_mj / 3.6 return ( diff --git a/process/profiles.py b/process/profiles.py index 118a9b987b..a2cf61dac8 100644 --- a/process/profiles.py +++ b/process/profiles.py @@ -158,8 +158,7 @@ def calculate_profile_y( self.profile_y[rho_index] = ( nped + (n0 - nped) - * (1 - (rho[rho_index] / radius_plasma_pedestal_density_norm) ** 2) - ** alphan + * (1 - (rho[rho_index] / radius_plasma_pedestal_density_norm) ** 2) ** alphan ) # Invert the rho_index self.profile_y[~rho_index] = nsep + (nped - nsep) * (1 - rho[~rho_index]) / ( diff --git a/process/quench.py b/process/quench.py index b830c3285c..b4f51ad1d6 100644 --- a/process/quench.py +++ b/process/quench.py @@ -340,9 +340,7 @@ def calculate_quench_protection_current_density( f_cond = 1.0 - f_he # Fraction of the cable XS area that is not helium f_cu_cable = f_cond * f_cu # Fraction of the cable XS that is copper - f_sc_cable = f_cond * ( - 1.0 - f_cu - ) # Fraction of the cable XS that is superconductor + f_sc_cable = f_cond * (1.0 - f_cu) # Fraction of the cable XS that is superconductor factor = 1.0 / (0.5 * tau_discharge + detection_time) total_integral = f_he * i_he + f_cu_cable * i_cu + f_sc_cable * i_sc diff --git a/process/resistive_tf_coil.py b/process/resistive_tf_coil.py index cf51f19949..c17674cd06 100644 --- a/process/resistive_tf_coil.py +++ b/process/resistive_tf_coil.py @@ -211,9 +211,7 @@ def run(self, output: bool): ) tfcoil_variables.casestr = ( - tfcoil_variables.casestr - if tfcoil_variables.casestr is None - else casestr + tfcoil_variables.casestr if tfcoil_variables.casestr is None else casestr ) tfcoil_variables.insstrain = ( @@ -374,8 +372,7 @@ def res_tf_internal_geom(self): + tfcoil_variables.dx_tf_turn_insulation * tfcoil_variables.n_tf_coil_turns ) tfcoil_variables.a_res_tf_coil_conductor = ( - tfcoil_variables.a_res_tf_coil_conductor - * (1.0e0 - tfcoil_variables.fcoolcp) + tfcoil_variables.a_res_tf_coil_conductor * (1.0e0 - tfcoil_variables.fcoolcp) ) # Inter turn insulation area per coil [m2] @@ -489,9 +486,7 @@ def tf_res_heating(self) -> None: < np.finfo(float(tfcoil_variables.temp_tf_legs_outboard)).eps ): superconducting_tf_coil_variables.is_leg_cp_temp_same = 1 - tfcoil_variables.temp_tf_legs_outboard = ( - tfcoil_variables.temp_cp_average - ) + tfcoil_variables.temp_tf_legs_outboard = tfcoil_variables.temp_cp_average # Leg resistivity (different leg temperature as separate cooling channels) if tfcoil_variables.i_tf_sup == 0: @@ -499,8 +494,7 @@ def tf_res_heating(self) -> None: tfcoil_variables.frholeg * ( 1.86e0 - + 0.00393e0 - * (tfcoil_variables.temp_tf_legs_outboard - 293.15e0) + + 0.00393e0 * (tfcoil_variables.temp_tf_legs_outboard - 293.15e0) ) * 1.0e-8 ) @@ -686,8 +680,7 @@ def resistive_tf_coil_areas_and_masses(self): # Total TF conductor volume [m3] vol_cond = ( - tfcoil_variables.vol_cond_cp - + tfcoil_variables.n_tf_coils * vol_cond_leg + tfcoil_variables.vol_cond_cp + tfcoil_variables.n_tf_coils * vol_cond_leg ) # Outboard leg TF turn insulation layer volume (per leg) [m3] diff --git a/process/scan.py b/process/scan.py index 1729b68f90..7299ccb123 100644 --- a/process/scan.py +++ b/process/scan.py @@ -99,9 +99,7 @@ def __iter__(self): 57: ScanVariable("boundl(2)", "b_plasma_toroidal_on_axis minimum"), 58: ScanVariable("dr_fw_plasma_gap_inboard", "Inboard FW-plasma sep gap"), 59: ScanVariable("dr_fw_plasma_gap_outboard", "Outboard FW-plasma sep gap"), - 60: ScanVariable( - "sig_tf_wp_max", "Allowable_stress_in_tf_coil_conduit_Tresca_(pa)" - ), + 60: ScanVariable("sig_tf_wp_max", "Allowable_stress_in_tf_coil_conduit_Tresca_(pa)"), 61: ScanVariable("copperaoh_m2_max", "Max CS coil current / copper area"), 62: ScanVariable("coheof", "CS coil current density at EOF (A/m2)"), 63: ScanVariable("dr_cs", "CS coil thickness (m)"), @@ -553,9 +551,7 @@ def verror(self, ifail: int): """ if ifail == -1: process_output.ocmmnt(constants.NOUT, "User-terminated execution of VMCON.") - process_output.ocmmnt( - constants.IOTTY, "User-terminated execution of VMCON." - ) + process_output.ocmmnt(constants.IOTTY, "User-terminated execution of VMCON.") elif ifail == 0: process_output.ocmmnt( constants.NOUT, "Improper input parameters to the VMCON routine." diff --git a/process/solver.py b/process/solver.py index 2a4ddb88c5..32611b28b1 100644 --- a/process/solver.py +++ b/process/solver.py @@ -304,7 +304,7 @@ def solve(self) -> int: :rtype: int """ print("Solving equality constraints using fsolve") - self.x, info, err, msg = fsolve( + self.x, _info, err, msg = fsolve( self.evaluate_eq_cons, self.x_0, full_output=True ) diff --git a/process/stellarator.py b/process/stellarator.py index b2c58bc629..b673719253 100644 --- a/process/stellarator.py +++ b/process/stellarator.py @@ -198,9 +198,7 @@ def stnewconfig(self): # If physics_variables.aspect ratio is not in numerics.ixc set it to default value # Or when you call it the first time if 1 not in numerics.ixc: - physics_variables.aspect = ( - stellarator_configuration.stella_config_aspect_ref - ) + physics_variables.aspect = stellarator_configuration.stella_config_aspect_ref # Set the physics_variables.rminor radius as result here. physics_variables.rminor = physics_variables.rmajor / physics_variables.aspect @@ -213,17 +211,14 @@ def stnewconfig(self): # Factors used to scale the reference point. stellarator_variables.f_r = ( - physics_variables.rmajor - / stellarator_configuration.stella_config_rmajor_ref + physics_variables.rmajor / stellarator_configuration.stella_config_rmajor_ref ) # Size scaling factor with respect to the reference calculation stellarator_variables.f_a = ( - physics_variables.rminor - / stellarator_configuration.stella_config_rminor_ref + physics_variables.rminor / stellarator_configuration.stella_config_rminor_ref ) # Size scaling factor with respect to the reference calculation stellarator_variables.f_aspect = ( - physics_variables.aspect - / stellarator_configuration.stella_config_aspect_ref + physics_variables.aspect / stellarator_configuration.stella_config_aspect_ref ) stellarator_variables.f_n = tfcoil_variables.n_tf_coils / ( stellarator_configuration.stella_config_coilspermodule @@ -879,9 +874,7 @@ def stdiv(self, output: bool): # Length 'along' plasma (m) - l_p = ( - 2 * np.pi * r * (stellarator_variables.m_res) / stellarator_variables.n_res - ) + l_p = 2 * np.pi * r * (stellarator_variables.m_res) / stellarator_variables.n_res # Connection length from X-point to divertor plate (m) @@ -1012,9 +1005,7 @@ def stdiv(self, output: bool): po.ovarre(self.outfile, "Divertor plate length (m)", "(L_d)", l_d) po.ovarre(self.outfile, "Divertor plate width (m)", "(L_w)", l_w) po.ovarre(self.outfile, "Flux channel broadening factor", "(F_x)", f_x) - po.ovarre( - self.outfile, "Power decay width (cm)", "(100*l_q)", 100.0e0 * l_q - ) + po.ovarre(self.outfile, "Power decay width (cm)", "(100*l_q)", 100.0e0 * l_q) po.ovarre(self.outfile, "Island width (m)", "(w_r)", w_r) po.ovarre( self.outfile, @@ -1357,9 +1348,7 @@ def stfwbs(self, output: bool): pnucfwbs * build_variables.a_fw_inboard / build_variables.a_fw_total ) pnucfwbso = ( - pnucfwbs - * build_variables.a_fw_outboard - / build_variables.a_fw_total + pnucfwbs * build_variables.a_fw_outboard / build_variables.a_fw_total ) # Radiation power incident on divertor (MW) @@ -2662,9 +2651,7 @@ def stcoil(self, output: bool): ) ** 2 # If REBCO, : start at smaller winding pack ratios # Find the intersection between LHS and RHS (or: how much awp do I need to get to the desired coil current) - wp_width_r_min = self.intersect( - wp_width_r, lhs, wp_width_r, rhs, wp_width_r_min - ) + wp_width_r_min = self.intersect(wp_width_r, lhs, wp_width_r, rhs, wp_width_r_min) # Maximum field at superconductor surface (T) wp_width_r_min = max(tfcoil_variables.dx_tf_turn_general**2, wp_width_r_min) @@ -2968,17 +2955,15 @@ def stcoil(self, output: bool): ) # [kg] mass of Superconductor tfcoil_variables.m_tf_coil_superconductor = ( - ( - tfcoil_variables.len_tf_coil - * tfcoil_variables.n_tf_coil_turns - * tfcoil_variables.a_tf_turn_cable_space_no_void - * (1.0e0 - tfcoil_variables.f_a_tf_turn_cable_space_extra_void) - * (1.0e0 - tfcoil_variables.f_a_tf_turn_cable_copper) - - tfcoil_variables.len_tf_coil - * tfcoil_variables.a_tf_wp_coolant_channels - ) - * tfcoil_variables.dcond[tfcoil_variables.i_tf_sc_mat - 1] - ) # a_tf_wp_coolant_channels is 0 for a stellarator. but keep this term for now. + tfcoil_variables.len_tf_coil + * tfcoil_variables.n_tf_coil_turns + * tfcoil_variables.a_tf_turn_cable_space_no_void + * (1.0e0 - tfcoil_variables.f_a_tf_turn_cable_space_extra_void) + * (1.0e0 - tfcoil_variables.f_a_tf_turn_cable_copper) + - tfcoil_variables.len_tf_coil * tfcoil_variables.a_tf_wp_coolant_channels + ) * tfcoil_variables.dcond[ + tfcoil_variables.i_tf_sc_mat - 1 + ] # a_tf_wp_coolant_channels is 0 for a stellarator. but keep this term for now. # [kg] mass of Copper in conductor tfcoil_variables.m_tf_coil_copper = ( tfcoil_variables.len_tf_coil @@ -3303,8 +3288,8 @@ def jcrit_frommaterial( else: ( j_crit_sc, - bcrit, - tcrit, + _bcrit, + _tcrit, ) = superconductors.itersc(thelium, bmax, strain, bc20m, tc0m) # j_crit_cable = j_crit_sc * non-copper fraction of conductor * conductor fraction of cable @@ -3327,11 +3312,10 @@ def jcrit_frommaterial( # jstrand = 0 # as far as I can tell this will always be 0 # because jwp was never set in fortran (so 0) - j_crit_cable, tmarg = superconductors.bi2212( + j_crit_cable, _tmarg = superconductors.bi2212( bmax, jstrand, thelium, fhts ) # bi2212 outputs j_crit_cable j_crit_sc = j_crit_cable / (1 - fcu) - tcrit = thelium + tmarg elif i_tf_sc_mat == 3: # NbTi data bc20m = 15.0 tc0m = 9.3 @@ -3340,14 +3324,13 @@ def jcrit_frommaterial( if bmax > bc20m: j_crit_sc = 1.0e-9 # Set to a small nonzero value else: - j_crit_sc, tcrit = superconductors.jcrit_nbti( + j_crit_sc, _tcrit = superconductors.jcrit_nbti( thelium, bmax, c0, bc20m, tc0m, ) - # I dont need tcrit here so dont use it. # j_crit_cable = j_crit_sc * non-copper fraction of conductor * conductor fraction of cable j_crit_cable = j_crit_sc * (1 - fcu) * (1 - fhe) @@ -3358,7 +3341,7 @@ def jcrit_frommaterial( elif i_tf_sc_mat == 4: # As (1), but user-defined parameters bc20m = bcritsc tc0m = tcritsc - j_crit_sc, bcrit, tcrit = superconductors.itersc( + j_crit_sc, _bcrit, _tcrit = superconductors.itersc( thelium, bmax, strain, bc20m, tc0m ) # j_crit_cable = j_crit_sc * non-copper fraction of conductor * conductor fraction of cable @@ -3370,7 +3353,7 @@ def jcrit_frommaterial( # j_crit_sc returned by itersc is the critical current density in the # superconductor - not the whole strand, which contains copper - j_crit_sc, bcrit, tcrit = superconductors.western_superconducting_nb3sn( + j_crit_sc, _bcrit, _tcrit = superconductors.western_superconducting_nb3sn( thelium, bmax, strain, @@ -3382,7 +3365,7 @@ def jcrit_frommaterial( elif ( i_tf_sc_mat == 6 ): # ! "REBCO" 2nd generation HTS superconductor in CrCo strand - j_crit_sc, validity = superconductors.jcrit_rebco(thelium, bmax, 0) + j_crit_sc, _validity = superconductors.jcrit_rebco(thelium, bmax, 0) j_crit_sc = max(1.0e-9, j_crit_sc) # j_crit_cable = j_crit_sc * non-copper fraction of conductor * conductor fraction of cable j_crit_cable = j_crit_sc * (1 - fcu) * (1 - fhe) @@ -3390,7 +3373,7 @@ def jcrit_frommaterial( elif i_tf_sc_mat == 7: # Durham Ginzburg-Landau Nb-Ti parameterisation bc20m = b_crit_upper_nbti tc0m = t_crit_nbti - j_crit_sc, bcrit, tcrit = superconductors.gl_nbti( + j_crit_sc, _bcrit, _tcrit = superconductors.gl_nbti( thelium, bmax, strain, bc20m, tc0m ) # j_crit_cable = j_crit_sc * non-copper fraction of conductor * conductor fraction of cable @@ -3398,7 +3381,7 @@ def jcrit_frommaterial( elif i_tf_sc_mat == 8: bc20m = 429 tc0m = 185 - j_crit_sc, bcrit, tcrit = superconductors.gl_rebco( + j_crit_sc, _bcrit, _tcrit = superconductors.gl_rebco( thelium, bmax, strain, bc20m, tc0m ) # A0 calculated for tape cross section already @@ -3854,9 +3837,7 @@ def stcoil_output( "(e_tf_magnetic_stored_total_gj)", tfcoil_variables.e_tf_magnetic_stored_total_gj, ) - po.ovarre( - self.outfile, "Inductance of TF Coils (H)", "(inductance)", inductance - ) + po.ovarre(self.outfile, "Inductance of TF Coils (H)", "(inductance)", inductance) po.ovarre( self.outfile, "Total mass of coils (kg)", @@ -4477,9 +4458,7 @@ def stphys(self, output): ) physics_variables.pden_plasma_sync_mw = radpwr_data.pden_plasma_sync_mw physics_variables.pden_plasma_core_rad_mw = radpwr_data.pden_plasma_core_rad_mw - physics_variables.pden_plasma_outer_rad_mw = ( - radpwr_data.pden_plasma_outer_rad_mw - ) + physics_variables.pden_plasma_outer_rad_mw = radpwr_data.pden_plasma_outer_rad_mw physics_variables.pden_plasma_rad_mw = radpwr_data.pden_plasma_rad_mw physics_variables.pden_plasma_core_rad_mw = max( @@ -4522,9 +4501,7 @@ def stphys(self, output): # Here the implementation sometimes leaves the accessible regime when p_plasma_rad_mw> powht which is unphysical and # is not taken care of by the rad module. We restrict the radiation power here by the heating power: - physics_variables.p_plasma_rad_mw = max( - 0.0e0, physics_variables.p_plasma_rad_mw - ) + physics_variables.p_plasma_rad_mw = max(0.0e0, physics_variables.p_plasma_rad_mw) # Power to divertor, = (1-stellarator_variables.f_rad)*Psol @@ -4650,7 +4627,7 @@ def stphys(self, output): physics_variables.ntau, physics_variables.nTtau, physics_variables.figmer, - fusrat, + _fusrat, physics_variables.molflow_plasma_fuelling_required, physics_variables.rndfuel, physics_variables.t_alpha_confinement, @@ -4676,24 +4653,24 @@ def stphys(self, output): ( q_PROCESS, q_PROCESS_r1, - q_neo, - gamma_neo, - total_q_neo, + _q_neo, + _gamma_neo, + _total_q_neo, total_q_neo_e, q_neo_e, - q_neo_D, - q_neo_a, - q_neo_T, + _q_neo_D, + _q_neo_a, + _q_neo_T, g_neo_e, - g_neo_D, - g_neo_a, - g_neo_T, + _g_neo_D, + _g_neo_a, + _g_neo_T, dndt_neo_e, - dndt_neo_D, - dndt_neo_a, - dndt_neo_T, - dndt_neo_fuel, - dmdt_neo_fuel, + _dndt_neo_D, + _dndt_neo_a, + _dndt_neo_T, + _dndt_neo_fuel, + _dmdt_neo_fuel, dmdt_neo_fuel_from_e, chi_neo_e, chi_PROCESS_e, @@ -4972,11 +4949,9 @@ def calc_neoclassics(self): chi_neo_e = -( neoclassics_variables.q_flux[0] - + neoclassics_variables.gamma_flux[0] - * neoclassics_variables.temperatures[0] + + neoclassics_variables.gamma_flux[0] * neoclassics_variables.temperatures[0] ) / ( - neoclassics_variables.densities[0] - * neoclassics_variables.dr_temperatures[0] + neoclassics_variables.densities[0] * neoclassics_variables.dr_temperatures[0] + neoclassics_variables.temperatures[0] * neoclassics_variables.dr_densities[0] ) @@ -5103,13 +5078,13 @@ def stheat(self, output: bool): current_drive_variables.eta_hcd_primary_injector_wall_plug = ( current_drive_variables.eta_lowhyb_injector_wall_plug ) - current_drive_variables.p_hcd_electric_total_mw = ( + heat_transport_variables.p_hcd_electric_total_mw = ( current_drive_variables.p_hcd_injected_ions_mw + current_drive_variables.p_hcd_injected_electrons_mw ) / current_drive_variables.eta_hcd_primary_injector_wall_plug elif stellarator_variables.isthtr == 3: ( - effnbss, + _effnbss, f_p_beam_injected_ions, current_drive_variables.f_p_beam_shine_through, ) = self.current_drive.culnbi() @@ -5542,9 +5517,7 @@ def neoclassics_calc_nu(self): 32.2 - 1.15 * np.log10(neoclassics_variables.densities[0]) + 2.3 - * np.log10( - neoclassics_variables.temperatures[0] / constants.ELECTRON_CHARGE - ) + * np.log10(neoclassics_variables.temperatures[0] / constants.ELECTRON_CHARGE) ) neoclassics_calc_nu = np.zeros((4, self.no_roots), order="F") @@ -5757,34 +5730,22 @@ def neoclassics_calc_D11_plateau(self): v = np.empty((4, self.no_roots)) v[0, :] = constants.SPEED_LIGHT * np.sqrt( 1.0 - - ( - neoclassics_variables.kt[0, :] / (mass[0] * constants.SPEED_LIGHT**2) - + 1 - ) + - (neoclassics_variables.kt[0, :] / (mass[0] * constants.SPEED_LIGHT**2) + 1) ** (-1) ) v[1, :] = constants.SPEED_LIGHT * np.sqrt( 1.0 - - ( - neoclassics_variables.kt[1, :] / (mass[1] * constants.SPEED_LIGHT**2) - + 1 - ) + - (neoclassics_variables.kt[1, :] / (mass[1] * constants.SPEED_LIGHT**2) + 1) ** (-1) ) v[2, :] = constants.SPEED_LIGHT * np.sqrt( 1.0 - - ( - neoclassics_variables.kt[2, :] / (mass[2] * constants.SPEED_LIGHT**2) - + 1 - ) + - (neoclassics_variables.kt[2, :] / (mass[2] * constants.SPEED_LIGHT**2) + 1) ** (-1) ) v[3, :] = constants.SPEED_LIGHT * np.sqrt( 1.0 - - ( - neoclassics_variables.kt[3, :] / (mass[3] * constants.SPEED_LIGHT**2) - + 1 - ) + - (neoclassics_variables.kt[3, :] / (mass[3] * constants.SPEED_LIGHT**2) + 1) ** (-1) ) diff --git a/process/structure.py b/process/structure.py index 3dce91e3b6..a4ae1154fb 100644 --- a/process/structure.py +++ b/process/structure.py @@ -235,9 +235,7 @@ def structure( clgsmass, "OP ", ) - po.ovarre( - self.outfile, "Torus leg support mass (kg)", "(gsm1)", gsm1, "OP " - ) + po.ovarre(self.outfile, "Torus leg support mass (kg)", "(gsm1)", gsm1, "OP ") po.ovarre(self.outfile, "Ring beam mass (kg)", "(gsm2)", gsm2, "OP ") po.ovarre(self.outfile, "Ring legs mass (kg)", "(gsm3)", gsm3, "OP ") diff --git a/process/superconducting_tf_coil.py b/process/superconducting_tf_coil.py index 0d4fbe3794..88e0e8d7bc 100644 --- a/process/superconducting_tf_coil.py +++ b/process/superconducting_tf_coil.py @@ -235,9 +235,7 @@ def run(self, output: bool): ) tfcoil_variables.casestr = ( - tfcoil_variables.casestr - if tfcoil_variables.casestr is None - else casestr + tfcoil_variables.casestr if tfcoil_variables.casestr is None else casestr ) tfcoil_variables.insstrain = ( @@ -1038,9 +1036,7 @@ def tf_cable_in_conduit_superconductor_properties( temp_conductor=temp_tf_coolant_peak_field, f_strain=f_strain_scale, ) - j_superconductor_critical = j_crit_cable / ( - 1.0e0 - f_a_tf_turn_cable_copper - ) + j_superconductor_critical = j_crit_cable / (1.0e0 - f_a_tf_turn_cable_copper) # Critical current in cable c_turn_cables_critical = ( j_crit_cable * a_tf_turn_cable_space * f_a_tf_turn_cable_space_conductor @@ -1618,7 +1614,10 @@ def calculate_superconductor_temperature_margin( ) another_estimate = 2 * temp_tf_coolant_peak_field - t_zero_margin, root_result = optimize.newton( + ( + t_zero_margin, + _root_result, + ) = optimize.newton( superconductors.superconductor_current_density_margin, temp_tf_coolant_peak_field, fprime=None, @@ -1769,9 +1768,7 @@ def vv_stress_on_quench(self): # Assume the radius of the first ellipse of the VV is in the same proportion to # that of the plasma facing radii of the two structures tf_vv_frac = build_variables.r_tf_inboard_out / build_variables.r_vv_inboard_out - rm_vv = build_variables.r_vv_inboard_out + ( - tfcoil_variables.tfa[0] * tf_vv_frac - ) + rm_vv = build_variables.r_vv_inboard_out + (tfcoil_variables.tfa[0] * tf_vv_frac) superconducting_tf_coil_variables.vv_stress_quench = vv_stress_on_quench( # TF shape diff --git a/process/superconductors.py b/process/superconductors.py index a800b8f1c0..019d2a01cb 100644 --- a/process/superconductors.py +++ b/process/superconductors.py @@ -99,7 +99,7 @@ def deltaj_rebco(temperature): estimate = 10.0 another_estimate = 20.0 - current_sharing_t, root_result = optimize.newton( + current_sharing_t, _root_result = optimize.newton( deltaj_rebco, estimate, tol=1e-6, @@ -981,9 +981,7 @@ def croco(j_crit_sc, conductor_area, dia_croco_strand, dx_croco_strand_copper): conductor_critical_current = croco_strand_critical_current * 6.0 # Area of core = area of strand conductor_copper_bar_area = a_croco_strand - conductor_copper_area = ( - a_croco_strand_copper_total * 6.0 + conductor_copper_bar_area - ) + conductor_copper_area = a_croco_strand_copper_total * 6.0 + conductor_copper_bar_area conductor_copper_fraction = conductor_copper_area / conductor_area # Helium area is set by the user. @@ -1064,15 +1062,9 @@ def superconductor_current_density_margin( 9: High current density REBCO """ material_functions = { - 1: lambda: itersc(temp_superconductor, b_superconductor, strain, bc20m, tc0m)[ - 0 - ], - 3: lambda: jcrit_nbti(temp_superconductor, b_superconductor, c0, bc20m, tc0m)[ - 0 - ], - 4: lambda: itersc(temp_superconductor, b_superconductor, strain, bc20m, tc0m)[ - 0 - ], + 1: lambda: itersc(temp_superconductor, b_superconductor, strain, bc20m, tc0m)[0], + 3: lambda: jcrit_nbti(temp_superconductor, b_superconductor, c0, bc20m, tc0m)[0], + 4: lambda: itersc(temp_superconductor, b_superconductor, strain, bc20m, tc0m)[0], 5: lambda: western_superconducting_nb3sn( temp_superconductor, b_superconductor, strain, bc20m, tc0m )[0], diff --git a/process/tf_coil.py b/process/tf_coil.py index 84abe4ace7..3c02a8ceb6 100644 --- a/process/tf_coil.py +++ b/process/tf_coil.py @@ -1309,8 +1309,7 @@ def outtf(self): # po.ovarre(self.outfile,'Central helium channel area as fraction of winding pack','(tfcoil_variables.a_tf_wp_coolant_channels/ap)',a_tf_wp_coolant_channels/ap, 'OP ') ap = ( tfcoil_variables.a_tf_wp_conductor - + tfcoil_variables.n_tf_coil_turns - * tfcoil_variables.a_tf_turn_steel + + tfcoil_variables.n_tf_coil_turns * tfcoil_variables.a_tf_turn_steel + tfcoil_variables.a_tf_coil_wp_turn_insulation + tfcoil_variables.a_tf_wp_extra_void + tfcoil_variables.a_tf_wp_coolant_channels @@ -2023,9 +2022,7 @@ def outtf(self): # Radial build consistency check if ( - abs( - radius - build_variables.r_tf_inboard_in - build_variables.dr_tf_inboard - ) + abs(radius - build_variables.r_tf_inboard_in - build_variables.dr_tf_inboard) < 10.0e0 * np.finfo(float(radius)).eps ): po.ocmmnt(self.outfile, "TF coil dimensions are consistent") @@ -2620,12 +2617,8 @@ def tf_field_and_force( r_tf_wp_inboard_inner + dx_tf_wp_insulation + dx_tf_wp_insertion_gap ) else: - r_tf_wp_inboard_outer_conductor = ( - r_tf_wp_inboard_outer - dx_tf_wp_insulation - ) - r_tf_wp_inboard_inner_conductor = ( - r_tf_wp_inboard_inner + dx_tf_wp_insulation - ) + r_tf_wp_inboard_outer_conductor = r_tf_wp_inboard_outer - dx_tf_wp_insulation + r_tf_wp_inboard_inner_conductor = r_tf_wp_inboard_inner + dx_tf_wp_insulation # Associated WP thickness dr_tf_wp_inboard_conductor = ( @@ -2688,8 +2681,7 @@ def tf_field_and_force( * ( r_tf_wp_inboard_outer_conductor * np.log( - r_tf_wp_inboard_inner_conductor - / r_tf_wp_inboard_outer_conductor + r_tf_wp_inboard_inner_conductor / r_tf_wp_inboard_outer_conductor ) + r_tf_wp_outboard_inner_conductor * np.log( @@ -2712,8 +2704,7 @@ def tf_field_and_force( 2.0e0 * r_tf_wp_inboard_outer_conductor**2 * np.log( - r_tf_wp_inboard_outer_conductor - / r_tf_wp_inboard_inner_conductor + r_tf_wp_inboard_outer_conductor / r_tf_wp_inboard_inner_conductor ) + 2.0e0 * dr_tf_wp_inboard_conductor**2 @@ -2726,8 +2717,7 @@ def tf_field_and_force( * dr_tf_wp_inboard_conductor * r_tf_wp_inboard_outer_conductor * np.log( - r_tf_wp_inboard_inner_conductor - / r_tf_wp_inboard_outer_conductor + r_tf_wp_inboard_inner_conductor / r_tf_wp_inboard_outer_conductor ) ) ) @@ -3099,9 +3089,7 @@ def generic_tf_coil_area_and_masses(self): # Surface areas (for cryo system) [m²] wbtf = ( build_variables.r_tf_inboard_out - * np.sin( - superconducting_tf_coil_variables.rad_tf_coil_inboard_toroidal_half - ) + * np.sin(superconducting_tf_coil_variables.rad_tf_coil_inboard_toroidal_half) - build_variables.r_tf_inboard_in * superconducting_tf_coil_variables.tan_theta_coil ) @@ -4740,10 +4728,7 @@ def extended_plane_strain( # Axial stiffness products ey_bar_z_area = np.pi * sum( ey_bar_z[nonslip_layer - 1 : nlayers] - * ( - rad[nonslip_layer : nlayers + 1] ** 2 - - rad[nonslip_layer - 1 : nlayers] ** 2 - ) + * (rad[nonslip_layer : nlayers + 1] ** 2 - rad[nonslip_layer - 1 : nlayers] ** 2) ) ey_bar_z_area_slip = np.pi * sum( ey_bar_z[: nonslip_layer - 1] diff --git a/process/vacuum.py b/process/vacuum.py index 2e884980e7..7f71c0ec46 100644 --- a/process/vacuum.py +++ b/process/vacuum.py @@ -43,10 +43,7 @@ def run(self, output: bool) -> None: # MDK Check this!! gasld = ( - 2.0e0 - * pv.molflow_plasma_fuelling_required - * pv.m_fuel_amu - * constants.UMASS + 2.0e0 * pv.molflow_plasma_fuelling_required * pv.m_fuel_amu * constants.UMASS ) self.i_vacuum_pumping = vacv.i_vacuum_pumping @@ -366,13 +363,16 @@ def vacuum( source = pfus * 1.47e-09 fhe = source / (frate * 4.985e5) - s.append(source / vacv.pres_div_chamber_burn / fhe) - - # Removal of dt on steady state basis - # s(4) = net speed (D-T) required to remove dt at fuelling rate (m^3/s) - - s.append( - (frate * 4.985e5 - source) / (vacv.pres_div_chamber_burn * (1.0e0 - fhe)) + s.extend( + ( + (source / vacv.pres_div_chamber_burn / fhe), + # Removal of dt on steady state basis + # s(4) = net speed (D-T) required to remove dt at fuelling rate (m^3/s) + ( + (frate * 4.985e5 - source) + / (vacv.pres_div_chamber_burn * (1.0e0 - fhe)) + ), + ), ) # Calculate conductance of a single duct @@ -396,9 +396,7 @@ def vacuum( d = np.full(4, 1e-6) for i in range(4): - sss = nduct / ( - 1.0e0 / sp[i] / pumpn + 1.0e0 / cmax * xmult[i] / xmult[imax] - ) + sss = nduct / (1.0e0 / sp[i] / pumpn + 1.0e0 / cmax * xmult[i] / xmult[imax]) if sss > s[i]: continue imax = i @@ -470,9 +468,7 @@ def vacuum( # Area between adjacent TF coils available for pump ducts # ritf = outer radius of inboard leg of TF coil (m) - a1max = (r0 + aw - ritf - thcsh / math.tan(theta)) ** 2 * math.tan( - theta - ) + a1max = (r0 + aw - ritf - thcsh / math.tan(theta)) ** 2 * math.tan(theta) d1max = math.sqrt(4.0e0 * a1max / math.pi) # Equivalent diameter if a1 < a1max: break @@ -661,9 +657,7 @@ def vacuum( elif imax == 3: po.ocmmnt(self.outfile, "requirements for helium ash removal.") else: - po.ocmmnt( - self.outfile, "requirements for D-T removal at fuelling rate." - ) + po.ocmmnt(self.outfile, "requirements for D-T removal at fuelling rate.") po.oblnkl(self.outfile) po.ovarin(self.outfile, "Number of large pump ducts", "(nduct)", nduct) diff --git a/scripts/vardes.py b/scripts/vardes.py index 53f4c23b18..34da528b32 100644 --- a/scripts/vardes.py +++ b/scripts/vardes.py @@ -66,8 +66,6 @@ def get_variables_and_modules(ford_project: Path): vardes_template = env.get_template("vardes.jinja2") - with open( - Path(__file__).resolve().parent / "../documentation/io/vardes.md", - "w", - ) as f: - f.write(vardes_template.render(mods=mods)) + (Path(__file__).resolve().parent / "../documentation/io/vardes.md").write_text( + vardes_template.render(mods=mods) + ) diff --git a/tests/integration/test_pfcoil_int.py b/tests/integration/test_pfcoil_int.py index c8b35f64b4..72b1bedc43 100644 --- a/tests/integration/test_pfcoil_int.py +++ b/tests/integration/test_pfcoil_int.py @@ -255,9 +255,7 @@ def test_ohcalc(monkeypatch, reinitialise_error_module, cs_coil): monkeypatch.setattr(pfcoil_variables, "z_pf_coil_middle", np.full(22, 0.0)) monkeypatch.setattr(pfcoil_variables, "r_pf_coil_outer", np.full(22, 0.0)) monkeypatch.setattr(pfcoil_variables, "r_pf_coil_inner", np.full(22, 0.0)) - monkeypatch.setattr( - pfcoil_variables, "j_cs_conductor_critical_pulse_start", 3.562e8 - ) + monkeypatch.setattr(pfcoil_variables, "j_cs_conductor_critical_pulse_start", 3.562e8) monkeypatch.setattr( pfcoil_variables, "c_pf_coil_turn_peak_input", np.full(22, 4.22e4) ) @@ -313,9 +311,7 @@ def test_ohcalc(monkeypatch, reinitialise_error_module, cs_coil): cs_coil.ohcalc() assert pytest.approx(pfcoil_variables.b_pf_coil_peak[4]) == 13.073958753751993 - assert ( - pytest.approx(pfcoil_variables.j_cs_critical_flat_top_end) == 54101481.7685945 - ) + assert pytest.approx(pfcoil_variables.j_cs_critical_flat_top_end) == 54101481.7685945 def test_efc(pfcoil: PFCoil, monkeypatch: pytest.MonkeyPatch): diff --git a/tests/regression/regression_test_assets.py b/tests/regression/regression_test_assets.py index 6e718db7e4..679cfd95e9 100644 --- a/tests/regression/regression_test_assets.py +++ b/tests/regression/regression_test_assets.py @@ -55,8 +55,9 @@ def get_reference_mfile( if (mf.scenario_name == scenario_name and target_hash is None) or ( mf.scenario_name == scenario_name and target_hash == mf.hash ): - with open(reference_mfile_location, "w") as f: - f.write(requests.get(mf.download_link).content.decode()) + Path(reference_mfile_location).write_text( + requests.get(mf.download_link).content.decode() + ) logger.info(f"Reference MFile found for commit {mf.hash}") return reference_mfile_location diff --git a/tests/unit/test_blanket_library.py b/tests/unit/test_blanket_library.py index 24b8b34910..c902fde26f 100644 --- a/tests/unit/test_blanket_library.py +++ b/tests/unit/test_blanket_library.py @@ -1734,12 +1734,8 @@ def test_liquid_breeder_properties( "b_plasma_toroidal_on_axis", liquidbreederpropertiesparam.b_plasma_toroidal_on_axis, ) - monkeypatch.setattr( - physics_variables, "aspect", liquidbreederpropertiesparam.aspect - ) - monkeypatch.setattr( - physics_variables, "rmajor", liquidbreederpropertiesparam.rmajor - ) + monkeypatch.setattr(physics_variables, "aspect", liquidbreederpropertiesparam.aspect) + monkeypatch.setattr(physics_variables, "rmajor", liquidbreederpropertiesparam.rmajor) monkeypatch.setattr( build_variables, "dr_blkt_inboard", liquidbreederpropertiesparam.dr_blkt_inboard ) diff --git a/tests/unit/test_buildings.py b/tests/unit/test_buildings.py index 197155917b..f91d3954ba 100644 --- a/tests/unit/test_buildings.py +++ b/tests/unit/test_buildings.py @@ -952,9 +952,7 @@ def test_bldgs(buildings, bldgsparam, monkeypatch): monkeypatch.setattr(buildings_variables, "wgt", bldgsparam.wgt) monkeypatch.setattr(buildings_variables, "shmf", bldgsparam.shmf) monkeypatch.setattr(buildings_variables, "clh2", bldgsparam.clh2) - monkeypatch.setattr( - buildings_variables, "dz_tf_cryostat", bldgsparam.dz_tf_cryostat - ) + monkeypatch.setattr(buildings_variables, "dz_tf_cryostat", bldgsparam.dz_tf_cryostat) monkeypatch.setattr(buildings_variables, "stcl", bldgsparam.stcl) monkeypatch.setattr(buildings_variables, "rbvfac", bldgsparam.rbvfac) monkeypatch.setattr(buildings_variables, "rbwt", bldgsparam.rbwt) diff --git a/tests/unit/test_ccfe_hcpb.py b/tests/unit/test_ccfe_hcpb.py index d45e467467..be450cd753 100644 --- a/tests/unit/test_ccfe_hcpb.py +++ b/tests/unit/test_ccfe_hcpb.py @@ -1048,9 +1048,7 @@ def test_powerflow_calc(powerflowcalcparam, monkeypatch, ccfe_hcpb): powerflowcalcparam.f_p_div_coolant_pump_total_heat, ) - monkeypatch.setattr( - physics_variables, "n_divertors", powerflowcalcparam.n_divertors - ) + monkeypatch.setattr(physics_variables, "n_divertors", powerflowcalcparam.n_divertors) monkeypatch.setattr( physics_variables, "p_plasma_rad_mw", powerflowcalcparam.p_plasma_rad_mw @@ -1074,9 +1072,7 @@ def test_powerflow_calc(powerflowcalcparam, monkeypatch, ccfe_hcpb): primary_pumping_variables, "gamma_he", powerflowcalcparam.gamma_he ) - monkeypatch.setattr( - primary_pumping_variables, "t_in_bb", powerflowcalcparam.t_in_bb - ) + monkeypatch.setattr(primary_pumping_variables, "t_in_bb", powerflowcalcparam.t_in_bb) monkeypatch.setattr( primary_pumping_variables, "t_out_bb", powerflowcalcparam.t_out_bb @@ -1098,13 +1094,9 @@ def test_powerflow_calc(powerflowcalcparam, monkeypatch, ccfe_hcpb): powerflowcalcparam.expected_p_fw_rad_total_mw ) - assert fwbs_variables.psurffwi == pytest.approx( - powerflowcalcparam.expected_psurffwi - ) + assert fwbs_variables.psurffwi == pytest.approx(powerflowcalcparam.expected_psurffwi) - assert fwbs_variables.psurffwo == pytest.approx( - powerflowcalcparam.expected_psurffwo - ) + assert fwbs_variables.psurffwo == pytest.approx(powerflowcalcparam.expected_psurffwo) assert heat_transport_variables.p_shld_coolant_pump_mw == pytest.approx( powerflowcalcparam.expected_p_shld_coolant_pump_mw @@ -1684,9 +1676,7 @@ def test_component_masses(componentmassesparam, monkeypatch, ccfe_hcpb): assert fwbs_variables.m_blkt_li2o == pytest.approx( componentmassesparam.expected_m_blkt_li2o ) - assert fwbs_variables.whtshld == pytest.approx( - componentmassesparam.expected_whtshld - ) + assert fwbs_variables.whtshld == pytest.approx(componentmassesparam.expected_whtshld) assert fwbs_variables.wpenshld == pytest.approx( componentmassesparam.expected_wpenshld ) diff --git a/tests/unit/test_coolprop_interface.py b/tests/unit/test_coolprop_interface.py index 77cacdb992..d5b79bb78a 100644 --- a/tests/unit/test_coolprop_interface.py +++ b/tests/unit/test_coolprop_interface.py @@ -25,8 +25,7 @@ def test_water_with_pressure_temp(): # calculated assert pytest.approx(fluid_properties.density, rel=1e-3) == WATER_PROPERTIES.density assert ( - pytest.approx(fluid_properties.viscosity, rel=1e-3) - == WATER_PROPERTIES.viscosity + pytest.approx(fluid_properties.viscosity, rel=1e-3) == WATER_PROPERTIES.viscosity ) assert ( pytest.approx(fluid_properties.enthalpy, rel=1e-3) == WATER_PROPERTIES.enthalpy diff --git a/tests/unit/test_costs_1990.py b/tests/unit/test_costs_1990.py index 260bf883e9..8cece7e1fa 100644 --- a/tests/unit/test_costs_1990.py +++ b/tests/unit/test_costs_1990.py @@ -470,9 +470,7 @@ def test_acc242(monkeypatch, costs): """ monkeypatch.setattr(cost_variables, "lsa", 4) monkeypatch.setattr(heat_transport_variables, "pacpmw", 630.0) - monkeypatch.setattr( - heat_transport_variables, "p_plant_electric_base_total_mw", 65.0 - ) + monkeypatch.setattr(heat_transport_variables, "p_plant_electric_base_total_mw", 65.0) monkeypatch.setattr(cost_variables, "c242", 0) costs.acc242() diff --git a/tests/unit/test_costs_2015.py b/tests/unit/test_costs_2015.py index f7fd9c0094..7ba328a9da 100644 --- a/tests/unit/test_costs_2015.py +++ b/tests/unit/test_costs_2015.py @@ -16044,9 +16044,7 @@ class CalcRemainingSubsystemsParam(NamedTuple): ), ), ) -def test_calc_remaining_subsystems( - calcremainingsubsystemsparam, monkeypatch, costs2015 -): +def test_calc_remaining_subsystems(calcremainingsubsystemsparam, monkeypatch, costs2015): """ Automatically generated Regression Unit Test for calc_remaining_subsystems. diff --git a/tests/unit/test_cryostat.py b/tests/unit/test_cryostat.py index b5cc74b585..133c07c410 100644 --- a/tests/unit/test_cryostat.py +++ b/tests/unit/test_cryostat.py @@ -181,9 +181,7 @@ def test_external_cryo_geometry( ) monkeypatch.setattr(fwbs_variables, "m_vv", externalcryogeometryparam.m_vv) monkeypatch.setattr(fwbs_variables, "vol_vv", externalcryogeometryparam.vol_vv) - monkeypatch.setattr( - fwbs_variables, "den_steel", externalcryogeometryparam.den_steel - ) + monkeypatch.setattr(fwbs_variables, "den_steel", externalcryogeometryparam.den_steel) monkeypatch.setattr(fwbs_variables, "dewmkg", externalcryogeometryparam.dewmkg) monkeypatch.setattr( pfcoil_variables, "r_pf_coil_outer", externalcryogeometryparam.r_pf_coil_outer diff --git a/tests/unit/test_current_drive.py b/tests/unit/test_current_drive.py index d6b9792ed9..b625861173 100644 --- a/tests/unit/test_current_drive.py +++ b/tests/unit/test_current_drive.py @@ -63,9 +63,7 @@ def test_cudriv_primary_lower_hybrid(current_drive): assert current_drive_variables.c_hcd_primary_driven == pytest.approx( 3000000.0, rel=1e-6 ) - assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx( - 0.2, rel=1e-6 - ) + assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx(0.2, rel=1e-6) assert heat_transport_variables.p_hcd_primary_electric_mw == pytest.approx( 96.00232726, rel=1e-6 ) @@ -109,9 +107,7 @@ def test_cudriv_primary_lower_hybrid_with_heat(current_drive): assert current_drive_variables.c_hcd_primary_driven == pytest.approx( 3000000.0, rel=1e-6 ) - assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx( - 0.2, rel=1e-6 - ) + assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx(0.2, rel=1e-6) assert heat_transport_variables.p_hcd_primary_electric_mw == pytest.approx( 108.50232725752629, rel=1e-6 ) # Adjusted for extra heat @@ -124,9 +120,7 @@ def test_cudriv_primary_lower_hybrid_with_heat(current_drive): assert current_drive_variables.p_hcd_injected_electrons_mw == pytest.approx( 43.4009309, rel=1e-6 ) - assert current_drive_variables.p_hcd_injected_ions_mw == pytest.approx( - 0.0, rel=1e-6 - ) + assert current_drive_variables.p_hcd_injected_ions_mw == pytest.approx(0.0, rel=1e-6) def test_sigbeam(current_drive): @@ -167,9 +161,7 @@ def test_cudriv_primary_neutral_beam(current_drive): assert current_drive_variables.c_hcd_primary_driven == pytest.approx( 3000000.0, rel=1e-6 ) - assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx( - 0.2, rel=1e-6 - ) + assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx(0.2, rel=1e-6) assert heat_transport_variables.p_hcd_primary_electric_mw == pytest.approx( 59.32237274617019, rel=1e-6 ) @@ -212,9 +204,7 @@ def test_cudriv_primary_electron_cyclotron(current_drive): assert current_drive_variables.c_hcd_primary_driven == pytest.approx( 3000000.0, rel=1e-6 ) - assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx( - 0.2, rel=1e-6 - ) + assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx(0.2, rel=1e-6) assert heat_transport_variables.p_hcd_primary_electric_mw == pytest.approx( 17.71428571428571, rel=1e-6 ) @@ -260,9 +250,7 @@ def test_cudriv_primary_ion_cyclotron(current_drive): assert current_drive_variables.c_hcd_primary_driven == pytest.approx( 3000000.0, rel=1e-6 ) - assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx( - 0.2, rel=1e-6 - ) + assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx(0.2, rel=1e-6) assert heat_transport_variables.p_hcd_primary_electric_mw == pytest.approx( 337.4149659863946, rel=1e-6 ) @@ -310,9 +298,7 @@ def test_cudriv_primary_electron_bernstein(current_drive): assert current_drive_variables.c_hcd_primary_driven == pytest.approx( 3000000.0, rel=1e-6 ) - assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx( - 0.2, rel=1e-6 - ) + assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx(0.2, rel=1e-6) assert heat_transport_variables.p_hcd_primary_electric_mw == pytest.approx( 572.7156734979227, rel=1e-6 ) diff --git a/tests/unit/test_dcll.py b/tests/unit/test_dcll.py index cbf2ec6c3a..7a9ae3af8e 100644 --- a/tests/unit/test_dcll.py +++ b/tests/unit/test_dcll.py @@ -235,13 +235,9 @@ def test_dcll_neutronics_and_power(dcllneutronicsandpowerparam, monkeypatch, dcl dcllneutronicsandpowerparam.p_fw_nuclear_heat_total_mw, ) - monkeypatch.setattr( - fwbs_variables, "psurffwi", dcllneutronicsandpowerparam.psurffwi - ) + monkeypatch.setattr(fwbs_variables, "psurffwi", dcllneutronicsandpowerparam.psurffwi) - monkeypatch.setattr( - fwbs_variables, "psurffwo", dcllneutronicsandpowerparam.psurffwo - ) + monkeypatch.setattr(fwbs_variables, "psurffwo", dcllneutronicsandpowerparam.psurffwo) monkeypatch.setattr( fwbs_variables, @@ -854,13 +850,9 @@ def test_dcll_masses(dcllmassesparam, monkeypatch, dcll): dcllmassesparam.a_plasma_surface_outboard, ) - monkeypatch.setattr( - fwbs_variables, "i_blkt_inboard", dcllmassesparam.i_blkt_inboard - ) + monkeypatch.setattr(fwbs_variables, "i_blkt_inboard", dcllmassesparam.i_blkt_inboard) - monkeypatch.setattr( - fwbs_variables, "vol_blkt_total", dcllmassesparam.vol_blkt_total - ) + monkeypatch.setattr(fwbs_variables, "vol_blkt_total", dcllmassesparam.vol_blkt_total) monkeypatch.setattr( fwbs_variables, "vol_blkt_inboard", dcllmassesparam.vol_blkt_inboard @@ -880,9 +872,7 @@ def test_dcll_masses(dcllmassesparam, monkeypatch, dcll): fwbs_variables, "fw_armour_thickness", dcllmassesparam.fw_armour_thickness ) - monkeypatch.setattr( - fwbs_variables, "fw_armour_mass", dcllmassesparam.fw_armour_mass - ) + monkeypatch.setattr(fwbs_variables, "fw_armour_mass", dcllmassesparam.fw_armour_mass) monkeypatch.setattr(fwbs_variables, "vol_fw_total", dcllmassesparam.vol_fw_total) @@ -926,9 +916,7 @@ def test_dcll_masses(dcllmassesparam, monkeypatch, dcll): fwbs_variables, "i_blkt_dual_coolant", dcllmassesparam.i_blkt_dual_coolant ) - monkeypatch.setattr( - fwbs_variables, "den_fw_coolant", dcllmassesparam.den_fw_coolant - ) + monkeypatch.setattr(fwbs_variables, "den_fw_coolant", dcllmassesparam.den_fw_coolant) monkeypatch.setattr( fwbs_variables, "den_blkt_coolant", dcllmassesparam.den_blkt_coolant @@ -972,9 +960,7 @@ def test_dcll_masses(dcllmassesparam, monkeypatch, dcll): dcll_variables, "f_vol_mfbss_stl", dcllmassesparam.f_vol_mfbss_stl ) - monkeypatch.setattr( - dcll_variables, "f_vol_mfbss_he", dcllmassesparam.f_vol_mfbss_he - ) + monkeypatch.setattr(dcll_variables, "f_vol_mfbss_he", dcllmassesparam.f_vol_mfbss_he) monkeypatch.setattr( dcll_variables, "f_vol_mfbss_pbli", dcllmassesparam.f_vol_mfbss_pbli @@ -996,9 +982,7 @@ def test_dcll_masses(dcllmassesparam, monkeypatch, dcll): monkeypatch.setattr(dcll_variables, "wht_cer", dcllmassesparam.wht_cer) - monkeypatch.setattr( - dcll_variables, "wht_stl_struct", dcllmassesparam.wht_stl_struct - ) + monkeypatch.setattr(dcll_variables, "wht_stl_struct", dcllmassesparam.wht_stl_struct) monkeypatch.setattr( dcll_variables, "wht_cool_struct", dcllmassesparam.wht_cool_struct @@ -1010,13 +994,9 @@ def test_dcll_masses(dcllmassesparam, monkeypatch, dcll): monkeypatch.setattr(dcll_variables, "wht_mfbss_stl", dcllmassesparam.wht_mfbss_stl) - monkeypatch.setattr( - dcll_variables, "wht_mfbss_cool", dcllmassesparam.wht_mfbss_cool - ) + monkeypatch.setattr(dcll_variables, "wht_mfbss_cool", dcllmassesparam.wht_mfbss_cool) - monkeypatch.setattr( - dcll_variables, "wht_mfbss_pbli", dcllmassesparam.wht_mfbss_pbli - ) + monkeypatch.setattr(dcll_variables, "wht_mfbss_pbli", dcllmassesparam.wht_mfbss_pbli) monkeypatch.setattr(dcll_variables, "fwmass_stl", dcllmassesparam.fwmass_stl) diff --git a/tests/unit/test_fusion_reactions.py b/tests/unit/test_fusion_reactions.py index 4af562eca0..d41a7f6806 100644 --- a/tests/unit/test_fusion_reactions.py +++ b/tests/unit/test_fusion_reactions.py @@ -174,9 +174,9 @@ def test_set_fusion_powers(setfusionpowersparam, monkeypatch): ( pden_neutron_total_mw, - p_plasma_alpha_mw, + _p_plasma_alpha_mw, p_alpha_total_mw, - p_plasma_neutron_mw, + _p_plasma_neutron_mw, p_neutron_total_mw, p_non_alpha_charged_mw, pden_alpha_total_mw, @@ -218,9 +218,7 @@ def test_set_fusion_powers(setfusionpowersparam, monkeypatch): assert p_charged_particle_mw == pytest.approx( setfusionpowersparam.expected_charged_particle_power ) - assert p_fusion_total_mw == pytest.approx( - setfusionpowersparam.expected_fusion_power - ) + assert p_fusion_total_mw == pytest.approx(setfusionpowersparam.expected_fusion_power) @pytest.mark.parametrize( diff --git a/tests/unit/test_ife.py b/tests/unit/test_ife.py index ea9b87100b..19633850e8 100644 --- a/tests/unit/test_ife.py +++ b/tests/unit/test_ife.py @@ -1580,9 +1580,7 @@ def test_ifefbs(ifefbsparam, monkeypatch, ife): monkeypatch.setattr(fwbs_variables, "m_fw_total", ifefbsparam.m_fw_total) monkeypatch.setattr(fwbs_variables, "m_blkt_total", ifefbsparam.m_blkt_total) monkeypatch.setattr(fwbs_variables, "whtshld", ifefbsparam.whtshld) - monkeypatch.setattr( - fwbs_variables, "m_blkt_beryllium", ifefbsparam.m_blkt_beryllium - ) + monkeypatch.setattr(fwbs_variables, "m_blkt_beryllium", ifefbsparam.m_blkt_beryllium) monkeypatch.setattr(fwbs_variables, "m_blkt_vanadium", ifefbsparam.m_blkt_vanadium) monkeypatch.setattr( fwbs_variables, "m_blkt_steel_total", ifefbsparam.m_blkt_steel_total @@ -3147,9 +3145,7 @@ def test_ifepw2(ifepw2param, monkeypatch, ife): "p_plant_primary_heat_mw", ifepw2param.p_plant_primary_heat_mw, ) - monkeypatch.setattr( - heat_transport_variables, "eta_turbine", ifepw2param.eta_turbine - ) + monkeypatch.setattr(heat_transport_variables, "eta_turbine", ifepw2param.eta_turbine) monkeypatch.setattr(heat_transport_variables, "fgrosbop", ifepw2param.fgrosbop) monkeypatch.setattr( heat_transport_variables, diff --git a/tests/unit/test_input.py b/tests/unit/test_input.py index d0c894a30d..d354d626dc 100644 --- a/tests/unit/test_input.py +++ b/tests/unit/test_input.py @@ -1,3 +1,5 @@ +from pathlib import Path + import numpy as np import pytest @@ -9,8 +11,7 @@ def _create_input_file(directory, content: str): file_location = directory / "IN.DAT" - with open(file_location, "w") as f: - f.write(content) + Path(file_location).write_text(content) return str(file_location) diff --git a/tests/unit/test_mfile2dict.py b/tests/unit/test_mfile2dict.py index 68133a5790..0623bc4f4e 100644 --- a/tests/unit/test_mfile2dict.py +++ b/tests/unit/test_mfile2dict.py @@ -38,24 +38,24 @@ def test_value_read(read_mfile): def test_write_json(read_mfile, temporary_dir): - _json_f = os.path.join(temporary_dir, "2017_baseline.json") - read_mfile.write(_json_f) - assert os.path.exists(_json_f) - with open(_json_f) as file: + json_f = os.path.join(temporary_dir, "2017_baseline.json") + read_mfile.write(json_f) + assert os.path.exists(json_f) + with open(json_f) as file: assert json.load(file) def test_write_yaml(read_mfile, temporary_dir): - _yml_f = os.path.join(temporary_dir, "2017_baseline.yml") - read_mfile.write(_yml_f) - assert os.path.exists(_yml_f) - with open(_yml_f) as file: + pckl_f = os.path.join(temporary_dir, "2017_baseline.yml") + read_mfile.write(pckl_f) + assert os.path.exists(pckl_f) + with open(pckl_f) as file: assert yaml.load(file, Loader=yaml.BaseLoader) def test_write_pickle(read_mfile, temporary_dir): - _pckl_f = os.path.join(temporary_dir, "2017_baseline.pckl") - read_mfile.write(_pckl_f) - assert os.path.exists(_pckl_f) - with open(_pckl_f, "rb") as file: + pckl_f = os.path.join(temporary_dir, "2017_baseline.pckl") + read_mfile.write(pckl_f) + assert os.path.exists(pckl_f) + with open(pckl_f, "rb") as file: assert pickle.load(file) diff --git a/tests/unit/test_neoclassics.py b/tests/unit/test_neoclassics.py index 0ba50e60f3..8dcf933e6a 100644 --- a/tests/unit/test_neoclassics.py +++ b/tests/unit/test_neoclassics.py @@ -82,9 +82,7 @@ class InitNeoclassicsParam(NamedTuple): ti=5.7180500000000007, nd_plasma_electrons_vol_avg=2.07086e20, nd_plasma_fuel_ions_vol_avg=1.47415411616e20, - densities=np.array( - np.array((0, 0, 0, 0), order="F"), order="F" - ).transpose(), + densities=np.array(np.array((0, 0, 0, 0), order="F"), order="F").transpose(), temperatures=np.array( np.array((0, 0, 0, 0), order="F"), order="F" ).transpose(), diff --git a/tests/unit/test_pfcoil.py b/tests/unit/test_pfcoil.py index b5c2583ed8..498869cfed 100644 --- a/tests/unit/test_pfcoil.py +++ b/tests/unit/test_pfcoil.py @@ -2287,8 +2287,8 @@ def test_calculate_cs_turn_geometry_eu_demo_zero_corner( dz_cs_turn, dr_cs_turn, radius_cs_turn_cable_space, - dr_cs_turn_conduit, - dz_cs_turn_conduit, + _dr_cs_turn_conduit, + _dz_cs_turn_conduit, ) = cs_coil.calculate_cs_turn_geometry_eu_demo( a_cs_turn, f_dr_dz_cs_turn, radius_cs_turn_corners, f_a_cs_turn_steel ) @@ -2311,8 +2311,8 @@ def test_calculate_cs_turn_geometry_eu_demo_high_aspect( dz_cs_turn, dr_cs_turn, radius_cs_turn_cable_space, - dr_cs_turn_conduit, - dz_cs_turn_conduit, + _dr_cs_turn_conduit, + _dz_cs_turn_conduit, ) = cs_coil.calculate_cs_turn_geometry_eu_demo( a_cs_turn, f_dr_dz_cs_turn, radius_cs_turn_corners, f_a_cs_turn_steel ) @@ -2332,9 +2332,9 @@ def test_calculate_cs_turn_geometry_eu_demo_output_consistency( # Check that the sum of cable space and conduit thicknesses does not exceed half-width ( dz_cs_turn, - dr_cs_turn, + _dr_cs_turn, radius_cs_turn_cable_space, - dr_cs_turn_conduit, + _dr_cs_turn_conduit, dz_cs_turn_conduit, ) = cs_coil.calculate_cs_turn_geometry_eu_demo( a_cs_turn, f_dr_dz_cs_turn, radius_cs_turn_corners, f_a_cs_turn_steel diff --git a/tests/unit/test_physics.py b/tests/unit/test_physics.py index 4b8fa90aed..a262ba33c1 100644 --- a/tests/unit/test_physics.py +++ b/tests/unit/test_physics.py @@ -437,9 +437,7 @@ def test_bootstrap_fraction_sauter(bootstrapfractionsauterparam, monkeypatch, ph bootstrapfractionsauterparam.nd_plasma_ions_total_vol_avg, ) - monkeypatch.setattr( - physics_variables, "rminor", bootstrapfractionsauterparam.rminor - ) + monkeypatch.setattr(physics_variables, "rminor", bootstrapfractionsauterparam.rminor) monkeypatch.setattr( physics_variables, @@ -453,9 +451,7 @@ def test_bootstrap_fraction_sauter(bootstrapfractionsauterparam, monkeypatch, ph bootstrapfractionsauterparam.temp_plasma_ion_vol_avg_kev, ) - monkeypatch.setattr( - physics_variables, "triang", bootstrapfractionsauterparam.triang - ) + monkeypatch.setattr(physics_variables, "triang", bootstrapfractionsauterparam.triang) monkeypatch.setattr(physics_variables, "q0", bootstrapfractionsauterparam.q0) @@ -517,9 +513,7 @@ def test_bootstrap_fraction_sauter(bootstrapfractionsauterparam, monkeypatch, ph bootstrapfractionsauterparam.te, ) - monkeypatch.setattr( - physics_variables, "rmajor", bootstrapfractionsauterparam.rmajor - ) + monkeypatch.setattr(physics_variables, "rmajor", bootstrapfractionsauterparam.rmajor) monkeypatch.setattr(physics_variables, "q95", bootstrapfractionsauterparam.q95) @@ -549,9 +543,7 @@ def test_bootstrap_fraction_sauter(bootstrapfractionsauterparam, monkeypatch, ph bootstrapfractionsauterparam.nd_plasma_electron_on_axis, ) - monkeypatch.setattr( - physics_variables, "alphan", bootstrapfractionsauterparam.alphan - ) + monkeypatch.setattr(physics_variables, "alphan", bootstrapfractionsauterparam.alphan) monkeypatch.setattr( physics_variables, @@ -559,9 +551,7 @@ def test_bootstrap_fraction_sauter(bootstrapfractionsauterparam, monkeypatch, ph bootstrapfractionsauterparam.radius_plasma_pedestal_temp_norm, ) - monkeypatch.setattr( - physics_variables, "alphat", bootstrapfractionsauterparam.alphat - ) + monkeypatch.setattr(physics_variables, "alphat", bootstrapfractionsauterparam.alphat) physics.plasma_profile.run() bfs, _ = physics.bootstrap_fraction_sauter(physics.plasma_profile) @@ -1228,9 +1218,7 @@ def test_calculate_plasma_current(plasmacurrentparam, monkeypatch, physics): plasmacurrentparam.beta_norm_total, ) - monkeypatch.setattr( - physics_variables, "beta_total_vol_avg", plasmacurrentparam.beta - ) + monkeypatch.setattr(physics_variables, "beta_total_vol_avg", plasmacurrentparam.beta) b_plasma_poloidal_average, qstar, plasma_current = physics.calculate_plasma_current( i_plasma_current=plasmacurrentparam.i_plasma_current, @@ -2278,7 +2266,7 @@ def test_phyaux(phyauxparam, monkeypatch, physics): ( burnup, ntau, - nTtau, + _nTtau, figmer, fusrat, molflow_plasma_fuelling_required, @@ -2313,9 +2301,7 @@ def test_phyaux(phyauxparam, monkeypatch, physics): assert rndfuel == pytest.approx(phyauxparam.expected_rndfuel) - assert t_alpha_confinement == pytest.approx( - phyauxparam.expected_t_alpha_confinement - ) + assert t_alpha_confinement == pytest.approx(phyauxparam.expected_t_alpha_confinement) def test_rether(): @@ -2410,9 +2396,7 @@ def test_pohm(pohmparam, monkeypatch, physics): zeff=pohmparam.zeff, ) - assert pden_plasma_ohmic_mw == pytest.approx( - pohmparam.expected_pden_plasma_ohmic_mw - ) + assert pden_plasma_ohmic_mw == pytest.approx(pohmparam.expected_pden_plasma_ohmic_mw) assert p_plasma_ohmic_mw == pytest.approx(pohmparam.expected_p_plasma_ohmic_mw) @@ -3294,9 +3278,7 @@ def test_calculate_confinement_time(confinementtimeparam, monkeypatch, physics): :type monkeypatch: _pytest.monkeypatch.monkeypatch """ - monkeypatch.setattr( - physics_variables, "i_rad_loss", confinementtimeparam.i_rad_loss - ) + monkeypatch.setattr(physics_variables, "i_rad_loss", confinementtimeparam.i_rad_loss) monkeypatch.setattr(physics_variables, "tauee_in", confinementtimeparam.tauee_in) diff --git a/tests/unit/test_plasma_profiles.py b/tests/unit/test_plasma_profiles.py index 3d08682b0f..58c713eca2 100644 --- a/tests/unit/test_plasma_profiles.py +++ b/tests/unit/test_plasma_profiles.py @@ -482,9 +482,7 @@ def test_plasma_profiles(plasmaprofilesparam, monkeypatch): plasmaprofilesparam.expected_tin ) - assert physics_variables.alphap == pytest.approx( - plasmaprofilesparam.expected_alphap - ) + assert physics_variables.alphap == pytest.approx(plasmaprofilesparam.expected_alphap) assert physics_variables.temp_plasma_electron_on_axis_kev == pytest.approx( plasmaprofilesparam.expected_te0 diff --git a/tests/unit/test_power.py b/tests/unit/test_power.py index 506c6105e4..1e0e9c6d9f 100644 --- a/tests/unit/test_power.py +++ b/tests/unit/test_power.py @@ -1877,9 +1877,7 @@ def test_pfpwr(pfpwrparam, monkeypatch, power): power.pfpwr(output=False) - assert heat_transport_variables.peakmva == pytest.approx( - pfpwrparam.expected_peakmva - ) + assert heat_transport_variables.peakmva == pytest.approx(pfpwrparam.expected_peakmva) assert pf_power_variables.pfckts == pytest.approx(pfpwrparam.expected_pfckts) @@ -2743,9 +2741,7 @@ def test_power2(power2param, monkeypatch, power): power2param.p_coolant_pump_elec_total_mw, ) - monkeypatch.setattr( - heat_transport_variables, "eta_turbine", power2param.eta_turbine - ) + monkeypatch.setattr(heat_transport_variables, "eta_turbine", power2param.eta_turbine) monkeypatch.setattr( heat_transport_variables, diff --git a/tests/unit/test_pulse.py b/tests/unit/test_pulse.py index abbcfc9daf..a73fe0044e 100644 --- a/tests/unit/test_pulse.py +++ b/tests/unit/test_pulse.py @@ -1224,9 +1224,7 @@ def test_tohswg(tohswgparam, monkeypatch, pulse): pfcoil_variables, "c_pf_cs_coils_peak_ma", tohswgparam.c_pf_cs_coils_peak_ma ) - monkeypatch.setattr( - pfcoil_variables, "n_pf_coil_turns", tohswgparam.n_pf_coil_turns - ) + monkeypatch.setattr(pfcoil_variables, "n_pf_coil_turns", tohswgparam.n_pf_coil_turns) monkeypatch.setattr( pfcoil_variables, diff --git a/tests/unit/test_resistive_tf_coil.py b/tests/unit/test_resistive_tf_coil.py index e3b664ef0d..12a88496cb 100644 --- a/tests/unit/test_resistive_tf_coil.py +++ b/tests/unit/test_resistive_tf_coil.py @@ -723,9 +723,7 @@ def test_cpost(cpostparam, monkeypatch, resistive_tf_coil): :type monkeypatch: _pytest.monkeypatch.monkeypatch """ - monkeypatch.setattr( - build_variables, "z_tf_inside_half", cpostparam.z_tf_inside_half - ) + monkeypatch.setattr(build_variables, "z_tf_inside_half", cpostparam.z_tf_inside_half) ( a_cp_cool, diff --git a/tests/unit/test_sctfcoil.py b/tests/unit/test_sctfcoil.py index 993f476d14..d276f3f020 100644 --- a/tests/unit/test_sctfcoil.py +++ b/tests/unit/test_sctfcoil.py @@ -383,9 +383,7 @@ def test_supercon(superconparam, monkeypatch, sctfcoil): superconparam.b_tf_inboard_peak_with_ripple, ) - monkeypatch.setattr( - tfcoil_variables, "str_tf_con_res", superconparam.str_tf_con_res - ) + monkeypatch.setattr(tfcoil_variables, "str_tf_con_res", superconparam.str_tf_con_res) monkeypatch.setattr( tfcoil_variables, "b_crit_upper_nbti", superconparam.b_crit_upper_nbti @@ -1422,7 +1420,7 @@ def test_tf_cable_in_conduit_averaged_turn_geometry( t_conductor, radius_tf_turn_cable_space_corners, dx_tf_turn_cable_space_average, - a_tf_turn_cable_space_effective, + _a_tf_turn_cable_space_effective, f_a_tf_turn_cable_space_cooling, ) = sctfcoil.tf_cable_in_conduit_averaged_turn_geometry( j_tf_wp=tfaveragedturngeomparam.j_tf_wp, diff --git a/tests/unit/test_stellarator.py b/tests/unit/test_stellarator.py index 0ecf7a2814..51a8b0ecb9 100644 --- a/tests/unit/test_stellarator.py +++ b/tests/unit/test_stellarator.py @@ -3058,9 +3058,7 @@ def test_sctfcoil_nuclear_heating_iter90( p_tf_nuclear_heat_mw, ) = stellarator.sctfcoil_nuclear_heating_iter90() - assert coilhtmx == pytest.approx( - sctfcoilnuclearheatingiter90param.expected_coilhtmx - ) + assert coilhtmx == pytest.approx(sctfcoilnuclearheatingiter90param.expected_coilhtmx) assert dpacop == pytest.approx(sctfcoilnuclearheatingiter90param.expected_dpacop) assert htheci == pytest.approx(sctfcoilnuclearheatingiter90param.expected_htheci) assert nflutf == pytest.approx(sctfcoilnuclearheatingiter90param.expected_nflutf) diff --git a/tests/unit/test_superconductors.py b/tests/unit/test_superconductors.py index 018c05c0e6..a982a63811 100644 --- a/tests/unit/test_superconductors.py +++ b/tests/unit/test_superconductors.py @@ -221,9 +221,7 @@ def test_hijc_rebco(): pytest.approx( 1.5989918329615573e-05, rel=1e-3 ), # a_croco_strand_hastelloy - pytest.approx( - 1.8285645798205533e-05, rel=1e-3 - ), # a_croco_strand_solder + pytest.approx(1.8285645798205533e-05, rel=1e-3), # a_croco_strand_solder pytest.approx(5.329972776538525e-06, rel=1e-3), # a_croco_strand_rebco pytest.approx(7.85398e-5, rel=1e-3), # croco_strand_area pytest.approx(5.5556e-3, rel=1e-3), # dr_hts_tape diff --git a/tests/unit/test_tfcoil.py b/tests/unit/test_tfcoil.py index 007b6060df..1372534e45 100644 --- a/tests/unit/test_tfcoil.py +++ b/tests/unit/test_tfcoil.py @@ -11227,9 +11227,9 @@ def test_eyoung_t_nested_squares(eyoungtnestedsquaresparam, monkeypatch): """ ( - eyoung_j_out, - l_out, - poisson_j_perp_out, + _eyoung_j_out, + _l_out, + _poisson_j_perp_out, eyoung_stiffest, ) = tfcoil_module.eyoung_t_nested_squares( n=eyoungtnestedsquaresparam.n, @@ -11306,9 +11306,7 @@ def test_eyoung_series(eyoungseriesparam, monkeypatch): assert l_3 == pytest.approx(eyoungseriesparam.expected_l_3) - assert poisson_j_perp_3 == pytest.approx( - eyoungseriesparam.expected_poisson_j_perp_3 - ) + assert poisson_j_perp_3 == pytest.approx(eyoungseriesparam.expected_poisson_j_perp_3) @pytest.mark.parametrize( diff --git a/tests/unit/test_water_usage.py b/tests/unit/test_water_usage.py index 91e167379b..27a5a6b4a1 100644 --- a/tests/unit/test_water_usage.py +++ b/tests/unit/test_water_usage.py @@ -84,16 +84,12 @@ class CoolingTowersParam(NamedTuple): ) def test_cooling_towers(coolingtowersparam, monkeypatch, water_use): monkeypatch.setattr(water_usage_variables, "airtemp", coolingtowersparam.airtemp) - monkeypatch.setattr( - water_usage_variables, "waterdens", coolingtowersparam.waterdens - ) + monkeypatch.setattr(water_usage_variables, "waterdens", coolingtowersparam.waterdens) monkeypatch.setattr( water_usage_variables, "latentheat", coolingtowersparam.latentheat ) monkeypatch.setattr(water_usage_variables, "volheat", coolingtowersparam.volheat) - monkeypatch.setattr( - water_usage_variables, "evapratio", coolingtowersparam.evapratio - ) + monkeypatch.setattr(water_usage_variables, "evapratio", coolingtowersparam.evapratio) monkeypatch.setattr(water_usage_variables, "evapvol", coolingtowersparam.evapvol) monkeypatch.setattr( water_usage_variables, "energypervol", coolingtowersparam.energypervol diff --git a/tracking/tracking_data.py b/tracking/tracking_data.py index 93c0c569e9..02889eb708 100644 --- a/tracking/tracking_data.py +++ b/tracking/tracking_data.py @@ -38,6 +38,7 @@ import logging import math import pathlib +from pathlib import Path from typing import ClassVar import git @@ -522,8 +523,7 @@ def write_tracking_html_file(database, output, tracking_variables_file): tracking_html = plot_tracking_data(database, tracked_variables) - with open(output, "w") as f: - f.write(tracking_html) + Path(output).write_text(tracking_html) def track_entrypoint(arguments):