11# [ Low rank master equation] (@id doc-tutor: Low-rank-master-equation )
22
3+ In this tutorial, we will show how to solve the master equation using the low-rank method. For a detailed explaination of the method, we recommend to read the article [ gravina2024adaptive] ( @cite ) .
4+
5+ As a test, we will consider the dissipative Ising model with a transverse field. The Hamiltonian is given by
6+
7+ ``` math
8+ \hat{H} = \frac{J_x}{2} \sum_{\langle i,j \rangle} \sigma_i^x \sigma_j^x + \frac{J_y}{2} \sum_{\langle i,j \rangle} \sigma_i^y \sigma_j^y + \frac{J_z}{2} \sum_{\langle i,j \rangle} \sigma_i^z \sigma_j^z - \sum_i h_i \sigma_i^z + h_x \sum_i \sigma_i^x + h_y \sum_i \sigma_i^y + h_z \sum_i \sigma_i^z,
9+ ```
10+
11+ where the sums are over nearest neighbors, and the collapse operators are given by
12+
13+ ``` math
14+ c_i = \sqrt{\gamma} \sigma_i^-.
15+ ```
16+
317We start by importing the packages
418
519``` @example lowrank
@@ -21,42 +35,42 @@ Define lr-space dimensions
2135N_cut = 2 # Number of states of each mode
2236N_modes = latt.N # Number of modes
2337N = N_cut^N_modes # Total number of states
24- M = Nx * Ny + 1 # Number of states in the LR basis
38+ M = latt.N + 1 # Number of states in the LR basis
2539```
2640
2741Define lr states. Take as initial state all spins up. All other N states are taken as those with miniman Hamming distance to the initial state.
2842
2943``` @example lowrank
30- ϕ = Vector{QuantumObject{Vector{ComplexF64},KetQuantumObject}}(undef, M)
31- ϕ[1] = kron(repeat([ basis(2, 0)] , N_modes)...)
44+ ϕ = Vector{QuantumObject{Vector{ComplexF64},KetQuantumObject,M-1 }}(undef, M)
45+ ϕ[1] = kron(fill( basis(2, 1) , N_modes)...)
3246
33- global i = 1
47+ i = 1
3448for j in 1:N_modes
3549 global i += 1
36- i <= M && (ϕ[i] = mb(sp , j, latt) * ϕ[1])
50+ i <= M && (ϕ[i] = SingleSiteOperator(sigmap() , j, latt) * ϕ[1])
3751end
3852for k in 1:N_modes-1
3953 for l in k+1:N_modes
4054 global i += 1
41- i <= M && (ϕ[i] = mb(sp , k, latt) * mb(sp , l, latt) * ϕ[1])
55+ i <= M && (ϕ[i] = SingleSiteOperator(sigmap() , k, latt) * SingleSiteOperator(sigmap() , l, latt) * ϕ[1])
4256 end
4357end
4458for i in i+1:M
4559 ϕ[i] = QuantumObject(rand(ComplexF64, size(ϕ[1])[1]), dims = ϕ[1].dims)
4660 normalize!(ϕ[i])
4761end
62+ nothing # hide
4863```
4964
5065Define the initial state
5166
5267``` @example lowrank
53- z = hcat(broadcast(x -> x.data, ϕ)...)
54- p0 = 0.0 # Population of the lr states other than the initial state
55- B = Matrix(Diagonal([1 + 0im; p0 * ones(M - 1)]))
68+ z = hcat(get_data.(ϕ)...)
69+ B = Matrix(Diagonal([1 + 0im; zeros(M - 1)]))
5670S = z' * z # Overlap matrix
5771B = B / tr(S * B) # Normalize B
5872
59- ρ = QuantumObject(z * B * z', dims = ones(Int, N_modes) * N_cut ); # Full density matrix
73+ ρ = QuantumObject(z * B * z', dims = ntuple(i->N_cut, Val( N_modes)) ); # Full density matrix
6074```
6175
6276Define the Hamiltonian and collapse operators
@@ -67,26 +81,26 @@ Jx = 0.9
6781Jy = 1.04
6882Jz = 1.0
6983hx = 0.0
84+ hy = 0.0
85+ hz = 0.0
7086γ = 1
7187
72- Sx = sum([mb(sx, i, latt) for i in 1:latt.N])
73- Sy = sum([mb(sy, i, latt) for i in 1:latt.N])
74- Sz = sum([mb(sz, i, latt) for i in 1:latt.N])
75- SFxx = sum([mb(sx, i, latt) * mb(sx, j, latt) for i in 1:latt.N for j in 1:latt.N])
88+ Sx = mapreduce(i->SingleSiteOperator(sigmax(), i, latt), +, 1:latt.N)
89+ Sy = mapreduce(i->SingleSiteOperator(sigmay(), i, latt), +, 1:latt.N)
90+ Sz = mapreduce(i->SingleSiteOperator(sigmaz(), i, latt), +, 1:latt.N)
7691
77- H, c_ops = TFIM (Jx, Jy, Jz, hx, γ, latt; bc = pbc , order = 1)
78- e_ops = (Sx, Sy, Sz, SFxx )
92+ H, c_ops = DissipativeIsing (Jx, Jy, Jz, hx, hy, hz, γ, latt; boundary_condition = Val(:periodic_bc) , order = 1)
93+ e_ops = (Sx, Sy, Sz)
7994
80- tl = LinRange(0, 10, 100);
95+ tl = range(0, 10, 100)
96+ nothing # hide
8197```
8298
8399### Full evolution
84100
85101``` @example lowrank
86- @time mesol = mesolve(H, ρ, tl, c_ops; e_ops = [e_ops...]);
87- A = Matrix(mesol.states[end].data)
88- λ = eigvals(Hermitian(A))
89- Strue = -sum(λ .* log2.(λ)) / latt.N;
102+ sol_me = mesolve(H, ρ, tl, c_ops; e_ops = [e_ops...]);
103+ Strue = entropy_vn(sol_me.states[end], base=2) / latt.N
90104```
91105
92106### Low Rank evolution
@@ -120,26 +134,23 @@ function f_entropy(p, z, B)
120134
121135 mul!(C, z, sqrt(B))
122136 mul!(σ, C', C)
123- λ = eigvals(Hermitian(σ))
124- λ = λ[λ.>1e-10]
125- return -sum(λ .* log2.(λ))
126- end;
137+ return entropy_vn(Qobj(Hermitian(σ), type=Operator), base=2)
138+ end
127139```
128140
129141Define the options for the low-rank evolution
130142
131143``` @example lowrank
132- opt =
133- LRMesolveOptions(err_max = 1e-3, p0 = 0.0, atol_inv = 1e-6, adj_condition = "variational", Δt = 0.0);
144+ opt = (err_max = 1e-3, p0 = 0.0, atol_inv = 1e-6, adj_condition = "variational", Δt = 0.0);
134145
135- @time lrsol = lr_mesolve(H, z, B, tl, c_ops; e_ops = e_ops, f_ops = (f_purity, f_entropy, f_trace), opt = opt);
146+ sol_lr = lr_mesolve(H, z, B, tl, c_ops; e_ops = e_ops, f_ops = (f_purity, f_entropy, f_trace), opt = opt);
136147```
137148
138149Plot the results
139150
140151``` @example lowrank
141- m_me = real(mesol .expect[3, :]) / Nx / Ny
142- m_lr = real(lrsol.expvals [3, :]) / Nx / Ny
152+ m_me = real(sol_me .expect[3, :]) / Nx / Ny
153+ m_lr = real(sol_lr.expect [3, :]) / Nx / Ny
143154
144155fig = Figure(size = (500, 350), fontsize = 15)
145156ax = Axis(fig[1, 1], xlabel = L"\gamma t", ylabel = L"M_{z}", xlabelsize = 20, ylabelsize = 20)
@@ -148,17 +159,17 @@ lines!(ax, tl, m_me, label = "Fock", linewidth = 2, linestyle = :dash)
148159axislegend(ax, position = :rb)
149160
150161ax2 = Axis(fig[1, 2], xlabel = L"\gamma t", ylabel = "Value", xlabelsize = 20, ylabelsize = 20)
151- lines!(ax2, tl, 1 .- real(lrsol.funvals [1, :]), label = L"$1-P$", linewidth = 2)
162+ lines!(ax2, tl, 1 .- real(sol_lr.fexpect [1, :]), label = L"$1-P$", linewidth = 2)
152163lines!(
153164 ax2,
154165 tl,
155- 1 .- real(lrsol.funvals [3, :]),
166+ 1 .- real(sol_lr.fexpect [3, :]),
156167 label = L"$1-\mathrm{Tr}(\rho)$",
157168 linewidth = 2,
158169 linestyle = :dash,
159170 color = :orange,
160171)
161- lines!(ax2, tl, real(lrsol.funvals [2, :]) / Nx / Ny, color = :blue, label = L"S", linewidth = 2)
172+ lines!(ax2, tl, real(sol_lr.fexpect [2, :]) / Nx / Ny, color = :blue, label = L"S", linewidth = 2)
162173hlines!(ax2, [Strue], color = :blue, linestyle = :dash, linewidth = 2, label = L"S^{\,\mathrm{true}}_{\mathrm{ss}}")
163174axislegend(ax2, position = :rb)
164175
0 commit comments