Skip to content

Commit 742af86

Browse files
committed
Avoid round-off errors on U-matrix diagonal.
Diagonal elements of Lattice.isotropicunit should be exactly 1. Matrix multiplication could introduce slight round-off errors. This had caused inexact assignments of U_ii for isotropic matrices.
1 parent 0ada820 commit 742af86

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

diffpy/Structure/lattice.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ def setLatPar(self, a=None, b=None, c=None,
197197
self.normbase = self.base * [[ar], [br], [cr]]
198198
self.recnormbase = self.recbase / [ar, br, cr]
199199
self.isotropicunit = numpy.dot(self.recnormbase.T, self.recnormbase)
200+
# ensure there are no round-off deviations on the diagonal
201+
self.isotropicunit[0, 0] = 1
202+
self.isotropicunit[1, 1] = 1
203+
self.isotropicunit[2, 2] = 1
200204
return
201205

202206

0 commit comments

Comments
 (0)