function and string based hand in hand?

5 views
Skip to first unread message

A. Barış Özgüler

unread,
Oct 20, 2017, 10:50:29 PM10/20/17
to QuTiP: Quantum Toolbox in Python
Hello,

I have the following Hamiltonian to be solved in sesolve or mesolve represented as function based:

args = {'x': x, 'y': y, 'z': z}

H = [H0, [H1(0), S(0, x, y, z)], [H1(1), S(1, x, y, z)], [H1(2), S(2, x, y, z)], [H1(3), S(3, x, y, z)], [H1(4), S(4, x, y, z)]]

I want to use the string based method because it can be faster, but it would be tedious to write the function S manually as a string for each group. Is it possible to combine the string based and function based methods? I would definitely need to write the strings in H as a function of "n" if I had many more groups of [H1(n), S(n, x, y, z)] in H. My primary concern in the code is efficiency and being fast.

Thanks!

Barış

Paul Nation

unread,
Oct 20, 2017, 11:51:54 PM10/20/17
to QuTiP Group
It is not currently possible to do that.  However, it is possible to modify the internal QuTiP code to allow for such things.

Why not write a function that returns a string, say called ‘f_str’, and then just use this function to generate the required strings for you?

For example:

def f_str(A, w, phi):
    out_str = '{A}*sin({w}*t+{phi})'
    return out_str.format(A=A, w=w, phi=phi)

-P


--
You received this message because you are subscribed to the Google Groups "QuTiP: Quantum Toolbox in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qutip+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages