-
Notifications
You must be signed in to change notification settings - Fork 706
Description
Bug Description
I wanted to use the new step
method for the stochastic solver class SMESolver
, but it always breaks down. I also tried it for SSESolver
, but the same error message occurs. I use qutip 5.0.3. I took the example from the documentation as a minimal working example. I also tried step
for the MESolver
class and there it works. I think it should also not only output the state but also the measurement output if possible.
As a side note, I also wanted to know if there is a particular reason why the argument for the initial state in the start
method is called state0
for MESolver
, and state
for SMESolver
.
Code to Reproduce the Bug
import numpy as np
from qutip import destroy, coherent, SMESolver, expect
# parameters
DIM = 20 # Hilbert space dimension
DELTA = 5 * 2 * np.pi # cavity detuning
KAPPA = 2 # cavity decay rate
INTENSITY = 4 # intensity of initial state
NUMBER_OF_TRAJECTORIES = 500
# operators
a = destroy(DIM)
x = a + a.dag()
H = DELTA * a.dag() * a
rho_0 = coherent(DIM, np.sqrt(INTENSITY))
times = np.arange(0, 1, 0.0025)
stoc_solver = SMESolver(
H,
c_ops=[],
sc_ops=[np.sqrt(KAPPA) * a],
heterodyne=False,
options={"dt": 0.00125, "store_measurement": True,}
)
data = [4.]
stoc_solver.start(state=rho_0, t0=times[0])
for t in times[1:]:
psi_t = stoc_solver.step(t)
data.append(expect(x, psi_t))
Code Output
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[4], line 29
27 stoc_solver.start(state=rho_0, t0=times[0])
28 for t in times[1:]:
---> 29 psi_t = stoc_solver.step(t)
30 data.append(expect(x, psi_t))
File /user/anaconda/envs/myenv/lib/python3.9/site-packages/qutip/solver/multitraj.py:129, in MultiTrajSolver.step(self, t, args, copy)
127 raise RuntimeError("The `start` method must called first.")
128 self._argument(args)
--> 129 _, state = self._integrator.integrate(t, copy=False)
130 return self._restore_state(state, copy=copy)
ValueError: too many values to unpack (expected 2)
Expected Behaviour
It should have returned the state at time step t instead of failing. It would also be nice if the method would return the output of the measurement current as well.
Your Environment
QuTiP Version: 5.0.3
Numpy Version: 1.26.4
Scipy Version: 1.13.1
Cython Version: None
Matplotlib Version: 3.6.0
Python Version: 3.9.19
Number of CPUs: 16
BLAS Info: Generic
INTEL MKL Ext: False
Platform Info: Linux (x86_64)
Additional Context
No response