Turning off `store_state` in mesolve
See original GitHub issueDescribe the issue
In mesolve
, all the intermediate result for each t
in the tlist
will be saved. If the given tlist
is very long, this can be a bottleneck for time and memory. In the Option
class, there is an option store_states
, but it does not work as I expected. Setting it to False does not turn this off.
According to the code above, there is no way to completely turn this off. One has to either save expectation values or save the intermediate states.
To Reproduce
from qutip import *
import numpy as np
options = Options()
options.store_states = False
print(options.store_states)
result = mesolve(sigmax(), basis(2,0), np.linspace(0,1,10), options=options)
print(options.store_states)
gives
False
True
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Functions — QuTiP 4.7 Documentation
On using callback functions: mesolve transforms all qutip. ... List of callback functions that compute the noise power spectrum as a function of...
Read more >qutip.mesolve — QuTiP 4.0 Documentation
Source code for qutip.mesolve. # This file is part of QuTiP: Quantum Toolbox in Python. # # Copyright (c) ...
Read more >Setting Options for the Dynamics Solvers - QuTiP
Use OPENMP for sparse matrix vector multiplication. As an example, let us consider changing the number of processors used, turn the GUI off,...
Read more >Solving Problems with Time-dependent Hamiltonians - QuTiP
Accesing the state from solver The state of the system, the ket vector or the density matrix, is available to time-dependent Hamiltonian and...
Read more >Source code for qutip.mesolve
Source code for qutip.mesolve. """ This module provides solvers for the Lindblad master equation and von Neumann equation. """ __all__ = ['mesolve'] import ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
When no options and no e_ops are given, the solver should store the states, otherwise nothing is done. Since the default value si
store_states=False
, the solver don’t know that the value was explicitly given or the default. We should havestore_states=None
as the default. This allow us to respect an explicit False while keeping the expected behaviour when no options are given. I will make this change in the v5 solver (And make sure no Options are modified).tlist
was never meant to control time dependence, it represent the time at which the solver look at the state (+ first and last times). I added array support as coefficient as a shortcut to Cubic_Spline and I used the already existing tlist, but this is clearly a limitation and in v5 they will be controlled independently.Ok, cool. I don’t think there’s any situation we should be mutating the
Options
class we’re passed in though - I’d consider that a bug no matter what, since that leaks like your print statement shows. We can just duplicate it on entry, then modify that.To me it’s not clear that passing several items in
tlist
should override an explicitstore_states=False
- as long as we allow you to pass an array as time-dependence, there is a sensible reason to pass more items intlist
than you need results for. Sure, you may also be able to useCubic_Spline
, but if we punish you for using arrays by swapping your options, why do we provide them? I think we should only warn and change the settings if nothing is going to be stored -store_final_state
should be enough to suppress it and not store the intermediate states, even if that implies the user might not be doing the fastest possible thing. I don’t necessarily think we should try to promote ideal usage through runtime warnings if that’s more verbose to type - that’s what documentation is for, and some people will do stuff because it’s faster to type, since they work interactively.