From ecebe25f367e9482b8c475f9484c32cddd2be338 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 7 Feb 2023 10:23:28 +0000 Subject: [PATCH 1/4] making error message more helpful with material name --- openmc/deplete/openmc_operator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openmc/deplete/openmc_operator.py b/openmc/deplete/openmc_operator.py index b00d831272..6233322ab4 100644 --- a/openmc/deplete/openmc_operator.py +++ b/openmc/deplete/openmc_operator.py @@ -223,8 +223,9 @@ class OpenMCOperator(TransportOperator): if mat.depletable: burnable_mats.add(str(mat.id)) if mat.volume is None: - raise RuntimeError("Volume not specified for depletable " - "material with ID={}.".format(mat.id)) + msh = ("Volume not specified for depletable material with " + f"ID={mat.id}. Name={mat.name}") + raise RuntimeError(msh) volume[str(mat.id)] = mat.volume self.heavy_metal += mat.fissionable_mass @@ -242,7 +243,6 @@ class OpenMCOperator(TransportOperator): for nuc in model_nuclides: if nuc not in nuclides: nuclides.append(nuc) - return burnable_mats, volume, nuclides def _load_previous_results(self): From 016a5e5b3c3fdfe90bb9413958e2df0f371861a5 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 7 Feb 2023 10:24:39 +0000 Subject: [PATCH 2/4] moved full stop --- openmc/deplete/openmc_operator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/deplete/openmc_operator.py b/openmc/deplete/openmc_operator.py index 6233322ab4..874a1da23d 100644 --- a/openmc/deplete/openmc_operator.py +++ b/openmc/deplete/openmc_operator.py @@ -224,7 +224,7 @@ class OpenMCOperator(TransportOperator): burnable_mats.add(str(mat.id)) if mat.volume is None: msh = ("Volume not specified for depletable material with " - f"ID={mat.id}. Name={mat.name}") + f"ID={mat.id} Name={mat.name}.") raise RuntimeError(msh) volume[str(mat.id)] = mat.volume self.heavy_metal += mat.fissionable_mass From b559d32d6849f8ef680a935afd33012c2a593490 Mon Sep 17 00:00:00 2001 From: shimwell Date: Thu, 9 Feb 2023 19:47:29 +0000 Subject: [PATCH 3/4] custom error message for name is None --- openmc/deplete/openmc_operator.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openmc/deplete/openmc_operator.py b/openmc/deplete/openmc_operator.py index 874a1da23d..9122b93d39 100644 --- a/openmc/deplete/openmc_operator.py +++ b/openmc/deplete/openmc_operator.py @@ -223,9 +223,11 @@ class OpenMCOperator(TransportOperator): if mat.depletable: burnable_mats.add(str(mat.id)) if mat.volume is None: - msh = ("Volume not specified for depletable material with " - f"ID={mat.id} Name={mat.name}.") - raise RuntimeError(msh) + msg = ("Volume not specified for depletable material with " + f"ID={mat.id}.") + if mat.name is not None: + msg = f"{msg[:-1]} Name={mat.name}." + raise RuntimeError(msg) volume[str(mat.id)] = mat.volume self.heavy_metal += mat.fissionable_mass From c0391781ca8268989b064d71b2850246d12bf9c9 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Fri, 10 Feb 2023 09:22:10 +0000 Subject: [PATCH 4/4] changed error message to preferred option --- openmc/deplete/openmc_operator.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openmc/deplete/openmc_operator.py b/openmc/deplete/openmc_operator.py index 9122b93d39..8a13bff7fa 100644 --- a/openmc/deplete/openmc_operator.py +++ b/openmc/deplete/openmc_operator.py @@ -223,10 +223,12 @@ class OpenMCOperator(TransportOperator): if mat.depletable: burnable_mats.add(str(mat.id)) if mat.volume is None: - msg = ("Volume not specified for depletable material with " - f"ID={mat.id}.") - if mat.name is not None: - msg = f"{msg[:-1]} Name={mat.name}." + if mat.name is None: + msg = ("Volume not specified for depletable material " + f"with ID={mat.id}.") + else: + msg = ("Volume not specified for depletable material " + f"with ID={mat.id} Name={mat.name}.") raise RuntimeError(msg) volume[str(mat.id)] = mat.volume self.heavy_metal += mat.fissionable_mass