学术, 其他笔记

倒格子基矢的计算(附数值计算、符号计算Python代码)

一、定义

正格子基矢:\vec{a_1}, \vec{a_2}, \vec{a_3}

倒格子基矢:\vec{b_1}, \vec{b_2}, \vec{b_3}

需要满足关系:\vec{b_i}\cdot \vec{a_j}=2\pi\delta_{ij}

1. 三维的情况

倒格子基矢可以写为以下形式:

\vec{b_1}=2\pi\frac{\vec{a_2}\times\vec{a_3}}{\vec{a_1} \cdot (\vec{a_2}\times\vec{a_3})}

\vec{b_2}=2\pi\frac{\vec{a_3}\times\vec{a_1}}{\vec{a_1} \cdot (\vec{a_2}\times\vec{a_3})}

\vec{b_3}=2\pi\frac{\vec{a_1}\times\vec{a_2}}{\vec{a_1} \cdot (\vec{a_2}\times\vec{a_3})}

2. 二维的情况

倒格子基矢可以写为以下形式:

\vec{b_1}=2\pi\frac{\vec{a_2}\times\vec{a_3}}{\vec{a_1} \cdot (\vec{a_2}\times\vec{a_3})}

\vec{b_2}=2\pi\frac{\vec{a_3}\times\vec{a_1}}{\vec{a_1} \cdot (\vec{a_2}\times\vec{a_3})}

其中,\vec{a_3}表示的是垂直于二维平面的单位矢量[1]。

1. 一维的情况

直接写出倒格子基矢表达式:

\vec{a_1}=a\vec{x}

\vec{b_1}=\frac{2\pi}{a_1}\vec{x}

此外,也可以写为以下形式:

\vec{b_1}=2\pi\frac{\vec{a_2}\times\vec{a_3}}{\vec{a_1} \cdot (\vec{a_2}\times\vec{a_3})}

其中,\vec{a_2}, \vec{a_3}表示的是垂直于\vec{a_1}的两个相互垂直单位矢量。

二、数值计算

以方格子的基矢为例,数值计算代码如下:

"""
This code is supported by the website: https://www.guanjihuan.com
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/15978
"""

import numpy as np
from math import *

def main():
    a1 = [0, 1]
    a2 = [1, 0]
    b1, b2 = calculate_two_dimensional_reciprocal_lattice_vectors(a1, a2)
    print(b1, b2)


def calculate_one_dimensional_reciprocal_lattice_vector(a1):
    b1 = 2*pi/a1
    return b1


def calculate_two_dimensional_reciprocal_lattice_vectors(a1, a2):
    a1 = np.array(a1)
    a2 = np.array(a2)
    a1 = np.append(a1, 0)
    a2 = np.append(a2, 0)
    a3 = np.array([0, 0, 1])
    b1 = 2*pi*np.cross(a2, a3)/np.dot(a1, np.cross(a2, a3))
    b2 = 2*pi*np.cross(a3, a1)/np.dot(a1, np.cross(a2, a3))
    b1 = np.delete(b1, 2)
    b2 = np.delete(b2, 2)
    return b1, b2


def calculate_three_dimensional_reciprocal_lattice_vectors(a1, a2, a3):
    a1 = np.array(a1)
    a2 = np.array(a2)
    a3 = np.array(a3)
    b1 = 2*pi*np.cross(a2, a3)/np.dot(a1, np.cross(a2, a3))
    b2 = 2*pi*np.cross(a3, a1)/np.dot(a1, np.cross(a2, a3))
    b3 = 2*pi*np.cross(a1, a2)/np.dot(a1, np.cross(a2, a3))
    return b1, b2, b3


if __name__ == '__main__':
    main()

运算结果:

[-0.          6.28318531] [ 6.28318531 -0.        ]

三、符号计算

以石墨烯格子的基矢为例,符号计算代码如下(用到Python符号运算库SymPy):

"""
This code is supported by the website: https://www.guanjihuan.com
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/15978
"""

import sympy


