From b4deb90ad84f8dcf0b9f58311073f181bc82d59c Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Fri, 16 Oct 2020 15:27:36 -0500 Subject: [PATCH] Ensure user sets particles before using entropy mesh dimension heuristic. --- openmc/settings.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openmc/settings.py b/openmc/settings.py index 1f0627207b..7166a5119c 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -930,9 +930,13 @@ class Settings: if self.entropy_mesh is not None: # use default heuristic for entropy mesh if not set by user if self.entropy_mesh.dimension is None: - n = ceil((self.particles / 20.0)**(1.0 / 3.0)) - d = len(self.entropy_mesh.lower_left) - self.entropy_mesh.dimension = (n,)*d + if self.particles is None: + raise RuntimeError("Number of particles must be set in order to " \ + "use entropy mesh dimension heuristic") + else: + n = ceil((self.particles / 20.0)**(1.0 / 3.0)) + d = len(self.entropy_mesh.lower_left) + self.entropy_mesh.dimension = (n,)*d # See if a element already exists -- if not, add it path = "./mesh[@id='{}']".format(self.entropy_mesh.id)