Skip to content

Commit

Permalink
more comments on mesh sources
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Apr 9, 2024
1 parent 588560c commit 4286624
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
36 changes: 13 additions & 23 deletions tasks/task_04_make_sources/6_unstructured_mesh_spatial_source.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
# This example makes use of a DAGMC unstructured tet mesh to produce a source with
# a MeshSpatial distribution.

from cad_to_dagmc import CadToDagmc

my_model = CadToDagmc()

my_model.add_stp_file('plasma_simplified_180.step')
# import gmsh
# gmsh.initialize()

gmshm = my_model.export_unstructured_mesh_file(filename="umesh.h5m", max_mesh_size=100, min_mesh_size=10)

# perhaps trimesh can get volumes
# import trimesh
# trimesh_mesh_object = trimesh.load_mesh('umesh.h5m')
# vertices = trimesh_mesh_object.vertices
# this section loads a CAD step file and creates an unstrucutred DAGMC tet mesh
# the resulting mesh file (umesh.mesh) is already included in the repo
# so this creation from step file is included for completeness but can be skipped
from cad_to_dagmc import CadToDagmc
cad = CadToDagmc()
cad.add_stp_file('plasma_simplified_180.step')
cad.export_unstructured_mesh_file(filename="umesh.h5m", max_mesh_size=100, min_mesh_size=10)


import openmc
import openmc.lib

openmc.config['cross_sections'] = '/home/j/endf-b8.0-hdf5/endfb-viii.0-hdf5/cross_sections.xml'
# setting the nuclear data path to the correct location in the docker image
openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'

umesh = openmc.UnstructuredMesh(filename="umesh.h5m",library='moab')

Expand All @@ -36,18 +30,14 @@
my_source.energy = openmc.stats.Discrete([14e6], [1])
# link to docs for MeshSpatial
# https://docs.openmc.org/en/latest/pythonapi/generated/openmc.stats.MeshSpatial.html
# the main difference between MeshSpatial and MeshSource is that in MeshSpatial
# each mesh element has the same source with potentially a different strength
# while in MeshSource the elements can have a different source.
# Having a different source would allow a different energy distribution and therefore
# MeshSources are useful for shut down dose rate simulations where each active element
# results in a different photon emission
# allows us to apply the same source to each element in the mesh. The source can be varied in terms of strength
my_source.space = openmc.stats.MeshSpatial(
mesh=umesh,
strengths=[1]*1104, # in a more detailed version the strength could be adjusted based on the source position.
#we set the strengths to sum to 1 to make post processing easier.
# in a more accurate plasma source the strength could be adjusted based on the source position.
strengths=[1/1104]*1104,
volume_normalized=False
)
my_source.strength=1

my_settings = openmc.Settings()
my_settings.batches = 10
Expand Down
9 changes: 8 additions & 1 deletion tasks/task_04_make_sources/7_strucutured_mesh_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import openmc
import numpy as np

openmc.config['cross_sections'] = '/home/j/endf-b8.0-hdf5/endfb-viii.0-hdf5/cross_sections.xml'
# setting the nuclear data path to the correct location in the docker image
openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'

# making a minimal geometry
sphere_surf_1 = openmc.Sphere(r=2000)
Expand Down Expand Up @@ -47,6 +48,12 @@
all_sources.append(my_source)

# creating the mesh source from the mesh and the list of sources
# the main difference between MeshSpatial (previous example) and MeshSource is that in
# MeshSpatial each mesh element has the same source with potentially a different
# strength while in MeshSource the elements can have a different source.
# Having a different source would allow a different energy distribution and therefore
# MeshSources are useful for shut down dose rate simulations where each active element
# results in a different photon emission
mesh_source = openmc.MeshSource(
mesh=cylindrical_mesh,
sources=np.array(all_sources).reshape(cylindrical_mesh.dimension)
Expand Down

0 comments on commit 4286624

Please sign in to comment.