Skip to content
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

Stochastic solver using v5 class interface #2131

Merged
merged 61 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
e0db8e7
Stochastic for v5 idea
Ericgig Dec 20, 2022
0f1cab0
Better idea
Ericgig Dec 20, 2022
0a3052c
first sode integrator
Dec 20, 2022
c774be8
Start SMESolver
Ericgig Dec 22, 2022
e8e8b5f
Working
Ericgig Jan 12, 2023
a4f54f2
Merge remote-tracking branch 'upstream/master' into stochastic.v5
Ericgig Jan 18, 2023
de8a752
Simple smesolve run working
Ericgig Jan 18, 2023
b4120f3
add explicit 1.5
Jan 19, 2023
be091be
debug platen1.5
Ericgig Jan 20, 2023
0717e01
Fix a bug in explicit1.5
Ericgig Jan 23, 2023
9a0368e
make debugging tools
Jan 24, 2023
c202776
all explicit methods added
Ericgig Jan 26, 2023
88c48a9
Safe StochasticOpenSystem derrivatives
Ericgig Jan 27, 2023
bb7e845
add check code
Ericgig Jan 27, 2023
d4f5bc2
add check code
Ericgig Jan 27, 2023
0a95382
More debug tools
Ericgig Jan 31, 2023
1fa3ec6
Add tests
Ericgig Feb 8, 2023
df41b93
working tests
Ericgig Feb 15, 2023
7a9205a
Merge remote-tracking branch 'upstream/master' into stochastic.v5
Ericgig Feb 15, 2023
7f24ba4
smesolve work
Ericgig Feb 15, 2023
10b7aa9
Passing test for smesolve
Feb 16, 2023
e9f494a
Add rouchon
Ericgig Feb 17, 2023
9ef000a
Finish rouchon + test for the method
Ericgig Feb 20, 2023
3884750
Add integrator test for time-dependant cases
Ericgig Feb 21, 2023
158660f
sse derivative
Ericgig Feb 21, 2023
21a9cef
sse derr only support one c_ops
Feb 22, 2023
27b46db
sse derr only support one c_ops
Feb 22, 2023
ea32f31
add rouchon for sse and rm milstein
Ericgig Feb 23, 2023
7127405
opt
Ericgig Feb 27, 2023
7f13330
Optimized milstein
Ericgig Feb 28, 2023
2c9496e
opt pred_corr
Ericgig Mar 1, 2023
6fb6d96
superop rouchon
Mar 1, 2023
a09f1c3
Adding tests
Ericgig Mar 13, 2023
23a64ed
Add implicit methods
Ericgig Mar 14, 2023
e2b1c15
weiner process in result
Ericgig Mar 15, 2023
7d748ce
fix naming
Ericgig Mar 15, 2023
1673009
Fill most doctring and error msg
Mar 16, 2023
b61ba1f
rename file
Mar 16, 2023
13f6345
Fixed tests
Ericgig Mar 17, 2023
4d29594
More tests
Ericgig Mar 17, 2023
fe9b973
Finish documentation
Ericgig Mar 20, 2023
8f958a4
Merge remote-tracking branch 'upstream/master' into stochastic.v5
Mar 21, 2023
1318cad
Remove old stochastic
Mar 21, 2023
8c588dd
Docstring fixes
Mar 21, 2023
ede8cae
Roll back some changes
Mar 21, 2023
413aa79
Documentation fixes
Mar 21, 2023
f328930
Add towncrier entry
Mar 21, 2023
fe439d1
Fix some style issue
Ericgig Mar 22, 2023
5d47f83
Add restore for parallel map
Ericgig Mar 23, 2023
0c4a6fa
Change default method
Ericgig Mar 23, 2023
a6f9fec
Ensure that smesolve run in parallel in at least one test
Ericgig Mar 23, 2023
8b74ada
More direct reuse test
Ericgig Mar 24, 2023
8f6a3c3
Change the parallel test
Ericgig Mar 24, 2023
f4237b8
Apply suggestions from code review
Ericgig Apr 13, 2023
13767c9
Apply PR comments
Apr 13, 2023
19a858d
Merge branch 'stochastic.v5' of https://github.com/Ericgig/qutip into…
Apr 13, 2023
75887e1
Merge remote-tracking branch 'upstream/master' into stochastic.v5
Apr 13, 2023
d0b6c14
Add photocurrent example in mcsolve documentation page
Apr 13, 2023
aca339d
Merge branch 'master' of https://github.com/qutip/qutip into stochast…
Ericgig Apr 14, 2023
1c9dd89
use zeros_like
Ericgig Apr 14, 2023
8cee3c2
Fix solver namespace
Apr 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ source = qutip
omit =
# QuTiP test files
*/qutip/tests/*
# Tool for tests
*/qutip/solver/sode/_noise.py

