diff --git a/test/runtests.jl b/test/runtests.jl index fe4d20c..1c287c8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,3 +7,4 @@ include("testintegration.jl") include("testfidelity.jl") include("teststochastics.jl") include("testspectrum.jl") +include("testthreads.jl") \ No newline at end of file diff --git a/test/testthreads.jl b/test/testthreads.jl new file mode 100644 index 0000000..af36f48 --- /dev/null +++ b/test/testthreads.jl @@ -0,0 +1,28 @@ +using Test +using SpinShuttling +using DelimitedFiles +# using UnicodePlots +# using ProgressMeter + +@testset "test multithreading" begin + T=4; L=10; σ = sqrt(2) / 20; N=501; κₜ=1;κₓ=1; + + B=OrnsteinUhlenbeckField(0,[κₜ,κₓ],σ) + model=OneSpinModel(T,L,N,B) + + # save the original Σ to text file + if Threads.nthreads() > 1 + writedlm("test/cache.csv", model.R.Σ) + else + # read the original Σ from text file + Σ = readdlm("test/cache.csv") + # test the original Σ is the same as the one in the model + @test isapprox(Σ, model.R.Σ, rtol=1e-10) + # delete the cache file + rm("test/cache.csv", force=true) + end + + M = 100000; + F=sampling(model, fidelity, M) + println(F) +end