Skip to content

Commit

Permalink
quickfix depletable only
Browse files Browse the repository at this point in the history
  • Loading branch information
bam241 committed Oct 2, 2024
1 parent 8148957 commit ce99675
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
3 changes: 2 additions & 1 deletion include/openmc/capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ int openmc_cell_set_temperature(
int32_t index, double T, const int32_t* instance, bool set_contained = false);
int openmc_cell_set_translation(int32_t index, const double xyz[]);
int openmc_cell_set_rotation(int32_t index, const double rot[], size_t rot_len);
int openmc_get_dagmc_cell_ids(int32_t univ_id, int32_t* ids, size_t* n);
int openmc_dagmc_universe_get_cell_ids(
int32_t univ_id, int32_t* ids, size_t* n);
int openmc_dagmc_universe_get_num_cells(int32_t univ_id, size_t* n);
int openmc_energy_filter_get_bins(
int32_t index, const double** energies, size_t* n);
Expand Down
15 changes: 12 additions & 3 deletions openmc/dagmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class DAGMCUniverse(openmc.UniverseBase):
auto_mat_ids : bool
Set IDs automatically on initialization (True) or report overlaps in ID
space between OpenMC and UWUW materials (False)
material_overrides : dict
A dictionary of material overrides. The keys are material name
strings and the values are Iterables of openmc.Material objects. If a
material name is found in the DAGMC file, the material will be replaced
with the openmc.Material object in the value.
Attributes
----------
Expand Down Expand Up @@ -75,8 +80,8 @@ class DAGMCUniverse(openmc.UniverseBase):
material_overrides : dict
A dictionary of material overrides. The keys are material name
strings and the values are Iterables of openmc.Material objects. If a
material name is found in the DAGMC file, the material will be replaced with the
openmc.Material object in the value.
material name is found in the DAGMC file, the material will be replaced
with the openmc.Material object in the value.
"""

def __init__(self,
Expand Down Expand Up @@ -118,7 +123,10 @@ def material_overrides(self):

@material_overrides.setter
def material_overrides(self, val):
if val is not None:
if val is None:
self._material_overrides = val
return
else:
cv.check_type('material overrides', val, dict)
for key, value in val.items():
# ensuring key is a string and exists in the DAGMC file
Expand Down Expand Up @@ -508,6 +516,7 @@ def sync_dagmc_cells(self, mats={}):

class DAGMCCell(openmc.Cell):
"""
.. versionadded:: 0.13.2
A cell class for DAGMC-based geometries.
Parameters
Expand Down
8 changes: 4 additions & 4 deletions openmc/lib/dagmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@


# DAGMC functions
_dll.openmc_get_dagmc_cell_ids.argtypes = [c_int32, POINTER(c_int32), POINTER(c_size_t)]
_dll.openmc_get_dagmc_cell_ids.restype = c_int
_dll.openmc_get_dagmc_cell_ids.errcheck = _error_handler
_dll.openmc_dagmc_universe_get_cell_ids.argtypes = [c_int32, POINTER(c_int32), POINTER(c_size_t)]
_dll.openmc_dagmc_universe_get_cell_ids.restype = c_int
_dll.openmc_dagmc_universe_get_cell_ids.errcheck = _error_handler
_dll.openmc_dagmc_universe_get_num_cells.argtypes = [c_int32, POINTER(c_size_t)]
_dll.openmc_dagmc_universe_get_num_cells.restype = c_int
_dll.openmc_dagmc_universe_get_num_cells.errcheck = _error_handler
Expand All @@ -36,7 +36,7 @@ def get_dagmc_cell_ids(dagmc_id):
_dll.openmc_dagmc_universe_get_num_cells(dagmc_id, n)
cell_ids = np.empty(n.value, dtype=np.int32)

_dll.openmc_get_dagmc_cell_ids(
_dll.openmc_dagmc_universe_get_cell_ids(
dagmc_id,
cell_ids.ctypes.data_as(POINTER(c_int32)),
n
Expand Down
2 changes: 1 addition & 1 deletion openmc/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ def differentiate_mats(self, diff_volume_method: str = None, depletable_only: bo
# Extract all depletable materials which have multiple instances
distribmats = set(
[mat for mat in self.materials
if mat.depletable and mat.num_instances > 1])
if (mat.depletable or not depletable_only) and mat.num_instances > 1])

if diff_volume_method == "divide equally":
for mat in distribmats:
Expand Down
4 changes: 2 additions & 2 deletions src/dagmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ int32_t next_cell(int32_t surf, int32_t curr_cell, int32_t univ)
return univp->cell_index(new_vol);
}

extern "C" int openmc_get_dagmc_cell_ids(
extern "C" int openmc_dagmc_universe_get_cell_ids(
int32_t univ_id, int32_t* ids, size_t* n)
{
// make sure the universe id is a DAGMC Universe
Expand Down Expand Up @@ -888,7 +888,7 @@ extern "C" int openmc_dagmc_universe_get_num_cells(int32_t univ_id, size_t* n)

namespace openmc {

extern "C" int openmc_get_dagmc_cell_ids(
extern "C" int openmc_dagmc_universe_get_cell_ids(
int32_t univ_id, int32_t* ids, size_t* n) {};

extern "C" int openmc_dagmc_universe_get_num_cells(
Expand Down

0 comments on commit ce99675

Please sign in to comment.