Esempio n. 1
0
def run_bllz_wrapper( hvib, istate, outfile_name, params ):
    """
    A small wrapper function to run the bllz dynamics. 
        hvib ( list of list of matrices ): The vibronic hamiltonian for all timesteps
        istate ( int ): Index of the initial state. This index is from 0
        outfile ( string ): The name of the output file
        params ( dict ): A dictionary of important dynamical parameters
    returns: A list of energy values that is the electronic energy vs time. Returned energy is in eV
    """

    params["outfile"]  = outfile_name
    params["nstates"]  = hvib[0].num_of_rows
    params["istate"]   = istate
    res_bllz, P = lz.run( [hvib], params )
    bllz_namd   = data_conv.MATRIX2nparray( res_bllz )
    # Recall that for bllz, we use the schrodiger not the surface hopping energy
    energy_bllz = ( bllz_namd[:,3*params["nstates"]+1] - bllz_namd[:,1] )*units.au2ev
    # for bllz surface hopping energy
    #energy_bllz = ( bllz_namd[:,3*params["nstates"]+2] - bllz_namd[:,1] )*units.au2ev
    return energy_bllz
Esempio n. 2
0
def test_lz(Hvib, params, expected_result):
    """Tests that the LZ probabilities are computed correctly according to the NBRA BLSH scheme"""
    params["istate"]             = 1                  # From 0
    params["T"]                  = 300.0              # Temperature, K
    params["target_space"]       = 1
    params["gap_min_exception"]  = 0
    params["Boltz_opt_BL"]       = 1                  # Option to incorporate hte frustrated hops into BL probabilities
    params["outfile"]            = "_out_Markov_.txt" # output file
    params["evolve_Markov"]      = True               # Rely on the Markov approach
    params["evolve_TSH"]         = False              # don't care about TSH
    params["ntraj"]              = 1                  # how many stochastic trajectories
    params["init_times"]         = [0]                # starting points for sub-trajectories
    params["do_output"]          = True               # request to print the results into a file
    params["do_return"]          = False              # request to not store the date in the operating memory    
    params["return_probabilities"] = True

    res, P = lz.run(Hvib, params)

    computed_result = 0
    for t in range(len(P[0])):
        if P[0][t].get(0,0) != 1:
            computed_result = P[0][t].get(0,1); #print (computed_result); sys.exit(0)
            assert expected_result == round(computed_result, 4)
            break
#====================== One case =====================
# Looking on the "SH" populations - NBRA-TSH approach
params["gap_min_exception"]  = 0
params["Boltz_opt"]          = 1                     # Option for the frustrated hops acceptance/rejection
params["Boltz_opt_BL"]       = 0                     # Option to incorporate hte frustrated hops into BL probabilities
params["outfile"]            = "_out_TSH_.txt"       # output file
params["evolve_Markov"]      = False                 # don't propagate Markov
params["evolve_TSH"]         = True                  # Rely on propagating trajectories
params["ntraj"]              = 100                   # how many stochastic trajectories
start = time.time()
res = lz.run(Hvib, params)
end = time.time()
print("Time to run TSH = ", end - start)
"""

#====================== Another case =====================
# Looking on the "SE" populations - Markov chain approach
params["target_space"] = 1
params["gap_min_exception"] = 0
params["Boltz_opt"] = 0  # Option for the frustrated hops acceptance/rejection
params[
    "Boltz_opt_BL"] = 1  # Option to incorporate hte frustrated hops into BL probabilities
params["outfile"] = "_out_Markov_.txt"  # output file
params["evolve_Markov"] = True  # Rely on the Markov approach
params["evolve_TSH"] = False  # don't care about TSH
params["ntraj"] = 1  # how many stochastic trajectories
start = time.time()
res = lz.run(Hvib, params)
end = time.time()
print("Time to run Markov = ", end - start)