def test_vasp_hybrid_bands( configure_with_daemon, # pylint: disable=unused-argument assert_finished, wait_for, get_insb_input # pylint: disable=redefined-outer-name ): """ Runs the VASP + hybrids reference bands workflow with InSb, on a very coarse grid. """ from aiida.orm import Bool from aiida.plugins import DataFactory, load_node from aiida.engine import submit from aiida_tbextraction.fp_run.reference_bands import VaspReferenceBands KpointsData = orm.KpointsData kpoints_mesh = KpointsData() kpoints_mesh.set_kpoints_mesh([2, 2, 2]) kpoints = KpointsData() kpoints.set_kpoints_path([('G', (0, 0, 0), 'M', (0.5, 0.5, 0.5))]) pk = submit(VaspReferenceBands, merge_kpoints=Bool(True), kpoints=kpoints, kpoints_mesh=kpoints_mesh, **get_insb_input).pk wait_for(pk) assert_finished(pk) result = load_node(pk).get_outputs_dict() assert 'bands' in result assert (result['bands'].get_bands().shape == (len(kpoints.get_kpoints()), 36))
def create_unit_cell_expansions(self): print('start Gruneisen (pk={})'.format(self.pid)) print('start create cell expansions') # For testing testing = False if testing: self.ctx._content['plus'] = load_node(13603) self.ctx._content['origin'] = load_node(13600) self.ctx._content['minus'] = load_node(13606) return calcs = {} for expansions in { 'plus': float(self.inputs.pressure) + float(self.inputs.stress_displacement), 'origin': float(self.inputs.pressure), 'minus': float(self.inputs.pressure) - float(self.inputs.stress_displacement) }.items(): future = submit(PhononPhonopy, structure=self.inputs.structure, ph_settings=self.inputs.ph_settings, es_settings=self.inputs.es_settings, pressure=Float(expansions[1]), optimize=Bool(True), use_nac=self.inputs.use_nac) calcs[expansions[0]] = future print('phonon workchain: {} {}'.format(expansions[0], future.pid)) return ToContext(**calcs)
def optimize(self): print('start optimize') future = submit( OptimizeStructure, structure=self.inputs.structure, es_settings=self.inputs.es_settings, pressure=self.inputs.pressure, ) if __testing__: self.ctx._content['optimize'] = load_node(9357) return print('optimize workchain: {}'.format(future.pid)) return ToContext(optimized=future)
def get_recover_calc(wc, label): if type(wc) is Bool: return None try: pk_list = wc.out.calcs_pk except: pk_list = [] out_list = [load_node(pk) for pk in pk_list] for calc in wc.get_outputs() + out_list: if calc.label == label: if calc.get_state() == 'FINISHED': return calc return None
def harmonic_calculation(self): print('start thermal conductivity (pk={})'.format(self.pid)) if __testing__: self.ctx._content['harmonic'] = load_node(83559) return self.report('Harmonic calculation') future = submit(PhononPhonopy, structure=self.inputs.structure, ph_settings=self.inputs.ph_settings, es_settings=self.inputs.es_settings, pressure=self.inputs.pressure, optimize=self.inputs.optimize, use_nac=self.inputs.use_nac) return ToContext(harmonic=future)
def create_grid_points(self): print('start phono3py distributed (pk={})'.format(self.pid)) if 'nac' in self.inputs: nac_data = self.ctx.inputs.nac else: nac_data = None if __testing__: self.ctx._content['gp_0'] = load_node(85570) self.ctx._content['gp_1'] = load_node(85572) self.ctx._content['gp_2'] = load_node(85574) self.ctx._content['gp_3'] = load_node(85576) self.ctx._content['gp_4'] = load_node(85578) self.ctx._content['gp_5'] = load_node(85580) self.ctx.labels = [0, 1, 2, 3, 4, 5] return grid_points = get_grid_points(self.inputs.structure, self.inputs.parameters) def chunks(l, m): n = len(l) / m for i in range(0, len(l), n): yield l[i:i + n] calcs = {} self.ctx.labels = [] for label, gp_range in enumerate( chunks(grid_points, int(self.inputs.gp_chunks))): JobCalculation, calculation_input = generate_phono3py_params( structure=self.inputs.structure, parameters=self.inputs.parameters, force_sets=self.inputs.force_sets, nac_data=nac_data, grid_point=gp_range) future = submit(JobCalculation, **calculation_input) print('gp_{} pk = {}'.format(label, future.pid)) calcs['gp_{}'.format(label)] = future self.ctx.labels.append(label) return ToContext(**calcs)
computer = Computer.objects.get(computer_name) JobCalc = FleurinputgenCalculation.process() attrs = { 'max_wallclock_seconds': 180, 'resources': { 'num_machines': 1 }, 'withmpi': False, #'computer': computer } inp = {'structure': s, 'parameters': parameters, 'code': code} f = run(JobCalc, _options=attrs, **inp) fleurinp = f['fleurinpData'] fleurinpd = load_node(fleurinp.pk) # now run a Fleur calculation ontop of an inputgen calculation code = Code.get_from_string(codename2) JobCalc = FleurCalculation.process() attrs = {'max_wallclock_seconds': 180, 'resources': {'num_machines': 1}} inp1 = {'code': code, 'fleurinpdata': fleurinpd} #'parent' : parent_calc, f1 = run(JobCalc, _options=attrs, **inp1) ''' # You can also run Fleur from a Fleur calculation and apply some changes to the input file. #parent_id = JobCalc.pk #parentcalc = FleurCalculation.get_subclass_from_pk(parent_id) fleurinp = f1['fleurinpData'] fleurinpd = load_node(fleurinp.pk).copy() fleurinpd.set_changes({'dos' : T})
def create_displacement_calculations(self): from aiida_phonopy.workflows.phonopy import get_primitive print('create displacements') self.report('create displacements') if 'optimized' in self.ctx: self.ctx.final_structure = self.ctx.optimized.out.optimized_structure self.out('optimized_data', self.ctx.optimized.out.optimized_structure_data) else: self.ctx.final_structure = self.inputs.structure self.ctx.primitive_structure = get_primitive( self.ctx.final_structure, self.inputs.ph_settings)['primitive_structure'] supercells = create_supercells_with_displacements_using_phono3py( self.ctx.final_structure, self.inputs.ph_settings, self.inputs.cutoff) self.ctx.data_sets = supercells.pop('data_sets') self.ctx.number_of_displacements = len(supercells) if __testing__: f = open('labels', 'r') lines = f.readlines() f.close() from aiida.orm import load_node nodes = [int(line.split()[3]) for line in lines] print(nodes) labels = [line.split()[0] for line in lines] print(labels) for pk, label in zip(nodes, labels): future = load_node(pk) self.ctx._content[label] = future print('{} pk = {}'.format(label, pk)) return calcs = {} for label, supercell in supercells.iteritems(): JobCalculation, calculation_input = generate_inputs( supercell, # self.inputs.machine, self.inputs.es_settings, # pressure=self.input.pressure, type='forces') calculation_input._label = label future = submit(JobCalculation, **calculation_input) print('{} pk = {}'.format(label, future.pid)) # self.report('{} pk = {}'.format(label, future.pid)) calcs[label] = future # Born charges (for primitive cell) if bool(self.inputs.use_nac): self.report('calculate born charges') JobCalculation, calculation_input = generate_inputs( self.ctx.primitive_structure, # self.inputs.machine, self.inputs.es_settings, # pressure=self.input.pressure, type='born_charges') future = submit(JobCalculation, **calculation_input) print('single_point: {}'.format(future.pid)) calcs['single_point'] = future return ToContext(**calcs)
'num_machines': 1, 'parallel_env': 'mpi*', 'tot_num_mpiprocs': 16 }, 'max_wallclock_seconds': 3600 * 10, } machine = Dict(dict=machine_dict) # PHONOPY settings ph_settings = Dict( dict={ 'supercell': [[2, 0, 0], [0, 2, 0], [0, 0, 2]], 'primitive': [[0.0, 0.5, 0.5], [0.5, 0.0, 0.5], [0.5, 0.5, 0.0]], 'distance': 0.01, 'mesh': [20, 20, 20], 'symmetry_tolerance': 1e-5, 'code': 'phono3py@stern_in', 'machine': machine_dict }) # Chose how to run the calculation result = run( Phono3pyDist, structure=structure, parameters=ph_settings, force_sets=load_node(81481), # load previous data gp_chunks=Int(8)) print(result)