Skip to content

Commit

Permalink
correct covariance function for two dimensional PL sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
EigenSolver committed Aug 22, 2024
1 parent 640fc67 commit 468eb8d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions src/stochastics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ end


"""
Pink-Brownian Field, the correlation function of which is
Pink-Lorentzian Field, the correlation function of which is
`σ^2 * (expinti(-γ[2]abs(t₁ - t₂)) - expinti(-γ[1]abs(t₁ - t₂)))/log(γ[2]/γ[1]) * exp(-|x₁-x₂|/θ)`
where `expinti` is the exponential integral function.
"""
struct PinkLorentzianField <: GaussianRandomField
μ::Union{<:Real,Function} # mean
θ::Vector{<:Real}
κ::Real
σ::Real
γ::Tuple{<:Real,<:Real} # cutoffs of 1/f
end
Expand Down Expand Up @@ -151,8 +151,8 @@ function covariance(p₁::Point, p₂::Point, process::PinkLorentzianField)::Rea
x₂ = p₂[2:end]
γ = process.γ
cov_pink = t₁ != t₂ ? (expinti(-γ[2]abs(t₁ - t₂)) - expinti(-γ[1]abs(t₁ - t₂))) / log(γ[2] / γ[1]) : 1
cov_brown = exp(-dot(process.θ, abs.(x₁ .- x₂)))
return process.σ^2 * cov_pink * cov_brown
cov_exp = exp(-process.κ*norm(x₁ .- x₂))
return process.σ^2 * cov_pink * cov_exp
end

"""
Expand Down
44 changes: 22 additions & 22 deletions test/testfidelity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ end
σ = sqrt(2)/20; M = 5000; N=501; L=10; γ=(1e-2,1e2); # MHz
# 0.01 ~ 100 μs
# v = 0.1 ~ 1000 m/s
v=1; T=L/v; κₓ=10;
v=1; T=L/v; κ=10;
# T=10
# 1/T=0.1 N/T=20
B=PinkLorentzianField(0,[κₓ],σ, γ)
B=PinkLorentzianField(0,κ,σ, γ)
model=OneSpinModel(T,L,N,B)

f1=statefidelity(model)
Expand Down Expand Up @@ -133,24 +133,24 @@ end
println("TH:", f3)
end

@testset "test two spin parallel shuttling fidelity with 1/f noise" begin
σ = sqrt(2)/20; M = 5000; N=501; L=10; γ=(1e-9,1e3); # MHz
# 0.01 ~ 100 μs
# v = 0.1 ~ 1000 m/s
v=1; T=L/v; κₓ=10;
# T=10
# 1/T=0.1 N/T=20
D=0.3;
B=PinkLorentzianField(0,[κₓ,κₓ],σ, γ)
model=TwoSpinParallelModel(T, D, L, N, B)
# @testset "test two spin parallel shuttling fidelity with 1/f noise" begin
# σ = sqrt(2)/20; M = 5000; N=501; L=10; γ=(1e-9,1e3); # MHz
# # 0.01 ~ 100 μs
# # v = 0.1 ~ 1000 m/s
# v=1; T=L/v; κₓ=10;
# # T=10
# # 1/T=0.1 N/T=20
# D=0.3;
# B=PinkLorentzianField(0,[κₓ,κₓ],σ, γ)
# model=TwoSpinParallelModel(T, D, L, N, B)

f1=statefidelity(model)
f2, f2_err=sampling(model, statefidelity, M)
w=exp(-B.σ^2 * T^2 * 2(1-exp(-κₓ*D)) * SpinShuttling.F3.*T, κₓ*L))
f3=1/2*(1+w)
@test isapprox(f1, f3,rtol=3e-2)
@test isapprox(f2, f3, rtol=3e-2)
println("NI:", f1)
println("MC:", f2)
println("TH:", f3)
end
# f1=statefidelity(model)
# f2, f2_err=sampling(model, statefidelity, M)
# w=exp(-B.σ^2 * T^2 * 2(1-exp(-κₓ*D)) * SpinShuttling.F3(γ.*T, κₓ*L))
# f3=1/2*(1+w)
# @test isapprox(f1, f3,rtol=3e-2)
# @test isapprox(f2, f3, rtol=3e-2)
# println("NI:", f1)
# println("MC:", f2)
# println("TH:", f3)
# end
4 changes: 2 additions & 2 deletions test/testspectrum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ visualize=true

##
@testset "test 1/f noise" begin
σ = 1; M = 1000; N=1001; κₜ=1;κₓ=0;
σ = 1; M = 1000; N=1001;
L=10;
γ=(1e-5,1e3) # MHz
# 0.01 ~ 100 μs
# v = 0.1 ~ 1000 m/s
v=1; T=L/v;
B=PinkLorentzianField(0,[κₓ],σ, γ)
B=PinkLorentzianField(0.0,0.0,σ, γ)
model=OneSpinModel(T,L,N,B)
println(model)

Expand Down
2 changes: 1 addition & 1 deletion test/teststochastics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ end
# 0.01 ~ 100 μs
# v = 0.1 ~ 1000 m/s
v=2;
B=PinkLorentzianField(0,[κₓ],σ, γ)
B=PinkLorentzianField(0,κₓ, σ, γ)
# B=OrnsteinUhlenbeckField(0,[κₜ,κₓ],σ)

M=5
Expand Down

0 comments on commit 468eb8d

Please sign in to comment.