Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Jan 18, 2025
2 parents 42c12a7 + f129c5a commit d4f1b0d
Show file tree
Hide file tree
Showing 22 changed files with 709 additions and 514 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: wheel-build-and-deploy

on:
push:
branches:
- make-wheel
- make-wheel-test

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest,]
# os: [ubuntu-latest, windows-latest, macos-13, macos-latest]


steps:
- uses: actions/checkout@v4

# Used to host cibuildwheel
- uses: actions/setup-python@v5

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.22.0

- name: Build wheels
run: |
git tag v`grep __version__ phono3py/version.py|awk -F'"' '{print($2)}'`
python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_SKIP: "cp39-* pp* *_i686 *musllinux*"
CIBW_BUILD_VERBOSITY: 1

# to supply options, put them in 'env', like:
# env:
# CIBW_SOME_OPTION: value

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

upload_pypi_test:
name: Upload to PyPI (test)
strategy:
matrix:
os: [ubuntu-latest,]
needs: [build_wheels,]
runs-on: ${{ matrix.os }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/make-wheel-test')
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-wheels-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip-existing: true

upload_pypi:
name: Upload to PyPI
strategy:
matrix:
os: [ubuntu-latest,]
needs: [build_wheels,]
runs-on: ${{ matrix.os }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/make-wheel')
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-wheels-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
exclude: ^example/AlN-LDA/

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.1
hooks:
- id: ruff
args: [ "--fix", "--show-fixes" ]
Expand Down
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ else()
endif()

if(BUILD_NANOBIND_MODULE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
project(${SKBUILD_PROJECT_NAME})
set(DEV_MODULE Development.Module)
find_package(
Expand Down Expand Up @@ -136,17 +137,17 @@ if(BUILD_RECGRID_LIB
OR BUILD_PHPHCALC_LIB
OR BUILD_NANOBIND_MODULE)
# Source code
set(SOURCES_PHPHCALC
set(SOURCES_RECGRID
${PROJECT_SOURCE_DIR}/c/bzgrid.c ${PROJECT_SOURCE_DIR}/c/grgrid.c
${PROJECT_SOURCE_DIR}/c/lagrid.c ${PROJECT_SOURCE_DIR}/c/snf3x3.c
${PROJECT_SOURCE_DIR}/c/recgrid.c)

if(BUILD_SHARED_LIBS)
# Shared library
add_library(recgrid_lib SHARED ${SOURCES_PHPHCALC})
add_library(recgrid_lib SHARED ${SOURCES_RECGRID})
else()
# Static link library
add_library(recgrid_lib STATIC ${SOURCES_PHPHCALC})
add_library(recgrid_lib STATIC ${SOURCES_RECGRID})
endif()

if(NOT BUILD_NANOBIND_MODULE)
Expand Down
4 changes: 4 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# Change Log

## Jan-18-2024: Version 3.11.2

- Maintenance release.

## Jan-12-2024: Version 3.11.1

- `-i`, `-o`, `--io` options have been deprecated.
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# The short X.Y version.
version = "3.11"
# The full version, including alpha/beta/rc tags.
release = "3.11.1"
release = "3.11.2"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
78 changes: 40 additions & 38 deletions doc/pypolymlp.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,16 @@ crystal symmetry.
Having `phono3py_params.yaml`, phono3py is executed with `--pypolymlp` option,

```
% phono3py-load --pypolymlp phono3py_params.yaml
% phono3py-load phono3py_params.yaml --pypolymlp -d
_ _____
_ __ | |__ ___ _ __ ___|___ / _ __ _ _
| '_ \| '_ \ / _ \| '_ \ / _ \ |_ \| '_ \| | | |
| |_) | | | | (_) | | | | (_) |__) | |_) | |_| |
| .__/|_| |_|\___/|_| |_|\___/____/| .__/ \__, |
|_| |_| |___/
3.5.0
3.11.2
-------------------------[time 2024-09-19 15:20:27]-------------------------
-------------------------[time 2025-01-15 16:25:17]-------------------------
Compiled with OpenMP support (max 10 threads).
Running in phono3py.load mode.
Python version 3.12.6
Expand All @@ -187,7 +187,6 @@ Primitive matrix:
Spacegroup: Fm-3m (225)
Use -v option to watch primitive cell, unit cell, and supercell structures.
NAC parameters were read from "phono3py_params.yaml".
----------------------------- Force constants ------------------------------
Displacement dataset for fc3 was read from "phono3py_params.yaml".
----------------------------- pypolymlp start ------------------------------
Pypolymlp is a generator of polynomial machine learning potentials.
Expand All @@ -204,16 +203,17 @@ Clear training X.T @ X
Calculate X.T @ X for test data
Clear test X.T @ X
Regression: model selection ...
- alpha = 1.000e-03 : rmse (train, test) = 9.39542e+14 9.39543e+14
- alpha = 1.000e-02 : rmse (train, test) = 9.39542e+14 9.39543e+14
- alpha = 1.000e-01 : rmse (train, test) = 0.03738 0.04961
- alpha = 1.000e+00 : rmse (train, test) = 0.03900 0.04742
- alpha = 1.000e+01 : rmse (train, test) = 0.04058 0.04584
- alpha = 1.000e-03 : rmse (train, test) = 1.12211e+15 1.12211e+15
- alpha = 1.000e-02 : rmse (train, test) = 1.12211e+15 1.12211e+15
- alpha = 1.000e-01 : rmse (train, test) = 0.00002 0.00002
- alpha = 1.000e+00 : rmse (train, test) = 0.00002 0.00002
- alpha = 1.000e+01 : rmse (train, test) = 0.00002 0.00002
MLPs were written into "phono3py.pmlp"
------------------------------ pypolymlp end -------------------------------
Generate displacements
Displacement distance: 0.001
Evaluate forces in 292 supercells by pypolymlp
----------------------------- Force constants ------------------------------
Computing fc3[ 1, x, x ] using numpy.linalg.pinv.
Displacements (in Angstrom):
[ 0.0010 0.0000 0.0000]
Expand All @@ -225,14 +225,14 @@ Displacements (in Angstrom):
Expanding fc3.
fc3 was symmetrized.
fc2 was symmetrized.
Max drift of fc3: -0.000000 (zzz) -0.000000 (zzz) -0.000000 (zzz)
Max drift of fc2: -0.000000 (zz) -0.000000 (zz)
Max drift of fc3: 0.000000 (xxx) 0.000000 (xxx) 0.000000 (xxx)
Max drift of fc2: 0.000000 (yy) 0.000000 (yy)
fc3 was written into "fc3.hdf5".
fc2 was written into "fc2.hdf5".
----------- None of ph-ph interaction calculation was performed. -----------
Dataset generated using MLPs was written in "phono3py_mlp_eval_dataset.yaml".
Summary of calculation was written in "phono3py.yaml".
-------------------------[time 2024-09-19 15:21:41]-------------------------
-------------------------[time 2025-01-15 16:26:37]-------------------------
_
___ _ __ __| |
/ _ \ '_ \ / _` |
Expand All @@ -257,24 +257,25 @@ corresponding forces are stored in the `phono3py_mlp_eval_dataset` file.
After developing MLPs, random displacements are generated by specifying
{ref}`--rd <random_displacements_option>` option. To compute force constants
with random displacements, an external force constants calculator is necessary.
For this, symfc is used which is invoked by `--symfc` option.
By default, symfc is used unless another force constants solver is explicitly
specified.

Having `phono3py_params.yaml`, phono3py is executed with `--pypolymlp` option,

```
% phono3py-load --pypolymlp --rd 200 --symfc phono3py_params.yaml
% phono3py-load --pypolymlp --rd 200 phono3py_params.yaml
_ _____
_ __ | |__ ___ _ __ ___|___ / _ __ _ _
| '_ \| '_ \ / _ \| '_ \ / _ \ |_ \| '_ \| | | |
| |_) | | | | (_) | | | | (_) |__) | |_) | |_| |
| .__/|_| |_|\___/|_| |_|\___/____/| .__/ \__, |
|_| |_| |___/
3.5.0
3.11.2
-------------------------[time 2024-09-19 15:33:23]-------------------------
-------------------------[time 2025-01-15 19:30:47]-------------------------
Compiled with OpenMP support (max 10 threads).
Running in phono3py.load mode.
Python version 3.12.6
Python version 3.12.3
Spglib version 2.5.0
----------------------------- General settings -----------------------------
HDF5 data compression filter: gzip
Expand All @@ -287,7 +288,6 @@ Primitive matrix:
Spacegroup: Fm-3m (225)
Use -v option to watch primitive cell, unit cell, and supercell structures.
NAC parameters were read from "phono3py_params.yaml".
----------------------------- Force constants ------------------------------
Displacement dataset for fc3 was read from "phono3py_params.yaml".
----------------------------- pypolymlp start ------------------------------
Pypolymlp is a generator of polynomial machine learning potentials.
Expand All @@ -304,39 +304,41 @@ Clear training X.T @ X
Calculate X.T @ X for test data
Clear test X.T @ X
Regression: model selection ...
- alpha = 1.000e-03 : rmse (train, test) = 9.39542e+14 9.39543e+14
- alpha = 1.000e-02 : rmse (train, test) = 9.39542e+14 9.39543e+14
- alpha = 1.000e-01 : rmse (train, test) = 0.03738 0.04961
- alpha = 1.000e+00 : rmse (train, test) = 0.03900 0.04742
- alpha = 1.000e+01 : rmse (train, test) = 0.04058 0.04584
- alpha = 1.000e-03 : rmse (train, test) = 1.12211e+15 1.12211e+15
- alpha = 1.000e-02 : rmse (train, test) = 1.12211e+15 1.12211e+15
- alpha = 1.000e-01 : rmse (train, test) = 0.00002 0.00002
- alpha = 1.000e+00 : rmse (train, test) = 0.00002 0.00002
- alpha = 1.000e+01 : rmse (train, test) = 0.00002 0.00002
MLPs were written into "phono3py.pmlp"
------------------------------ pypolymlp end -------------------------------
Generate random displacements
Twice of number of snapshots will be generated for plus-minus displacements.
Displacement distance: 0.001
Evaluate forces in 400 supercells by pypolymlp
----------------------------- Force constants ------------------------------
Symfc will be used to handle general (or random) displacements.
-------------------------------- Symfc start -------------------------------
Symfc is a non-trivial force constants calculator. Please cite the paper:
A. Seko and A. Togo, arXiv:2403.03588.
Symfc is a force constants calculator. See the following paper:
A. Seko and A. Togo, Phys. Rev. B, 110, 214302 (2024).
Symfc is developed at https://github.com/symfc/symfc.
Computing [2, 3] order force constants.
Increase log-level to watch detailed symfc log.
--------------------------------- Symfc end --------------------------------
-------------------------------- Symfc start -------------------------------
Symfc is a non-trivial force constants calculator. Please cite the paper:
A. Seko and A. Togo, arXiv:2403.03588.
Symfc is a force constants calculator. See the following paper:
A. Seko and A. Togo, Phys. Rev. B, 110, 214302 (2024).
Symfc is developed at https://github.com/symfc/symfc.
Computing [2] order force constants.
Increase log-level to watch detailed symfc log.
--------------------------------- Symfc end --------------------------------
Max drift of fc3: -0.000000 (xyx) 0.000000 (zyy) -0.000000 (xyx)
Max drift of fc2: 0.000000 (xx) 0.000000 (xx)
Max drift of fc3: -0.000000 (zxz) -0.000000 (xzz) -0.000000 (xzz)
Max drift of fc2: -0.000000 (yy) -0.000000 (yy)
fc3 was written into "fc3.hdf5".
fc2 was written into "fc2.hdf5".
----------- None of ph-ph interaction calculation was performed. -----------
Dataset generated using MLPs was written in "phono3py_mlp_eval_dataset.yaml".
Summary of calculation was written in "phono3py.yaml".
-------------------------[time 2024-09-19 15:34:41]-------------------------
-------------------------[time 2025-01-15 19:32:04]-------------------------
_
___ _ __ __| |
/ _ \ '_ \ / _` |
Expand All @@ -360,26 +362,25 @@ resulting forces are computed accordingly. The displacement distance is set by
the `--amplitude` option, whose default value is 0.001 Angstrom. When the `--rd`
option is used, it specifies the number of supercells with random directional
displacements. Note that to achieve accurate force constants, the actual number
of generated supercells is twice the specified number. Additionally, when using
`--rd`, the `--symfc` option must be used together. If `--rd` is omitted,
systematic displacements are introduced, and thus `--symfc` is not required.
of generated supercells is twice the specified number. If `--rd` is omitted,
systematic displacements are introduced.

Once the file `phono3py.pmlp` is obtained, force constants can be calculated
using MLPs from `phono3py.pmlp`. After removing the `fc3.hdf5` and `fc2.hdf5`
files, `phono3py-load` will detect `phono3py.pmlp` and then compute the force
constants by loading the MLPs from `phono3py.pmlp` as follows:

```
% phono3py-load --pypolymlp --rd 100 --symfc --amplitude 0.01 phono3py.yaml
% phono3py-load --pypolymlp --rd 100 --amplitude 0.01 phono3py.yaml
_ _____
_ __ | |__ ___ _ __ ___|___ / _ __ _ _
| '_ \| '_ \ / _ \| '_ \ / _ \ |_ \| '_ \| | | |
| |_) | | | | (_) | | | | (_) |__) | |_) | |_| |
| .__/|_| |_|\___/|_| |_|\___/____/| .__/ \__, |
|_| |_| |___/
3.11.1-dev14+g5f281b65
3.11.2
-------------------------[time 2025-01-12 10:08:31]-------------------------
-------------------------[time 2025-01-15 19:28:22]-------------------------
Compiled with OpenMP support (max 10 threads).
Running in phono3py.load mode.
Python version 3.12.3
Expand All @@ -395,7 +396,6 @@ Primitive matrix:
Spacegroup: Fm-3m (225)
Use -v option to watch primitive cell, unit cell, and supercell structures.
NAC parameters were read from "phono3py.yaml".
----------------------------- Force constants ------------------------------
----------------------------- pypolymlp start ------------------------------
Pypolymlp is a generator of polynomial machine learning potentials.
Please cite the paper: A. Seko, J. Appl. Phys. 133, 011101 (2023).
Expand All @@ -406,6 +406,8 @@ Generate random displacements
Twice of number of snapshots will be generated for plus-minus displacements.
Displacement distance: 0.01
Evaluate forces in 200 supercells by pypolymlp
----------------------------- Force constants ------------------------------
Symfc will be used to handle general (or random) displacements.
-------------------------------- Symfc start -------------------------------
Symfc is a force constants calculator. See the following paper:
A. Seko and A. Togo, Phys. Rev. B, 110, 214302 (2024).
Expand All @@ -427,7 +429,7 @@ fc2 was written into "fc2.hdf5".
----------- None of ph-ph interaction calculation was performed. -----------
Dataset generated using MLPs was written in "phono3py_mlp_eval_dataset.yaml".
Summary of calculation was written in "phono3py.yaml".
-------------------------[time 2025-01-12 10:08:40]-------------------------
-------------------------[time 2025-01-15 19:28:30]-------------------------
_
___ _ __ __| |
/ _ \ '_ \ / _` |
Expand Down
9 changes: 9 additions & 0 deletions example/NaCl-pypolymlp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Example to create force constants using MLPs by pypolymlp

This is an example to follow the documentation
https://phonopy.github.io/phono3py/pypolymlp.html.
`phono3py_params.yaml` can be also generated by

```bash
% python make_phono3py_params.py ../NaCl-rd/phono3py_params_NaCl.yaml.xz
```
13 changes: 13 additions & 0 deletions example/NaCl-pypolymlp/make_phono3py_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import sys

import phono3py

ph3 = phono3py.load(sys.argv[1], produce_fc=False, log_level=1)
ph3_new = phono3py.Phono3py(
ph3.unitcell,
supercell_matrix=ph3.supercell_matrix,
primitive_matrix=ph3.primitive_matrix,
)
ph3_new.dataset = ph3.dataset
ph3_new.nac_params = ph3.nac_params
ph3_new.save("phono3py_params.yaml")
Loading

0 comments on commit d4f1b0d

Please sign in to comment.