Skip to content

Update phonopy to 3.0.0 #633

Merged
jan-janssen merged 4 commits intomainfrom
phonopy
Mar 4, 2026
Merged

Update phonopy to 3.0.0 #633
jan-janssen merged 4 commits intomainfrom
phonopy

Conversation

@jan-janssen
Copy link
Copy Markdown
Member

@jan-janssen jan-janssen commented Mar 4, 2026

Summary by CodeRabbit

  • Chores
    • Updated phonopy dependency to version 3.0.0 across environment configurations.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

The pull request updates the phonopy dependency from version 2.47.1 to 3.0.0 across four configuration and manifest files that define the project's dependencies and environment specifications.

Changes

Cohort / File(s) Summary
Dependency Version Bump
.ci_support/environment-docs.yml, .ci_support/environment.yml, binder/environment.yml, pyproject.toml
Updated phonopy dependency from 2.47.1 to 3.0.0 across all configuration files.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Poem

🐰 A hop, a skip, a version's climb,
From 2.47 to 3.0 in time,
Four files now dance in harmony,
Phonopy hops with you and me! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Update phonopy to 3.0.0' clearly and concisely summarizes the primary change across all four modified files, which consistently update the phonopy dependency from 2.47.1 to 3.0.0.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch phonopy

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pyproject.toml`:
- Line 42: Remove the deprecated factor parameter from Phonopy constructor calls
in src/atomistics/workflows/phonons/helper.py: locate the Phonopy(...)
invocations (around the block that calls generate_displacements(), accesses
supercells_with_displacements, assigns .forces and later reads .force_constants)
and delete the factor=... argument; if you need calculator-based unit conversion
instead, instantiate Phonopy with calculator=... and
set_factor_by_calculator=True as recommended or otherwise rely on the default
THz conversion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0336dafa-aff7-4d82-925d-6abda6fba7f0

📥 Commits

Reviewing files that changed from the base of the PR and between 0bf19f9 and 68a5078.

📒 Files selected for processing (4)
  • .ci_support/environment-docs.yml
  • .ci_support/environment.yml
  • binder/environment.yml
  • pyproject.toml

Comment thread pyproject.toml
[project.optional-dependencies]
phonopy = [
"phonopy==2.47.1",
"phonopy==3.0.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find the actual Phonopy usages in helper.py and related files
find src -name "*.py" -type f | head -20

Repository: pyiron/atomistics

Length of output: 865


🏁 Script executed:

# Search for Phonopy imports and usage patterns
rg -n --type=py -C2 'from phonopy|import phonopy|Phonopy\(' src tests 2>/dev/null | head -100

Repository: pyiron/atomistics

Length of output: 5670


🏁 Script executed:

# Specifically check helper.py
if [ -f "src/atomistics/workflows/phonons/helper.py" ]; then
  wc -l "src/atomistics/workflows/phonons/helper.py"
  echo "---"
  cat -n "src/atomistics/workflows/phonons/helper.py"
else
  echo "Helper file not found; searching for it..."
  find . -name "helper.py" -path "*/phonons/*" -type f
fi

Repository: pyiron/atomistics

Length of output: 25737


🌐 Web query:

Phonopy 3.0.0 API release notes breaking changes

💡 Result:

Phonopy 3.0.0?

I couldn’t find any Phonopy v3.0.0 release notes—Phonopy’s published changelog shows v2.48.0 (Feb 15, 2026) as the latest entry, i.e., still on the 2.x line. [1]

If you meant Phono3py 3.0.0 (common mix-up): breaking / backward-incompatible changes

Phono3py v3.0.0 (Apr 19, 2024) lists these backward-incompatible changes: [2]

  • Changed fc3 real→reciprocal transform method, changing results vs phono3py v2 behavior.
    Compatibility options: use --v2 in the CLI; in the Python API use make_r0_average=True (default) when creating Phono3py, and similarly for phono3py.load.
  • Dropped support for disp_fc3.yaml and disp_fc2.yaml (completely removed).
  • Dropped support for “old style” phono3py-kaccum script usage.

Sources: [1] Phonopy changelog, [2] Phono3py changelog.


🌐 Web query:

Phonopy 3.0.0 constructor parameters unitcell supercell_matrix primitive_matrix

💡 Result:

In phonopy 3.0.0, the Phonopy constructor begins like this (showing the three parameters you asked about): (raw.githubusercontent.com)

Phonopy(
    unitcell: PhonopyAtoms,
    supercell_matrix: Sequence[int] | Sequence[Sequence[int]] | NDArray | None = None,
    primitive_matrix: Literal["P","F","I","A","C","R","auto"]
                    | Sequence[Sequence[float]] | NDArray | None = None,
    ...
)
  • unitcell: a PhonopyAtoms object (the input unit cell). (raw.githubusercontent.com)
  • supercell_matrix: an integer supercell transformation given as either
    • length-3 integers (interpreted as a diagonal [na, nb, nc]), or
    • a 3×3 integer matrix / ndarray,
      used to build the supercell from the unit cell. (raw.githubusercontent.com)
  • primitive_matrix: a primitive-cell transformation given as either
    • a 3×3 float matrix / ndarray, or
    • one of "P","F","I","A","C","R","auto",
      used to build the primitive cell from the unit cell. (raw.githubusercontent.com)

Citations:


🌐 Web query:

Phonopy version 3.0.0 release date changelog

💡 Result:

Phonopy itself has not released a v3.0.0 (its releases are still in the 2.x series). (phonopy.github.io)

The v3.0.0 release you’re likely referring to is Phono3py v3.0.0, released on April 19, 2024. (phonopy.github.io)

Phono3py v3.0.0 changelog (highlights)

  • Major release with backward-incompatible changes. (phonopy.github.io)
  • Changed the real→reciprocal transform method for fc3 (affects results vs v2); v2-like behavior can be requested via --v2 (and make_r0_average=True defaults for the API). (phonopy.github.io)
  • Dropped support for disp_fc3.yaml and disp_fc2.yaml. (phonopy.github.io)
  • Dropped support for old-style phono3py-kaccum usage. (phonopy.github.io)
  • Removed write_fc3_dat, write_triplets, write_grid_address from file_IO.py; removed deprecated methods; and removed several Phono3py.__init__() parameters (masses, band_indices, sigmas, sigma_cutoff). (phonopy.github.io)

Citations:


🌐 Web query:

Phonopy 3.0.0 generate_displacements method signature supercells_with_displacements property

💡 Result:

I couldn’t find any evidence that Phonopy has a “3.0.0” release line; the Phonopy docs/changelog I can access are for the 2.x series (e.g. v2.48.0), where the API below applies. In that API, displacement generation is done explicitly by calling generate_displacements(...) with a distance argument. [1]

generate_displacements (Phonopy API)

Signature (keyword args shown with typical defaults):

phonon.generate_displacements(
    distance=0.01,
    is_plusminus="auto",
    is_diagonal=True,
    is_trigonal=False,
)

[2]

supercells_with_displacements (property/attribute)

After calling generate_displacements(), you can access the generated displaced supercells via:

  • phonon.supercells_with_displacements → a list of phonopy.structure.atoms.PhonopyAtoms objects (one per displacement supercell). [3]

If you meant Phono3py 3.0.0 (not Phonopy), tell me and I’ll pull the exact 3.0.0 API details for that specific version.

Sources: [1] [2] [3]


🌐 Web query:

Phonopy 3.0.0 forces property force_constants attribute API

💡 Result:

  • There is no “phonopy 3.0.0” release: on PyPI the latest phonopy is 2.48.0 (uploaded Feb 15, 2026). [1]
  • The forces attribute/property you’re referring to matches the phono3py 3.x API: calculated supercell force sets are stored on the object as Phono3py.forces with shape (num_supercells, num_atoms_in_supercell, 3). [2]
  • In phono3py, don’t expect a generic force_constants attribute on the main object: users have historically hit AttributeError: 'Phono3py' object has no attribute 'force_constants'. Instead, phono3py exposes force constants via order-specific data (e.g., fc2/fc3) after running the production routines (e.g., produce_fc3()). [2][3]

Sources: [1] [2] [3]


🏁 Script executed:

cat pyproject.toml | grep -A 2 -B 2 phonopy

Repository: pyiron/atomistics

Length of output: 182


🏁 Script executed:

# Verify PyPI availability of phonopy versions
pip index versions phonopy 2>/dev/null | head -20 || python3 << 'EOF'
import json
try:
    import urllib.request
    response = urllib.request.urlopen("https://pypi.org/pypi/phonopy/json", timeout=5)
    data = json.loads(response.read())
    releases = sorted(data['releases'].keys(), reverse=True)
    print("Available phonopy versions (latest 20):")
    for v in releases[:20]:
        print(f"  {v}")
except Exception as e:
    print(f"Could not fetch PyPI data: {e}")
EOF

Repository: pyiron/atomistics

Length of output: 2189


🌐 Web query:

Phonopy 3.0.0 constructor factor parameter documentation

💡 Result:

  • There is no “Phonopy 3.0.0” release as of Feb 15, 2026 (latest Phonopy is v2.48.0). (phonopy.github.io)
  • The “3.0.0” version you may be thinking of is Phono3py v3.0.0 (released Apr 19, 2024). (phonopy.github.io)

What factor refers to in the Python API

In both phonopy/phono3py Python usage, factor is documented as part of the NAC (non-analytical term correction) parameters dict (i.e., not a Phonopy(...) constructor argument):

nac_params = {
  "born": ...,        # Born effective charges
  "dielectric": ...,  # dielectric tensor
  "factor": float,    # unit conversion factor
}
ph.nac_params = nac_params

The docs describe factor as a “Unit conversion factor” inside nac_params, which is set via the *.nac_params attribute. (phonopy.github.io)

Related note (CLI)

If you were looking for a constructor-like “factor” because of older workflows: the --factor / FREQUENCY_CONVERSION_FACTOR mechanism is deprecated (since v2.44) in phonopy’s CLI context. (phonopy.github.io)

Citations:


🌐 Web query:

site:github.com Phonopy v3.0.0 generate_displacements supercells_with_displacements

💡 Result:

In Phonopy / Phono3py, generate_displacements() populates a list of displaced supercells that you access via the attribute supercells_with_displacements:

# Phonopy
phonon.generate_displacements(distance=0.03)
supercells = phonon.supercells_with_displacements

(Older docs also describe the getter get_supercells_with_displacements(), but the attribute access above is the direct way.) [1]

# Phono3py (v3.x)
ph3.generate_displacements()
supercells = ph3.supercells_with_displacements
n = len(supercells)

supercells_with_displacements is a list of PhonopyAtoms supercells with the generated displacements. [2]

Sources: [1] [2]


🌐 Web query:

Phonopy 3.0.0 forces property assignment force_constants

💡 Result:

In Phonopy/Phono3py you generally don’t set force_constants by assigning to a forces property. The workflows are:

  1. You have force constants already (array fc): set them explicitly via the API method (not by property assignment), e.g.
  • phonon.set_force_constants(fc) (typical Phonopy usage) [2].
  1. You have displacements + forces and want Phonopy/Phono3py to build force constants:
  • Set the displacement dataset and then assign the forces array (shape (n_supercells, n_atoms_supercell, 3)), and finally call the force-constants builder (e.g. produce_fc3() in Phono3py). Example shown in the Phono3py API:
    • ph3.dataset = disp_dataset
    • ph3.forces = forces
    • ph3.produce_fc3() [1].

If your goal is file-based I/O instead, Phonopy can read/write force constants from FORCE_CONSTANTS via settings (e.g. FORCE_CONSTANTS = READ/WRITE) [3].

Sources: Phono3py API example of setting forces then producing FCs [1]; Phonopy-style set_force_constants usage example [2]; Phonopy FORCE_CONSTANTS read/write setting [3].


🏁 Script executed:

python3 << 'EOF'
import json
import urllib.request

# Get PyPI data for phonopy 3.0.0
try:
    response = urllib.request.urlopen("https://pypi.org/pypi/phonopy/3.0.0/json", timeout=10)
    data = json.loads(response.read())
    print("Phonopy 3.0.0 found on PyPI")
    print(f"Release date: {data['releases'].get('3.0.0', [{}])[0].get('upload_time', 'N/A') if isinstance(data['releases'], dict) else 'N/A'}")
except Exception as e:
    print(f"Error: {e}")
EOF

Repository: pyiron/atomistics

Length of output: 195


🌐 Web query:

site:github.com/phonopy/phonopy "v3.0.0" Phonopy constructor factor parameter

💡 Result:

In phonopy/phonopy v3.0.0, the Phonopy constructor still accepts a factor: float | None = None parameter, but it is deprecated (deprecated since v2.24) and triggers a DeprecationWarning if you pass a non-None value. Its role is to set the internal frequency unit conversion factor (self._unit_conversion_factor). [1]

Behavior in __init__ is: [1]

  • If calculator is not None and set_factor_by_calculator=True, then
    unit_conversion_factor = get_calculator_physical_units(interface_mode=calculator).factor
  • Else if factor is None, then
    unit_conversion_factor = get_physical_units().DefaultToTHz (default is conversion to THz for Å displacements and eV/Å forces)
  • Else (i.e., factor given), then
    unit_conversion_factor = factor

So for v3.0.0, the recommended approach is to avoid factor and instead use calculator=... with set_factor_by_calculator=True, or rely on the default THz conversion. [1]


🌐 Web query:

Phonopy 3.0.0 API "def __init__" unitcell supercell_matrix primitive_matrix factor

💡 Result:

In Phonopy 3.x, the Phonopy constructor uses these inputs:

  • unitcell: a PhonopyAtoms object (your input structure).
  • supercell_matrix: the integer transformation that expands unitcell into the supercell (commonly [na, nb, nc] or a 3×3 integer matrix).
  • primitive_matrix: the transformation that extracts the primitive cell from unitcell (3×3 matrix or 'auto' to let symmetry search determine it).
  • factor: frequency unit conversion factor (to THz); you set it depending on the calculator/interface (e.g. AbinitToTHz, VaspToTHz, etc.). An example explicitly shows Phonopy(..., factor=AbinitToTHz). [1]
    (These matrix meanings match the way the Phono3py API describes them as well—Phono3py’s instantiation is “similar to the instantiation of Phonopy class”.) [2]

Example usage:

from phonopy import Phonopy
from phonopy.units import AbinitToTHz

phonon = Phonopy(
    unitcell,
    supercell_matrix=[[2,0,0],[0,2,0],[0,0,2]],
    primitive_matrix="auto",
    factor=AbinitToTHz,
)

[1] [2]


Remove deprecated factor parameter from Phonopy() constructor calls in src/atomistics/workflows/phonons/helper.py.

Phonopy 3.0.0 is available and the APIs (Phonopy() constructor with unitcell, supercell_matrix, primitive_matrix; generate_displacements(), supercells_with_displacements, .forces assignment, and .force_constants property) remain compatible. However, the factor parameter has been deprecated since Phonopy v2.24 and will trigger a DeprecationWarning at runtime in 3.0.0.

At line 286–294, replace the deprecated factor parameter with the recommended approach: rely on the default THz conversion by removing the factor argument, or if unit conversion from a specific calculator interface is needed, use the calculator= parameter with set_factor_by_calculator=True instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pyproject.toml` at line 42, Remove the deprecated factor parameter from
Phonopy constructor calls in src/atomistics/workflows/phonons/helper.py: locate
the Phonopy(...) invocations (around the block that calls
generate_displacements(), accesses supercells_with_displacements, assigns
.forces and later reads .force_constants) and delete the factor=... argument; if
you need calculator-based unit conversion instead, instantiate Phonopy with
calculator=... and set_factor_by_calculator=True as recommended or otherwise
rely on the default THz conversion.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.81%. Comparing base (2fede01) to head (68a5078).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #633   +/-   ##
=======================================
  Coverage   86.81%   86.81%           
=======================================
  Files          43       43           
  Lines        2419     2419           
=======================================
  Hits         2100     2100           
  Misses        319      319           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jan-janssen jan-janssen merged commit c324480 into main Mar 4, 2026
46 of 51 checks passed
@jan-janssen jan-janssen deleted the phonopy branch March 4, 2026 17:03
@coderabbitai coderabbitai Bot mentioned this pull request Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant