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

Random integer in element_composition range #97

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/mindlessgen/molecules/generate_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,16 @@ 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

### ACTUAL WORKFLOW START ###
# Add a random number of atoms of random types
Expand Down
Loading