Skip to content

Commit

Permalink
Meanfield derivation works without actual errors in the code
Browse files Browse the repository at this point in the history
  • Loading branch information
david-pl committed Jan 18, 2025
1 parent 93c6b7a commit 428d988
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/average.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ function undo_average(t)
f = SymbolicUtils.operation(t)
if isequal(f,sym_average) # "===" results in false sometimes in Symbolics version > 5
return SymbolicUtils.arguments(t)[1]
elseif isequal(f, sym_csum) # TODO: is this clean?
args = map(undo_average, SymbolicUtils.arguments(t))
return Sum(args...)
else
args = map(undo_average, SymbolicUtils.arguments(t))
return f(args...)
Expand Down Expand Up @@ -150,8 +147,6 @@ function cumulant_expansion(x::SymbolicUtils.Symbolic,order::Integer;simplify=tr
cumulants = [cumulant_expansion(arg,order;kwargs...) for arg in args]
return f(cumulants...)
end
elseif x isa AvgSums
return _cumulant_expansion(x,order;simplify,kwargs...) # basically just another cumulant_expansion dispatch
else
return x
end
Expand Down
3 changes: 3 additions & 0 deletions src/indexing_sums.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ struct CSumSym <: CNumber end

csum(args...) = Sum(args...)

# SymbolicUtils.maketerm(::Type{T}, ::typeof(csum), args, metadata) where T = csum(args...)
# SymbolicUtils.maketerm(::Type{<:SymbolicUtils.BasicSymbolic}, ::typeof(csum), args, metadata) = csum(args...)

function Sum(term::SymbolicUtils.Symbolic{<:Number}, index::Index; metadata = nothing)
# TODO: don't ignore metadata here
# TODO: printing for CNumber sums
Expand Down
3 changes: 3 additions & 0 deletions test/test_indexed_meanfield.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ g(k) = IndexedVariable(:g,k)
@test qc.get_indices(Γ_ij) == Set([i_ind, j_ind])
# Hamiltonian

@qnumbers a::Destroy(h)
σ(i,j,k) = IndexedOperator(Transition(h,,i,j),k)

ex = Ω_ij*σ(2,1,i_ind)*σ(1,2,j_ind)
@test has_index(ex, i_ind)
@test has_index(ex, j_ind)
Expand Down

0 comments on commit 428d988

Please sign in to comment.