def main(): # # create a system object with spin one-half sites and blocks. # spin_one_half_site = SpinOneHalfSite() system = System(spin_one_half_site) # # build the Hamiltonian, and solve it using Lanczos. # set_hamiltonian_to_AF_Heisenberg(system) ground_state_energy, ground_state_wf = system.calculate_ground_state() # # print results # print "The ground state energy is %8.6f." % ground_state_energy print "The ground state wavefunction is :" print ground_state_wf.as_matrix
def main(args): # # create a system object with spin one-half sites and blocks. # spin_one_half_site = SpinOneHalfSite() system = System(spin_one_half_site) # # read command-line arguments and initialize some stuff # number_of_sites = int(args['-n']) number_of_states_kept = int(args['-m']) sizes = [] energies = [] entropies = [] truncation_errors = [] # # infinite DMRG algorithm # number_of_sites = 2 * (number_of_sites / 2) # make it even for current_size in range(4, number_of_sites + 1, 2): #block_size = current_size / 2 - 1 energy, entropy, truncation_error = (infinite_dmrg_step( system, current_size, number_of_states_kept)) sizes.append(current_size) energies.append(energy) entropies.append(entropy) truncation_errors.append(truncation_error) # # save results # output_file = os.path.join(os.path.abspath(args['--dir']), args['--output']) f = open(output_file, 'w') zipped = zip(sizes, energies, entropies, truncation_errors) f.write('\n'.join('%s %s %s %s' % x for x in zipped)) f.close() print 'Results stored in ' + output_file
def main(args): # # create a system object with electron sites and blocks, and set # its model to be the Hubbard model. # electronic_site = ElectronicSite() system = System(electronic_site) system.model = HubbardModel() # # read command-line arguments and initialize some stuff # number_of_sites = int(args['-n']) number_of_states_kept = int(args['-m']) number_of_sweeps = int(args['-s']) system.model.U = float(args['-U']) number_of_states_infinite_algorithm = 10 if number_of_states_kept < number_of_states_infinite_algorithm: number_of_states_kept = number_of_states_infinite_algorithm sizes = [] energies = [] entropies = [] truncation_errors = [] system.number_of_sites = number_of_sites # # infinite DMRG algorithm # max_left_block_size = number_of_sites - 3 for left_block_size in range(1, max_left_block_size + 1): energy, entropy, truncation_error = (system.infinite_dmrg_step( left_block_size, number_of_states_infinite_algorithm)) current_size = left_block_size + 3 sizes.append(left_block_size) energies.append(energy) entropies.append(entropy) truncation_errors.append(truncation_error) # # finite DMRG algorithm # states_to_keep = calculate_states_to_keep( number_of_states_infinite_algorithm, number_of_states_kept, number_of_sweeps) half_sweep = 0 while half_sweep < len(states_to_keep): # sweep to the left for left_block_size in range(max_left_block_size, 0, -1): states = states_to_keep[half_sweep] energy, entropy, truncation_error = (system.finite_dmrg_step( 'right', left_block_size, states)) sizes.append(left_block_size) energies.append(energy) entropies.append(entropy) truncation_errors.append(truncation_error) half_sweep += 1 # sweep to the right # if this is the last sweep, stop at the middle if half_sweep == 2 * number_of_sweeps - 1: max_left_block_size = number_of_sites / 2 - 1 for left_block_size in range(1, max_left_block_size + 1): energy, entropy, truncation_error = (system.finite_dmrg_step( 'left', left_block_size, states)) sizes.append(left_block_size) energies.append(energy) entropies.append(entropy) truncation_errors.append(truncation_error) half_sweep += 1 # # save results # output_file = os.path.join(os.path.abspath(args['--dir']), args['--output']) f = open(output_file, 'w') zipped = zip(sizes, energies, entropies, truncation_errors) f.write('\n'.join('%s %s %s %s' % x for x in zipped)) f.close() print 'Results stored in ' + output_file