Exemplo n.º 1
0
Arquivo: run.py Projeto: mir1995/QMD
    DELTA, C, ALPHA = 0.5, -np.pi, np.pi
    # space
    XL, XR = -30, 30
    N = 2**14
    # time
    T, TSTEP, TDIR = 20 / P0, 1 / 100 / P0, 1
    #potential params
    NEQS = 2
    if len(sys.argv) > 1:
        DELTA, C, ALPHA, EPS, P0 = [float(string) for string in sys.argv[1:]]
    FNAME = './data/delta%.3fc%.3falpha%.3feps%.3fp%d.txt' % (DELTA, C, ALPHA,
                                                              EPS, P0)
    print(ALPHA)
    # ---------------- INIT -------------------------
    space = Space(N, XL, EPS, XR)
    time_back = Time(T / 2, TSTEP, -1)
    wave_boa = Gaussian6(EPS, Q0, P0, 'boa', 1, space)  # init psi and psi hat
    potential = Single(DELTA, C, ALPHA, 'up')
    solver_boa = Strang(EPS, space, time_back, potential, 1)

    # ---------------- RUN BACKWARD ------------------
    wave_boa = run_backward(time_back, solver_boa, wave_boa)

    time = Time(T, TSTEP, TDIR)
    wave = Gaussian6(EPS, Q0, P0, 'exact')  # init psi and psi hat
    wave.psi = np.stack(
        (wave_boa.psi.copy(), np.zeros(space.n, dtype='complex_')))
    wave_formulaup = Gaussian6(EPS, Q0, P0,
                               'formulaup')  # init psi and psi hat
    wave_formuladown = Gaussian6(EPS, Q0, P0,
                                 'formuladown')  # init psi and psi hat
Exemplo n.º 2
0
    # ----------------- SAVE DATA TO FOLLOWING FILE
    FNAME = './data/onelevelwavepacketdelta%.4falpha%.4feps%.4fp%d.txt' \
            %(DELTA, ALPHA, EPS, p) # TO CHANGE
    FNAME_OBS = './data/onelevelobservablesdelta%.4falpha%.4feps%.4fp%d.txt' \
            %(DELTA, ALPHA, EPS, p) # TO CHANGE

    print("############ Simulation parameters ##############")
    print("-----> Potential is Simple1")
    # makes sense to have this potential class
    print("-----> delta={:.4f}, alpha={:.4f}".format(DELTA, ALPHA))
    print("------------ Simulation parameters ---------------")
    print("------------ Simulation parameters ---------------")

    # --------------- INITIALISE SPACE-TIME-POTENTIAL BACKWARD
    space = Space(N, XL, EPS, XR)
    time_back = Time(T / 2, TSTEP, -1)
    potential = Simple1(ALPHA, DELTA, 'up')
    solver_boa_back = Strang(EPS, space, time_back, potential, 1)
    """
    # --------------- INITIALISE GAUSSIAN WAVEPACKET WITH DEFINED PARAMETERS 
    wave_boa = Gaussian(EPS, q, p, 'boa', 1, space) # init psi and psi hat
    
    # --------------- EVOLVE BACKWARD FROM CROSSING --------------
    #run_simple(time_back, space, solver_boa_back, wave_boa, FNAME_OBS)
    # --------------- EVOLVE FORWARD --------------
    """
    wave = Gaussian(EPS, q, p, 'exact', 1, space)  # init psi and psi hat
    #wave = Gaussian(EPS, q, p, 'exact') # init psi and psi hat
    #wave.psi = np.stack((wave_boa.psi.copy(), np.zeros(space.n, dtype='complex_')))
    time_forward = Time(T, TSTEP, 1)
    solver_single = Strang(EPS, space, time_forward, potential, 1)
Exemplo n.º 3
0
Arquivo: run.py Projeto: mir1995/QMD
            %(DELTA, ALPHA, EPS, p) # TO CHANGE
    FNAME_OBS = './data/observablesdelta%.4falpha%.4feps%.4fp%d.txt' \
            %(DELTA, ALPHA, EPS, p) # TO CHANGE

    print("############ Simulation parameters ##############")
    print("-----> Potential is Landau Zener")
    # makes sense to have this potential class
    print("-----> delta={:.4f}, alpha={:.4f}".format(DELTA, ALPHA))
    print("------------ Simulation parameters ---------------")
    print("------------ Simulation parameters ---------------")

    # --------------- INITIALISE SPACE-TIME-POTENTIAL BACKWARD
    space = Space(N, XL, EPS, XR)
    potential = LZ(ALPHA, DELTA, 'up')
    wave = Gaussian(EPS, q, p, 'exact', 2, space)  # init psi and psi hat
    time_forward = Time(T, TSTEP, 1)
    solver_coupled = Strang(EPS, space, time_forward, potential, 2)
    run_coupled(time_forward, space, solver_coupled, wave, potential,
                FNAME_OBS)

    # --------------- SAVE DATA --------------
    wave_up = Gaussian(EPS, q, p, 'exact_up')  # init psi and psi hat
    wave_up.psi = wave.psi[0, :]
    wave_up.psihat = wave.psihat[0, :]
    wave_down = Gaussian(EPS, q, p, 'exact_down')  # init psi and psi hat
    wave_down.psi = wave.psi[1, :]
    wave_down.psihat = wave.psihat[1, :]
    Data.save(FNAME, space, [wave_up, wave_down])  # this will not work

    # ----------------- SAVE DATA
    print("GOOD LUCK -------------------------------------------")
Exemplo n.º 4
0
Arquivo: run.py Projeto: mir1995/QMD
    import numpy as np
    import matplotlib.pyplot as plt
    # ------------------- PARAMETERS ----------------
    # init wave params - reason behind 2 - see paper initial condition 
    EPS, Q0, P0 = 1/10, -10, 4 # momentums 2 and 5 in the paper 
    A, B, C, D = 1, 1, 0.5, 1
    # space    
    XL, XR = -30, 30
    N = 2**14
    # time
    T, TSTEP, TDIR= 24/P0, 1/100/P0, 1
    #potential params
    FNAME = './tullya%.3fb%.3fc%.3fd%.3feps%.3fp%d.txt' %(A, B, C, D, EPS, P0)
    # ---------------- INIT -------------------------
    space = Space(N, XL, EPS, XR)
    time = Time(T, TSTEP, TDIR)
    potential = Tully(A, B, C, D,  'up')
    wave = Gaussian(EPS, Q0, P0, 'exact') # init psi and psi hat
    wave_boa = Gaussian(EPS, Q0, P0, 'boa', 1, space) # init psi and psi hat
    solver = Strang(EPS, space, time, potential, 2)
    solver_boa = Strang(EPS, space, time, potential, 1)

    # ---------------- RUN BACKWARD ------------------
    wave.psi = np.stack((wave_boa.psi.copy(), np.zeros(space.n, dtype='complex_')))
    # ----------------- RUN -----------------------
    for itr in range(1, time.max_itr + 1):
        # this should return, amongst else, boa at the crossing
        solver.do_step(wave, space, itr, time.max_itr)
        solver_boa.do_step(wave_boa, space, itr, time.max_itr)
        print('mass %.6f, %.6f ' % (np.sum(np.abs(wave.psi[0,:])**2)*space.dx,
                             np.sum(np.abs(wave.psi[1,:])**2)*space.dx), end='\r')