lime/oqs.py
def _lindblad(H, rho0, c_ops, e_ops=None, Nt=1, dt=0.005, return_result=True):

    """
    time propagation of the lindblad quantum master equation
    with second-order differencing

    Input
    -------
    h0: 2d array
            system Hamiltonian
    Nt: total number of time steps

    dt: time step
        c_ops: list of collapse operators
        e_ops: list of observable operators
        rho0: initial density matrix

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

    # initialize the density matrix
    rho = rho0.copy()
    rho = rho.astype(complex)

    if e_ops is None:
        e_ops = []

    t = 0.0
    # first-step
    # rho_half = rho0 + liouvillian(rho0, h0, c_ops) * dt2
    # rho1 = rho0 + liouvillian(rho_half, h0, c_ops) * dt

    # rho_old = rho0
    # rho = rho1
    if return_result == False:

        # f_dm = open('den_mat.dat', 'w')
        # fmt_dm = '{} ' * (nstates**2 + 1) + '\n'

        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[i] = obs_dm(rho, obs_op)

            t += dt

            # rho_new = rho_old + liouvillian(rho, h0, c_ops) * 2. * dt
            # # update rho_old
            # rho_old = rho
            # rho = rho_new

            rho = rk4(rho, liouvillian, dt, H, c_ops)

            # 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, liouvillian, dt, H, c_ops)

            rholist.append(rho.copy())


            observables[k, :] = [obs_dm(rho, op) for op in e_ops]


        result.observables = observables
        result.rholist = rholist

        return result

    time propagation of the lindblad quantum master equation
    with second-order differencing

    Input
    -------
    h0: 2d array
            system Hamiltonian
    Nt: total number of time steps

    dt: time step
        c_ops: list of collapse operators
        e_ops: list of observable operators
        rho0: initial density matrix

    Returns
    =========
    rho: 2D array
        density matrix at time t = Nt * dt
    
time propagation of the lindblad quantum master equation
with second-order differencing

Input

2d array
system Hamiltonian
Nt: total number of time steps

time step
c_ops: list of collapse operators
e_ops: list of observable operators
rho0: initial density matrix

Returns

2D array
density matrix at time t = Nt * dt
time propagation of the lindblad quantum master equation with second - order differencing Input 2d array system Hamiltonian Nt : total number of time steps time step c_ops : list of collapse operators e_ops : list of observable operators rho0 : initial density matrix Returns 2D array density matrix at time t = Nt * dt
def _lindblad(H, rho0, c_ops, e_ops=None, Nt=1, dt=0.005, return_result=True):
    rho = rho0.copy()
    rho = rho.astype(complex)
    if e_ops is None:
        e_ops = []
    t = 0.0
    if return_result == False:
        f_obs = open('obs.dat', 'w')
        fmt = '{} '* (len(e_ops) + 1) + '\n'
        for k in range(Nt):
            observables = np.zeros(len(e_ops), dtype=complex)
            for i, obs_op in enumerate(e_ops):
                observables[i] = obs_dm(rho, obs_op)
            t += dt
            rho = rk4(rho, liouvillian, dt, H, c_ops)
            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, liouvillian, dt, H, c_ops)
            rholist.append(rho.copy())
            observables[k, :] = [obs_dm(rho, op) for op in e_ops]
        result.observables = observables
        result.rholist = rholist
        return result
def _lindblad ( H , rho0 , c_ops , e_ops = None , Nt = 1 , dt = 0.005 , return_result = True ) : rho = rho0 . copy ( ) rho = rho . astype ( complex ) if e_ops is None : e_ops = [ ] t = 0.0 if return_result == False : f_obs = open ( 'obs.dat' , 'w' ) fmt = '{} ' * ( len ( e_ops ) + 1 ) + '\n' for k in range ( Nt ) : observables = np . zeros ( len ( e_ops ) , dtype = complex ) for i , obs_op in enumerate ( e_ops ) : observables [ i ] = obs_dm ( rho , obs_op ) t += dt rho = rk4 ( rho , liouvillian , dt , H , c_ops ) 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 , liouvillian , dt , H , c_ops ) rholist . append ( rho . copy ( ) ) observables [ k , : ] = [ obs_dm ( rho , op ) for op in e_ops ] result . observables = observables result . rholist = rholist return result
time propagation of the lindblad quantum master equation
with second-order differencing
time propagation of the lindblad quantum master equation with second - order differencing
"""
    time propagation of the lindblad quantum master equation
    with second-order differencing

    Input
    -------
    h0: 2d array
            system Hamiltonian
    Nt: total number of time steps

    dt: time step
        c_ops: list of collapse operators
        e_ops: list of observable operators
        rho0: initial density matrix

    Returns
    =========
    rho: 2D array
        density matrix at time t = Nt * dt
    """ # initialize the density matrix # first-step # rho_half = rho0 + liouvillian(rho0, h0, c_ops) * dt2 # rho1 = rho0 + liouvillian(rho_half, h0, c_ops) * dt # rho_old = rho0 # rho = rho1 # f_dm = open('den_mat.dat', 'w') # fmt_dm = '{} ' * (nstates**2 + 1) + '\n' # compute observables # rho_new = rho_old + liouvillian(rho, h0, c_ops) * 2. * dt # # update rho_old # rho_old = rho # rho = rho_new # 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
H
rho0
c_ops
e_ops
Nt
dt
return_result