Skip to content

Commit

Permalink
Merge pull request #2303 from Matt-Ord/Split-density-matrix-and-state…
Browse files Browse the repository at this point in the history
…-results

Add new store_density_matricies Result option
  • Loading branch information
Ericgig committed Feb 6, 2024
2 parents c3a1916 + d550e7c commit 48ff43b
Show file tree
Hide file tree
Showing 4 changed files with 242 additions and 124 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
14 changes: 11 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,9 +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(
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 48ff43b

Please sign in to comment.