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

added export geometry method; #57

Closed shimwell closed 2 years ago

shimwell commented 2 years ago

Attempt to solve issue #56

What do you think @RemDelaporteMathurin, is this suitable

I will have to fix the tests to get it working as the arguments have moved around between methods a bit

RemDelaporteMathurin commented 2 years ago

@Shimwell wow so quick

So if i get this right, this means:

1) the nb of particles and all won't be in the simulate() method anymore 2) a geometry can be parsed in export_xml

How would one specify a geometry with a reflective surface out-of-the-box as here:


neutronics_model = NeutronicsModel(
    source=my_source,
    materials={
        'inboard_tf_coils_mat': 'copper',
        'center_column_shield_mat': 'WC',
        'outboard_pf_coils_mat': 'copper',
        'tf_coil_casing_mat': "eurofer",
        'pf_coils_mat': 'copper',
        'divertor_mat': 'tungsten',
        'blanket_mat': 'tungsten'
    },
    h5m_filename='stage_2_output/dagmc.h5m',
    tet_mesh_filename='stage_2_output/unstructured_mesh.h5m',
    mesh_tally_tet=['(n,Xa)']  # , '(n,Xa)'
)

results = neutronics_model.simulate(
    simulation_batches=4,
    simulation_particles_per_batch=1e4,
)
print(results)

should it be passed to NeutronicsModel?

shimwell commented 2 years ago

Something like this where geometry is a openmc.Geometry

import openmc_openmc_wrapper as odw
neutronics_model = odw.NeutronicsModel(
    source=my_source,
    materials={
        'inboard_tf_coils_mat': 'copper',
        'center_column_shield_mat': 'WC',
        'outboard_pf_coils_mat': 'copper',
        'tf_coil_casing_mat': "eurofer",
        'pf_coils_mat': 'copper',
        'divertor_mat': 'tungsten',
        'blanket_mat': 'tungsten'
    },
    h5m_filename='stage_2_output/dagmc.h5m',
    tet_mesh_filename='stage_2_output/unstructured_mesh.h5m',
    mesh_tally_tet=['(n,Xa)']  # , '(n,Xa)'
)

neutronics_model.export_xml(
    geometry=geometry,
    simulation_batches=4,
    simulation_particles_per_batch=1e4,

h5m_filename = neutronics_model.simulate()

results = odw.process_results(h5m_filename)
print(results)
RemDelaporteMathurin commented 2 years ago

@Shimwell oh ok it's nice! I think the examples need to be reworked then for the tests to pass right?

shimwell commented 2 years ago

@RemDelaporteMathurin tests are working again and example has been updated, I think this can be merged in to develop

shimwell commented 2 years ago

circle ci tests are passing :tada:

shimwell commented 2 years ago

If there are no objections I think this is ready to merge

shimwell commented 2 years ago

Just fixed a few merge conflicts