Skip to content

Commit

Permalink
add the verbose option
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhu2017 committed Jun 3, 2024
1 parent 46214f8 commit 475eeb9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
23 changes: 23 additions & 0 deletions pyxtal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,29 @@ def from_random(
tm = None,
use_hall = False,
):
"""
The main function to generate random crystals.
It calls `block_crysstal` or `random_crystal` internally.
Args:
dim (int): dimenion (0, 1, 2, 3)
group (int): the group number (1-56, 1-75, 1-80, 1-230)
species (list): a list of atomic symbols for each ion type, e.g., `["Ti", "O"]`
numIons (list): a list of the number of each type of atom within the
primitive cell (NOT the conventional cell), e.g., `[4, 2]`
factor (optional): volume factor used to generate the crystal
thickness:
area (float):
lattice (optional): `Lattice <pyxtal.lattice.Lattice.html>`_ to define the cell
sites (optional): pre-assigned wyckoff sites (e.g., `[["4a"], ["2b"]]`)
conventional (bool): whether or not use the conventional setting
t_factor ():
max_count ():
tm (optional): `Tol_matrix <pyxtal.tolerance.Tol_matrix.html>`_ object
to define the distances
"""
if self.molecular:
prototype = "molecular"
else:
Expand Down
4 changes: 2 additions & 2 deletions pyxtal/crystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def set_crystal(self):
else:
self.lattice_attempts = 40
self.coord_attempts = 10

#QZ: Maybe we no longer need this tag
#if not self.lattice.allow_volume_reset:
# self.lattice_attempts = 1
Expand Down Expand Up @@ -368,7 +368,7 @@ def _set_ion_wyckoffs(self, numIon, specie, cell, wyks):
# Generate a list of coords from ops
pt = self.lattice.generate_point()
pt, wp, _ = wp.merge(pt, cell, tol, group=self.group)
#print('good pt', pt)
#print('good pt', pt)
if wp is not False:
# For pure planar structure
if self.dim == 2 and self.thickness is not None and \
Expand Down
24 changes: 20 additions & 4 deletions pyxtal/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,8 @@ def export_structures(self, fmt='vasp', folder='mof_out', criteria=None,
eng = float(vasp_eng)
elif ff_eng is not None:
eng = float(ff_eng)
else:
eng = None
#if True:
try:
xtal = self.get_pyxtal(id, use_relaxed)
Expand Down Expand Up @@ -1264,9 +1266,14 @@ def get_db_unique(self, db_name=None, etol=2e-3):
db.write(row.toatoms(), key_value_pairs=kvp)
print("Created {:s} with {:d} strucs".format(db_name, db.count()))

def check_overlap(self, reference_db, etol=2e-3):
def check_overlap(self, reference_db, etol=2e-3, verbose=True):
"""
Check the overlap w.r.t the reference database
Args:
reference_db (str): path of reference database
etol (float): energy tolerence to distinguish the identical structure
verbose (bool): whether or not print out details
"""

db_ref = database_topology(reference_db)
Expand Down Expand Up @@ -1294,13 +1301,22 @@ def check_overlap(self, reference_db, etol=2e-3):
strs += "/{:d}/{:d}".format(self.db.count(), db_ref.db.count())
print(strs)
sorted_overlaps = sorted(overlaps, key=lambda x: x[-1])
for entry in sorted_overlaps:
print('{:4d} {:6s} {:4d} {:20s} {:10.3f}'.format(*entry))
if verbose:
for entry in sorted_overlaps:
print('{:4d} {:6s} {:4d} {:20s} {:10.3f}'.format(*entry))

return overlaps

def print_info(self, excluded_ids=[], cutoff=100):
"""
Print out the summary of the database based on the calculated energy
Mostly used to quickly view the most interesting low-energy structures.
Todo: show vasp_energy if available
Args:
excluded_ids (list): list of unwanted row ids
cutoff (int): the cutoff value for the print
"""
print("\nCurrent database {:s}: {:d}".format(self.db_name, self.db.count()))
output = []
for row in self.db.select():
Expand All @@ -1312,7 +1328,7 @@ def print_info(self, excluded_ids=[], cutoff=100):
for entry in sorted_output[:cutoff]:
print('{:4d} {:6s} {:4d} {:20s} {:10.3f}'.format(*entry))

strs = "Output structures: {:d}/{:d}".format(len(sorted_output), self.db.count())
strs = "Showed structures: {:d}/{:d}".format(len(sorted_output), self.db.count())
print(strs)


Expand Down

0 comments on commit 475eeb9

Please sign in to comment.