# About Error:"Correlation function is not specified"

**URL:** <https://discourse.julialang.org/t/about-error-correlation-function-is-not-specified/85753>\
**Category:** General Usage\
**Tags:** question, quantum\
**Created:** [August 15, 2022, 2:32am UTC](https://discourse.julialang.org/t/about-error-correlation-function-is-not-specified/85753 "2022-08-15T02:32:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yangheng\_Jizhe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yangheng_jizhe/32/36007_2.png) [@Yangheng\_Jizhe](https://discourse.julialang.org/u/Yangheng_Jizhe)\
**Post date:** [August 15, 2022, 2:32am UTC](https://discourse.julialang.org/t/about-error-correlation-function-is-not-specified/85753/1 "2022-08-15T02:32:53Z")

</div>

Hi there,  
I’m new to Julia, and I jumped into this error:

I defined a CustomBath:

physFact = 16/0.33338579560200365  
ctoff = 0.01_2_pi  
function smsi(x)  
if abs(x) \<ctoff  
a = x/(ctoff^2)  
else  
a =sign(x)/abs(x)  
end  
a  
end

a1 = 0.003  
a2 = 0.25  
cT1 = 15  
cT2 = 0.25

function f(x)  
if x==0  
a2_pi_η\_h_cT2_T\_h_4_pi/(physFact\*(ctoff^2))+pi\*(a1_η\_h)cT1T\_h_4_pi/(physFact)  
else  
a2_pi_η\_h_smsi(x)_(1+coth(physFact_x/(cT2_T\_h_4_pi)))exp(-abs(x)/(fc\_h2_pi))+pi\*(a1_η\_h_x)_(1+coth(physFact_x/(cT1_T\_h_4_pi)))exp(-abs(x)/(fc\_h2_pi))  
end  
end

bath\_f = CustomBath(spectrum = f)

And I used this Bath to build an Annealing Object and solved Redfield to this annealing object:  
P\_r\_f =   
epsilon = 0.5

H\_s\_05 = DenseHamiltonian([(s)-\>0.035, (s)-\>epsilon], [-σx, -σz], unit =:ħ)  
annealing\_r\_05 = Annealing(H\_s\_05, u0, coupling = coupling, bath = bath\_f)

U\_05 = solve\_unitary(annealing\_r\_05, tf, alg = Tsit5(), abstol = 1e-8)  
sol\_r\_05 = solve\_redfield(annealing\_r\_05,tf,U\_05; alg = Tsit5(), abstol = 1e-18,int\_atol = 1e-10,tstops=range(0,tf,length=100))

time\_list\_r\_05 = 1:length(sol\_r\_05)  
for t in time\_list\_r\_05  
push!(P\_r\_f, sol\_r\_05[Int(t)][1,1].re)  
end  
print(length(time\_list\_r\_05))  
scatter(time\_list\_r\_05\*tf/length(sol\_r\_05),P\_r\_f[1:end], label="rf,ϵ=0.5,T = 128 ",legend = (.4,.65),markersize = 1)

And then the error “correlation function is not specified” showed up with the Stacktrace:

Correlation function is not specified.

Stacktrace:  
[1] error(s::String)  
@ Base ./error.jl:33  
[2] build\_correlation(bath::CustomBath)  
@ OpenQuantumBase ~/.julia/packages/OpenQuantumBase/Hx01G/src/bath/custom.jl:21  
[3] build\_redfield\_kernel(i::Interaction)  
@ OpenQuantumBase ~/.julia/packages/OpenQuantumBase/Hx01G/src/coupling/interaction.jl:159  
[4] #112  
@ ./array.jl:0 [inlined]  
[5] iterate  
@ ./generator.jl:47 [inlined]  
[6] grow\_to!(dest::Vector{Tuple{Any, OpenQuantumBase.AbstractCouplings, Any}}, itr::Base.Generator{Base.Iterators.Filter{OpenQuantumBase.var"#113#115", InteractionSet{Tuple{Interaction}}}, OpenQuantumBase.var"#112#114"})  
@ Base ./array.jl:797  
[7] collect  
@ ./array.jl:721 [inlined]  
[8] redfield\_from\_interactions(iset::InteractionSet{Tuple{Interaction}}, U::ODESolution{ComplexF64, 3, Vector{Matrix{ComplexF64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Matrix{ComplexF64}}}, ODEProblem{Matrix{ComplexF64}, Tuple{Float64, Float64}, true, ODEParams, ODEFunction{true, DiffEqArrayOperator{ComplexF64, Matrix{ComplexF64}, OpenQuantumTools.var"#31#33"}, UniformScaling{Bool}, Nothing, Nothing, typeof(update\_coefficients!), Nothing, Nothing, DiffEqArrayOperator{ComplexF64, Matrix{ComplexF64}, OpenQuantumTools.var"#30#32"}, DiffEqArrayOperator{ComplexF64, Matrix{ComplexF64}, OpenQuantumTools.var"#30#32"}, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT\_OBSERVED), Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, Tsit5{typeof(OrdinaryDiffEq.trivial\_limiter!), typeof(OrdinaryDiffEq.trivial\_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{ODEFunction{true, DiffEqArrayOperator{ComplexF64, Matrix{ComplexF64}, OpenQuantumTools.var"#31#33"}, UniformScaling{Bool}, Nothing, Nothing, typeof(update\_coefficients!), Nothing, Nothing, DiffEqArrayOperator{ComplexF64, Matrix{ComplexF64}, OpenQuantumTools.var"#30#32"}, DiffEqArrayOperator{ComplexF64, Matrix{ComplexF64}, OpenQuantumTools.var"#30#32"}, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT\_OBSERVED), Nothing}, Vector{Matrix{ComplexF64}}, Vector{Float64}, Vector{Vector{Matrix{ComplexF64}}}, OrdinaryDiffEq.Tsit5Cache{Matrix{ComplexF64}, Matrix{ComplexF64}, Matrix{ComplexF64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}, typeof(OrdinaryDiffEq.trivial\_limiter!), typeof(OrdinaryDiffEq.trivial\_limiter!), Static.False}}, DiffEqBase.DEStats}, Ta::Int64, atol::Float64, rtol::Float64)  
@ OpenQuantumBase ~/.julia/packages/OpenQuantumBase/Hx01G/src/coupling/interaction.jl:77  
[9] solve\_redfield(A::Annealing{DenseHamiltonian{ComplexF64, true}, Vector{ComplexF64}}, tf::Int64, unitary::ODESolution{ComplexF64, 3, Vector{Matrix{ComplexF64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Matrix{ComplexF64}}}, ODEProblem{Matrix{ComplexF64}, Tuple{Float64, Float64}, true, ODEParams, ODEFunction{true, DiffEqArrayOperator{ComplexF64, Matrix{ComplexF64}, OpenQuantumTools.var"#31#33"}, UniformScaling{Bool}, Nothing, Nothing, typeof(update\_coefficients!), Nothing, Nothing, DiffEqArrayOperator{ComplexF64, Matrix{ComplexF64}, OpenQuantumTools.var"#30#32"}, DiffEqArrayOperator{ComplexF64, Matrix{ComplexF64}, OpenQuantumTools.var"#30#32"}, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT\_OBSERVED), Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, Tsit5{typeof(OrdinaryDiffEq.trivial\_limiter!), typeof(OrdinaryDiffEq.trivial\_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{ODEFunction{true, DiffEqArrayOperator{ComplexF64, Matrix{ComplexF64}, OpenQuantumTools.var"#31#33"}, UniformScaling{Bool}, Nothing, Nothing, typeof(update\_coefficients!), Nothing, Nothing, DiffEqArrayOperator{ComplexF64, Matrix{ComplexF64}, OpenQuantumTools.var"#30#32"}, DiffEqArrayOperator{ComplexF64, Matrix{ComplexF64}, OpenQuantumTools.var"#30#32"}, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT\_OBSERVED), Nothing}, Vector{Matrix{ComplexF64}}, Vector{Float64}, Vector{Vector{Matrix{ComplexF64}}}, OrdinaryDiffEq.Tsit5Cache{Matrix{ComplexF64}, Matrix{ComplexF64}, Matrix{ComplexF64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}, typeof(OrdinaryDiffEq.trivial\_limiter!), typeof(OrdinaryDiffEq.trivial\_limiter!), Static.False}}, DiffEqBase.DEStats}; vectorize::Bool, int\_atol::Float64, int\_rtol::Float64, Ta::Int64, kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:alg, :abstol, :tstops), Tuple{Tsit5{typeof(OrdinaryDiffEq.trivial\_limiter!), typeof(OrdinaryDiffEq.trivial\_limiter!), Static.False}, Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}}})  
@ OpenQuantumTools ~/.julia/packages/OpenQuantumTools/Eu6Hn/src/QSolver/redfield\_solver.jl:29  
[10] top-level scope  
@ In[122]:8  
[11] eval  
@ ./boot.jl:373 [inlined]  
[12] include\_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)  
@ Base ./loading.jl:1196

I’m wondering if anyone here knows what’s going on here. Thank you so much!

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [August 15, 2022, 2:44am UTC](https://discourse.julialang.org/t/about-error-correlation-function-is-not-specified/85753/2 "2022-08-15T02:44:12Z")

</div>

I’ve moved your question to the General Usage category, since it’s not about internals of the julia language.

It’ll be easier for someone to help you if you format your code as a code block, by surrounding it in triple backticks (`).

---

<div class="post-metadata">

**Author:** ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)\
**Post date:** [August 15, 2022, 4:16am UTC](https://discourse.julialang.org/t/about-error-correlation-function-is-not-specified/85753/3 "2022-08-15T04:16:41Z")

</div>

Agreed about the formatting, as an example, typing

````julia
```
bath_f = CustomBath(spectrum = f)
```

````

will result in

```julia
bath_f = CustomBath(spectrum = f)

```

* * *

I’m not familiar with this package or this field of study (so I may be wrong about this), but based on a look at the code, it seems like for solvers other than `solve_ame`, you need to specify a correlation function when building the `CustomBath`. The only example I found of using a `CustomBath` with `solve_redfield` is [in the tests for the package](https://github.com/USCqserver/OpenQuantumTools.jl/blob/v0.7.2/test/QSolvers/redfield_solver_test.jl#L45), and that builds the `CustomBath` as

```julia
cfun(x) = x <= 20 ? 1e-4 : 0
bath = CustomBath(correlation=cfun)

```

i.e. using the `correlation` argument to specify a correlation function.

---

<div class="post-metadata">

**Author:** ![Yangheng\_Jizhe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yangheng_jizhe/32/36007_2.png) [@Yangheng\_Jizhe](https://discourse.julialang.org/u/Yangheng_Jizhe)\
**Post date:** [August 16, 2022, 2:31am UTC](https://discourse.julialang.org/t/about-error-correlation-function-is-not-specified/85753/4 "2022-08-16T02:31:22Z")

</div>

Cool, thanks for your suggestion!

---

<div class="post-metadata">

**Author:** ![Yangheng\_Jizhe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yangheng_jizhe/32/36007_2.png) [@Yangheng\_Jizhe](https://discourse.julialang.org/u/Yangheng_Jizhe)\
**Post date:** [August 16, 2022, 2:36am UTC](https://discourse.julialang.org/t/about-error-correlation-function-is-not-specified/85753/5 "2022-08-16T02:36:34Z")

</div>

Thank you so much for your reply! It;'s been very helpful!
