lime/oqs.py
def _redfield(R, rho0, evecs=None, Nt=1, dt=0.005, t0=0, e_ops=[], return_result=True):

    """
    time propagation of the Redfield quantum master equation with RK4

    Input
    -------
    R: 2d array
        Redfield tensor

    rho0: 2d array
        initial density matrix

    Nt: total number of time steps

    dt: time step
    e_ops: list of observable operators

    Returns
    =========
    rho: 2D array
        density matrix at time t = Nt * dt
    """

    N = rho0.shape[0]
    # initialize the density matrix
    if e_ops is None:
        e_ops = []

    # basis transformation
    if evecs is not None:
        rho0 = transform(rho0, evecs)
        e_ops = [transform(e, evecs) for e in e_ops]

    rho = rho0.copy()
    rho = dm2vec(rho).astype(complex)

    # tf = t0 + dt * Nt
    # result = solve_ivp(rhs, t_span=(t0, tf), y0=rho0, vectorized=True, args=(R, ))

    t = t0

    if return_result == False:

        f_obs = open('obs.dat', 'w')
        fmt = '{} '* (len(e_ops) + 1) + '\n'

        for k in range(Nt):

            # compute observables
            # observables = np.zeros(len(e_ops), dtype=complex)
            # for i, obs_op in enumerate(e_ops):

            observables = [obs_dm(rho, e) for e in e_ops]

            t += dt
            rho = rk4(rho, rhs, dt, R)

            # dipole-dipole auto-corrlation function
            #cor = np.trace(np.matmul(d, rho))

            # take a partial trace to obtain the rho_el


            f_obs.write(fmt.format(t, *observables))


        f_obs.close()
        # f_dm.close()

        return rho

    else:

        rholist = [] # store density matries

        result = Result(dt=dt, Nt=Nt, rho0=rho0)

        observables = np.zeros((Nt, len(e_ops)), dtype=complex)

        for k in range(Nt):

            t += dt
            rho = rk4(rho, rhs, dt, R)

            tmp = np.reshape(rho, (N, N))
            rholist.append(transform(tmp, dag(evecs)))


            observables[k, :] = [obs_dm(tmp, e) for e in e_ops]


        result.observables = observables
        result.rholist = rholist

        return result

    time propagation of the Redfield quantum master equation with RK4

    Input
    -------
    R: 2d array
        Redfield tensor

    rho0: 2d array
        initial density matrix

    Nt: total number of time steps

    dt: time step
    e_ops: list of observable operators

    Returns
    =========
    rho: 2D array
        density matrix at time t = Nt * dt
    
time propagation of the Redfield quantum master equation with RK4
Input

2d array
Redfield tensor

2d array
initial density matrix

total number of time steps

time step
e_ops: list of observable operators

Returns

2D array
density matrix at time t = Nt * dt
time propagation of the Redfield quantum master equation with RK4 Input 2d array Redfield tensor 2d array initial density matrix total number of time steps time step e_ops : list of observable operators Returns 2D array density matrix at time t = Nt * dt
def _redfield(R, rho0, evecs=None, Nt=1, dt=0.005, t0=0, e_ops=[], return_result=True):
    N = rho0.shape[0]
    if e_ops is None:
        e_ops = []
    if evecs is not None:
        rho0 = transform(rho0, evecs)
        e_ops = [transform(e, evecs) for e in e_ops]
    rho = rho0.copy()
    rho = dm2vec(rho).astype(complex)
    t = t0
    if return_result == False:
        f_obs = open('obs.dat', 'w')
        fmt = '{} '* (len(e_ops) + 1) + '\n'
        for k in range(Nt):
            observables = [obs_dm(rho, e) for e in e_ops]
            t += dt
            rho = rk4(rho, rhs, dt, R)
            f_obs.write(fmt.format(t, *observables))
        f_obs.close()
        return rho
    else:
        rholist = [] 
        result = Result(dt=dt, Nt=Nt, rho0=rho0)
        observables = np.zeros((Nt, len(e_ops)), dtype=complex)
        for k in range(Nt):
            t += dt
            rho = rk4(rho, rhs, dt, R)
            tmp = np.reshape(rho, (N, N))
            rholist.append(transform(tmp, dag(evecs)))
            observables[k, :] = [obs_dm(tmp, e) for e in e_ops]
        result.observables = observables
        result.rholist = rholist
        return result
def _redfield ( R , rho0 , evecs = None , Nt = 1 , dt = 0.005 , t0 = 0 , e_ops = [ ] , return_result = True ) : N = rho0 . shape [ 0 ] if e_ops is None : e_ops = [ ] if evecs is not None : rho0 = transform ( rho0 , evecs ) e_ops = [ transform ( e , evecs ) for e in e_ops ] rho = rho0 . copy ( ) rho = dm2vec ( rho ) . astype ( complex ) t = t0 if return_result == False : f_obs = open ( 'obs.dat' , 'w' ) fmt = '{} ' * ( len ( e_ops ) + 1 ) + '\n' for k in range ( Nt ) : observables = [ obs_dm ( rho , e ) for e in e_ops ] t += dt rho = rk4 ( rho , rhs , dt , R ) f_obs . write ( fmt . format ( t , * observables ) ) f_obs . close ( ) return rho else : rholist = [ ] result = Result ( dt = dt , Nt = Nt , rho0 = rho0 ) observables = np . zeros ( ( Nt , len ( e_ops ) ) , dtype = complex ) for k in range ( Nt ) : t += dt rho = rk4 ( rho , rhs , dt , R ) tmp = np . reshape ( rho , ( N , N ) ) rholist . append ( transform ( tmp , dag ( evecs ) ) ) observables [ k , : ] = [ obs_dm ( tmp , e ) for e in e_ops ] result . observables = observables result . rholist = rholist return result
time propagation of the Redfield quantum master equation with RK4
Input
time propagation of the Redfield quantum master equation with RK4 Input
"""
    time propagation of the Redfield quantum master equation with RK4

    Input
    -------
    R: 2d array
        Redfield tensor

    rho0: 2d array
        initial density matrix

    Nt: total number of time steps

    dt: time step
    e_ops: list of observable operators

    Returns
    =========
    rho: 2D array
        density matrix at time t = Nt * dt
    """ # initialize the density matrix # basis transformation # tf = t0 + dt * Nt # result = solve_ivp(rhs, t_span=(t0, tf), y0=rho0, vectorized=True, args=(R, )) # compute observables # observables = np.zeros(len(e_ops), dtype=complex) # for i, obs_op in enumerate(e_ops): # dipole-dipole auto-corrlation function #cor = np.trace(np.matmul(d, rho)) # take a partial trace to obtain the rho_el # f_dm.close() # store density matries
R
rho0
evecs
Nt
dt
t0
e_ops
return_result