From 0b09921bb5a24e1f873d28aa10adcb57efc7e5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Thu, 3 Aug 2017 08:07:50 +0000 Subject: [PATCH] Two conventions for reciprocalBasis Former-commit-id: 698fca8df5631e704e4a33dd9871b780f542a130 --- qpms/lattices2d.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/qpms/lattices2d.py b/qpms/lattices2d.py index 8e3768c..fe43aa4 100644 --- a/qpms/lattices2d.py +++ b/qpms/lattices2d.py @@ -213,18 +213,20 @@ def filledWS(b1, b2, density=10, scale=1.): rot90_ = np.array([[0,1],[-1,0]]) -def reciprocalBasis(a1, a2): +def reciprocalBasis1(a1, a2): a1, a2 = reduceBasisSingle(a1,a2) # this can be replaced with the vector version of reduceBasis when it is made - prefac = 2*np.pi/np.sum(np.tensordot(a1, rot90_, axes=[-1,0]) * a2, axis=-1) + prefac = np.sum(np.tensordot(a1, rot90_, axes=[-1,0]) * a2, axis=-1) b1 = np.tensordot(rot90_, a2, axes=[-1,-1]) * prefac b2 = np.tensordot(rot90_, a1, axes=[-1,-1]) * prefac - return (b1, b2) + return np.array([b1, b2]) +def reciprocalBasis2pi(*pargs): + return 2*np.pi*reciprocalBasis1(*pargs) # TODO fill it with "points from reciprocal space" instead def filledWS2(b1,b2, density=10, scale=1.): b1, b2 = reduceBasisSingle(b1,b2) - b1r, b2r = reciprocalBasis(b1,b2) + b1r, b2r = reciprocalBasis2pi(b1,b2) b1l = np.linalg.norm(b1, ord=2) b2l = np.linalg.norm(b2, ord=2) b1rl = np.linalg.norm(b1r, ord=2)