Skip to content

Commit

Permalink
refactor issue unresolved yet
Browse files Browse the repository at this point in the history
  • Loading branch information
EigenSolver committed Apr 19, 2024
1 parent 8d667d6 commit 2b66fb1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/SpinShuttling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ function averagefidelity(model::ShuttlingModel)::Real
elseif model.n > 2
error("The number of spins is not supported")
end
χ = real(characteristicvalue(R))
F = @. 1 / 2 * (1 + χ)
W = real(characteristicvalue(R))
F = @. 1 / 2 * (1 + W)
return F
end

Expand Down
10 changes: 7 additions & 3 deletions src/stochastics.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
abstract type RandomField end
abstract type GaussianRandomField <: RandomField end # n-dimensional

Point = Tuple{Vararg{Real}}
Point{N} = Tuple{Vararg{Real,N}}

"""
Ornstein-Uhlenbeck field, the correlation function of which is
Expand Down Expand Up @@ -85,7 +85,8 @@ function CompositeRandomFunction(R::RandomFunction, c::Vector{Int})::RandomFunct
N=size(R.Σ,1)
μ = sum(c .*meanpartition(R, n))
Σ = Symmetric(sum((c*c') .* covariancepartition(R, n)))
return RandomFunction(μ, R.P[1:(N÷n)], Σ, cholesky(Σ))
t=[(p[1],) for p in R.P[1:(N÷n)]]
return RandomFunction(μ, t, Σ, cholesky(Σ))
end

function CompositeRandomFunction(P::Vector{<:Point}, process::GaussianRandomField, c::Vector{Int})::RandomFunction
Expand Down Expand Up @@ -115,6 +116,9 @@ function covariance(p₁::Point, p₂::Point, process::OrnsteinUhlenbeckField)::
process.σ^2 / 4*prod( process.θ) * exp(-dot(process.θ, abs.(p₁ .- p₂)))
end

function covariance(p₁::Vector{<:Real}, p₂::Vector{<:Real}, process::OrnsteinUhlenbeckField)::Real
process.σ^2 / 4*prod( process.θ) * exp(-dot(process.θ, abs.(p₁ .- p₂)))
end

function covariance(p₁::Point, p₂::Point, process::PinkBrownianField)::Real
t₁ = p₁[1]
Expand All @@ -123,7 +127,7 @@ function covariance(p₁::Point, p₂::Point, process::PinkBrownianField)::Real
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₂)))
cov_brown = exp(-dot(process.θ, abs.(x₁ .- x₂)))
return process.σ^2 * cov_pink * cov_brown
end

Expand Down
8 changes: 3 additions & 5 deletions test/testfidelity.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
##
visualize=true

#
##
@testset begin "test single spin shuttling fidelity"
T=400; L=10; σ = sqrt(2) / 20; M = 20000; N=601; κₜ=1/20;κₓ=1/0.1;
v=L/T;
t=range(0, T, N)
P=collect(zip(t, v.*t))
T=200; L=10; σ = sqrt(2) / 20; M = 2000; N=601; κₜ=1/20;κₓ=1/0.1;

B=OrnsteinUhlenbeckField(0,[κₜ,κₓ],σ)

model=OneSpinModel(T,L,N,B)
Expand Down

0 comments on commit 2b66fb1

Please sign in to comment.