我如何 select python 中的六角布里渊区的三角扇区?

How do I select a trigonal sector of a hexagonal Brillouin zone in python?

我正在尝试 select 石墨烯六角布里渊的 k 点周围的三角形区域。我这样试过:

import random
import numpy as np

def trisample(A, B, C):
  r1 = float(random.random())
  r2 = float(random.random())
  s1 =float( np.sqrt(r1))
  x = float( A[0] * (1.0 - s1) + B[0] * (1.0 - r2) * s1 + C[0] * r2 * s1)
  y = float( A[1] * (1.0 - s1) + B[1] * (1.0 - r2) * s1 + C[1] * r2 * s1)
  return (x, y)
    
random.seed(5)
A = (0.2,0.1)
B = (0.5, 0.1)
C = (0.5, 0.0)
points = [trisample(A, B, C) for _ in range(10000)]

kxx, kyy = (zip(*points))

然后,我尝试将 kxx, kyy 插入

(2*np.cos(2*np.pi*kyy) + 4*np.cos((3**0.5)*np.pi*kxx)*np.cos(np.pi*kyy))

但报错

TypeError                                 Traceback (most recent call last)

<ipython-input-5-cb758caa3c7d> in <module>()
----> 1 (2*np.cos(2*np.pi*kyy)+ 4*np.cos((3**0.5)*np.pi* kxx)*np.cos(np.pi*kyy))

TypeError: can't multiply sequence by non-int of type 'float'

我做错了什么?如何摆脱这个错误?

尝试将 kxxkyy 转换为 numpy 数组:

kxx = np.array(kxx)
kyy = np.array(kyy)

在将它们插入该公式之前。