Skip to content

Commit

Permalink
adjust the generation of lattice for very long molecules
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhu2017 committed Jul 14, 2024
1 parent 02a8405 commit 7fd428a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
8 changes: 8 additions & 0 deletions pyxtal/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(self, ltype, volume=None, matrix=None, PBC=None, **kwargs):
"min_l",
"mid_l",
"max_l",
"min_special", #min special for mole
]:
setattr(self, key, value)
self.kwargs[key] = value
Expand Down Expand Up @@ -1127,6 +1128,7 @@ def generate_cellpara(
minvec=1.2,
minangle=np.pi / 6,
max_ratio=10.0,
min_special=None,
maxattempts=100,
**kwargs,
):
Expand All @@ -1153,6 +1155,7 @@ def generate_cellpara(
a 6-length array representing the lattice of the unit cell. If
generation fails, outputs a warning message and returns empty
"""
min_special = kwargs.get("min_special", min_special) #; print("min_special", min_special)
maxangle = np.pi - minangle
for _n in range(maxattempts):
# Triclinic
Expand Down Expand Up @@ -1185,6 +1188,11 @@ def generate_cellpara(
a = vec[0] * np.cbrt(abc) / np.cbrt(xyz)
b = vec[1] * np.cbrt(abc) / np.cbrt(xyz)
c = vec[2] * np.cbrt(abc) / np.cbrt(xyz)
if min_special is not None and c < min_special:
coef = random.uniform(0.8, 1.2) * min_special / c
c *= coef
b /= np.sqrt(coef)
a /= np.sqrt(coef)
# Orthorhombic
# elif sg <= 74:
elif ltype in ["orthorhombic"]:
Expand Down
1 change: 1 addition & 0 deletions pyxtal/molecular_crystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def set_lattice(self, lattice):
unique_axis=unique_axis,
thickness=self.thickness,
area=self.area,
min_special=max([mol.get_max_length() for mol in self.molecules]),
)
good_lattice = True
break
Expand Down
10 changes: 10 additions & 0 deletions pyxtal/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,16 @@ def get_box(self, padding=None):
dims[i] = max([dims[i] + r, 3.4]) # for planar molecules
return Box(dims)

def get_lengths(self):
if not hasattr(self, 'box'):
self.box = self.get_box()
return self.box.width, self.box.height, self.box.length

def get_max_length(self):
w, h, l = self.get_lengths()
return max([w, h, l])


def get_box_coordinates(self, xyz, padding=0, resolution=1.0):
"""
create the points cloud to describe the molecular box
Expand Down
2 changes: 1 addition & 1 deletion pyxtal/optimize/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __init__(
ff_style,
)
params0 = self.parameters.params_init.copy()
self.parameters.export_parameters(self.wdir + "/" + self.ff_parameters, params0)
self.parameters.export_parameters(self.workdir + "/" + self.ff_parameters, params0)

self.prepare_chm_info(params0)

Expand Down
6 changes: 2 additions & 4 deletions pyxtal/wyckoff_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,9 @@ def _create_matrix(self, center=False, ignore=False):
ijk_lists = []
for id in range(3):
if self.PBC[id]:
if not ignore and abc[id] > 25 and self.radius < 10:
if not ignore and abc[id] > 50.0 and self.radius < 10:
ijk_lists.append([0])
elif abc[id] < 7.0:
elif abc[id] < 8.5:
ijk_lists.append([-3, -2, -1, 0, 1, 2, 3])
else:
ijk_lists.append([-1, 0, 1])
Expand Down Expand Up @@ -866,7 +866,6 @@ def get_dists_auto(self, ignore=False):
a distance matrix (M, N, N)
list of molecular xyz (M, N, 3)
"""
len(self.numbers)
coord1, _ = self._get_coords_and_species(first=True, unitcell=True)

return self.get_distances(coord1, coord1, center=False, ignore=ignore)
Expand Down Expand Up @@ -918,7 +917,6 @@ def short_dist(self):
Returns:
True or False
"""
len(self.numbers)
tols_matrix = self.tols_matrix
# Check periodic images
d, _ = self.get_dists_auto()
Expand Down

0 comments on commit 7fd428a

Please sign in to comment.