Error encountered while using "qutip.spectrum"

85 views
Skip to first unread message

Cedric Chia

unread,
May 18, 2022, 5:15:35 AM5/18/22
to QuTiP: Quantum Toolbox in Python
I have encountered the following error while calculating the correlation function for emission spectrum:
Screenshot 2022-05-18 170120.png

It is saying that wlist[i] is "NoneType" even though I have already defined it properly as:
Screenshot 2022-05-18 170555.png

However, if I were to compute the absorption spectrum by switching the order of the operator and the sign in the frequency, it works perfectly and give me the absorption spectrum as expected: Screenshot 2022-05-18 170920.png
where the same system Hamiltonian "H_S" and the same set collapse operators "c_op_list" have been used in both cases.

I have checked that the rate in the collapse operators are all postivie and the order of magnitudes of the parameters are consistent, so I would really appreciate if anyone can help me understand the reason I'm getting this error message? 

Thank you

Simon Cross

unread,
May 23, 2022, 11:00:55 AM5/23/22
to qu...@googlegroups.com
Hi Cedric,

I think this is because sig * rho0 = 0 -- i.e. your "b_op" annihilates your steady state. Swapping your a_op and b_op fixes the problem.

In my own toy example I see:

>>> a = qutip.destroy(2)
>>> H = a * a.dag() + 0.1 * qutip.qeye(2)
>>> qutip.spectrum(H, [0.1, 0.2, 0.3], [0.1 * a], a, a.dag())
array([0.0123453 , 0.01562439, 0.02040712])
>>> qutip.spectrum(H, [0.1, 0.2, 0.3], [0.1 * a], a.dag(), a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/simon/repos/github/qutip/qutip/correlation.py", line 511, in spectrum
    return _spectrum_es(H, wlist, c_ops, a_op, b_op)
  File "/home/simon/repos/github/qutip/qutip/correlation.py", line 1172, in _spectrum_es
    return esspec(cov_es, wlist)
  File "/home/simon/repos/github/qutip/qutip/eseries.py", line 364, in esspec
    return es.spec(wlist)
  File "/home/simon/repos/github/qutip/qutip/eseries.py", line 272, in spec
    val_list[i] = 2 * np.real(
TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'

This error message is rather confusing and probably QuTiP could raise an error earlier. `np.dot(...)` returns None if both arguments are empty arrays of type object (wat). Then np.real(None) returns None. Then 2 * np.real(...) raises the error -- so it is unrelated to the wlist. The amplitude list is empty because we call "ode2es(L, rho0)" with rho0 = 0.

We will probably not attempt to fix this in QuTiP 4.7 because the relevant code is being removed in QuTiP 5, but if you would like to submit a small PR which checks for this condition and raises an error sooner, I would be happy to review it and include it in QuTiP 4.7.1.

Regards,
Simon

Cedric Chia

unread,
May 24, 2022, 9:35:02 PM5/24/22
to QuTiP: Quantum Toolbox in Python
Thank you very much for your attention to my entry. I hope you don't mind I ask a further question on the same issue I had but with more details.

From the QuTiP user guide online, the qutip.spectrum function is used to compute:
Screenshot 2022-05-24 225047.png

Now if we look at any quantum optics or spectroscopy textbook, we would find the following formula for absorption and emission spectrum
Screenshot 2022-05-24 225617.png

Therefore, I cannot simply switch a_op and b_op as you suggested because that would give me different physical quantity. Note that the sign different in the exponential of absorption spectrum, this is why for my absorption spectrum, I put the frequency list -wlist instead of just wlist. So if I cannot simply exchange  a_op and b_op, how could I avoid my operators annihilating my steady state? Also I don't fully understand why the absorption spectrum works but the emission spectrum does not work.

Thanks again.

Reply all
Reply to author
Forward
0 new messages