fusion-energy / openmc-dagmc-wrapper

A Python package that extends OpenMC base classes to provide convenience features and standardized tallies when simulating DAGMC geometry with OpenMC.
https://openmc-dagmc-wrapper.readthedocs.io/
MIT License
7 stars 2 forks source link

Allowing h5m files #31

Closed shimwell closed 3 years ago

shimwell commented 3 years ago

This is a bit of a redesign of the package

The PR allows the paramak neutronics to use h5m files directly instead of using paramak.Reactor objects.

Currently my_model = paramak_neutronics(geometry=paramak.Reactor()....

With this PR my_model = paramak_neutronics(h5m_filenmae='dagmc.h5m' ....

The geometry argument has been removed and replaced with h5m_filename

codecov[bot] commented 3 years ago

Codecov Report

Merging #31 (3d36c9e) into develop (19c92c0) will increase coverage by 0.92%. The diff coverage is 77.69%.

:exclamation: Current head 3d36c9e differs from pull request most recent head cbbfb09. Consider uploading reports for the commit cbbfb09 to get more accurate results Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #31      +/-   ##
===========================================
+ Coverage    89.77%   90.69%   +0.92%     
===========================================
  Files            3        3              
  Lines          528      516      -12     
===========================================
- Hits           474      468       -6     
+ Misses          54       48       -6     
Impacted Files Coverage Δ
paramak_neutronics/__init__.py 100.00% <ø> (ø)
paramak_neutronics/neutronics_model.py 88.81% <67.94%> (-4.85%) :arrow_down:
paramak_neutronics/neutronics_utils.py 93.36% <90.16%> (+9.20%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 19c92c0...cbbfb09. Read the comment docs.

shimwell commented 3 years ago

The mesh tallies try to sense the size of the geometry and build a mesh accordingly however now that the paramak.Reactor() object is no longer used we will have to get the size of the geometry from the h5m file directly.

This size can then be set to the largest_dimention variable and used when making the meshes.

shimwell commented 3 years ago

I've added a find_bounding_box method with help from @pshriwise but currently it is returning very large numbers.

Here is the script I've been testing it with but any h5m file should work


import openmc
import paramak
import paramak_neutronics

my_shape = paramak.CenterColumnShieldHyperbola(
    height=500,
    inner_radius=50,
    mid_radius=60,
    outer_radius=100,
    material_tag='center_column_shield_mat',

)

# h5m_filename = my_shape.export_h5m_with_cubit(faceting_tolerance=1e-1, merge_tolerance=1e-4)
h5m_filename = my_shape.export_h5m_with_pymoab(faceting_tolerance=1e-1)

# # makes the openmc neutron source at x,y,z 0, 0, 0 with isotropic
# # directions and 14MeV neutrons
source = openmc.Source()
source.space = openmc.stats.Point((0, 0, 0))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([14e6], [1])

h5m_filename='dagmc.h5m'
my_model = paramak_neutronics.NeutronicsModel(
    h5m_filename=h5m_filename,
    source=source,
    materials={'center_column_shield_mat': 'Be'},
    simulation_batches=3.1,
    simulation_particles_per_batch=2.1
)

bb=my_model.find_bounding_box()

# bb has strange values (array([6.95308753e-310, 1.18575755e-322, 6.95308753e-310]), array([3.45845952e-323, 1.48219694e-323, 6.92668734e-310]))
print(bb)

I am getting some MOAB errors so perhaps that is the cause

Screenshot from 2021-08-14 16-50-17