Skip to content

Conversation

@lan496
Copy link
Contributor

@lan496 lan496 commented Dec 29, 2025

Summary

  • Enable specifying a dictionary recognizable by atomate2.forcefields.utils.ase_calculator at ForceFieldMixin.force_fields_name parameter. This will be useful to integrate atomate2.forcefields with recently released MLIPs or in-house developed MLIPs.
  • Add document on how to specify forcefields in docs/user/codes/forcefields.md

Backward compatibility

The following table summarizes the stored attributes in Maker and schemas for forcefields.
For str or MLFF input, the behavior does not change.

For a dict input,

  • It is regarded as the placeholder MLFF to keep the other behavior
  • ForceFieldMixin.calculator_meta parameter (initialized in __post_init__) is newly introduced to remember the dict information
  • ForceFieldMixin.ase_calculator_name property is newly introduced to keep schemas for ForceFieldMeta.forcefield_name. Letting calc_cls be a decoded calculator function from the dict, calc_cls.__name__ is stored
  • The package version is inferred from calc_cls.__module__
Input for ForceFieldMixin.force_field_name 'CHGNet' | 'MLFF.CHGNet' | MLFF.CHGNet {"@module": "chgnet.model.dynamics", "@callable": "CHGNetCalculator"}
ForceFieldMixin.force_field_name after __post__init__ 'MLFF.CHGNet' 'MLFF.Forcefield'
ForceFieldMixin.mlff (introduced in #1360) MLFF.CHGNet MLFF.Forcefield
ForceFieldMixin.calculator_meta (added in this PR) MLFF.CHGNet {"@module": "chgnet.model.dynamics", "@callable": "CHGNetCalculator"}
ForceFieldMixin.ase_calculator_name (added in this PR) / ForceFieldMeta.forcefield_name 'MLFF.CHGNet' 'CHGNetCalculator'
ForceFieldMeta.forcefield_version version('chgnet') version('chgnet')

Checklist

Work-in-progress pull requests are encouraged, but please put [WIP] in the pull request
title.

Before a pull request can be merged, the following items must be checked:

  • Code is in the standard Python style.
    The easiest way to handle this is to run the following in the correct sequence on
    your local machine. Start with running ruff and ruff format on your new code. This will
    automatically reformat your code to PEP8 conventions and fix many linting issues.
  • Doc strings have been added in the Numpy docstring format.
    Run ruff on your code.
  • Type annotations are highly encouraged. Run mypy to
    type check your code.
  • Tests have been added for any new functionality or bug fixes.
  • All linting and tests pass.

Note that the CI system will run all the above checks. But it will be much more
efficient if you already fix most errors prior to submitting the PR. It is highly
recommended that you use the pre-commit hook provided in the repository. Simply run
pre-commit install and a check will be run prior to allowing commits.

There are predefined "recipes" for generating `InputSets` tailored to specific tasks like structural relaxation or the band structure calculation and more, that are provided as `InputGenerator` classes.

## Technical Aspects
### Technical Aspects
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not an essential fix to the PR itself

@lan496 lan496 changed the title Allow specifying custom calculator in forcefield makers forcefields: allow specifying custom calculator in forcefield makers Dec 29, 2025
@lan496 lan496 marked this pull request as ready for review December 29, 2025 05:50
@lan496
Copy link
Contributor Author

lan496 commented Dec 29, 2025

I have confirmed test-force-field-notebook passes, but I have no idea why tests/abinit/jobs/test_base.py fails with this unrelated PR 🤷‍♂️
https://github.com/materialsproject/atomate2/actions/runs/20565430185/job/59062899029?pr=1362

@JaGeo
Copy link
Member

JaGeo commented Dec 29, 2025

@lan496 Yeah, it has nothing to do with your PR. I have restarted the tests manually.

@lan496 lan496 force-pushed the allow-ext-load-calculator branch from 3ae94d4 to 30a4b0f Compare December 29, 2025 10:36
@JaGeo
Copy link
Member

JaGeo commented Dec 29, 2025

@lan496 thanks!

One more question: what happens if the phonon maker is not initalized via the from_... method but rather manually via _init_? Would the code still work without issue?

@lan496
Copy link
Contributor Author

lan496 commented Dec 29, 2025

For PhononMaker, ASE calculator information is taken from PhononMaker.phonon_displacement_maker: ForceFieldStaticMaker (this attribute is not optional). So, if PhononMaker is properly constructed, it should work as expected.

@JaGeo
Copy link
Member

JaGeo commented Dec 29, 2025

@esoteric-ephemera I will merge. It is backwards compatible and should work well with all previous examples. Feel free to comment more after the holidays in case I overlooked anything.

@JaGeo
Copy link
Member

JaGeo commented Dec 29, 2025

@lan496 Thank you! I will merge!

@JaGeo JaGeo merged commit 7027247 into materialsproject:main Dec 29, 2025
15 checks passed
@lan496
Copy link
Contributor Author

lan496 commented Dec 29, 2025

@JaGeo Thank you so much!

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.

2 participants