예제 #1
0
def converge(base_path, structures_list, calculation_set_input_dictionary_template, change_set):

	Path.make(base_path)

	for structure_count, structure in enumerate(structures_list):
		structure_path = Path.join(base_path, 'structure_'+str(structure_count))

		Path.make(structure_path)

		change_key = change_set[0]
		change_values_list = change_set[1]
		num_relaxations = len(change_values_list)


		for run_set_count, change_set_value in enumerate(change_values_list):
			relaxation_set_path = Path.join(structure_path, 'relaxation_set_'+str(run_set_count))

			inputs = copy.deepcopy(calculation_set_input_dictionary_template)
			inputs[change_key] = change_set_value

			vasp_relaxation = VaspRelaxation(path=relaxation_set_path, initial_structure=structure, input_dictionary=inputs)

			vasp_relaxation.update()

			if vasp_relaxation.complete:
				print change_key, change_set_value, vasp_relaxation.get_final_energy(per_atom=True), vasp_relaxation.total_time
예제 #2
0
def npar_converger(base_path, structure, npar_list, base_kpoints_scheme,
                   base_kpoints_subdivisions_list, base_ediff, base_encut,
                   node_count):
    """Takes in a structure, set of npars, and base params and runs set in base_path"""
    encut_convergence_set_path = Path.clean(base_path)
    Path.make(encut_convergence_set_path)

    for npar in npar_list:
        run_path = Path.join(encut_convergence_set_path, str(npar))

        input_dictionary = {
            'external_relaxation_count': 0,
            'kpoint_schemes_list': [base_kpoints_scheme],
            'kpoint_subdivisions_lists': [base_kpoints_subdivisions_list],
            'submission_script_modification_keys_list': ['100'],
            'submission_node_count_list': [node_count],
            'ediff': [base_ediff],
            'encut': [base_encut],
            'npar': [npar]
        }

        vasp_relaxation = VaspRelaxation(run_path,
                                         structure,
                                         input_dictionary,
                                         verbose=False)

        if vasp_relaxation.update():
            print "npar:", npar, "node_count:", node_count, round(
                vasp_relaxation.get_final_energy(True),
                5), round(vasp_relaxation.total_time, 2)
        else:
            pass
예제 #3
0
	def get_data_dictionaries_list(self, get_polarization=False):
		"""
		Starts at most negative misfit runs and goes to larger misfits finding the minimum energy data set. To encourage continuity, if two or more relaxations are within a small energy threshold of each other, the 
		structure that is closest to the last chosen structure is chosen.

		The output of this function looks like [[-0.02, energy_1, [polarization_vector_1]], [-0.015, energy_2, [polarization_vector_2]], ...]
		"""

		output_data_dictionaries = []
		spg_symprecs = [0.1, 0.05, 0.04, 0.03, 0.02, 0.01, 0.001]

		for misfit_strain in self.misfit_strains_list:
			# print str(misfit_strain)
			data_dictionary = OrderedDict()
			data_dictionary['misfit_strain'] = misfit_strain

			misfit_path = self.get_extended_path(str(misfit_strain).replace('-', 'n'))

			minimum_energy = 10000000000
			minimum_energy_relaxation = None
			for i in range(10000):
				relax_path = Path.join(misfit_path, 'structure_' + str(i))

				if not Path.exists(relax_path):
					break

				relaxation = VaspRelaxation(path=relax_path)

				if not relaxation.complete:
					continue

				energy = relaxation.get_final_energy(per_atom=False)
				# print 'structure_' + str(i), energy
				
				if energy < minimum_energy:
					minimum_energy = energy
					minimum_energy_relaxation = relaxation

			# print 
			# print "minimum E " + str(minimum_energy)
			# print 
			
			if minimum_energy_relaxation == None:
				data_dictionary['structure'] = None
				data_dictionary['energy'] = None
				data_dictionary['polarization_vector'] = None

				for symprec in spg_symprecs:
					data_dictionary['spg_' + str(symprec)] = None

				data_dictionary['path'] = None
			else:				

				structure = copy.deepcopy(minimum_energy_relaxation.final_structure)

				if get_polarization:
					polarization_vector = self.update_polarization_run(minimum_energy_relaxation)
				else:
					polarization_vector = None

				data_dictionary['structure'] = structure
				data_dictionary['energy'] = minimum_energy
				data_dictionary['polarization_vector'] = polarization_vector

				for symprec in spg_symprecs:
					data_dictionary['spg_' + str(symprec)] = structure.get_spacegroup_string(symprec)

				data_dictionary['path'] = Path.join(minimum_energy_relaxation.path, 'static')

			output_data_dictionaries.append(data_dictionary)

		return output_data_dictionaries
예제 #4
0
        eigen_structure[component_index + 6] = i * increment

        distorted_structure = eigen_structure.get_distorted_structure()

        relax = VaspRelaxation(path=relaxation_path,
                               initial_structure=distorted_structure,
                               input_dictionary=relax_input_dictionary)

        relax.update()

        if start_range == 1 and i == 1:
            print str(0.0), stored_energy

        if relax.complete:
            if i == 0:
                stored_energy = relax.get_final_energy()

            relaxed_structure = relax.final_structure

            print str(eigen_structure[component_index +
                                      6]), relax.get_final_energy()

            if not i == 0:
                energies.append(relax.get_final_energy())
        else:
            component_complete = False

    if component_complete:

        curvature = (energies[1] - stored_energy) / (increment**2.0)
        curvature_2 = (energies[2] - stored_energy) / ((increment * 2.0)**2.0)
    eigen_structure = EigenStructure(reference_structure=reference_structure,
                                     hessian=hessian)

    relaxation_path = Path.join(base_path,
                                "chromosome_index_" + str(chromosome_index))

    Path.make(relaxation_path)

    eigen_structure.set_eigen_chromosome(chromosome)

    print "Chromosome index is " + str(
        chromosome_index) + "\n\t initial eigenstructure is " + str(
            eigen_structure)

    distorted_structure = eigen_structure.get_distorted_structure()

    relax = VaspRelaxation(path=relaxation_path,
                           initial_structure=distorted_structure,
                           input_dictionary=relax_input_dictionary)

    relax.update()

    if relax.complete:
        relaxed_structure = relax.final_structure
        relaxed_eigen_structure = EigenStructure(
            reference_structure=reference_structure,
            hessian=hessian,
            distorted_structure=relaxed_structure)
        print "\t   final eigenstructure is " + str(
            relaxed_eigen_structure) + " " + str(relax.get_final_energy())