fusion-energy / fusion_neutronics_workflow Goto Github PK
View Code? Open in Web Editor NEWCombines open source packages to produce an automated fusion specific neutronics workflow
License: MIT License
Combines open source packages to produce an automated fusion specific neutronics workflow
License: MIT License
To avoid swamping the repository with stp, stl, h5, h5m files it would be ideal if they could all be generated on a release and added to the tar.gz file made on release.
The CAD geometry could be made (stp, stl) converted to neutronics (h5m) and simulated mading (h5) output files.
I've had a quick go at this using a github action but couldn't get it to work
The action is currently commented out and I hope to come back to this at some point
fusion_neutronics_workflow/.github/workflows/docker_publish.yml
Lines 74 to 131 in 4b0823a
I pulled the latest docker image and it seems like cadquery isn't in it?
Did something go wrong with the build?
Test the same 3d model made with 3 different methods
Perhaps this code can be used
# # move to neutronics_workflow
# class TestSimulationResultsVsCsg(unittest.TestCase):
# """Makes a geometry in the paramak and in CSG geometry, simulates and
# compares the results"""
# def simulate_cylinder_cask_csg(
# self, material, source, height, outer_radius, thickness, batches, particles
# ):
# """Makes a CSG cask geometry runs a simulation and returns the result"""
# mats = openmc.Materials([material])
# outer_cylinder = openmc.ZCylinder(r=outer_radius)
# inner_cylinder = openmc.ZCylinder(r=outer_radius - thickness)
# inner_top = openmc.ZPlane(z0=height * 0.5)
# inner_bottom = openmc.ZPlane(z0=-height * 0.5)
# outer_top = openmc.ZPlane(z0=(height * 0.5) + thickness)
# outer_bottom = openmc.ZPlane(z0=(-height * 0.5) - thickness)
# sphere_1 = openmc.Sphere(r=100, boundary_type="vacuum")
# cylinder_region = -outer_cylinder & +inner_cylinder & -inner_top & +inner_bottom
# cylinder_cell = openmc.Cell(region=cylinder_region)
# cylinder_cell.fill = material
# top_cap_region = -outer_top & +inner_top & -outer_cylinder
# top_cap_cell = openmc.Cell(region=top_cap_region)
# top_cap_cell.fill = material
# bottom_cap_region = +outer_bottom & -inner_bottom & -outer_cylinder
# bottom_cap_cell = openmc.Cell(region=bottom_cap_region)
# bottom_cap_cell.fill = material
# inner_void_region = -inner_cylinder & -inner_top & +inner_bottom
# inner_void_cell = openmc.Cell(region=inner_void_region)
# # sphere 1 region is below -sphere_1 and not (~) in the other regions
# sphere_1_region = -sphere_1
# sphere_1_cell = openmc.Cell(
# region=sphere_1_region
# & ~bottom_cap_region
# & ~top_cap_region
# & ~cylinder_region
# & ~inner_void_region
# )
# universe = openmc.Universe(
# cells=[
# inner_void_cell,
# cylinder_cell,
# top_cap_cell,
# bottom_cap_cell,
# sphere_1_cell,
# ]
# )
# geom = openmc.Geometry(universe)
# # Instantiate a Settings object
# sett = openmc.Settings()
# sett.batches = batches
# sett.particles = particles
# sett.inactive = 0
# sett.run_mode = "fixed source"
# sett.photon_transport = True
# sett.source = source
# cell_filter = openmc.CellFilter([cylinder_cell, top_cap_cell, bottom_cap_cell])
# tally = openmc.Tally(name="csg_heating")
# tally.filters = [cell_filter]
# tally.scores = ["heating"]
# tallies = openmc.Tallies()
# tallies.append(tally)
# model = openmc.model.Model(geom, mats, sett, tallies)
# sp_filename = model.run()
# # open the results file
# results = openmc.StatePoint(sp_filename)
# # access the tally using pandas dataframes
# tally = results.get_tally(name="csg_heating")
# tally_df = tally.get_pandas_dataframe()
# return tally_df["mean"].sum()
# def simulate_cylinder_cask_cad(
# self, material, source, height, outer_radius, thickness, batches, particles
# ):
# """Makes a CAD cask geometry runs a simulation and returns the result"""
# top_cap_cell = paramak.RotateStraightShape(
# stp_filename="top_cap_cell.stp",
# material_tag="test_mat",
# points=[
# (outer_radius, height * 0.5),
# (outer_radius, (height * 0.5) + thickness),
# (0, (height * 0.5) + thickness),
# (0, height * 0.5),
# ],
# )
# bottom_cap_cell = paramak.RotateStraightShape(
# stp_filename="bottom_cap_cell.stp",
# material_tag="test_mat",
# points=[
# (outer_radius, -height * 0.5),
# (outer_radius, (-height * 0.5) - thickness),
# (0, (-height * 0.5) - thickness),
# (0, -height * 0.5),
# ],
# )
# cylinder_cell = paramak.CenterColumnShieldCylinder(
# height=height,
# inner_radius=outer_radius - thickness,
# outer_radius=outer_radius,
# material_tag="test_mat",
# )
# my_geometry = paramak.Reactor(
# shapes_and_components=[cylinder_cell, bottom_cap_cell, top_cap_cell],
# method="pymoab",
# )
# my_model = openmc_dagmc_wrapper.NeutronicsModel(
# h5m_filename=my_geometry.export_h5m(),
# source=source,
# simulation_batches=batches,
# simulation_particles_per_batch=particles,
# materials={"test_mat": material},
# cell_tallies=["heating"],
# )
# my_model.simulate()
# # scaled from MeV to eV
# return (
# my_model.results["test_mat_heating"]["MeV per source particle"]["result"]
# * 1e6
# )
# def test_cylinder_cask(self):
# """Runs the same source and material with CAD and CSG geoemtry"""
# height = 100
# outer_radius = 50
# thickness = 10
# batches = 10
# particles = 500
# test_material = openmc.Material(name="test_material")
# test_material.set_density("g/cm3", 7.75)
# test_material.add_element("Fe", 0.95, percent_type="wo")
# test_material.add_element("C", 0.05, percent_type="wo")
# source = openmc.Source()
# source.space = openmc.stats.Point((0, 0, 0))
# source.angle = openmc.stats.Isotropic()
# source.energy = openmc.stats.Discrete([14e6], [1.0])
# csg_result = self.simulate_cylinder_cask_csg(
# test_material, source, height, outer_radius, thickness, batches, particles
# )
# cad_result = self.simulate_cylinder_cask_cad(
# test_material, source, height, outer_radius, thickness, batches, particles
# )
# assert pytest.approx(csg_result, rel=0.02) == cad_result
Some excellent principles for Reproducible pipelines that should be applied where possible to this workflow
In this very nice looking workflow are there plans to add any automated variance reduction? Magic? You could imagine a check on the tally to determine if passing some metric and if not running some automated VR routines, depending on if global or target based VR is required. Considering OpenMC VR is only just in most recent versions, I guess this might needs OpenMC developments as well.
How to reproduce the issue:
docker run -it ghcr.io/fusion-energy/fusion-neutronics-workflow
using the latest tag
cd examples/example_01_single_volume_cell_tally/
python 1_create_cad_and_convert_to_dagmc.py
This produces:
Traceback (most recent call last):
File "1_create_cad_and_convert_to_dagmc.py", line 4, in <module>
import paramak
File "/opt/conda/lib/python3.8/site-packages/paramak/__init__.py", line 14, in <module>
from .shape import Shape
File "/opt/conda/lib/python3.8/site-packages/paramak/shape.py", line 10, in <module>
import cadquery as cq
File "/opt/conda/lib/python3.8/site-packages/cadquery/__init__.py", line 14, in <module>
from .occ_impl import exporters
File "/opt/conda/lib/python3.8/site-packages/cadquery/occ_impl/exporters/__init__.py", line 10, in <module>
from ...cq import Workplane
File "/opt/conda/lib/python3.8/site-packages/cadquery/cq.py", line 54, in <module>
from .selectors import (
File "/opt/conda/lib/python3.8/site-packages/cadquery/selectors.py", line 23, in <module>
from pyparsing import (
ImportError: cannot import name 'upcaseTokens' from 'pyparsing' (/opt/conda/lib/python3.8/site-packages/pyparsing/__init__.py)
Example for is not a regular mesh tally example but an unstructured mesh
Steps to reproduce:
docker pull ghcr.io/fusion-energy/fusion-neutronics-workflow
docker run -it -v $PWD:/local_dir ghcr.io/fusion-energy/fusion-neutronics-workflow
cd example_01_single_volume_cell_tally
python3 1_create_cad_and_convert_to_dagmc.py
Saved file as steel.stl
python3 2_run_neutronics_simulation.py
Using the DOUBLE-DOWN interface to Embree.
Loading file dagmc.h5m
Initializing the GeomQueryTool...
Using faceting tolerance: 1.81323e-317
Building acceleration data structures...
Illegal instruction
Same is true for all the examples. I simply cannot run anything ๐ข
I've investigated it a bit and it seems to be related to the call
odw.Geometry(h5m_filename='dagmc.h5m')
Currently the only tag available for the docker image is latest.
Would it be possible to have tags for each release?
I noticed that the old requirements file has gone and we are pointing to the latest releases of everything.
I guess this is partly because the requirments couldn't incorporate conda package versions
Perhaps we should move to use enviroment files like I have for this repo
https://github.com/shimwell/cad-to-dagmc-to-openmc-example/blob/develop/environment_cad.yml
https://github.com/shimwell/cad-to-dagmc-to-openmc-example/blob/develop/environment_neutronics.yml
These can be installed with conda env create -f environment_cad.yml
and conda env create -f environment_neutronics.yml
This variable doesn't seem to be used anywhere. How can we plot the tally with the correct unit?
I know it's not essential but it would be useful to have pip in the fusion-neutronics-workflow container :-)
error message is ```cannot reshape array of size 1 into shape (400,400)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.