コード例 #1
0
    basis.append(tmp_basis)
print (basis)





####################
# 3.0. Now, for each timestep, we compute the energies of the SDs and sort them by energy. This prevents the state energies from crossing in this basis. However, note that the St_ks files (time-overlaps in the KS basis) have no knowledge of the reordering of the SDs by energies
nSDs = len(basis)
E_sd_sorted  = []
basis_sorted = []
SD_energy_corr = [0.0]*nSDs
for step in range(finish_time-start_time):

    E = mapping.energy_mat_arb( basis, E_ks[0][step], SD_energy_corr )
    nstates = E.num_of_cols
    e = np.zeros( nstates )
    for state in range(nstates):
        e[state] =  E.get(state,state).real
    reindex = np.argsort(e)
    E_sd_sorted.append( CMATRIX(nstates,nstates) )
    basis_sorted.append( [] )
    for i in range(len(reindex)):
        E_sd_sorted[step].set( i, i, E.get(  int(reindex[i]), int(reindex[i]) ) )
        basis_sorted[step].append( basis[ int(reindex[i]) ] )




コード例 #2
0
        1. Reindexing the SD bases from the native ES format to what Libra expects
        2. Sorting the SD bases at each timestep by their energies

"""
# 3.1. Reindex the SDs into the format expected by Libra
sd_states_reindexed = step2_many_body.reindex_cp2k_sd_states( ks_orbital_homo_index, ks_orbital_indicies, sd_basis_states_unique, sd_format=1 )
#print("The reindexed Slater determinants = \n", sd_states_reindexed)

# 3.2. Sort the SDs at each timestep
E_sd_job = []
sd_states_reindexed_sorted = []
sd_states_unique_sorted = []
SD_energy_corr = [0.0]*len(sd_states_reindexed)
for step in range( finish_time-start_time ):
    # At this step, compute the energy of the SD
    E_this_sd  = mapping.energy_mat_arb( sd_states_reindexed, E_ks_job[0][step], SD_energy_corr )
    nstates_sd = len(sd_states_reindexed)
    # Make an array of zeros, these will be overwritten with the energy of each SD
    e = np.zeros( nstates_sd )
    for state in range(nstates_sd):
        e[state] =  E_this_sd.get(state,state).real
    # Obtain the indexing fo the SDs by their energies
    reindex = np.argsort(e)
    # We need to write the energies into matrix form 
    E_sd_job.append(  CMATRIX(nstates_sd,nstates_sd) )
    sd_states_reindexed_sorted.append( [] )
    # For each SD basis, make the energy matrix and reindex the list of basis according to their energies
    for i in range(len(reindex)):
        # This is making the energy matrix
        E_sd_job[step].set(  i,i, E_this_sd.get(  int(reindex[i]), int(reindex[i])) )
        # This is reindexing the list of SD bases at this time step according to their energies