Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

differentiate_depletable_mats "cell match" option #3132

Open
bam241 opened this issue Sep 12, 2024 · 1 comment
Open

differentiate_depletable_mats "cell match" option #3132

bam241 opened this issue Sep 12, 2024 · 1 comment

Comments

@bam241
Copy link
Contributor

bam241 commented Sep 12, 2024

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.

openmc/openmc/model/model.py

Lines 1049 to 1060 in 57816e6

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

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 ?

@shimwell
Copy link
Member

Looking through the PRs perhaps this was the one that changed the material depletion. There is some motivation in the PR.

#2718

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants