-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnoise.py
120 lines (95 loc) · 3.86 KB
/
noise.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# This is the script for plotting the spin
# texture and spin currents.
# Here we will add some noise to the order
# parameter
#
# Tian-Qi Chen, 20/11/2016
# from scipy.special import jn
from matplotlib.pyplot import cm
# from sympy import Symbol, diff
import matplotlib.pyplot as plt
import numpy as np
from pylab import rcParams
rcParams['figure.figsize'] = 10, 8
# Here we plot the spin superfluid current with noice
# First we try to test how to perform partial derivative
# in python using sympy
#X = Symbol('X')
#Y = Symbol('Y')
#f_X = diff(1/(X**2+Y**2), X)
#g_Y = diff(1/(X**2+Y**2), Y)
#print(f_X)
# Parameter define
gamma = 1.00 # the strength of the noise
sigma_2 = 100 # the sigma squared in the function of noise
sigma_1 = 10000 # the sigma squared in the exponential of all Chi's
sigma_3 = 10000 # the sigma squared in Chi_1 and Chi_{-1}
sigma_4 = 10000 # the sigma squared in Chi_0
C_1 = 1/np.sqrt(2*np.pi*sigma_3)
C_2 = 1/np.sqrt(2*np.pi*sigma_4)
N_f = 1 # N_f winding number
N_g = 2 # N_g winding number
x_0 = np.array([1, -2])
y_0 = np.array([0, 0]) # the coordinates of the centers of the noise
N = len(x_0) # the length of the coordinates array
# Define functions to calculate partial derivatives
def devx(x, y):
tmp_1 = 0
tmp_2 = 0 # initialization
for i in range(N):
tmp_1 = tmp_1+np.exp(-((x-x_0[i])**2+(y-y_0[i])**2)/(2*sigma_2))
for j in range(N):
tmp_2 = tmp_2+(-1)*(x-x_0[j])/sigma_2 *np.exp(-((x-x_0[j])**2+(y-y_0[j])**2)/(2*sigma_2))
return (-y/(x**2+y**2))*(1+gamma*tmp_1)+np.arctan(y/x)*gamma*tmp_2
def devy(x, y):
tmp_1 = 0
tmp_2 = 0
for i in range(N):
tmp_1 = tmp_1+np.exp(-((x-x_0[i])**2+(y-y_0[i])**2)/(2*sigma_2))
for j in range(N):
tmp_2 = tmp_2+(-1)*(y-y_0[j])/sigma_2 *np.exp(-((x-x_0[j])**2+(y-y_0[j])**2)/(2*sigma_2))
return (x/(x**2+y**2))*(1+gamma*tmp_1)+np.arctan(y/x)*gamma*tmp_2
# Define the y-dependent density function
def rho(y):
return np.sqrt((2*C_1**2+C_2**2)*np.exp(-y**2/sigma_1))
def KdotF1(y):
return 2*np.sqrt(2/3)*C_1*C_2*np.exp(-y**2/(1*sigma_1))
def KdotF2(y):
return 2/3 * (2*C_1**2+C_2**2) * np.exp(-y**2/(1*sigma_1))
# Define the Hermite polynomial function for n=2
#def Her(x, y, a, b, s):
# rst = 0
# if s == 0:
# rst = 1
# elif s == 1:
# rst = a*(x**2+y**2) - b
# else:
# print('The parameter s is wrong.')
# return rst
# Plot the spin superfluid current density
Y, X = np.mgrid[-5:5:20j, -5:5:20j] # X, Y are the plot starting points
#U = (devx(X, Y)*N_f + KdotF1(Y)*devx(X, Y)*N_g) * rho(Y) # the conventional current
#V = (devy(X, Y)*N_f + KdotF1(Y)*devy(X, Y)*N_g) * rho(Y)
#U = (devx(X, Y)*N_f*KdotF1(Y) + KdotF2(Y)*devx(X, Y)*N_g) * rho(Y) # the first-order spin current
#V = (devy(X, Y)*N_f*KdotF1(Y) + KdotF2(Y)*devy(X, Y)*N_g) * rho(Y)
U = (devx(X, Y)*N_f*KdotF2(Y) + KdotF1(Y)*devx(X, Y)*N_g) * rho(Y) # the second-order spin current
V = (devy(X, Y)*N_f*KdotF2(Y) + KdotF1(Y)*devy(X, Y)*N_g) * rho(Y)
#U = devx(X, Y) # The situation where Chi(r) is an constant
#V = devy(X, Y)
speed = np.sqrt(U**2 + V**2)
#speed = U*2+V
UN = U/speed
VN = V/speed
plot1 = plt.figure()
plt.quiver(X, Y, UN, VN, # data
speed*100000, # colour the arrows based on this array
cmap=cm.seismic, # colour map
headlength=5) # length of the arrows
plt.colorbar() # adds the colour bar
#plt.title('Spin superfluid current with noise')
plt.xticks(fontsize=20)
plt.yticks(fontsize=20)
plt.xlabel(r'$X$', fontsize=20)
plt.ylabel(r'$Y$', fontsize=20)
plt.savefig('Js2Plot(Noise='+str(gamma)+').eps', format='eps')
plt.show(plot1) # display the plot