def test_alas_ddb_444_nobecs(self): """Testing DDB for AlAs on a 4x4x4x q-mesh without Born effective charges.""" ddb = DdbFile(os.path.join(test_dir, "AlAs_444_nobecs_DDB")) print(ddb) print(ddb.header) ref_qpoints = np.reshape([ 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 0.00000000E+00, 0.00000000E+00, 5.00000000E-01, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 2.50000000E-01, 0.00000000E+00, -2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 5.00000000E-01, 0.00000000E+00, -2.50000000E-01, 5.00000000E-01, 2.50000000E-01, ], (-1, 3)) assert len(ddb.qpoints) == 8 for qpt, ref_qpt in zip(ddb.qpoints, ref_qpoints): assert qpt == ref_qpt for qpoint in ddb.qpoints: phbands = ddb.anaget_phmodes_at_qpoint(qpoint=qpoint) assert phbands is not None and hasattr(phbands, "phfreqs") assert np.all(ddb.guessed_ngqpt == [4, 4, 4]) # Get bands and Dos phbands_file, phdos_file = ddb.anaget_phbst_and_phdos_files() phbands, phdos = phbands_file.phbands, phdos_file.phdos if self.has_matplotlib(): phbands.plot_with_phdos(phdos, title="Phonon bands and DOS of %s" % phbands.structure.formula, show=False) # Thermodinamics in the Harmonic approximation harmo = phdos.get_harmonic_thermo(tstart=10, tstop=50) if self.has_matplotlib(): harmo.plot(show=False) self.assert_almost_equal(phdos.idos.values[-1], 3 * len(ddb.structure), decimal=1) phbands_file.close() phdos_file.close() c = ddb.anacompare_phdos(nqsmalls=[2, 4, 6], num_cpus=None) if self.has_matplotlib(): c.plotter.plot(show=False) ddb.close()
def test_alas_ddb_444_nobecs(self): """Testing DDB for AlAs on a 4x4x4x q-mesh without Born effective charges.""" ddb = DdbFile(os.path.join(test_dir, "AlAs_444_nobecs_DDB")) print(ddb) print(ddb.header) ref_qpoints = np.reshape([ 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 0.00000000E+00, 0.00000000E+00, 5.00000000E-01, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 2.50000000E-01, 0.00000000E+00, -2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 5.00000000E-01, 0.00000000E+00, -2.50000000E-01, 5.00000000E-01, 2.50000000E-01, ], (-1, 3)) assert len(ddb.qpoints) == 8 for qpt, ref_qpt in zip(ddb.qpoints, ref_qpoints): assert qpt == ref_qpt for qpoint in ddb.qpoints: phbands = ddb.anaget_phmodes_at_qpoint(qpoint=qpoint) assert phbands is not None and hasattr(phbands, "phfreqs") assert np.all(ddb.guessed_ngqpt == [4, 4, 4]) # Get bands and Dos phbands_file, phdos_file = ddb.anaget_phbst_and_phdos_files() phbands, phdos = phbands_file.phbands, phdos_file.phdos if have_matplotlib: phbands.plot_with_phdos(phdos, title="Phonon bands and DOS of %s" % phbands.structure.formula, show=False) # Thermodinamics in the Harmonic approximation harmo = phdos.get_harmonic_thermo(tstart=10, tstop=50) harmo.plot(show=False) self.assert_almost_equal(phdos.idos.values[-1], 3 * len(ddb.structure), decimal=1) phbands_file.close() phdos_file.close() c = ddb.anacompare_phdos(nqsmalls=[2, 4, 6], num_cpus=None) c.plotter.plot(show=False) ddb.close()
def test_alas_ddb_444_nobecs(self): """Testing DDB for AlAs on a 4x4x4x q-mesh without Born effective charges.""" ddb = DdbFile(os.path.join(test_dir, "AlAs_444_nobecs_DDB")) repr(ddb) str(ddb) assert str(ddb.header) assert ddb.to_string(verbose=2) assert ddb.header["nkpt"] == 256 assert ddb.header.nsym == 24 and ddb.header.ntypat == 2 self.assert_equal(ddb.header.znucl, [13, 33]) self.assert_equal(ddb.header.acell, [1, 1, 1]) self.assert_equal(ddb.header.ngfft, [10, 10, 10]) self.assert_equal(ddb.header.spinat, 0.0) #assert ddb.header.occ.shape = (ddb.header.nsppol, ddb.header.nkpt, ddb.header.nsppol) assert not ddb.has_qpoint([0.345, 0.456, 0.567]) assert ddb.has_qpoint([0, 0, 0]) for qpoint in ddb.qpoints: assert ddb.has_qpoint(qpoint) assert ddb.has_qpoint(qpoint.frac_coords) assert qpoint in ddb.computed_dynmat assert len(ddb.computed_dynmat[qpoint].index[0]) == 4 assert ddb.has_bec_terms(select="at_least_one") assert not ddb.has_bec_terms(select="all") assert not ddb.has_epsinf_terms() assert not ddb.has_lo_to_data() assert not ddb.has_internalstrain_terms() assert not ddb.has_piezoelectric_terms() assert not ddb.has_strain_terms() assert ddb.has_at_least_one_atomic_perturbation() ref_qpoints = np.reshape([ 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 0.00000000E+00, 0.00000000E+00, 5.00000000E-01, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 2.50000000E-01, 0.00000000E+00, -2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 5.00000000E-01, 0.00000000E+00, -2.50000000E-01, 5.00000000E-01, 2.50000000E-01, ], (-1, 3)) assert len(ddb.qpoints) == 8 for qpt, ref_qpt in zip(ddb.qpoints, ref_qpoints): assert qpt == ref_qpt for qpoint in ddb.qpoints: phbands = ddb.anaget_phmodes_at_qpoint(qpoint=qpoint, verbose=1) assert phbands is not None and hasattr(phbands, "phfreqs") assert np.all(ddb.guessed_ngqpt == [4, 4, 4]) # Get bands and Dos phbands_file, phdos_file = ddb.anaget_phbst_and_phdos_files(verbose=1) phbands, phdos = phbands_file.phbands, phdos_file.phdos assert ddb.view_phononwebsite(verbose=1, dryrun=True) == 0 if self.has_matplotlib(): assert phbands.plot_with_phdos(phdos, show=False, title="Phonon bands and DOS of %s" % phbands.structure.formula) assert phbands_file.plot_phbands(show=False) # Get epsinf and becs r = ddb.anaget_epsinf_and_becs(chneut=1, verbose=1) epsinf, becs = r.epsinf, r.becs assert np.all(becs.values == 0) repr(becs) str(becs) assert becs.to_string(verbose=2) self.assert_almost_equal(phdos.idos.values[-1], 3 * len(ddb.structure), decimal=1) phbands_file.close() phdos_file.close() # Test DOS computation via anaddb. c = ddb.anacompare_phdos(nqsmalls=[2, 3, 4], dipdip=0, num_cpus=1, verbose=2) assert c.phdoses and c.plotter is not None if self.has_matplotlib(): assert c.plotter.combiplot(show=False) # Use threads and gaussian DOS. c = ddb.anacompare_phdos(nqsmalls=[2, 3, 4], dos_method="gaussian", dipdip=0, asr=0, num_cpus=2, verbose=2) assert c.phdoses and c.plotter is not None # Execute anaddb to compute the interatomic force constants. ifc = ddb.anaget_ifc() str(ifc) repr(ifc) assert ifc.to_string(verbose=2) assert ifc.structure == ddb.structure assert ifc.number_of_atoms == len(ddb.structure) if self.has_matplotlib(): assert ifc.plot_longitudinal_ifc(show=False) assert ifc.plot_longitudinal_ifc_short_range(show=False) assert ifc.plot_longitudinal_ifc_ewald(show=False) # Test get_coarse. coarse_ddb = ddb.get_coarse([2, 2, 2]) # Check whether anaddb can read the coarse DDB. coarse_phbands_file, coarse_phdos_file = coarse_ddb.anaget_phbst_and_phdos_files( nqsmall=4, ndivsm=1, verbose=1) coarse_phbands_file.close() coarse_phdos_file.close() coarse_ddb.close() ddb.close()
def test_alas_ddb_444_nobecs(self): """Testing DDB for AlAs on a 4x4x4x q-mesh without Born effective charges.""" ddb = DdbFile(os.path.join(test_dir, "AlAs_444_nobecs_DDB")) print(ddb) print(ddb.header) ref_qpoints = np.reshape([ 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 0.00000000E+00, 0.00000000E+00, 5.00000000E-01, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 2.50000000E-01, 0.00000000E+00, -2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 5.00000000E-01, 0.00000000E+00, -2.50000000E-01, 5.00000000E-01, 2.50000000E-01, ], (-1, 3)) assert len(ddb.qpoints) == 8 for qpt, ref_qpt in zip(ddb.qpoints, ref_qpoints): assert qpt == ref_qpt for qpoint in ddb.qpoints: phbands = ddb.anaget_phmodes_at_qpoint(qpoint=qpoint, verbose=1) assert phbands is not None and hasattr(phbands, "phfreqs") assert np.all(ddb.guessed_ngqpt == [4, 4, 4]) # Get bands and Dos phbands_file, phdos_file = ddb.anaget_phbst_and_phdos_files(verbose=1) phbands, phdos = phbands_file.phbands, phdos_file.phdos if self.has_matplotlib(): phbands.plot_with_phdos(phdos, title="Phonon bands and DOS of %s" % phbands.structure.formula, show=False) # Get emacro and becs emacro, becs = ddb.anaget_emacro_and_becs(chneut=1, verbose=1) assert np.all(becs.values == 0) assert np.all(becs.becs == 0) print(becs) self.assert_almost_equal(phdos.idos.values[-1], 3 * len(ddb.structure), decimal=1) phbands_file.close() phdos_file.close() # Test DOS computation via anaddb. c = ddb.anacompare_phdos(nqsmalls=[2, 4, 6], num_cpus=None) if self.has_matplotlib(): c.plotter.plot(show=False) # Execute anaddb to compute the interatomic forces. ifc = ddb.anaget_ifc() assert ifc.structure == ddb.structure assert ifc.number_of_atoms == len(ddb.structure) if self.has_matplotlib(): ifc.plot_longitudinal_ifc(show=False) ifc.plot_longitudinal_ifc_short_range(show=False) ifc.plot_longitudinal_ifc_ewald(show=False) ddb.close()
def test_alas_ddb_444_nobecs(self): """Testing DDB for AlAs on a 4x4x4x q-mesh without Born effective charges.""" ddb = DdbFile(os.path.join(test_dir, "AlAs_444_nobecs_DDB")) repr(ddb); str(ddb) assert str(ddb.header) assert ddb.to_string(verbose=2) assert ddb.header["nkpt"] == 256 assert ddb.header.nsym == 24 and ddb.header.ntypat == 2 self.assert_equal(ddb.header.znucl, [13, 33]) self.assert_equal(ddb.header.acell, [1, 1, 1]) self.assert_equal(ddb.header.ngfft, [10, 10, 10]) self.assert_equal(ddb.header.spinat, 0.0) #assert ddb.header.occ.shape = (ddb.header.nsppol, ddb.header.nkpt, ddb.header.nsppol) assert not ddb.has_qpoint([0.345, 0.456, 0.567]) assert ddb.has_qpoint([0, 0, 0]) for qpoint in ddb.qpoints: assert ddb.has_qpoint(qpoint) assert ddb.has_qpoint(qpoint.frac_coords) assert qpoint in ddb.computed_dynmat assert len(ddb.computed_dynmat[qpoint].index[0]) == 4 assert ddb.has_bec_terms(select="at_least_one") assert not ddb.has_bec_terms(select="all") assert not ddb.has_epsinf_terms() assert not ddb.has_lo_to_data() assert not ddb.has_internalstrain_terms() assert not ddb.has_piezoelectric_terms() assert not ddb.has_strain_terms() assert ddb.has_at_least_one_atomic_perturbation() ref_qpoints = np.reshape([ 0.00000000E+00, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 0.00000000E+00, 0.00000000E+00, 5.00000000E-01, 0.00000000E+00, 0.00000000E+00, 2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 2.50000000E-01, 0.00000000E+00, -2.50000000E-01, 2.50000000E-01, 0.00000000E+00, 5.00000000E-01, 5.00000000E-01, 0.00000000E+00, -2.50000000E-01, 5.00000000E-01, 2.50000000E-01, ], (-1, 3)) assert len(ddb.qpoints) == 8 for qpt, ref_qpt in zip(ddb.qpoints, ref_qpoints): assert qpt == ref_qpt for qpoint in ddb.qpoints: phbands = ddb.anaget_phmodes_at_qpoint(qpoint=qpoint, verbose=1) assert phbands is not None and hasattr(phbands, "phfreqs") assert np.all(ddb.guessed_ngqpt == [4, 4, 4]) # Get bands and Dos phbands_file, phdos_file = ddb.anaget_phbst_and_phdos_files(verbose=1) phbands, phdos = phbands_file.phbands, phdos_file.phdos assert ddb.view_phononwebsite(verbose=1, dryrun=True) == 0 if self.has_matplotlib(): assert phbands.plot_with_phdos(phdos, show=False, title="Phonon bands and DOS of %s" % phbands.structure.formula) assert phbands_file.plot_phbands(show=False) # Get emacro and becs emacro, becs = ddb.anaget_emacro_and_becs(chneut=1, verbose=1) assert np.all(becs.values == 0) #assert np.all(emacro.values == 0) repr(becs); str(becs) assert becs.to_string(verbose=2) self.assert_almost_equal(phdos.idos.values[-1], 3 * len(ddb.structure), decimal=1) phbands_file.close() phdos_file.close() # Test DOS computation via anaddb. c = ddb.anacompare_phdos(nqsmalls=[2, 3, 4], dipdip=0, num_cpus=1, verbose=2) assert c.phdoses and c.plotter is not None if self.has_matplotlib(): assert c.plotter.combiplot(show=False) # Use threads and gaussian DOS. c = ddb.anacompare_phdos(nqsmalls=[2, 3, 4], dos_method="gaussian", dipdip=0, asr=0, num_cpus=2, verbose=2) assert c.phdoses and c.plotter is not None # Execute anaddb to compute the interatomic forces. ifc = ddb.anaget_ifc() str(ifc); repr(ifc) #assert ifc.to_string(verbose=2) assert ifc.structure == ddb.structure assert ifc.number_of_atoms == len(ddb.structure) if self.has_matplotlib(): assert ifc.plot_longitudinal_ifc(show=False) assert ifc.plot_longitudinal_ifc_short_range(show=False) assert ifc.plot_longitudinal_ifc_ewald(show=False) ddb.close()