[report]
exclude_lines =
# Skip Python wrappers which help load in C extension modules.
__bootstrap__()
# Skip empty method that are never meant to be used.
raise NotImplementedError
40 changes: 40 additions & 0 deletions doc/apidoc/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ Solver
.. autoclass:: qutip.solver.brmesolve.BRSolver
:members:

.. autoclass:: qutip.solver.stochastic.SMESolver
:members:

.. autoclass:: qutip.solver.stochastic.SSESolver
:members:



.. _classes-non_markov_heom:

Expand Down Expand Up @@ -132,6 +139,39 @@ Integrator
:members: options


.. _classes-sode:

Stochastic Integrator
---------------------

.. autoclass:: qutip.solver.sode.rouchon.RouchonSODE
:members: options

.. autoclass:: qutip.solver.sode.itotaylor.EulerSODE
:members: options

.. autoclass:: qutip.solver.sode.itotaylor.Milstein_SODE
:members: options

.. autoclass:: qutip.solver.sode.itotaylor.Taylor1_5_SODE
:members: options

.. autoclass:: qutip.solver.sode.itotaylor.Implicit_Milstein_SODE
:members: options

.. autoclass:: qutip.solver.sode.itotaylor.Implicit_Taylor1_5_SODE
:members: options

.. autoclass:: qutip.solver.sode.sode.PlatenSODE
:members: options

.. autoclass:: qutip.solver.sode.itotaylor.Explicit1_5_SODE
:members: options

.. autoclass:: qutip.solver.sode.sode.PredCorr_SODE
:members: options


.. _classes-non_markov_mc_and_tt:

Non-Markovian Memory Cascade and Transfer Tensor Solvers
Expand Down
4 changes: 2 additions & 2 deletions doc/apidoc/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ Floquet States and Floquet-Markov Master Equation
Stochastic Schrödinger Equation and Master Equation
---------------------------------------------------

.. automodule:: qutip.solve.stochastic
:members: ssesolve, photocurrent_sesolve, smepdpsolve, smesolve, photocurrent_mesolve, ssepdpsolve, stochastic_solvers, general_stochastic
.. automodule:: qutip.solver.stochastic
:members: ssesolve, smesolve


Hierarchical Equations of Motion
Expand Down
1 change: 1 addition & 0 deletions doc/changes/2131.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rewrite the stochastic solver to use the v5 solver interface.
35 changes: 34 additions & 1 deletion doc/guide/dynamics/dynamics-monte.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ When trajectories are stored, ``result.runs_expect`` is a list over the expectat
The averages are stored in ``result.average_expect`` and the standard derivation of the expectation values in ``result.std_expect``.
When the states are returned, ``result.runs_states`` will be an array of length ``ntraj``. Each element contains an array of "Qobj" type ket with the same number of elements as ``times``. ``result.average_states`` is a list of density matrices computed as the average of the states at each time step.
Furthermore, the output will also contain a list of times at which the collapse occurred, and which collapse operators did the collapse. These can be obtained in ``result.col_times`` and ``result.col_which`` respectively.
Lastly ``result.photocurrent`` contain the measurement of the evolution.


Photocurrent
------------

The photocurrent, previously computed using the ``photocurrent_sesolve`` and ``photocurrent_sesolve`` functions, are now included in the output of :func:`qutip.solver.mcsolve` as ``result.photocurrent``.


.. plot::
Expand Down Expand Up @@ -236,6 +241,34 @@ For example, the following code block plots expectation values for 1, 10 and 100
plt.legend()
plt.show()


.. openmcsolve:

Open Systems
------------

``mcsolve`` can be used to study system with have measured and dissipative interaction with the bath.
This is done by using a liouvillian including the dissipative interaction instead of an Hamiltonian.

.. plot::
:context: close-figs

times = np.linspace(0.0, 10.0, 200)
psi0 = tensor(fock(2, 0), fock(10, 8))
a = tensor(qeye(2), destroy(10))
sm = tensor(destroy(2), qeye(10))
H = 2*np.pi*a.dag()*a + 2*np.pi*sm.dag()*sm + 2*np.pi*0.25*(sm*a.dag() + sm.dag()*a)
L = liouvillian(H, [0.01 * sm, np.sqrt(0.1) * a])
data = mcsolve(L, psi0, times, [np.sqrt(0.1) * a], e_ops=[a.dag() * a, sm.dag() * sm])

plt.figure()
plt.plot((times[:-1] + times[1:])/2, data.photocurrent[0])
plt.title('Monte Carlo Photocurrent')
plt.xlabel('Time')
plt.ylabel('Photon detections')
plt.show()


.. plot::
:context: reset
:include-source: false
Expand Down
104 changes: 0 additions & 104 deletions doc/guide/dynamics/dynamics-photocurrent.rst

This file was deleted.