diff --git a/src/models/phi4_complex.jl b/src/models/phi4_complex.jl index 69307150..0e146b7a 100644 --- a/src/models/phi4_complex.jl +++ b/src/models/phi4_complex.jl @@ -105,7 +105,7 @@ function moment_matrix(N, μ0, λ; rtol = 1.0e-8) return M end -function phi4_complex_tensor(f::TensorMap{TT, SS, NN, NN}, weights::Matrix{Float64}; T::Type{<:Number} = ComplexF64) where {TT, SS, NN} # for Trivial symmetry +function phi4_complex_tensor(f::TensorMap{TT, SS, NN, NN}, weights::Matrix{<:Number}; T::Type{<:Number} = ComplexF64) where {TT, SS, NN} # for Trivial symmetry K = size(weights, 1) N = K^2 perms = collect(permutations(1:4)) # 24 total diff --git a/test/models.jl b/test/models.jl index ced09377..37b98afd 100644 --- a/test/models.jl +++ b/test/models.jl @@ -84,3 +84,56 @@ for (model, temp, answer, description) in model_temp_answer_string_3d @test free_energy(data, temp; scalefactor = 8.0) ≈ answer rtol = 1.0e-3 end end + + +# Test for impurity tensors +# Real phi^4 +@testset "Real φ⁴ model - Impure" begin + # Disordered phase + λ = 1.0 + μ0 = 0.0 + + Tpure = phi4_real(Trivial, 10, μ0, λ) + T_imp1 = phi4_real_imp1(Trivial, 10, μ0, λ) + T_imp2 = phi4_real_imp2(Trivial, 10, μ0, λ) + + scheme = ImpurityHOTRG(Tpure, T_imp1, T_imp1, T_imp2) + + data = run!(scheme, truncrank(16), maxiter(25)) + + order_para = data[end][4] / data[end][1] + @test order_para ≈ 0.0 atol = 1.0e-3 + + # Ordered phase + μ0 = -2.0 + + Tpure = phi4_real(Trivial, 10, μ0, λ) + T_imp1 = phi4_real_imp1(Trivial, 10, μ0, λ) + T_imp2 = phi4_real_imp2(Trivial, 10, μ0, λ) + + scheme = ImpurityHOTRG(Tpure, T_imp1, T_imp1, T_imp2) + + data = run!(scheme, truncrank(16), maxiter(25)) + + order_para = data[end][4] / data[end][1] + @test order_para ≈ 1.5317112652447245 rtol = 1.0e-3 +end + +# Complex phi^4 +@testset "Complex φ⁴ model - Impure" begin + # Disordered phase + λ = 1.0 + μ0 = 0.0 + + Tpure = phi4_complex(Trivial, 6, μ0, λ; T = ComplexF64) + T_imp11 = phi4_complex_impϕ(6, μ0, λ) + T_imp12 = phi4_complex_impϕdag(6, μ0, λ) + T_imp2 = phi4_complex_impϕ2(6, μ0, λ) + + scheme = ImpurityHOTRG(Tpure, T_imp11, T_imp12, T_imp2) + + data = run!(scheme, truncrank(16), maxiter(25)) + + order_para = data[end][4] / data[end][1] + @test order_para ≈ 0.0 atol = 1.0e-3 +end