Skip to content

Commit

Permalink
Only pre-compute density matrix if not stoing individual trajectories
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-Ord committed Feb 2, 2024
1 parent a4f132e commit 486ef92
Show file tree
Hide file tree
Showing 4 changed files with 261 additions and 145 deletions.
1 change: 1 addition & 0 deletions doc/changes/2303.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Only pre-compute density matricies if keep_runs_results is False
13 changes: 10 additions & 3 deletions qutip/solver/heom/bofin_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def _post_init(self):

self.store_ados = self.options["store_ados"]
if self.store_ados:
self.final_ado_state = None
self._final_ado_state = None
self.ado_states = []

def _e_op_func(self, e_op):
Expand All @@ -407,10 +407,17 @@ def _store_state(self, t, ado_state):
self.ado_states.append(ado_state)

def _store_final_state(self, t, ado_state):
self.final_state = ado_state.rho
self._final_state = ado_state.rho
if self.store_ados:
self.final_ado_state = ado_state
self._final_ado_state = ado_state

@property
def final_ado_state(self):
if self._final_ado_state is not None:
return self._final_state
if self.ado_states:
return self.ado_states[-1]
return None

def heomsolve(
H, bath, max_depth, state0, tlist, *, e_ops=None, args=None, options=None,
Expand Down
5 changes: 3 additions & 2 deletions qutip/solver/mcsolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class _MCSystem(_MTSystem):
"""
Container for the operators of the solver.
"""

def __init__(self, rhs, c_ops, n_ops):
self.rhs = rhs
self.c_ops = c_ops
Expand Down Expand Up @@ -247,8 +248,8 @@ def set_state(self, t, state0, generator,
self.target_norm = 0.0
else:
self.target_norm = (
self._generator.random() * (1 - jump_prob_floor)
+ jump_prob_floor
self._generator.random() * (1 - jump_prob_floor)
+ jump_prob_floor
)
self._integrator.set_state(t, state0)
self._is_set = True
Expand Down

0 comments on commit 486ef92

Please sign in to comment.