Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set version 3.8.0 #303

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

# Change Log

## Nov-25-2024: Version 3.8.0

- Follow the change due to phonopy's refactoring of MLP interface.
- Experimental option (`BUILD_WITHOUT_LAPACKE=ON`) to compile phono3py without
LAPACKE in C

## Nov-13-2024: Version 3.7.0

- Update to follow the change of phonopy's internal functions
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
# built documents.
#
# The short X.Y version.
version = "3.7"
version = "3.8"
# The full version, including alpha/beta/rc tags.
release = "3.7.0"
release = "3.8.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
7 changes: 6 additions & 1 deletion doc/direct-solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ is used through them. Multithreaded OpenBLAS is installed by conda and can be
used via LAPACKE in phono3py. MKL LAPACK and BLAS are also able to be used via
LAPACKE in phono3py with appropriate setting in `setup.py`.

Using `--pinv-solver=[number]`, one of the following solver is chosen:
Using `--pinv-solver NUMBER`, one of the following solver is chosen:

1. Lapacke `dsyev`: Smaller memory consumption than `dsyevd`, but slower. This
is the default solver when MKL LAPACKE is integrated or scipy is not
Expand All @@ -323,3 +323,8 @@ Using `--pinv-solver=[number]`, one of the following solver is chosen:
LAPACKE is not integrated.
5. Scipy's `dsyevd`: Similar to solver (2), this solver should be used
carefully.

```{note}
`pinv-solver` =3, 4, and 5 are only available when phono3py is compiled
without LAPACKE.
```
17 changes: 16 additions & 1 deletion doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ conda environment. Automatic search of required libraries and flags that are
already on the system is performed by cmake.

(install_with_cmake)=
### Build with automatic search of library configurations by cmake
### Building with automatic search of library configurations by cmake

With installed cmake and required libraries on the system, cmake tries to find
libraries to be linked and the compiler flags that are required during the build.
Expand All @@ -61,6 +61,21 @@ See an example at {ref}`install_an_example`. In the standard output, flags and
libraries found by cmake are shown. Please carefully check if those
configurations are expected ones or not.

### Building without linking LAPACKE

**Experimental**

To compile phono3py without linking LAPACKE in C, use the following command:

```
% BUILD_WITHOUT_LAPACKE=ON pip install -e . -vvv
```

When this option is enabled, linking to BLAS and LAPACKE libraries is not
required, so installing these libraries for C compilation may not be necessary.
However, since numpy and scipy rely on BLAS and LAPACK libraries, their runtime
versions are still required.

(install_an_example)=

## Installation instruction of latest development version of phono3py
Expand Down
7 changes: 7 additions & 0 deletions phono3py/conductivity/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,13 @@ def select_colmat_solver(pinv_solver):
print("Phono3py C-routine is not compiled correctly.")
default_solver = 4

if not phono3c.include_lapacke():
if pinv_solver in (1, 2, 6):
raise RuntimeError(
"Use pinv-solver 3, 4, or 5 because "
"phono3py is not compiled with LAPACKE."
)

solver_numbers = (1, 2, 3, 4, 5, 6)

