qojulia / QuantumCumulants.jl

Generalized mean-field equations in open quantum systems
Other
70 stars 13 forks source link

metadata function for QAdd #204

Closed oameye closed 2 months ago

oameye commented 4 months ago

The package defines a function to extract the metadata of the QAdd type but QAdd does not have a metadata field.

https://github.com/qojulia/QuantumCumulants.jl/blob/1d144b1811596057a4bd57eee601669db61cc8ac/src/qnumber.jl#L232

The function is used when you try to use Symbolics.expand on a QAdd expression:

using QuantumCumulant
using Symbolics

h = FockSpace(:cavity)

@qnumbers a::Destroy(h)

expr = (a'+a) |> simplify
expr |> expand
david-pl commented 4 months ago

Thanks for the report! The fact that the metadata is missing here is definitely an oversight on our end. However, that's not the whole story. I wouldn't expect expand to work properly on QNumber types right now. What we also need is an overload to expand similar to what we are doing with simplify so Symbolics can work on numbers. Something like this:

function Symbolics.expand(q::QTerm)
    q |> average |> expand |> undo_average
end