def setup_kpoints(self): """ Define the k-point mesh for the relax and scf calculations. Also get the k-point path for the bands calculation for the initial input structure from SeeKpath """ kpoints_mesh = KpointsData() kpoints_mesh.set_cell_from_structure(self.inputs.structure) kpoints_mesh.set_kpoints_mesh_from_density( distance=self.ctx.protocol['kpoints_mesh_density'], offset=self.ctx.protocol['kpoints_mesh_offset']) self.ctx.kpoints_mesh = kpoints_mesh
def setup_kpoints(self): """ Define the k-point mesh for the relax and scf calculations. """ kpoints_mesh = KpointsData() kpoints_mesh.set_cell_from_structure(self.ctx.structure_initial_primitive) kpoints_mesh.set_kpoints_mesh_from_density( distance=self.ctx.protocol['kpoints_mesh_density'], offset=self.ctx.protocol['kpoints_mesh_offset'] ) self.ctx.kpoints_mesh = kpoints_mesh
def create_kpoints_from_distance(structure, distance, force_parity): """ Generate a uniformly spaced kpoint mesh for a given structure where the spacing between kpoints in reciprocal space is guaranteed to be at least the defined distance. :param structure: the StructureData to which the mesh should apply :param distance: a Float with the desired distance between kpoints in reciprocal space :param force_parity: a Bool to specify whether the generated mesh should maintain parity :returns: a KpointsData with the generated mesh """ from aiida.orm.data.array.kpoints import KpointsData kpoints = KpointsData() kpoints.set_cell_from_structure(structure) kpoints.set_kpoints_mesh_from_density(distance.value, force_parity=force_parity.value) return kpoints
def run_bands(self): """ Run the SiestaBaseWorkChain in scf+bands mode on the primitive cell of the relaxed input structure """ self.report('Running bands calculation') try: structure = self.ctx.workchain_relax.out.output_structure except: self.abort_nowait('failed to get the output structure from the relaxation run') return self.ctx.structure_relaxed_primitive = structure inputs = dict(self.ctx.inputs) kpoints_mesh = KpointsData() kpoints_mesh.set_cell_from_structure(self.ctx.structure_relaxed_primitive) kpoints_mesh.set_kpoints_mesh_from_density( distance=self.ctx.protocol['kpoints_mesh_density'], offset=self.ctx.protocol['kpoints_mesh_offset']) bandskpoints = KpointsData() bandskpoints.set_cell(structure.cell, structure.pbc) bandskpoints.set_kpoints_path(kpoint_distance = 0.05) self.ctx.kpoints_path = bandskpoints # Final input preparation, wrapping dictionaries in ParameterData nodes inputs['bandskpoints'] = self.ctx.kpoints_path inputs['kpoints'] = kpoints_mesh inputs['structure'] = self.ctx.structure_relaxed_primitive inputs['parameters'] = ParameterData(dict=inputs['parameters']) inputs['basis'] = ParameterData(dict=inputs['basis']) inputs['settings'] = ParameterData(dict=inputs['settings']) running = submit(SiestaBaseWorkChain, **inputs) self.report('launching SiestaBaseWorkChain<{}> in scf+bands mode'.format(running.pid)) return ToContext(workchain_bands=running)
def run_seekpath(self): """ Run the relaxed structure through SeeKPath to get the new primitive structure, just in case the symmetry of the cell changed in the cell relaxation step """ if 'workchain_relax' not in self.ctx: structure = self.inputs.structure else: try: structure = self.ctx.workchain_relax.out.output_structure except: self.abort_nowait( 'the relax workchain did not output an output_structure node' ) return seekpath_parameters = ParameterData( dict={ 'reference_distance': self.inputs.kpoints_distance_bands.value }) result = seekpath_structure_analysis(structure, seekpath_parameters) self.ctx.structure = result['primitive_structure'] # Construct a new kpoint mesh for the scf calculation on the current primitive structure kpoints_mesh = KpointsData() kpoints_mesh.set_cell_from_structure(self.ctx.structure) kpoints_mesh.set_kpoints_mesh_from_density( self.inputs.kpoints_distance.value) # Save the kpoints objects for the scf and bands calculation in the context self.ctx.kpoints_mesh = kpoints_mesh self.ctx.kpoints_path = result['explicit_kpoints'] self.out('primitive_structure', result['primitive_structure']) self.out('seekpath_parameters', result['parameters'])