openmc icon indicating copy to clipboard operation
openmc copied to clipboard

differentiate_depletable_mats "cell match" option

Open bam241 opened this issue 1 year ago • 0 comments

Description

Working on #3056, I had to modify the model.differentiate_depletable_mats() method.

Right now when using the model.differentiate_depletable_mats("cell match) if a depletable materials (that has multiple instance) is filling a cell with multiple instances, a clone of this material is created for each of the cell instances, but only the last clone is used a the only cell.fill.

https://github.com/openmc-dev/openmc/blob/57816e6b8cf23ed0e9b020b72752ed6aeb9501dd/openmc/model/model.py#L1049-L1060

As a clone is created for each instance of the cell, but only the last one is actually used, (with @pshriwise) we were wondering what is the indented behaviour ?

  1. fill each cell instance with a different mat.clone() ? Therefore implementation should be:
                    if diff_volume_method == 'divide equally':
                        cell.fill = [mat.clone() for _ in range(cell.num_instances)]
                    elif diff_volume_method == 'match cell':
+                       cell.fill = [mat.clone() for _ in range(cell.num_instances)]
-                       for _ in range(cell.num_instances): 
+                       for i in range(cell.num_instances):
-                           cell.fill = mat.clone()
                            if not cell.volume:
                                raise ValueError(
                                    f"Volume of cell ID={cell.id} not specified. "
                                    "Set volumes of cells prior to using "
                                    "diff_volume_method='match cell'."
                                )
+                           cell.fill[i].volume = cell.volume/cell.num_instances
-                           cell.fill.volume = cell.volume

(I know the example of implementation if the the best but it explains the best changes in the targeted code)

  1. No material differentiation between the different cell instances ? In that case implementation should be:
                    if diff_volume_method == 'divide equally':
                        cell.fill = [mat.clone() for _ in range(cell.num_instances)]
                    elif diff_volume_method == 'match cell':
-                       for _ in range(cell.num_instances): 
                        cell.fill = mat.clone()
                        if not cell.volume:
                            raise ValueError(
                                f"Volume of cell ID={cell.id} not specified. "
                                "Set volumes of cells prior to using "
                                "diff_volume_method='match cell'."
                            )
                        cell.fill.volume = cell.volume
  1. something else ?

As you implemented it, @jon-proximafusion, do you know what was the intended behaviour ?

bam241 avatar Sep 12 '24 15:09 bam241