Exemplo n.º 1
0
def test_delta(fname=None):

    n_dims = [max_tier] * max_terms
    heom = Hierachy(n_dims, H, V, corr)

    # Adopt MCTDH
    root = simple_heom(rho_0, n_dims)
    leaves_dict = {leaf.name: leaf for leaf in root.leaves()}
    all_terms = []
    for term in heom.diff():
        all_terms.append([(leaves_dict[str(fst)], snd) for fst, snd in term])

    solver = MultiLayer(root, all_terms)
    solver.ode_method = 'RK45'
    solver.snd_order = False
    solver.atol = 1.e-7
    solver.rtol = 1.e-7

    # Define the obersevable of interest
    logger = Logger(filename=fname, level='info').logger
    for n, (time, r) in enumerate(
            solver.propagator(
                steps=count,
                ode_inter=dt_unit,
                #split=False,
            )):
        if n % callback_interval == 0:
            rho = np.reshape(r.array, (-1, 4))
            logger.info("{} {} {} {} {}".format(time, rho[0, 0], rho[0, 1],
                                                rho[0, 2], rho[0, 3]))

    return
Exemplo n.º 2
0
def test_heom(fname=None):
    n_dims = 2 * dof * [max_tier]

    root = simple_heom(rho_0, n_dims)
    leaves = root.leaves()
    h_list = model.heom_h_list(leaves[0], leaves[1], leaves[2:], beta=None)

    solver = MultiLayer(root, h_list)
    solver.ode_method = 'RK45'
    solver.cmf_steps = solver.max_ode_steps  # use constant mean-field
    solver.ps_method = 'split'
    solver.svd_err = 1.0e-12

    # Define the obersevable of interest
    logger = Logger(filename=prefix + fname, level='info').logger
    logger2 = Logger(filename=prefix + "en_" + fname, level='info').logger
    for n, (time, r) in enumerate(
            solver.propagator(
                steps=count,
                ode_inter=dt_unit,
                split=False,
            )):
        # renormalized by the trace of rho
        norm = np.trace(np.reshape(np.reshape(r.array, (4, -1))[:, 0], (2, 2)))
        r.set_array(r.array / norm)
        if n % callback_interval == 0:
            t = Quantity(time).convert_to(unit='fs').value
            rho = np.reshape(r.array, (4, -1))[:, 0]
            logger.info("{}    {} {} {} {}".format(t, rho[0], rho[1], rho[2],
                                                   rho[3]))
            en = np.trace(np.reshape(rho, (2, 2)) @ model.h)
            logger2.info('{}    {}'.format(t, en))
    return
Exemplo n.º 3
0
def test_simple(fname=None):
    # Type settings
    corr.print()

    n_dims = [max_tier] * max_terms
    heom = Hierachy(n_dims, H, V, corr)

    # Adopt MCTDH
    root = simple_heom(rho_0, n_dims)
    leaves_dict = {leaf.name: leaf for leaf in root.leaves()}
    all_terms = []
    for term in heom.diff():
        all_terms.append([(leaves_dict[str(fst)], snd) for fst, snd in term])

    #solver = ProjectorSplitting(root, all_terms)
    solver = MultiLayer(root, all_terms)
    solver.ode_method = 'RK45'
    solver.snd_order = False

    # Define the obersevable of interest
    logger = Logger(filename=fname, level='info').logger
    for n, (time, r) in enumerate(solver.propagator(
            steps=count,
            ode_inter=dt_unit,
    )):
        try:
            if n % callback_interval == 0:
                rho = np.reshape(r.array, (-1, 4))[0]
                logger.info("{} {} {} {} {}".format(time, rho[0], rho[1], rho[2], rho[3]))
        except:
            break

    return
Exemplo n.º 4
0
def test_simple():
    # Type settings
    corr = Correlation(k_max=max_terms)
    corr.symm_coeff = np.diag(corr_dict['s'].toarray())
    corr.asymm_coeff = np.diag(corr_dict['a'].toarray())
    corr.exp_coeff = np.diag(corr_dict['gamma'].toarray())
    corr.delta_coeff = 0.0  # delta_coeff
    corr.print()

    n_dims = [max_tier] * max_terms
    heom = Hierachy(n_dims, H, V, corr)

    # Adopt MCTDH
    root = simple_heom(rho_0, n_dims)
    leaves_dict = {leaf.name: leaf for leaf in root.leaves()}
    all_terms = []
    for term in heom.diff():
        all_terms.append([(leaves_dict[str(fst)], snd) for fst, snd in term])

    #solver = ProjectorSplitting(root, all_terms)
    solver = MultiLayer(root, all_terms)
    solver.ode_method = 'RK45'
    solver.snd_order = False
    solver.atol = 1.e-7
    solver.rtol = 1.e-7

    # Define the obersevable of interest
    dat = []
    for n, (time,
            r) in enumerate(solver.propagator(
                steps=count,
                ode_inter=dt_unit,
            )):
        try:
            if n % callback_interval == 0:
                rho = np.reshape(r.array, (-1, 4))
                flat_data = [time] + list(rho[0])
                dat.append(flat_data)
                print("Time: {};    Tr rho_0: {}".format(
                    time, rho[0, 0] + rho[0, -1]))
        except:
            break

    return np.array(dat)
Exemplo n.º 5
0
def test_drude(fname=None):
    # Type settings
    corr = Correlation(k_max=max_terms)
    corr.symm_coeff = np.diag(corr_dict['s'].toarray())
    corr.asymm_coeff = np.diag(corr_dict['a'].toarray())
    corr.exp_coeff = np.diag(corr_dict['gamma'].toarray())
    corr.delta_coeff = 0.0  # delta_coeff
    corr.print()

    n_dims = [max_tier] * max_terms
    heom = Hierachy(n_dims, H, V, corr)

    # Adopt MCTDH
    root = simple_heom(rho_0, n_dims)
    leaves_dict = {leaf.name: leaf for leaf in root.leaves()}
    all_terms = []
    for term in heom.diff():
        all_terms.append([(leaves_dict[str(fst)], snd) for fst, snd in term])

    solver = ProjectorSplitting(root, all_terms)
    solver.ode_method = 'DOP853'
    solver.snd_order = False
    solver.atol = 1.e-7
    solver.rtol = 1.e-7

    # Define the obersevable of interest
    logger = Logger(filename=fname, level='info').logger
    for n, (time, r) in enumerate(solver.propagator(
            steps=count,
            ode_inter=dt_unit,
    )):
        if n % callback_interval == 0:
            rho = np.reshape(r.array, (-1, 4))
            logger.info("{} {} {} {} {}".format(time, rho[0, 0], rho[0, 1], rho[0, 2], rho[0, 3]))
            print("Time: {};    Tr rho_0: {}".format(time, rho[0, 0] + rho[0, -1]))

    return