qojulia / QuantumCumulants.jl

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

`change_index` not working for a summed term #196

Closed Papageno2 closed 5 months ago

Papageno2 commented 6 months ago

I have successfully used the following expression: change_index(σ(1,2,j),j,i) =$\sigma_i^{12}$, It works as expected!

However, when attempting to calculate the product of collective operators, such as:

Using the code:

j = Index(h,:j,N,ha)

h1 = Σ(σ(1,2,j),j);

h1*h1

I encountered an error: "Specification of an extra Index is needed!"

Yet, if I utilize:

change_index(h1, j, i) 

It still returns $\sum_{j}^N\sigma_j^{12}$. Although I understand that h1 is a sum that is not dependent on the index j, the h1 * h1 operation requires a different index label.

Any insights on resolving this issue would be greatly appreciated!

Papageno2 commented 6 months ago

there maybe a bug for the conjugate of complex coeficient:

@cnumbers  Ω_1 

hc = FockSpace(:cavity);
ha = NLevelSpace(:a, 4);
h = hc⊗ha

σ(α,β,i) = IndexedOperator(Transition(h, :σ, α, β),i)
k = Index(h,:k,N,ha)
j = Index(h,:j,N,ha)
i = Index(h,:i,N,ha)

h1e = Ω_1*σ(3,4,j);

change_index(h1e, j,i)'*∑(h1e,j)

it returns:

image image
ChristophHotter commented 6 months ago

Sorry for the late reply.

Regarding your first part:

So far the function change_index does not work for sums but I think I can add a method if needed. Something like:

function change_index(S::SingleSum, i::Index, j::Index) 
    (j ∈ S.non_equal_indices) && error("Index $(j) is in the non-equal index list.")
    if S.sum_index == i
        return SingleSum(change_index(S.term,i,j), j, replace(S.non_equal_indices, i=>j), S.metadata)
    end        
    return S
end

There are two other alternatives. You can define a second sum with a different index:

h1i = Σ(σ(1,2,i),i)
h1j = Σ(σ(1,2,j),j)
h1i*h1j

or you can specify the extra index in the multiplication:

*(h1i,h1i;ind=j)

For the second part I think it is just a printing problem. If you look at the expression in the terminal you see a conj(Ω_1).
[Additionally, I think that the expression ∑(h1e,j)*∑(h1e,i)' does not make much sense, since you have a sum over i on an expression with index j only.]