Skip to content

Commit

Permalink
Add AlN test
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Feb 22, 2021
1 parent 0eef874 commit 86cec59
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
9 changes: 5 additions & 4 deletions phono3py/cui/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,11 @@ def set_dataset_and_force_constants(
name='fc2')

# Cases that dataset is in phono3py.yaml but not forces.
if (ph3py_yaml is not None and ph3py_yaml.dataset is not None):
ph3py.dataset = ph3py_yaml.dataset
if (ph3py_yaml is not None and ph3py_yaml.phonon_dataset is not None):
ph3py.phonon_dataset = ph3py_yaml.phonon_dataset
if ph3py.dataset is None:
if (ph3py_yaml is not None and ph3py_yaml.dataset is not None):
ph3py.dataset = ph3py_yaml.dataset
if (ph3py_yaml is not None and ph3py_yaml.phonon_dataset is not None):
ph3py.phonon_dataset = ph3py_yaml.phonon_dataset

return read_fc

Expand Down
7 changes: 7 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,10 @@ def nacl_pbe():
yaml_filename = os.path.join(current_dir,
"phono3py_params_NaCl222.yaml.xz")
return phono3py.load(yaml_filename, log_level=1)


@pytest.fixture(scope='session')
def aln_lda():
yaml_filename = os.path.join(current_dir,
"phono3py_params_AlN332.yaml.xz")
return phono3py.load(yaml_filename, log_level=1)
Binary file added test/phono3py_params_AlN332.yaml.xz
Binary file not shown.
35 changes: 34 additions & 1 deletion test/phonon3/test_kappa_RTA.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
si_pbesol_kappa_RTA_with_sigmas = [109.6985, 109.6985, 109.6985, 0, 0, 0]
si_pbesol_kappa_RTA_iso = [96.92419, 96.92419, 96.92419, 0, 0, 0]
si_pbesol_kappa_RTA_with_sigmas_iso = [96.03248, 96.03248, 96.03248, 0, 0, 0]
nacl_pbe_kappa_RTA = [7.72798252, 7.72798252, 7.72798252, 0, 0, 0]
nacl_pbe_kappa_RTA_with_sigma = [7.71913708, 7.71913708, 7.71913708, 0, 0, 0]


aln_lda_kappa_RTA = [203.304059, 203.304059, 213.003125, 0, 0, 0]
aln_lda_kappa_RTA_with_sigmas = [213.820000, 213.820000, 224.800121, 0, 0, 0]

def test_kappa_RTA_si(si_pbesol):
kappa = _get_kappa(si_pbesol, [9, 9, 9]).ravel()
np.testing.assert_allclose(si_pbesol_kappa_RTA, kappa, atol=0.5)
Expand Down Expand Up @@ -50,10 +55,38 @@ def test_kappa_RTA_si_compact_fc(si_pbesol_compact_fc):
np.testing.assert_allclose(si_pbesol_kappa_RTA, kappa, atol=0.5)


def test_kappa_RTA_nacl(nacl_pbe):
kappa = _get_kappa(nacl_pbe, [9, 9, 9]).ravel()
np.testing.assert_allclose(nacl_pbe_kappa_RTA, kappa, atol=0.5)


def test_kappa_RTA_nacl_with_sigma(nacl_pbe):
nacl_pbe.sigmas = [0.1, ]
nacl_pbe.sigma_cutoff = 3
kappa = _get_kappa(nacl_pbe, [9, 9, 9]).ravel()
np.testing.assert_allclose(nacl_pbe_kappa_RTA_with_sigma, kappa, atol=0.5)
nacl_pbe.sigmas = None
nacl_pbe.sigma_cutoff = None


def test_kappa_RTA_aln(aln_lda):
kappa = _get_kappa(aln_lda, [7, 7, 5]).ravel()
np.testing.assert_allclose(aln_lda_kappa_RTA, kappa, atol=0.5)


def test_kappa_RTA_aln_with_sigma(aln_lda):
aln_lda.sigmas = [0.1, ]
aln_lda.sigma_cutoff = 3
kappa = _get_kappa(aln_lda, [7, 7, 5]).ravel()
np.testing.assert_allclose(aln_lda_kappa_RTA_with_sigmas, kappa, atol=0.5)
aln_lda.sigmas = None
aln_lda.sigma_cutoff = None


def _get_kappa(ph3, mesh, is_isotope=False, is_full_pp=False):
ph3.mesh_numbers = mesh
ph3.init_phph_interaction()
ph3.run_thermal_conductivity(temperatures=[300, ],
is_isotope=is_isotope,
is_full_pp=True)
is_full_pp=is_full_pp)
return ph3.thermal_conductivity.kappa

0 comments on commit 86cec59

Please sign in to comment.