-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
203 additions
and
48 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
"""Tests for varpeq module.""" | ||
import abipy.data as abidata | ||
|
||
from abipy.core.testing import AbipyTest | ||
from abipy.eph.gpath import GpathFile, GpathRobot | ||
|
||
|
||
class GpathTest(AbipyTest): | ||
|
||
def test_gpath_file_fixed_k(self): | ||
"""Testing GPATH.nc file with fixed k.""" | ||
with GpathFile(abidata.ref_file("teph4zpr_9o_DS1_GPATH.nc")) as gpath: | ||
# g(k,q) at fixed k along q-path. | ||
repr(gpath) | ||
str(gpath) | ||
assert gpath.to_string(verbose=2) | ||
assert not gpath.params | ||
assert gpath.structure.formula == "Mg1 O1" and len(gpath.structure) == 2 | ||
assert gpath.r.eph_fix_korq == "k" | ||
assert gpath.r.bstart == 5 and gpath.r.bstop == 8 | ||
assert gpath.r.nk_path == 1 | ||
assert gpath.r.nq_path == 42 | ||
assert len(gpath.ebands_k.kpoints) == 1 | ||
assert len(gpath.ebands_kq.kpoints) == 42 | ||
assert len(gpath.phbands.qpoints) == 42 | ||
self.assert_equal(gpath.r.eph_fix_wavec, (0, 0, 0)) | ||
|
||
if self.has_matplotlib(): | ||
assert gpath.plot_g_qpath(show=False) | ||
with self.assertRaises(ValueError): | ||
gpath.plot_g_kpath(show=False) | ||
|
||
# Test jupyter notebook creation | ||
if self.has_nbformat(): | ||
gpath.write_notebook(nbpath=self.get_tmpname(text=True)) | ||
|
||
def test_gpath_file_fixed_q(self): | ||
"""Testing GPATH.nc file with fixed q.""" | ||
with GpathFile(abidata.ref_file("teph4zpr_9o_DS2_GPATH.nc")) as gpath: | ||
# g(k,q) at fixed q along k-path. | ||
repr(gpath) | ||
str(gpath) | ||
assert gpath.to_string(verbose=2) | ||
assert not gpath.params | ||
assert gpath.structure.formula == "Mg1 O1" and len(gpath.structure) == 2 | ||
assert gpath.r.eph_fix_korq == "q" | ||
assert gpath.r.bstart == 5 and gpath.r.bstop == 8 | ||
assert gpath.r.nk_path == 42 | ||
assert gpath.r.nq_path == 1 | ||
assert len(gpath.ebands_k.kpoints) == 42 | ||
#assert len(gpath.ebands_kq.kpoints) == 1 | ||
assert len(gpath.phbands.qpoints) == 1 | ||
self.assert_equal(gpath.r.eph_fix_wavec, (0.11, 0, 0)) | ||
|
||
if self.has_matplotlib(): | ||
assert gpath.plot_g_kpath(show=False) | ||
with self.assertRaises(ValueError): | ||
gpath.plot_g_qpath(show=False) | ||
|
||
# Test jupyter notebook creation | ||
if self.has_nbformat(): | ||
gpath.write_notebook(nbpath=self.get_tmpname(text=True)) | ||
|
||
def test_gpath_robot(self): | ||
"""Testing GpathRobot.""" | ||
files = abidata.ref_files( | ||
"abinitio_qpath_V1QAVG.nc", | ||
"interpolated_qpath_V1QAVG.nc", | ||
) | ||
|
||
with GpathRobot() as robot: | ||
robot.add_file("one", abidata.ref_file("teph4zpr_9o_DS1_GPATH.nc")) | ||
robot.add_file("two", abidata.ref_file("teph4zpr_9o_DS1_GPATH.nc")) | ||
assert len(robot) == 2 | ||
repr(robot); str(robot) | ||
robot.to_string(verbose=2) | ||
|
||
# Test matplotlib methods | ||
if self.has_matplotlib(): | ||
assert robot.plot_g_qpath(show=False) | ||
|
||
# Test jupyter notebook creation | ||
if self.has_nbformat(): | ||
robot.write_notebook(nbpath=self.get_tmpname(text=True)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python | ||
r""" | ||
e-ph matrix along a path in the BZ | ||
================================== | ||
This example shows how to use the GPATH.nc file produced by ABINIT | ||
to plot e-ph matrix along a path in the BZ. | ||
""" | ||
import os | ||
import abipy.data as abidata | ||
|
||
from abipy.eph.gpath import GpathFile | ||
|
||
#%% | ||
# Here we use one of the GPATH files shipped with abipy | ||
# with the e-ph matrix g(k,q) with q along a path and k fixed. | ||
# Replace the call to abidata.ref_file("") with the path to your GPATH.nc | ||
|
||
gpath_q = GpathFile(abidata.ref_file("teph4zpr_9o_DS1_GPATH.nc")) | ||
print(gpath_q) | ||
|
||
#%% | ||
# To plot the e-ph matrix elements as a function of q. | ||
gpath_q.plot_g_qpath(band_range=None, | ||
which_g="avg", | ||
with_qexp=0, | ||
scale=1, | ||
gmax_mev=250, | ||
ph_modes=None, | ||
with_phbands=True, | ||
with_ebands=False, | ||
) | ||
|
||
#%% | ||
# For the meaning of the different arguments, see the docstring | ||
print(gpath_q.plot_g_qpath.__doc__) | ||
|
||
#%% | ||
# Here we read another file | ||
# with the e-ph matrix g(k,q) with k along a path and q fixed. | ||
|
||
gpath_k = GpathFile(abidata.ref_file("teph4zpr_9o_DS2_GPATH.nc")) | ||
print(gpath_k) | ||
|
||
#%% | ||
# To plot the e-ph matrix elements as a function of q. | ||
gpath_k.plot_g_kpath(band_range=None, | ||
which_g="avg", | ||
scale=1, | ||
gmax_mev=250, | ||
ph_modes=None, | ||
with_ebands=True, | ||
) | ||
|
||
#%% | ||
# For the meaning of the different arguments, see the docstring | ||
print(gpath_k.plot_g_kpath.__doc__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.