Skip to content

Commit

Permalink
Merge pull request #23 from qutip/20-autmatically-convert-to-superope…
Browse files Browse the repository at this point in the history
…rators

Automatically convert to superoperator
  • Loading branch information
flowerthrower authored Oct 2, 2024
2 parents a5f0016 + ceb1de2 commit 9d6ef32
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/qutip_qoc/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def __init__(self, initial, H, target, weight=1):
self.target = target
self.weight = weight

# Check if any Hamiltonian in H is a superoperator
if any(qt.issuper(H_i) for H_i in (H if isinstance(H, list) else [H])):
# Convert initial and target accordingly
self.initial = qt.to_super(self.initial)
self.target = qt.to_super(self.target)

def __getstate__(self):
"""
Extract picklable information from the objective.
Expand Down

0 comments on commit 9d6ef32

Please # to comment.