-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathsystem-correlations.py
129 lines (100 loc) · 3.67 KB
/
system-correlations.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
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env python
# coding: utf-8
import sys
sys.path.insert(0,'.')
import numpy as np
import matplotlib.pyplot as plt
#from IPython import embed
import oqupy
import oqupy.operators as op
# -----------------------------------------------------------------------------
omega_cutoff = 3.04
alpha = 0.126
temperature = 0.1309
initial_state=op.spin_dm("z-")
def gaussian_shape(t, area = 1.0, tau = 1.0, t_0 = 0.0):
return area/(tau*np.sqrt(np.pi)) * np.exp(-(t-t_0)**2/(tau**2))
detuning = lambda t: 0.0 * t
t = np.linspace(-2,3,100)
Omega_t = gaussian_shape(t, area = np.pi/2.0, tau = 0.245)
Delta_t = detuning(t)
correlations = oqupy.PowerLawSD(alpha=alpha,
zeta=3,
cutoff=omega_cutoff,
cutoff_type='gaussian',
temperature=temperature)
print('type=',type(correlations))
print(issubclass(type(correlations), oqupy.correlations.BaseCorrelations))
bath = oqupy.Bath(op.sigma("z")/2.0, correlations)
tempo_parameters = oqupy.TempoParameters(
dt=0.10,
epsrel=10**(-5),
dkmax=20,
add_correlation_time=2.0)
oqupy.helpers.plot_correlations_with_parameters(correlations, tempo_parameters)
start_time = -1.0
process_tensor = oqupy.pt_tempo_compute(bath=bath,
start_time=start_time,
end_time=1.0,
parameters=tempo_parameters)
def hamiltonian_t(t, delta=0.0):
return delta/2.0 * op.sigma("z") \
+ gaussian_shape(t, area = np.pi/2.0, tau = 0.245)/2.0 \
* op.sigma("x")
system = oqupy.TimeDependentSystem(hamiltonian_t)
# -----------------------------------------------------------------------------
print("-------- Example A --------")
times_a, times_b, correlations = oqupy.compute_correlations(
system=system,
process_tensor=process_tensor,
operator_a=op.sigma("x"),
operator_b=op.sigma("z"),
times_a=-0.5,
times_b=0.5,
time_order="full",
initial_state=initial_state,
start_time=start_time,
progress_type="bar")
print(f"times_a = {times_a}")
print(f"times_b = {times_b}")
print("Correlation matrix:")
print(correlations)
control = oqupy.Control(2)
control.add_single(5, op.left_super(op.sigma("x")))
s_xy_list = []
t_list = []
dynamics = oqupy.compute_dynamics(
system=system,
process_tensor=process_tensor,
control=control,
start_time=start_time,
initial_state=initial_state)
t, s_x = dynamics.expectations(op.sigma("x"))
_, s_y = dynamics.expectations(op.sigma("y"))
_, s_z = dynamics.expectations(op.sigma("z"))
plt.figure(2)
for i, s_xyz in enumerate([s_x, s_y, s_z]):
plt.plot(t, s_xyz.real, color=f"C{i}", linestyle="solid")
plt.plot(t, s_xyz.imag, color=f"C{i}", linestyle="dotted")
plt.xlabel(r'$t/$ps')
plt.ylabel(r'$<\sigma_{xyz}>$')
plt.scatter(times_b[0],correlations[0, 0].real, color="C2", marker="o")
plt.scatter(times_b[0],correlations[0, 0].imag, color="C2", marker="x")
# -----------------------------------------------------------------------------
print("-------- Example B --------")
times_a, times_b, correlations = oqupy.compute_correlations(
system=system,
process_tensor=process_tensor,
operator_a=op.sigma("x"),
operator_b=op.sigma("z"),
times_a=(-0.4, 0.4),
times_b=slice(8, 14),
time_order="ordered",
initial_state=initial_state,
start_time=start_time,
progress_type="bar")
print(f"times_a = {times_a}")
print(f"times_b = {times_b}")
print("Shape of correlations matrix:")
print(np.abs(correlations) >= 0.0)
plt.show()