Skip to content

Commit

Permalink
allow the pass of tolerance value when parsing the wp site for from_t…
Browse files Browse the repository at this point in the history
…abular_representation function
  • Loading branch information
qzhu2017 committed Jun 6, 2024
1 parent 7080120 commit e11b6ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
5 changes: 3 additions & 2 deletions pyxtal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3663,8 +3663,9 @@ def from_tabular_representation(self, rep, max_abc=50.0, max_angle=180,
alpha, beta, gamma = alpha*max_angle, beta*max_angle, gamma*max_angle
else:
alpha, beta, gamma = np.degrees(alpha), np.degrees(beta), np.degrees(gamma)

lattice = np.array([a, b, c, alpha, beta, gamma])
lattice = Lattice.from_para(a, b, c, alpha, beta, gamma,
ltype=group.lattice_type,
force_symmetry=True)
sites_info = np.reshape(rep[7:], (int((len(rep)-7)/4), 4))
sites = []
numIons = 0
Expand Down
29 changes: 17 additions & 12 deletions pyxtal/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ def from_para(
radians=False,
PBC=[1, 1, 1],
factor=1.0,
force_symmetry=False,
**kwargs
):
"""
Expand Down Expand Up @@ -818,18 +819,22 @@ def from_para(
except:
msg = "Error: invalid cell parameters for lattice."
raise ValueError(msg)
volume = np.linalg.det(cell_matrix)
# Initialize a Lattice instance
l = Lattice(ltype, volume, PBC=PBC, **kwargs)
l.a, l.b, l.c = factor*a, factor*b, factor*c
l.alpha, l.beta, l.gamma = alpha * rad, beta * rad, gamma * rad
l.matrix = cell_matrix
l.inv_matrix = np.linalg.inv(cell_matrix)
l.ltype = ltype
l.volume = volume
l.random = False
l.allow_volume_reset = False
return l

if force_symmetry:
return Lattice.from_matrix(cell_matrix, ltype=ltype)
else:
volume = np.linalg.det(cell_matrix)
# Initialize a Lattice instance
l = Lattice(ltype, volume, PBC=PBC, **kwargs)
l.a, l.b, l.c = factor*a, factor*b, factor*c
l.alpha, l.beta, l.gamma = alpha * rad, beta * rad, gamma * rad
l.matrix = cell_matrix
l.inv_matrix = np.linalg.inv(cell_matrix)
l.ltype = ltype
l.volume = volume
l.random = False
l.allow_volume_reset = False
return l

@classmethod
def from_matrix(self, matrix, reset=True, shape='upper', ltype="triclinic", PBC=[1, 1, 1], **kwargs):
Expand Down

0 comments on commit e11b6ef

Please sign in to comment.