Exemple #1
0
def _mesolve_func_td(L_func, c_op_list, rho0, tlist, args, opt):
    """
    Evolve the density matrix using an ODE solver with time dependent
    Hamiltonian.
    """
    if type(c_op_list) is list:
        c_ops = []
        for op in c_op_list:
            op_td = QobjEvo(op, args, tlist=tlist, copy=False)
            if not issuper(op_td.cte):
                c_ops += [lindblad_dissipator(op_td)]
            else:
                c_ops += [op_td]
        if c_op_list:
            c_ops_ = [sum(c_ops)]
        else:
            c_ops_ = []
    elif callable(c_op_list):
        c_ops_ = c_op_list

    if opt.rhs_with_state:
        state0 = rho0.full().ravel("F")
        obj = L_func(0., state0, args)
        if not issuper(obj):
            L_func = _LiouvillianFromFunc(L_func, c_ops_).H2L_with_state
        else:
            L_func = _LiouvillianFromFunc(L_func, c_ops_).L_with_state
    else:
        obj = L_func(0., args)
        if callable(c_ops_):
            if not issuper(obj):
                L_func = _LiouvillianFromFunc(L_func, c_ops_).H2L_c
            else:
                L_func = _LiouvillianFromFunc(L_func, c_ops_).L_c
        else:
            if not issuper(obj):
                L_func = _LiouvillianFromFunc(L_func, c_ops_).H2L
            else:
                L_func = _LiouvillianFromFunc(L_func, c_ops_).L

    ss = SolverSystem()
    ss.L = L_func
    ss.makefunc = _Lfunc_set
    solver_safe["mesolve"] = ss
    return ss
Exemple #2
0
def _mesolve_func_td(L_func, c_op_list, rho0, tlist, args, opt):
    """
    Evolve the density matrix using an ODE solver with time dependent
    Hamiltonian.
    """
    c_ops = []
    for op in c_op_list:
        td = QobjEvo(op, args, tlist=tlist, copy=False)
        c_ops.append(td if td.cte.issuper else lindblad_dissipator(td))
    c_ops_ = [sum(c_ops)] if c_op_list else []
    L_api = _LiouvillianFromFunc(L_func, c_ops_, rho0.dims)
    if opt.rhs_with_state:
        obj = L_func(0., rho0.full().ravel("F"), args)
        L_func = L_api.L_with_state if issuper(obj) else L_api.H2L_with_state
    else:
        obj = L_func(0., args)
        L_func = L_api.L if issuper(obj) else L_api.H2L
    ss = SolverSystem()
    ss.L = L_func
    ss.makefunc = _Lfunc_set
    solver_safe["mesolve"] = ss
    return ss