Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Automatically convert to superoperator #23

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading