Created
March 17, 2016 20:09
-
-
Save ntezak/527cef050697e25c0f1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def time_dependent_to_qutip(operator, full_space=None, t=symbols("t", real=True)): | |
import re | |
if t in operator.all_symbols(): | |
operator = operator.expand() | |
if isinstance(operator, OperatorPlus): | |
return [time_dependent_to_qutip(o, full_space) for o in operator.operands] | |
elif isinstance(operator, ScalarTimesOperator): | |
return [operator.term.to_qutip(full_space), | |
re.sub("I", "(1.0j)", str(operator.coeff))] # a bit of a hack to replace imaginary unit | |
return [operator.to_qutip(full_space), "1"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment