From ceb1de2c47b6ccefc1ae1b7f40937d2f65a0227a Mon Sep 17 00:00:00 2001 From: flowerthrower Date: Wed, 2 Oct 2024 10:45:59 +0200 Subject: [PATCH] automatically convert to superoperator --- src/qutip_qoc/objective.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qutip_qoc/objective.py b/src/qutip_qoc/objective.py index 986961a..d91caac 100644 --- a/src/qutip_qoc/objective.py +++ b/src/qutip_qoc/objective.py @@ -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.