def main():
    print('bases in the real space')
    a = sympy.symbols('a')
    a1 = sympy.Matrix(1, 2, [3*a/2, sympy.sqrt(3)*a/2])
    a2 = sympy.Matrix(1, 2, [3*a/2, -sympy.sqrt(3)*a/2])
    print('a1:')
    sympy.pprint(a1)
    print('a2:')
    sympy.pprint(a2)
    print('\nbases in the reciprocal space')
    b1, b2 = calculate_two_dimensional_reciprocal_lattice_vectors_with_sympy(a1, a2)
    print('b1:')
    sympy.pprint(b1)
    print('b2:')
    sympy.pprint(b2)


def calculate_one_dimensional_reciprocal_lattice_vector_with_sympy(a1):
    b1 = 2*sympy.pi/a1
    return b1


def calculate_two_dimensional_reciprocal_lattice_vectors_with_sympy(a1, a2):
    a1 = sympy.Matrix(1, 3, [a1[0], a1[1], 0])
    a2 = sympy.Matrix(1, 3, [a2[0], a2[1], 0])
    a3 = sympy.Matrix(1, 3, [0, 0, 1])
    cross_a2_a3 = a2.cross(a3)
    cross_a3_a1 = a3.cross(a1)
    b1 = 2*sympy.pi*cross_a2_a3/a1.dot(cross_a2_a3)
    b2 = 2*sympy.pi*cross_a3_a1/a1.dot(cross_a2_a3)
    b1 = sympy.Matrix(1, 2, [b1[0], b1[1]])
    b2 = sympy.Matrix(1, 2, [b2[0], b2[1]])
    return b1, b2


def calculate_three_dimensional_reciprocal_lattice_vectors_with_sympy(a1, a2, a3):
    cross_a2_a3 = a2.cross(a3)
    cross_a3_a1 = a3.cross(a1)
    cross_a1_a2 = a1.cross(a2)
    b1 = 2*sympy.pi*cross_a2_a3/a1.dot(cross_a2_a3)
    b2 = 2*sympy.pi*cross_a3_a1/a1.dot(cross_a2_a3)
    b3 = 2*sympy.pi*cross_a1_a2/a1.dot(cross_a2_a3)
    return b1, b2, b3


if __name__ == '__main__':
    main()

运算结果:

bases in the real space
a1:
⎡3⋅a  √3⋅a⎤
⎢───  ────⎥
⎣ 2    2  ⎦
a2:
⎡3⋅a  -√3⋅a ⎤
⎢───  ──────⎥
⎣ 2     2   ⎦

bases in the reciprocal space
b1:
⎡2⋅π  2⋅√3⋅π⎤
⎢───  ──────⎥
⎣3⋅a   3⋅a  ⎦
b2:
⎡2⋅π  -2⋅√3⋅π ⎤
⎢───  ────────⎥
⎣3⋅a    3⋅a   ⎦

四、使用GUAN开源项目软件包

目前以上六个计算倒格子基矢的函数已加入开源项目Guan:https://py.guanjihuan.com,使用命令”pip install --upgrade guan“安装到最新版,安装后可直接调用。代码如下:

import guan
import sympy

a1 = [0, 1]
a2 = [1, 0]
b1, b2 = guan.calculate_two_dimensional_reciprocal_lattice_vectors(a1, a2)
print(b1, b2, '\n')

print('bases in the real space')
a = sympy.symbols('a')
a1 = sympy.Matrix(1, 2, [3*a/2, sympy.sqrt(3)*a/2])
a2 = sympy.Matrix(1, 2, [3*a/2, -sympy.sqrt(3)*a/2])
print('a1:')
sympy.pprint(a1)
print('a2:')
sympy.pprint(a2)
print('\nbases in the reciprocal space')
b1, b2 = guan.calculate_two_dimensional_reciprocal_lattice_vectors_with_sympy(a1, a2)
print('b1:')
sympy.pprint(b1)
print('b2:')
sympy.pprint(b2)

参考资料:

[1] 黄昆《固体物理学》

10,282 次浏览

【说明:本站主要是个人的一些笔记和代码分享,内容可能会不定期修改。为了使全网显示的始终是最新版本,这里的文章未经同意请勿转载。引用请注明出处:https://www.guanjihuan.com

2 thoughts on “倒格子基矢的计算(附数值计算、符号计算Python代码)”

发表评论

您的邮箱地址不会被公开。 必填项已用 * 标注

Captcha Code