solver = pinv_solver
Expand Down
21 changes: 18 additions & 3 deletions phono3py/phonon/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ def run_phonon_solver_c(
):
"""Bulid and solve dynamical matrices on grid in C-API.

Note
----
When LAPACKE is linked in C, `phononcalc.phonons_at_gridpoints` constucts
and solves dynamical matrices on grid points. Otherwise, it only constructs
dynamical matrices and solves them in python.

Parameters
----------
dm : DynamicalMatrix
DynamicalMatrix instance.
frequencies, eigenvectors, phonon_done :
Expand All @@ -65,8 +73,8 @@ def run_phonon_solver_c(
QDinv : ndarray
See BZGrid.QDinv.
frequency_conversion_factor : float, optional
Frequency convertion factor that is multiplied with
sqrt or eigenvalue of dynamical matrix. Default is VaspToTHz.
Frequency convertion factor that is multiplied with sqrt or eigenvalue
of dynamical matrix. Default is VaspToTHz.
nac_q_direction : array_like, optional
See Interaction.nac_q_direction. Default is None.
lapack_zheev_uplo : str, optional
Expand Down Expand Up @@ -126,6 +134,9 @@ def run_phonon_solver_c(
assert lapack_zheev_uplo in ("L", "U")

if not phono3c.include_lapacke():
# phonon_done is set even with phono3c.include_lapacke() == 0 for which
# dynamical matrices are not diagonalized in
# phononcalc.phonons_at_gridpoints.
phonon_undone = np.where(phonon_done == 0)[0]

fc_p2s, fc_s2p = _get_fc_elements_mapping(dm, fc)
Expand Down Expand Up @@ -159,8 +170,12 @@ def run_phonon_solver_c(
)

if not phono3c.include_lapacke():
# The variable `eigenvectors` contains dynamical matrices.
# They are diagonalized in python as follows.
for gp in phonon_undone:
frequencies[gp], eigenvectors[gp] = np.linalg.eigh(eigenvectors[gp])
frequencies[gp], eigenvectors[gp] = np.linalg.eigh(
eigenvectors[gp], UPLO=lapack_zheev_uplo
)
frequencies[phonon_undone] = (
np.sign(frequencies[phonon_undone])
* np.sqrt(np.abs(frequencies[phonon_undone]))
Expand Down
2 changes: 1 addition & 1 deletion phono3py/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

__version__ = "3.7.0"
__version__ = "3.8.0"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies = [
"matplotlib>=2.2.2",
"h5py>=3.0",
"spglib>=2.3",
"phonopy>=2.30,<2.31",
"phonopy>=2.31,<2.32",
]
license = { file = "LICENSE" }

Expand Down
39 changes: 37 additions & 2 deletions test/conductivity/test_kappa_LBTE.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
"""Tests for direct solution of LBTE."""

import numpy as np
import pytest

import phono3py._phono3py as phono3c
from phono3py.api_phono3py import Phono3py


def test_kappa_LBTE(si_pbesol: Phono3py):
@pytest.mark.skipif(
not phono3c.include_lapacke(), reason="test for phono3py compliled with lapacke"
)
@pytest.mark.parametrize("pinv_solver", [1, 2])
def test_kappa_LBTE_12(si_pbesol: Phono3py, pinv_solver: int):
"""Test for symmetry reduced collision matrix."""
_test_kappa_LBTE(si_pbesol, pinv_solver)


@pytest.mark.parametrize("pinv_solver", [3, 4, 5])
def test_kappa_LBTE_345(si_pbesol: Phono3py, pinv_solver: int):
"""Test for symmetry reduced collision matrix."""
_test_kappa_LBTE(si_pbesol, pinv_solver)


def _test_kappa_LBTE(si_pbesol: Phono3py, pinv_solver: int):
if si_pbesol._make_r0_average:
ref_kappa = [110.896, 110.896, 110.896, 0, 0, 0]
else:
Expand All @@ -18,11 +34,30 @@ def test_kappa_LBTE(si_pbesol: Phono3py):
temperatures=[
300,
],
pinv_solver=pinv_solver,
)
kappa = si_pbesol.thermal_conductivity.kappa.ravel()
np.testing.assert_allclose(ref_kappa, kappa, atol=0.3)


@pytest.mark.skipif(
phono3c.include_lapacke(), reason="test for phono3py compliled without lapacke"
)
@pytest.mark.parametrize("pinv_solver", [1, 2])
def test_kappa_LBTE_witout_lapacke(si_pbesol: Phono3py, pinv_solver: int):
"""Test for symmetry reduced collision matrix."""
si_pbesol.mesh_numbers = [9, 9, 9]
si_pbesol.init_phph_interaction()
with pytest.raises(RuntimeError):
si_pbesol.run_thermal_conductivity(
is_LBTE=True,
temperatures=[
300,
],
pinv_solver=pinv_solver,
)


def test_kappa_LBTE_full_colmat(si_pbesol: Phono3py):
"""Test for full collision matrix."""
if si_pbesol._make_r0_average:
Expand All @@ -40,7 +75,7 @@ def test_kappa_LBTE_full_colmat(si_pbesol: Phono3py):
is_reducible_collision_matrix=True,
)
kappa = si_pbesol.thermal_conductivity.kappa.ravel()
np.testing.assert_allclose(ref_kappa, kappa, atol=0.3)
np.testing.assert_allclose(ref_kappa, kappa, atol=0.5)


def test_kappa_LBTE_aln(aln_lda: Phono3py):
Expand Down
Loading