I am trying to select a trigonal region around the k point of the hexagonal Brillouin of graphene. I tried in this way:
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))
Then, I try to insert the kxx, kyy
into
(2*np.cos(2*np.pi*kyy) + 4*np.cos((3**0.5)*np.pi*kxx)*np.cos(np.pi*kyy))
but get as error
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'
What is the mistake that I am doing? How to get rid of this error?
Try to convert kxx
and kyy
to numpy arrays:
kxx = np.array(kxx)
kyy = np.array(kyy)
before inserting them in that formula.