-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfield.py
More file actions
32 lines (27 loc) · 734 Bytes
/
field.py
File metadata and controls
32 lines (27 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python3
import numpy as np
from numpy import tile
from scipy import linalg as LA
import math,cmath
pi = math.pi
cos = math.cos
sin = math.sin
exp=np.exp
sqrt = math.sqrt
log=np.log
def field(Nky, Nth, U1,U2):
Field=np.zeros((2*Nth+1,2*Nky+1),dtype=complex)
for nth in range(2*Nth+1):
for nky in range(2*Nky+1):
if (nth < 2*Nth):
nthh=nth+1
else:
nthh=1
if (nky < 2*Nky):
nkyy=nky+1
else:
nkyy=1
Field[nth,nky]=log((U1[nth,nky]*U2[nthh,nky])/(U1[nth,nkyy]*U2[nth,nky]))
mu=sum(sum(i) for i in Field)
mu=mu/(4.0*pi*1j)
return mu.real