Beispiel #1
0
	def update(self):

		for misfit_strain in self.misfit_strains_list:

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

			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)

				relaxation.update()

				print "Updating Epitaxial Relax run at " + relax_path + "  Status is " + relaxation.get_status_string()

				if self.calculate_polarizations and relaxation.complete:
					self.update_polarization_run(relaxation)
def run_misfit_strain(path, misfit_strain, input_dictionary,
                      initial_relaxation_input_dictionary, dfpt_incar_settings,
                      derivative_evaluation_vasp_run_inputs_dictionary,
                      minima_relaxation_input_dictionary,
                      epitaxial_relaxation_input_dictionary):

    Path.make(path)
    guessed_minima_data_path = Path.join(path, 'guessed_chromosomes')

    species_list = input_dictionary['species_list']
    reference_lattice_constant = input_dictionary['reference_lattice_constant']
    Nx = input_dictionary['supercell_dimensions_list'][0]
    Ny = input_dictionary['supercell_dimensions_list'][1]
    Nz = input_dictionary['supercell_dimensions_list'][2]
    displacement_finite_differences_step_size = input_dictionary[
        'displacement_finite_differences_step_size']
    perturbation_magnitudes_dictionary = input_dictionary[
        'perturbation_magnitudes_dictionary']

    a = reference_lattice_constant * (1.0 + misfit_strain)

    initial_structure = Perovskite(
        supercell_dimensions=[Nx, Ny, Nz],
        lattice=[[a * Nx, 0.0, 0.0], [0.0, a * Ny, 0.0],
                 [
                     0.0, 0.0, reference_lattice_constant * Nz *
                     (1.0 + 0.3 * (1.0 - (a / reference_lattice_constant)))
                 ]],
        species_list=species_list)
    relaxation = VaspRelaxation(
        path=Path.join(path, 'relaxation'),
        initial_structure=initial_structure,
        input_dictionary=initial_relaxation_input_dictionary)

    if not relaxation.complete:
        relaxation.update()
        return False

    relaxed_structure = relaxation.final_structure

    relaxed_structure_path = Path.join(path, 'output_relaxed_structure')
    relaxed_structure.to_poscar_file_path(relaxed_structure_path)

    force_calculation_path = Path.join(path, 'dfpt_force_calculation')

    kpoints = Kpoints(scheme_string=kpoint_scheme,
                      subdivisions_list=kpoint_subdivisions_list)
    incar = IncarMaker.get_dfpt_hessian_incar(dfpt_incar_settings)
    input_set = VaspInputSet(relaxed_structure,
                             kpoints,
                             incar,
                             auto_change_lreal=False,
                             auto_change_npar=False)
    input_set.incar['lepsilon'] = True

    dfpt_force_run = VaspRun(path=force_calculation_path, input_set=input_set)

    if not dfpt_force_run.complete:
        dfpt_force_run.update()
        return False

    hessian = Hessian(dfpt_force_run.outcar)

    if input_dictionary['write_hessian_data']:
        hessian.print_eigenvalues_to_file(
            Path.join(path, 'output_eigen_values'))
        hessian.print_eigen_components_to_file(
            Path.join(path, 'output_eigen_components'))
        hessian.print_mode_effective_charge_vectors_to_file(
            Path.join(path, 'output_mode_effective_charge_vectors'),
            relaxed_structure)

        eigen_structure = EigenStructure(reference_structure=relaxed_structure,
                                         hessian=hessian)

        mode_structures_path = Path.join(path, 'mode_rendered_structures')
        Path.make(mode_structures_path)

        mode_charge_file = File(
            Path.join(path, 'output_mode_effective_charge_vectors'))

        sorted_eigen_pairs = hessian.get_sorted_hessian_eigen_pairs_list()
        for i, structure in enumerate(
                eigen_structure.get_mode_distorted_structures_list(
                    amplitude=0.6)):
            if i > 30:
                break
            structure.to_poscar_file_path(
                Path.join(
                    mode_structures_path, 'u' + str(i + 1) + '_' +
                    str(round(sorted_eigen_pairs[i].eigenvalue, 2)) + '.vasp'))

            structure.lattice = Lattice([[8.0, 0.0, 0.0], [0.0, 8.0, 0.0],
                                         [0.0, 0.0, 8.0]])

            mode_charge_file[i] += '    ' + structure.get_spacegroup_string(
                symprec=0.2) + '  ' + structure.get_spacegroup_string(
                    symprec=0.1) + '  ' + structure.get_spacegroup_string(
                        symprec=0.001)

        mode_charge_file.write_to_path()
    #sys.exit()

    ################################################### random structure searcher
    if True:
        rand_path = Path.join(path, 'random_trials')
        Path.make(rand_path)

        num_guesses = 1
        num_modes = 12
        max_amplitude = 0.6

        if misfit_strain == 0.02:
            eigen_structure = EigenStructure(
                reference_structure=relaxed_structure, hessian=hessian)

            for i in range(num_guesses):
                trial_path = Path.join(rand_path, str(i))

                if not Path.exists(trial_path):
                    initial_structure_trial = eigen_structure.get_random_structure(
                        mode_count_cutoff=num_modes,
                        max_amplitude=max_amplitude)
                    trial_relaxation = VaspRelaxation(
                        path=trial_path,
                        initial_structure=initial_structure_trial,
                        input_dictionary=minima_relaxation_input_dictionary)
                else:
                    trial_relaxation = VaspRelaxation(path=trial_path)

                print "Updating random trial relaxation at " + trial_relaxation.path + "  Status is " + trial_relaxation.get_status_string(
                )
                trial_relaxation.update()

                if trial_relaxation.complete:
                    print "Trial " + str(i)
                    print trial_relaxation.get_data_dictionary()

        return None
    ###################################################

    if not Path.exists(guessed_minima_data_path):
        variable_specialty_points_dictionary = input_dictionary[
            'variable_specialty_points_dictionary_set'][
                misfit_strain] if input_dictionary.has_key(
                    misfit_strain) else {}

        derivative_evaluation_path = Path.join(
            path, 'expansion_coefficient_calculations')
        derivative_evaluator = DerivativeEvaluator(
            path=derivative_evaluation_path,
            reference_structure=relaxed_structure,
            hessian=hessian,
            reference_completed_vasp_relaxation_run=relaxation,
            vasp_run_inputs_dictionary=
            derivative_evaluation_vasp_run_inputs_dictionary,
            perturbation_magnitudes_dictionary=
            perturbation_magnitudes_dictionary,
            displacement_finite_differences_step_size=
            displacement_finite_differences_step_size,
            status_file_path=Path.join(path, 'output_derivative_plot_data'),
            variable_specialty_points_dictionary=
            variable_specialty_points_dictionary,
            max_displacement_variables=input_dictionary[
                'max_displacement_variables'])

        derivative_evaluator.update()

    else:
        minima_path = Path.join(path, 'minima_relaxations')

        minima_relaxer = MinimaRelaxer(
            path=minima_path,
            reference_structure=relaxed_structure,
            reference_completed_vasp_relaxation_run=relaxation,
            hessian=hessian,
            vasp_relaxation_inputs_dictionary=
            minima_relaxation_input_dictionary,
            eigen_chromosome_energy_pairs_file_path=guessed_minima_data_path,
            log_base_path=path,
            max_minima=input_dictionary['max_minima'])

        minima_relaxer.update()
        minima_relaxer.print_status_to_file(
            Path.join(path, 'output_minima_relaxations_status'))

        if minima_relaxer.complete:
            print "Minima relaxer complete: sorting the relaxations to find the lowest energy structure."
            #minima_relaxer.print_selected_uniques_to_file(file_path=Path.join(path, 'output_selected_unique_minima_relaxations'))
            sorted_uniques = minima_relaxer.get_sorted_unique_relaxation_data_list(
            )

            return sorted_uniques