def itest_dfpt_anaddb_ph(self, lp, fworker, tmpdir, input_scf_phonon_gan_low, db_data): """ Simple test of DteFWWorkflow with autoparal True and False. Skips dte permutations. """ dfpt_inputs = dfpt_from_gsinput(input_scf_phonon_gan_low, ph_ngqpt=[2, 2, 2], do_ddk=True, do_dde=True, do_strain=True, do_dte=False, ddk_tol = {"tolwfr": 1.0e-16}, dde_tol = {"tolvrs": 1.0e-7}, strain_tol={"tolvrs": 1.0e-7}, ph_tol={"tolvrs": 1.0e-7}) wf = DfptFWWorkflow(input_scf_phonon_gan_low, ddk_inp = dfpt_inputs.filter_by_tags(DDK), dde_inp = dfpt_inputs.filter_by_tags(DDE), strain_inp=dfpt_inputs.filter_by_tags(STRAIN), ph_inp = dfpt_inputs.filter_by_tags(PH_Q_PERT), dte_inp = dfpt_inputs.filter_by_tags(DTE), nscf_inp=dfpt_inputs.filter_by_tags(NSCF),initialization_info={"kppa": 100}, autoparal=False) wf.add_anaddb_dfpt_fw(input_scf_phonon_gan_low.structure, ph_ngqpt=[2, 2, 2], nqsmall=2, ndivsm=3) wf.add_mongoengine_db_insertion(db_data) wf.add_final_cleanup(["WFK"]) scf_fw_id = wf.scf_fw.fw_id old_new = wf.add_to_db(lpad=lp) scf_fw_id = old_new[scf_fw_id] rapidfire(lp, fworker, m_dir=str(tmpdir)) wf = lp.get_wf_by_fw_id(scf_fw_id) assert wf.state == "COMPLETED" scf_task = load_abitask(get_fw_by_task_index(wf, "scf", index=1)) # check the save in the DB from abiflows.database.mongoengine.abinit_results import DfptResult with db_data.switch_collection(DfptResult) as DteResult: results = DteResult.objects() assert len(results) == 1 r = results[0] assert r.abinit_input.structure.to_mgobj() == input_scf_phonon_gan_low.structure assert r.abinit_output.structure.to_mgobj() == input_scf_phonon_gan_low.structure assert r.abinit_input.ecut == input_scf_phonon_gan_low['ecut'] assert r.abinit_input.kppa == 100 nptu.assert_array_equal(r.abinit_input.gs_input.to_mgobj()['ngkpt'], input_scf_phonon_gan_low['ngkpt']) ana_task = load_abitask(get_fw_by_task_index(wf, "anaddb", index=None)) with tempfile.NamedTemporaryFile(mode="wb") as db_file: db_file.write(r.abinit_output.anaddb_nc.read()) db_file.seek(0) assert filecmp.cmp(ana_task.anaddb_nc_path, db_file.name) mrgddb_task = load_abitask(get_fw_by_task_index(wf, "mrgddb", index=None)) with tempfile.NamedTemporaryFile(mode="wb") as db_file: db_file.write(r.abinit_output.ddb.read()) db_file.seek(0) assert filecmp.cmp(mrgddb_task.merged_ddb_path, db_file.name) if self.check_numerical_values: with scf_task.open_gsr() as gsr: assert gsr.energy == pytest.approx(-680.402255069, rel=0.005) ana_task = load_abitask(get_fw_by_task_index(wf, "anaddb", index=None)) with ana_task.open_anaddbnc() as ananc: assert float(ananc.eps0[0,0]) == pytest.approx(64.8276774889143, rel=0.15) e = ananc.elastic_data if has_abinit("8.9.3"): assert float(e.elastic_relaxed[0,0,0,0]) == pytest.approx(41.230540749230556, rel=0.15)
""" Integration tests for flows (require pytest, ABINIT and a properly configured environment) """ from __future__ import print_function, division, unicode_literals import pytest import abipy.data as abidata import abipy.abilab as abilab from abipy.core.testing import has_abinit from pymatgen.io.abinitio.calculations import bandstructure # Tests in this module require abinit >= 7.9.0 pytestmark = pytest.mark.skipif(not has_abinit("7.9.0"), reason="Requires abinit >= 7.9.0") def make_scf_nscf_inputs(tvars, pp_paths, nstep=50): """ Returns two input files: GS run and NSCF on a high symmetry k-mesh """ inp = abilab.AbiInput(pseudos=abidata.pseudos(pp_paths), ndtset=2) structure = inp.set_structure_from_file(abidata.cif_file("si.cif")) nval = structure.num_valence_electrons(inp.pseudos) assert nval == 8 # Global variables ecut = 4 global_vars = dict(ecut=ecut, nband=int(nval/2), nstep=nstep,
from __future__ import print_function, division, unicode_literals import pytest import abipy.data as abidata import abipy.abilab as abilab from abipy.core.testing import has_abinit has_pseudodojo = True try: import pseudo_dojo except ImportError: has_pseudodojo = False # Tests in this module require abinit >= 7.9.0 and pseudodojo. pytestmark = pytest.mark.skipif(not has_abinit("7.9.0") or not has_pseudodojo, reason="Requires abinit >= 7.9.0 and pseudodojo") def itest_deltafactor(fwp, tvars): """Test the flow used for the computation of the deltafactor.""" # Path of the pseudopotential to test. pseudo = abidata.pseudo("Si.GGA_PBE-JTH-paw.xml") flow = abilab.AbinitFlow(workdir=fwp.workdir, manager=fwp.manager) # Build the workflow for the computation of the deltafactor. # The workflow will produce a pdf file with the equation of state # and a file deltafactor.txt with the final results in the # outdir directory DELTAFACTOR/work_0/outdir.