diff --git a/src/index_average.jl b/src/index_average.jl index a0cd17f3..b99f2ccd 100644 --- a/src/index_average.jl +++ b/src/index_average.jl @@ -119,7 +119,7 @@ end function IndexedAverageDoubleSum(term::symbolics_terms,sum_index::Index,non_equal_indices) if iscall(term) op = operation(term) - args = arguments(term) + args = copy(arguments(term)) param = 1.0 if op === * if args[1] isa Number #put numbers out in front diff --git a/test/test_double_sums.jl b/test/test_double_sums.jl index 3b868bb9..91c10907 100644 --- a/test/test_double_sums.jl +++ b/test/test_double_sums.jl @@ -49,6 +49,18 @@ a(k) = IndexedOperator(Destroy(h,:a),k) Ssum1 = Σ(g_ik*a(k_ind)*σ(2,1,i_ind),i_ind) Ssum2 = Σ(g_ik*a(k_ind)'*σ(1,2,i_ind),i_ind) +### issue 221 (DoubleSum) +@cnumbers c1 N1 +i_ind2 = Index(h,:i,N1,ha) +j_ind2 = Index(h,:j,N1,ha) +@test isequal(simplify(Σ(-σ(2,2,i_ind),i_ind,j_ind)),simplify(Σ(-σ(2,2,i_ind),i_ind)*4)) +@test isequal(simplify(Σ(3*σ(2,2,i_ind),i_ind,j_ind)),simplify(Σ(3*σ(2,2,i_ind),i_ind)*4)) +@test isequal(simplify(Σ(c1*σ(2,2,i_ind),i_ind,j_ind)),simplify(Σ(c1*σ(2,2,i_ind),i_ind)*4)) +@test isequal(simplify(Σ(-σ(2,2,i_ind2),i_ind2,j_ind2)),simplify(Σ( (1-N1)*σ(2,2,i_ind2) ,i_ind2)) - Σ( σ(2,2,i_ind2), i_ind2)) +@test isequal(simplify(Σ(3*σ(2,2,i_ind2),i_ind2,j_ind2)), simplify(Σ( 3*(N1-1)*σ(2,2,i_ind2) ,i_ind2)) + 3*Σ( σ(2,2,i_ind2), i_ind2)) +@test isequal(simplify(Σ(c1*σ(2,2,i_ind2),i_ind2,j_ind2)),simplify(c1*Σ( σ(2,2,i_ind2), i_ind2) + Σ( c1*(N1-1)*σ(2,2,i_ind2) ,i_ind2)) ) +### + @test isequal(Σ(conj(g_ik)*a(k_ind)'*σ(1,2,i_ind),i_ind),Ssum1') @test isequal(Σ(Σ(g_ik*(a(k_ind)*σ(2,1,i_ind) + a(k_ind)'*σ(1,2,i_ind)),i_ind),k_ind), diff --git a/test/test_indexed_correlation.jl b/test/test_indexed_correlation.jl index ef10b7a5..06128e14 100644 --- a/test/test_indexed_correlation.jl +++ b/test/test_indexed_correlation.jl @@ -139,7 +139,8 @@ p0_c2 = correlation_p0(corr2_sc, sol.u[end],ps.=>p0) u0_c2 = correlation_u0(corr2_sc, sol.u[end]) @named csys2 = ODESystem(corr2_sc) # 5 equations, 8 parameters -prob_c2 = ODEProblem(csys2,u0_c2,(0.0,5.0),p0_c2) +# prob_c2 = ODEProblem(csys2,u0_c2,(0.0,5.0),p0_c2) +prob_c2 = ODEProblem(csys2,u0_c2,(0.0,0.05),p0_c2) sol_c2 = solve(prob_c2,Tsit5();saveat=0.001,maxiters=1e8); @test sol_c2.retcode == SciMLBase.ReturnCode.Success @@ -152,8 +153,8 @@ eqs_ev = evaluate(eqs_c_2;limits=(N=>3)) u0_ev = zeros(ComplexF64, length(eqs_ev)) @named sys_ev = ODESystem(eqs_ev) -prob_ev = ODEProblem(sys_ev,u0_ev,(0.0, 1.0/50Γ_), ps.=>p0); - +# prob_ev = ODEProblem(sys_ev,u0_ev,(0.0, 1.0/50Γ_), ps.=>p0); +prob_ev = ODEProblem(sys_ev,u0_ev,(0.0, 0.1/50Γ_), ps.=>p0); sol_ev = solve(prob_ev,Tsit5(),maxiters=1e7) @test sol_ev.retcode == SciMLBase.ReturnCode.Success @@ -164,7 +165,8 @@ p0_c3 = correlation_p0(corr3_ev, sol_ev.u[end],ps.=>p0) u0_c3 = correlation_u0(corr3_ev, sol_ev.u[end]) @named csys3 = ODESystem(corr3_ev) -prob_c3 = ODEProblem(csys3,u0_c3,(0.0,5.0),p0_c3) +# prob_c3 = ODEProblem(csys3,u0_c3,(0.0,5.0),p0_c3) +prob_c3 = ODEProblem(csys3,u0_c3,(0.0,0.05),p0_c3) sol_c3 = solve(prob_c3,Tsit5();saveat=0.001,maxiters=1e8); @test sol_c3.retcode == SciMLBase.ReturnCode.Success @@ -186,8 +188,9 @@ u0_c = correlation_u0(corr_nss_sc, sol.u[end]) @named csys = ODESystem(corr_nss_sc) -prob_c = ODEProblem(csys,u0_c,(0.0,10.0),p0_c); -sol_c = solve(prob_c,Tsit5();saveat=0.001,maxiters=1e8); +# prob_c4 = ODEProblem(csys,u0_c,(0.0,10.0),p0_c); +prob_c4 = ODEProblem(csys,u0_c,(0.0,0.05),p0_c); +sol_c = solve(prob_c4,Tsit5();saveat=0.001,maxiters=1e8); @test sol_c.retcode == SciMLBase.ReturnCode.Success @@ -351,7 +354,8 @@ new_sum = qc._new_operator(sum1,h_) ν_ = 1000Γ_ #ν=1Hz ps = [N, Δ, g(1), κ, Γ, R, ν] p0 = [N_, Δ_, g_, κ_, Γ_, R_, ν_] - prob = ODEProblem(sys,u0,(0.0, 1.0/50Γ_), ps.=>p0) + # prob = ODEProblem(sys,u0,(0.0, 1.0/50Γ_), ps.=>p0) + prob = ODEProblem(sys,u0,(0.0, 0.1/50Γ_), ps.=>p0) # Solve the numeric problem sol = solve(prob,Tsit5(),maxiters=1e7); b = Index(h,:b,N,hA)