From e7e57cb47df816bca326614963671284ef7cd38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Sun, 15 Dec 2024 22:32:00 +0100 Subject: [PATCH 1/2] modify adaption to desired element_composition such that a random integer in the desired range is taken MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- src/mindlessgen/molecules/generate_molecule.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mindlessgen/molecules/generate_molecule.py b/src/mindlessgen/molecules/generate_molecule.py index e003ed0..ee6bb40 100644 --- a/src/mindlessgen/molecules/generate_molecule.py +++ b/src/mindlessgen/molecules/generate_molecule.py @@ -325,10 +325,17 @@ def check_composition(): # CAUTION: The setting to min/max count may violate the metal count restrictions for elem, count_range in cfg.element_composition.items(): min_count, max_count = count_range - if min_count is not None and natoms[elem] < min_count: - natoms[elem] = min_count - elif max_count is not None and natoms[elem] > max_count: - natoms[elem] = max_count + # define the random number of atoms to be added + if min_count is None: + min_count = 0 + if max_count is None: + max_count = cfg.max_num_atoms + # 50 % of the maximally allowed number of atoms + added_atoms_from_composition = rng.integers( + low=min_count, high=max_count, endpoint=True + ) + natoms[elem] = added_atoms_from_composition + print(f"Adding {added_atoms_from_composition} atoms of type {elem}...") ### ACTUAL WORKFLOW START ### # Add a random number of atoms of random types From 7112ffcd9df7493689ad16a466dc8ccb88ffcd8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Sun, 15 Dec 2024 22:36:53 +0100 Subject: [PATCH 2/2] remove dev printing statement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- src/mindlessgen/molecules/generate_molecule.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mindlessgen/molecules/generate_molecule.py b/src/mindlessgen/molecules/generate_molecule.py index ee6bb40..13a0ffd 100644 --- a/src/mindlessgen/molecules/generate_molecule.py +++ b/src/mindlessgen/molecules/generate_molecule.py @@ -335,7 +335,6 @@ def check_composition(): low=min_count, high=max_count, endpoint=True ) natoms[elem] = added_atoms_from_composition - print(f"Adding {added_atoms_from_composition} atoms of type {elem}...") ### ACTUAL WORKFLOW START ### # Add a random number of atoms of random types