def setUpClass(cls, *args, **kwargs): super(TestUpfParser, cls).setUpClass(*args, **kwargs) filepath_base = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, os.pardir, 'fixtures', 'pseudos')) filepath_barium = os.path.join(filepath_base, 'Ba.pbesol-spn-rrkjus_psl.0.2.3-tot-pslib030.UPF') filepath_oxygen = os.path.join(filepath_base, 'O.pbesol-n-rrkjus_psl.0.1-tested-pslib030.UPF') filepath_carbon = os.path.join(filepath_base, 'C_pbe_v1.2.uspp.F.UPF') cls.pseudo_barium = orm.UpfData(file=filepath_barium).store() cls.pseudo_oxygen = orm.UpfData(file=filepath_oxygen).store() cls.pseudo_carbon = orm.UpfData(file=filepath_carbon).store()
def setUpClass(cls, *args, **kwargs): super().setUpClass(*args, **kwargs) filepath_base = os.path.abspath(os.path.join(STATIC_DIR, 'pseudos')) cls.filepath_barium = os.path.join( filepath_base, 'Ba.pbesol-spn-rrkjus_psl.0.2.3-tot-pslib030.UPF') cls.filepath_oxygen = os.path.join( filepath_base, 'O.pbesol-n-rrkjus_psl.0.1-tested-pslib030.UPF') cls.filepath_carbon = os.path.join(filepath_base, 'C_pbe_v1.2.uspp.F.UPF') cls.pseudo_barium = orm.UpfData(file=cls.filepath_barium).store() cls.pseudo_oxygen = orm.UpfData(file=cls.filepath_oxygen).store() cls.pseudo_carbon = orm.UpfData(file=cls.filepath_carbon).store()
def test_constructor(self): """Tests for the constructor of `UpfData`.""" filename = 'C.some_custom_filename.upf' upf = orm.UpfData(file=self.filepath_carbon, filename=filename) self.assertEqual(upf.filename, filename) # Store and check that the filename is unchanged upf.store() self.assertEqual(upf.filename, filename)
def test_cif_structure_roundtrip(self): from aiida.tools.dbexporters.tcod import export_cif, export_values from aiida.common.folders import SandboxFolder import tempfile with tempfile.NamedTemporaryFile(mode='w+') as tmpf: tmpf.write(''' data_test _cell_length_a 10 _cell_length_b 10 _cell_length_c 10 _cell_angle_alpha 90 _cell_angle_beta 90 _cell_angle_gamma 90 loop_ _atom_site_label _atom_site_fract_x _atom_site_fract_y _atom_site_fract_z C 0 0 0 O 0.5 0.5 0.5 ''') tmpf.flush() a = orm.CifData(filepath=tmpf.name) c = a.get_structure() c.store() pd = orm.Dict() code = orm.Code(local_executable='test.sh') with tempfile.NamedTemporaryFile(mode='w+') as tmpf: tmpf.write("#/bin/bash\n\necho test run\n") tmpf.flush() code.put_object_from_filelike(tmpf, 'test.sh') code.store() calc = orm.CalcJobNode(computer=self.computer) calc.set_option('resources', { 'num_machines': 1, 'num_mpiprocs_per_machine': 1 }) calc.add_incoming(code, LinkType.INPUT_CALC, "code") calc.set_option('environment_variables', { 'PATH': '/dev/null', 'USER': '******' }) with tempfile.NamedTemporaryFile(mode='w+', prefix="Fe") as tmpf: tmpf.write("<UPF version=\"2.0.1\">\nelement=\"Fe\"\n") tmpf.flush() upf = orm.UpfData(filepath=tmpf.name) upf.store() calc.add_incoming(upf, LinkType.INPUT_CALC, "upf") with tempfile.NamedTemporaryFile(mode='w+') as tmpf: tmpf.write("data_test") tmpf.flush() cif = orm.CifData(filepath=tmpf.name) cif.store() calc.add_incoming(cif, LinkType.INPUT_CALC, "cif") with SandboxFolder() as fhandle: calc.put_object_from_tree(fhandle.abspath) calc.store() fd = orm.FolderData() with fd.open('_scheduler-stdout.txt', 'w') as fhandle: fhandle.write(u"standard output") with fd.open('_scheduler-stderr.txt', 'w') as fhandle: fhandle.write(u"standard error") fd.store() fd.add_incoming(calc, LinkType.CREATE, calc.link_label_retrieved) pd.add_incoming(calc, LinkType.CREATE, "create1") pd.store() with self.assertRaises(ValueError): export_cif(c, parameters=pd) c.add_incoming(calc, LinkType.CREATE, "create2") export_cif(c, parameters=pd) values = export_values(c, parameters=pd) values = values['0'] self.assertEquals(values['_tcod_computation_environment'], ['PATH=/dev/null\nUSER=unknown']) self.assertEquals(values['_tcod_computation_command'], ['cd 1; ./_aiidasubmit.sh'])
def create_builder(): builder = OptimizeFirstPrinciplesTightBinding.get_builder() # Add the input structure builder.structure = orm.StructureData() builder.structure.set_ase(read_vasp('inputs/POSCAR')) # Specify that QuantumEspressoFirstPrinciplesRun should be used to run the first-principles calculations builder.fp_run_workflow = QuantumEspressoFirstPrinciplesRun # Set the inputs for the QuantumEspressoFirstPrinciplesRun workflow common_qe_parameters = orm.Dict( dict=dict( CONTROL=dict(etot_conv_thr=1e-3), SYSTEM=dict(noncolin=True, lspinorb=True, nbnd=36, ecutwfc=30), ) ) pseudo_dir = pathlib.Path(__file__ ).parent.absolute() / 'inputs' / 'pseudos' pseudos = { 'In': orm.UpfData( file=str(pseudo_dir / 'In.rel-pbe-dn-kjpaw_psl.1.0.0.UPF') ), 'Sb': orm.UpfData(file=str(pseudo_dir / 'Sb.rel-pbe-n-kjpaw_psl.1.0.0.UPF')) } # We use the same general Quantum ESPRESSO parameters for the # scf, nscf, and bands calculations. The calculation type and # k-points will be set by the workflow. repeated_pw_inputs = { 'pseudos': pseudos, 'parameters': common_qe_parameters, 'metadata': METADATA_PW, 'code': CODE_PW } builder.fp_run = { 'scf': repeated_pw_inputs, 'bands': { 'pw': repeated_pw_inputs }, 'to_wannier': { 'nscf': repeated_pw_inputs, 'pw2wannier': { 'code': CODE_PW2WANNIER, 'metadata': METADATA_PW2WANNIER }, 'wannier': { 'code': CODE_WANNIER, 'metadata': METADATA_WANNIER } } } # Setting the k-points for the reference bandstructure kpoints_list = [] kvals = np.linspace(0, 0.5, 20, endpoint=False) kvals_rev = np.linspace(0.5, 0, 20, endpoint=False) for k in kvals_rev: kpoints_list.append((k, k, 0)) # Z to Gamma for k in kvals: kpoints_list.append((0, k, k)) # Gamma to X for k in kvals: kpoints_list.append((k, 0.5, 0.5)) # X to L for k in kvals_rev: kpoints_list.append((k, k, k)) # L to Gamma for k in np.linspace(0, 0.375, 21, endpoint=True): kpoints_list.append((k, k, 2 * k)) # Gamma to K builder.kpoints = orm.KpointsData() builder.kpoints.set_kpoints( kpoints_list, labels=[(i * 20, label) for i, label in enumerate(['Z', 'G', 'X', 'L', 'G', 'K'])] ) # Setting the k-points mesh used to run the SCF and Wannier calculations builder.kpoints_mesh = orm.KpointsData() builder.kpoints_mesh.set_kpoints_mesh([6, 6, 6]) builder.wannier.code = CODE_WANNIER builder.code_tbmodels = orm.Code.get_from_string('tbmodels') # Setting the workflow to evaluate the tight-binding models builder.model_evaluation_workflow = BandDifferenceModelEvaluation # Setting the additional inputs for the model evaluation workflow builder.model_evaluation = dict( code_bands_inspect=orm.Code.get_from_string('bands_inspect') ) # Set the initial energy window value builder.initial_window = orm.List(list=[-1, 3, 10, 18]) # Tolerance for the energy window. builder.window_tol = orm.Float(1.5) # Tolerance for the 'cost_value'. builder.cost_tol = orm.Float(0.3) # The tolerances are set higher than might be appropriate for a 'production' # run to make the example run more quickly. # Setting the parameters for Wannier90 builder.wannier_parameters = orm.Dict( dict=dict( num_wann=14, num_bands=36, dis_num_iter=100, num_iter=0, spinors=True, # exclude_bands=range(1, ) ) ) # Choose the Wannier90 trial orbitals builder.wannier_projections = orm.List( list=['In : s; pz; px; py', 'Sb : pz; px; py'] ) # Set the resource requirements for the Wannier90 run builder.wannier.metadata = METADATA_WANNIER # Set the symmetry file builder.symmetries = orm.SinglefileData( file=os.path.abspath('inputs/symmetries.hdf5') ) # Pick the relevant bands from the reference calculation builder.slice_reference_bands = orm.List(list=list(range(12, 26))) return builder