ukaea / paramak

Create parametric 3D fusion reactor CAD models
https://paramak.readthedocs.io/en/main/
36 stars 12 forks source link

added ability to load stp files into a shape #833

Closed shimwell closed 3 years ago

shimwell commented 3 years ago

Proposed changes

This adds Shape().from_stp_file to the Shape class and makes use of this method in the Reactor.export_h5m_with_pymoab method.

This allows pymoab to be used as a method when making a reactor from a manifest.json file.

Previously this was only possible with the "trelis" method.

This means one can take a stp file(s) and run a neutronics simulation in the following manner ...

assuming you have a manifest.json like this

[
    {
        "stp_filename":"geometry.step",
        "material_tag":"my_material"
    }
]
import paramak, openmc

my_reactor = paramak.Reactor(
    shapes_and_components='manifest.json'
)

my_reactor.method = 'pymoab'

coords = openmc.stats.Point((0, 0, 0))
energy = openmc.stats.Discrete([1.41E7], [1.0])
source = openmc.Source(space=coords, energy=energy)

my_model = paramak.NeutronicsModel(
    geometry=my_reactor,
    source=source,
    materials={'my_material': 'eurofer'},
    mesh_tally_3d=['flux', 'heating'],
    mesh_3d_corners=[(-1, -1, -1), (1, 1, 1)]  # needed for now as the dimensions are not yet found automatically using this method
)

my_model.simulate()

Types of changes

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

shimwell commented 3 years ago

Failing tests are unrelated and are being fixed in #830