New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix setting of sso.m_ops in heterodyne smesolver and passing through of sc_ops to photocurrent solver. #2081
Fix setting of sso.m_ops in heterodyne smesolver and passing through of sc_ops to photocurrent solver. #2081
Conversation
@theodotk Thank you for the bug report. I cherry-picked your fix into this PR. Any thoughts on a simple test case we could add? Ideally we could just pass in custom m_ops in something like |
@hodgestar Thanks for doing it! for c in sso.sc_ops:
m_ops += [c + c.dag(), -1j * (c - c.dag())] As for the tests, I can think of something like this def test_heterodyne_mesolve():
b = 1 # drive amplitude
gamma = 1 # spont. emission rate
eta = 0.3 # coupling efficiency
n_steps = 1000
n_traj = 50
H = np.sqrt(eta*gamma) * b * sigmay()
c_ops = [np.sqrt(gamma)*sigmam()]
psi0 = basis(2)
times = np.linspace(0, np.pi*2, n_steps)
n_tr = 3
sme_het = smesolve(
H,
psi0,
times,
[],
c_ops,
e_ops=[sigmax(), sigmay(), sigmaz()],
store_measurement = True,
dW_factors=[1e-5, 1e-5], # to make tests simpler
method="heterodyne",
m_ops=[np.sqrt(eta)*sigmax(), np.sqrt(eta)*sigmay()],
ntraj=n_traj,
noise=123, # random seed
)
assert np.array(sme_het.measurement).shape == (n_traj, n_steps, 1, 2)
assert all(np.isclose(np.array(sme_het.measurement).mean(axis=0)[:,0,0].T, np.sqrt(eta)*sme_het.expect[0], atol=2e-2))
def test_incorrect_m_ops_heterodyne_mesolve():
with pytest.raises(ValueError, match="The measured operators for the heterodyne method supposed to be pairs of quadratures: m_ops should have even length."):
sme_het_bad_mops = smesolve(
sigmax(),
basis(2),
np.linspace(0,1,10),
[],
[sigmam()],
e_ops=[],
store_measurement = True,
method="heterodyne",
m_ops=[np.sqrt(eta)*sigmax(), np.sqrt(eta)*sigmay(), np.sqrt(eta)*sigmaz()], # three operators
ntraj=10,
) |
@theodotk Apologies for the delay and thank you for the tests. I've incorporate them now and they look good. It would be nice to make the expected results match a little better. Supplying only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be 2 m_ops
per sc_ops
with heterodyne. The measurement use the noise of the corresponding sc_ops
in it's computation. Having m_ops
than effective sc_ops
will cause junk measurement.
…collapse operator.
… eigsh and eigvalsh in changelog.
Thanks for the PR @hodgestar ! |
Description
Fix setting of sso.m_ops in heterodyne smesolver and passing through of sc_ops to photocurrent solver.
Related issues or PRs
smesolve
for heterodyne detection. #2078