Git Product home page Git Product logo

fusion_neutronics_workflow's People

Contributors

remdelaportemathurin avatar shimwell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

fusion_neutronics_workflow's Issues

Generating geometry files and outputs on release

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

# not currently working due to outdated dockerfiles
# upload_workflow_output_files_to_release:
# needs: build_and_push_release
# runs-on: ubuntu-latest
# name: 'create_files'
# container:
# image: ghcr.io/fusion-energy/fusion-neutronics-workflow
# steps:
# - uses: actions/checkout@v2
# - name: run example_01_single_volume_cell_tally
# run: |
# cd example_01_single_volume_cell_tally
# python 1_create_cad_and_convert_to_dagmc.py
# python 2_run_neutronics_simulation.py
# - name: run example_02_multi_volume_cell_tally
# run: |
# cd example_02_multi_volume_cell_tally
# python 1_create_cad_and_convert_to_dagmc.py
# python 2_run_neutronics_simulation.py
# - name: run example_04_multi_volume_regular_mesh_tally
# run: |
# cd example_04_multi_volume_regular_mesh_tally
# python 1_create_cad_and_convert_to_dagmc.py
# python 2_run_neutronics_simulation.py
# - name: run example_05_3D_unstructured_mesh_tally
# run: |
# cd example_05_3D_unstructured_mesh_tally
# python 1_create_cad_and_convert_to_dagmc.py
# mbconvert stage_2_output/unstructured_mesh.cub stage_2_output/unstructured_mesh.h5m
# python 2_run_neutronics_simulation.py
# - name: Upload artifact for CI
# uses: actions/upload-artifact@v2
# with:
# name: output_files_produced.zip
# path: output_files_produced.zip
# if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
# - name: compress files
# run: |
# apt-get -y update
# apt-get -y install zip
# zip -r output_files_produced.zip example_*
# - name: Upload files into the release
# uses: svenstaro/upload-release-action@v2
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# file: output_files_produced.zip
# asset_name: output_files_produced.zip
# tag: ${{ github.ref }}

adding a csg / stl / stp simulation comparison to tests

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

feature request - VR

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.

can't import cadquery

How to reproduce the issue:

  1. Run:
docker run -it ghcr.io/fusion-energy/fusion-neutronics-workflow

using the latest tag

  1. Navigate to the examples folder:
cd examples/example_01_single_volume_cell_tally/
  1. Run
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)

Can't run any example

Steps to reproduce:

  1. Pull the latest docker image docker pull ghcr.io/fusion-energy/fusion-neutronics-workflow
  2. Run a new container docker run -it -v $PWD:/local_dir ghcr.io/fusion-energy/fusion-neutronics-workflow
  3. Navigate to folder cd example_01_single_volume_cell_tally
  4. Run step 1 python3 1_create_cad_and_convert_to_dagmc.py
    Produces:
Saved file as  steel.stl
  1. Run neutronics step python3 2_run_neutronics_simulation.py
    Produces:
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')

Adding an enviroment.yml file for version pins

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

pip in the container?

I know it's not essential but it would be useful to have pip in the fusion-neutronics-workflow container :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.