Skip to content

Commit

Permalink
✨ 2D Neutronics feature branch (#2656)
Browse files Browse the repository at this point in the history
* 2D Neutronics module  (#2344)

* Initial commit to repository

* Create basic README.md

* Editing README.md

* Code styling: Black, isort and whitespace/trailing new lines (#1)

* blacken and isort

* whitespace and new lines

* Rearrage and refactor (#2)

* Adding plasma source, DCLL and WCLL. Material defintions and geometries still need tweaking.

* Changing from toroidal first wall profile to match points and adding extra source geometry plots.

* Adding source code for parametric plasma source

* Adjusting point too close to plasma.

* Minor format tidy up. Moving function.

* Passing geometry_variables to get_fw_points

* Update make_materials.py

Changing tungsten isotopes and tidying export_materials()

* Update make_materials.py

W isotopes corrected.

* Made most of it OOP, especially the summary, so that the data can be recalled.

* Added vscode into gitignore

* Finished reformatting the Summary object so now it prints the entire run properly. Not documented yet, and kwargs not passed on yet.

* Finished some reformatting. Todo list is at the top.

* Some work done on load_fw_points, but incomplete. TODO list updated.

* Added some documentations, but found a lot of magic numbers and 'things that don't belong in this module'. I'll deal with them later.

* Changed the ordering and naming of the arguments to make_geometry in make_geometry.py, and added some docstring.

* Fxied the types of Blankets available using BlanketType in make_materials.py.

* Fixed the naming for cells in quick_tbr_heating.py - renamed them to cells_and_cell_lists

* Updated the todo list

* Cleaned up create_tallies, and in the process, created MaterialsLibrary in make_materials.py so that it becomes modular enough for testing.

* Formatted the 'print_df' booleans away into a decorator - can change into printing to bluemira log later.

* Added documentations to the rest of the important classes.

* Updated todo list

* one line change to make pandas print more prettily, before merge commit

* moved all relevant files into the neutronics directory.

* Moved files from the 2d-neutronics repo to here.

* restored comment style fix

* moved the neutronics files to the correct directory.

* changed the import relative path

* relocated files to the correct directory

* changed the import path

* minor changes before complete overhaul (the latter is for adhering to bluemira code style)

* moved some constants to constants.py

* Finished one task: placed the relevant constants and conversion units into constants.py

* updated to-do list

* Further broke down the make_materials.py file into materials_definition.py file

* Refactored all of materials.

* updated .gitignore

* Moved the results formatting functions to a separate file

* removed unused file

* Improved styling

* Broke functions down into appropriate modules

* Split into appropriate modules

* Added typing information

* Updated the import diagram to reflect the import relationships between modules.

* Fixed all fixable formatting issues according to flake8

* Fixed all flake8 messages!

* installs script

* cleaned up script

* added complete apt install deps

* Updated install script, removed pps_api

* Updated to-do list, improved result presentation workflow

* .npy requires conversion to BluemiraWire

* ➕ Use ninja and install libopenmpi-dev

* ➕ Add openmc to conda

* ✨ Start using wire as input

* 🚨 Some ruff fixes

* 🎨 Move ifmain to example

* 🚚 Move npy

* 🎨 Fix example

* 🎨 Get constants from base

* 🎨 Fix imports

* 🚨 Some ruff fixes

* added openmc version to install script, added pps-isotropic package import to quick tbr

* removed my path from config

* 🎨 Cleanup printing

* 🎨 Unit fix

* 🎨 Unit fix2

* 🎨 Unit fix3

* 🎨 Use openmc enum

* Preparing for unit changes

* quick commit before rebase, units half-done

* 🙈 Remove noise

* 🔥 Remove so file

* Removed the not-sensible default constants and placed thme into neutronics.ex.py instead.

* Added TODO comment

* 🎨 Cell filter cleanup

* 🎨 Cleanup tallies

* Changed all units

* minor fix of import statement

* Monkey patched successfully

* monkeypatched successfully, and separated plasma geometry variables from tokamak geometry variables. This is the commit BEFORE applying the DataclassUnitConverter pattern.

* Minor update to add comments.

* Removed the duplicate codes inside params.py. This is the commit AFTER applying the DataclassUnitConverter pattern.

* Bug fix - missing 'self,' argument fixed.

* Updated todos

* 🎨 Change raw_uc percent use and runtime var

* 🚧 Make geometry dataclass refactor

* 🚧 Slight cleanup of params

* 🚨 Ignores

* 📝 Docs

* 📝 Fixes and docs

* 📝 Fix documentation build

* Update neutronics.ex.py

* Update pyproject.toml

* 🐛 Fix volume calculation

* 🎨 Cleanup vol calc

* 🚨 Fix black

* 🎨 Small fixes

* 🚚 Move quick tbr to neutronics_axisymmetric

* 🎨 Add stochastic volume to output results

* Added comments on why only two quantities are excluded in the conversion

* pps-isotropic's API changed, making appropriate changes here to maintain usability

* Added markdown docs on neutronics.ex.py

* 💩 Hack for old version of openmc

* 👥 Add contributors

---------

Co-authored-by: jamesnha <[email protected]>
Co-authored-by: je-cook <[email protected]>
Co-authored-by: Oliver Funk <[email protected]>

* ✨ OpenMC data downloader (#2618)

* ✨ OpenMC data downloader

* 🎨 Parse known args

* 🎨 Ifmain

* 🎨 Rename file

* 🎨 Write them all then delete all

* 🐛 Overindent

* 🚨 Cleanup and linting

* 🐛 No output

* 🐛 Fix neutronics json location

* 🐛 Hack to force data into a given directory

* 🎨 Spelling

* 🏷️ Typing fix

* 🚨 Ruff fixes

* 🙈 Add to gitignore

* Minor error fixes to the outputted tables (#2689)

* Fixed unit conversion error in photon heat flux; and turned off Bremsstrahlung heating by default

* Undo accidental indent

* Kept all statepoint files' units as openmc as cgs, so that the conversion to SI is done purely in python. Fixed misinterpretation of photon flux.

* added comments to explain tally score choice.

* Minor bug fix to pass code quality checks

* 🚨 Ruff fixes

* first move to BM materials, lots of refactoring needed but the example runs

* 🎨 Basic cleanup

* 🎨 Dataclassify

* 🐛 Undo Be12Ti density change

* 💡 Minor fixes

* 📄 Copyright fixes after rebase

* ✨ Allow '*' to extract all XS data

* ⬆️ Openmc 0.13.3

* temperature docstring.

* removed rounding

* calculate the DT energy more accurately using plasma physics.

* Simplified code to use n_DT_reactions instead.

* 1. extracted (major_r, minor_r, elong, triang) into a different class than TokamakGeometry, and named this class PlasmaGeometry. 2. Removed the 'CGS' and 'PPS' from the 3 classes in params.py, and instead appended their baseclasses with 'Base', so that it becomes clearer that these dataclasses store SI units unless the .csg or .plasma_physics_units property is accessed.

* (minor bug fix)

* Updated the Shafranov shift description.

* 🚨 Fix linter

* Minor updates to docstrings

* 🚨 Ruff & python3.10 fixes

* Increase CSG speed without compromising on flexibility (#3079)

* :Changed params.py according to Matti's suggestion

* Made temporary script

* Added json data to be loaded as test case bluemirawires

* Added post_init checks.

* Created basic script to translate from existing dataclass TokamakGeometry (make_csg)

* WIP: making pre-cell.

* WIP: making pre-cell.

* Bodging serializing issue - fix later.

* Deleted failed files.

* Test script in attempt to replace the magic numbers/magic procedure to something more generalizable

* quick commit

* Script to load the divertor.

* Added capability to automatically slice up the blanket according to the first wall panels

* Updated script for creating neutronics csg

* extended the functionality of signed distance to check points as well.

* Added function based on signed_distance to check for overlaps.

* Add tolerance to account for low sampling rate/ float errors.

* Adding module to optimally slice the neutronics model.

* Updated module that chooses better surfaces for faster neutronics runs.

* Made the volume optimization converge.

* Made a better approximation of the reactor. Added tools necessary to make such approximation

* Added better documentations. Formatting.

* Made a very rigorous structure to create openmc.Cells.

* removed unused code

* Updated test case

* Half-working state

* Finally finished the blanket bug fix.

* Updated docstrings

* Updated equations

* Updated comment

* Interited from collections.abc.Sequence to avoid having to make def __iter__().

* Cleaned up excess code

* minor changes to naming and docstring

* Updated the run modes into context managers.

* Enforced self.setup() to be ran before self.run() in the contextmanagers.

* Added ability to slice divertor wire

* Variable renaming

* Removed redundant checks

* Improved typing (Iterables vs Sequence), and added classes to prepare for tallying.

* Added tallying functionality

* Developing divertor cells automatic conversion into pre-cells...

* Added type hints for return types.

* Fixed import

* Successfully exported into DivertorPreCellArray.

* Updated script correspondingly

* split up WireInfo etc. into its own file.

* Made make_divertor_pre_cell_array more robust (able to straighten out the cell walls better before passing onto DivertorPreCell).

* Typing and docstring improvement

* Added function to flip a direction vector if it is pointing the wrong way; Moved plane functionalities to geometry/plane.py

* Removed plane creation functionality (migrated to bluemira.geometry.plane)

* Minor change to type hinting in make_csg.py

* Minor changes to type hints in radial_wall.py

* Slight change to variable name

* Added plan to make the divertor slicing more robust.

* Moved the warning to an appropriate place

* Improved the interior_wire_offset method

* Fixed minor mistake in direction

* Working version: produces pre-cell arrays for both divertor and blanket

* Pointed the chord in the correct direction again

* Removed unused data loading files.

* Improved file structure so each class has separate responsibility. Surfaces that aren't shared among different BlanketCell stacks won't be created in BlanketCellArray.

* Minor bug fixes related to types and WireInfo

* Moved constants into constants.py

* Docstring updates

* Simplified boolean expression; made plasma cell.

* Deleted unused statement.

* updated test script to plot better.

* Named file more sensibly.

* Fixed some ID control issues

* docstring rearrangement

* Fixed up the get_all_hollow_merged_cells method so the test script won't have to write something as long to plot the overall-cells.

* Fixed the thickness issue - now instead we have absolute thickness.

* Got as far as getting some segfaults out of openmc.

* Finally working. Tallies need fixing

* Fixed floating point issue

* Added missing conversion function

* Changed thickness.

* Modified to allow for a variable number of batches.

* Delete some of the obsolete classes

* Updated TODO tags in test script.

* Updated TODOs

* Added missing method back in

* Updated documentations slightly to make it more readable.

* Updated docstring to conform usage of anti- vs counter-

* Ensured backward (neutronics.ex.py) compatibility

* Calculated volumes without relying on openmc.

* Added function to support volume calculation of the openmc.Cell's .volumes.

* Optimized volume calculation (commented them out where they're not needed)

* Working version.

* Added TODO on reducing the number of negated regions.

* ruff fixes

* Some updates to how surfaces are get

* fixed ONE TODO tag.

* Updated zip strict = True almost everywhere, pairwise where applicable.

* Cleaned up code slightly at make_csg

* We can now control the thickness of the central solenoid from parameter frame directly.

* Attempting to use vacuum vessel wire as well.

* Further attempt at incorporating the vacuum vessel interior curve into the pre-cells

* VV now successfully sandwhiched between the two curvesgit add .

* Minor formatting updates

* Finished porting over the materials library

* Cleaned out all low-lying fruit TODO tags

* Made note about convexity.

* Neutronics Solver interface (#3231)

* 🚧 OpenMC designer

* 🚧 Working designer

* ✨ Openmc solver

* ✨ Fixup from upstream

* 🚚 Move stuff

* Neutronics old code removal and architectural adjustments (#3232)

* 🌐 Bye Z

* ♻️ Initial cleanup

* ♻️ More cleanup

* ♻️ More cleanup

* ♻️ More cleanup

* 🔥 Destroying Vertices pt1

* 🔥 Destroying Vertices pt2

* ♻️ More cleanup

* 🔥 Remove Sequence inheritance

* 🎨 Types

* 🚨 Remove ruff ignores

* ♻️ More cleanup

* ♻️ Remove global hangar variable

* ♻️ More cleanup

* ♻️ More cleanup

* 🚨 More cleanup

* 📝 Docs cleanup

* 📝 Docs cleanup

* 🐛 Fix double counting of divertor material

* 🐛 Fix 0 volumetric heating

* 🎨 Convert SingleNullTokamak to a function

* 🏷️ Typing and general cleanup

* ♻️ Cleanup dimensions

* 🎨 Order functions

* ✨ Split of Neutroics pre cell csg and openmc running (#3243)

* 🎨 Neutronics PreCell / openmc separation

* 🚚 Move stuff about

* 🎨 Reduce surface that requires openmc

* 🚚 Move materials about

* 🎨 Initial material rearrangement

* 🌐 More internationalisation

* ♻️ Neutronics material movement

* 🎨 More materials stuff

* ♻️ Cleanup

* 🎨 Materials cleanup

* Neutronics EUDEMO integration (#3239)

* inital go

* Saving

* hard part done

* pass vals to Solver

* Updated WireInfoList so it doesn't use horrible mixed types.

* expected div wire

* Fixed the issue of 'sometimes misordering wires', and used recursion to shorted the break_wire_into_convex_chunks method for better readability with no loss in speed.

* 🚧 Tmp get it working

* Fixed the .reverse() method, which didn't flip the sign of the tangent.

* Improved plotting in plot_2d and plot_surfaces (mainly used for debugging)

* 🐛 Fix inner panel point

* 🔥 Reduce interface

* ♻️ More cleanup

* 🎨 More cleanup

* 🎨 Remove while loop from break wire into convex chunks

* 🎨 Reduce interface

* 🎨 More cleanup

* 🔥 Remove readme

* 🐛 Typing and divertor start point fix

* 🎨 Fix extra error and cleanup some reactor mechanics

* 🎨 Improve file save location

* 🎨 Only pass in ivcshapes not divertor

* 🎨 Feed in correct blanket cut point

* 🎨 Cleanup runmode

* Fixed leaking plasma void.

* 🎨 Cleanup inputs

* Added the the half_bounding_box function to get the minimum positive r.

* 🔥 Remove old data files

* ♻️ Run through cleanup

* Fixed the final overlap issue at the bottom of the divertor

* 🚚 Move some geometry functions to geometry

* 🐛 Fix tfcoil size

* 🐛 Fix blanket test

* 🚨 Linter fix

* 🚚 Move some things about

* 🚚 Move openmc to codes

* 🎨 Isolate eudemo from openmc

* 🚚 Move neutronics under radiation_transport

* Added volume tag

* Added checks to ensure convexity.

* Forced the pair of first and last pre-cells in the blanket to mate with the first and last pre-cell pair of divertor.

* Fixed the convexity proble; but a different issue arose: floating point precision of the exterior points are all wrong.

* Removed debug statement

* Added tolerances back in

* Floating point precision issue FIXEDgit add make_pre_cell.py openmc/make_csg.py  Now we can use tighter tolerances.

* 🔥 Remove old examples

* integrated rad shield into the neutronics run

* move set_volumes to CellStage

---------

Co-authored-by: ocean <[email protected]>
Co-authored-by: james <[email protected]>

* 🎨 Radiation shield initial material

* 📝 Remove neutronics example reference

* 📝 Add notice for use and update environment

* Improve tallies (#3275)

* 🎨 Allow custom filter for tallies

* 🐛 Fix tally function for eudemo run

* 🐛 Fix remove reindex to avoid nans

* Changed tallies to get the required data (need to multiply by appropriate constants in output.py to finish the job)

* minor bug fix (missed a variable)

* 🐛 Fix filter creation

* 🐛 Fix output for temporary output

---------

Co-authored-by: ocean <[email protected]>

* ⬆️ Upgrade openmc

---------

Co-authored-by: Ocean <[email protected]>
Co-authored-by: jamesnha <[email protected]>
Co-authored-by: Oliver Funk <[email protected]>
Co-authored-by: Oliver Funk <[email protected]>
  • Loading branch information
5 people authored May 14, 2024
1 parent 66e83e1 commit 6d64073
Show file tree
Hide file tree
Showing 48 changed files with 8,439 additions and 42 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,10 @@ autoapi
generated_data
!generated_data/naughty_geometry/README.md
tests/bluemira/test_generated_data
cross_section_data
plasmod_*.dat

# openmc outputs
*.svg
*.xml
*.out
8 changes: 8 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ authors:
given-names: G. A.
affiliation: United Kingdom Atomic Energy Authority, Culham Science Centre, Abingdon, Oxfordshire OX14 3DB, United Kingdom

- family-names: Hagues
given-names: J.
affiliation: United Kingdom Atomic Energy Authority, Culham Science Centre, Abingdon, Oxfordshire OX14 3DB, United Kingdom

- family-names: Humphrey
given-names: L.
affiliation: United Kingdom Atomic Energy Authority, Culham Science Centre, Abingdon, Oxfordshire OX14 3DB, United Kingdom
Expand Down Expand Up @@ -88,6 +92,10 @@ authors:
given-names: D.
affiliation: United Kingdom Atomic Energy Authority, Culham Science Centre, Abingdon, Oxfordshire OX14 3DB, United Kingdom

- family-names: Wong
given-names: O.
affiliation: United Kingdom Atomic Energy Authority, Culham Science Centre, Abingdon, Oxfordshire OX14 3DB, United Kingdom

message: "If you use this software, please cite it using these references."
references:
- type: article
Expand Down
10 changes: 10 additions & 0 deletions bluemira/codes/openmc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: 2021-present M. Coleman, J. Cook, F. Franza
# SPDX-FileCopyrightText: 2021-present I.A. Maione, S. McIntosh
# SPDX-FileCopyrightText: 2021-present J. Morris, D. Short
#
# SPDX-License-Identifier: LGPL-2.1-or-later
"""OpenMC interface"""

from bluemira.codes.openmc.solver import OpenMCNeutronicsSolver as Solver

__all__ = ["Solver"]
Loading

0 comments on commit 6d64073

Please sign in to comment.