Skip to content

Conversation

@ejmeitz
Copy link
Collaborator

@ejmeitz ejmeitz commented Aug 19, 2025

A new package extension for LAMMPS.jl that defines a general interaction which uses LAMMPS to calculate force and energies. It even uses OpenMP to do multi-threaded calculations!

This requires a new tagged version of LAMMPS.jl before we can merge as I made some PRs there to enable in-place calculation of forces.

In principle this approach could be used to have LAMMPS calculate properties of the system as well.

@codecov
Copy link

codecov bot commented Aug 19, 2025

Codecov Report

❌ Patch coverage is 0% with 97 lines in your changes missing coverage. Please review.
✅ Project coverage is 22.15%. Comparing base (bf208b5) to head (959e019).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
ext/MollyLAMMPSExt.jl 0.00% 97 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (bf208b5) and HEAD (959e019). Click for more details.

HEAD has 7 uploads less than BASE
Flag BASE (bf208b5) HEAD (959e019)
8 1
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #213       +/-   ##
===========================================
- Coverage   69.55%   22.15%   -47.40%     
===========================================
  Files          41       42        +1     
  Lines        6884     6938       +54     
===========================================
- Hits         4788     1537     -3251     
- Misses       2096     5401     +3305     

☔ 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.

@jgreener64
Copy link
Member

Looks interesting. Could potentially be an extension in LAMMPS.jl if you wanted to maintain it yourself.

@ejmeitz
Copy link
Collaborator Author

ejmeitz commented Aug 22, 2025

Yeah I decided its just easier to have it here lol. I can live with downloading Molly.

I'll add some tests for this soon. The energies do appear to be correct, but I'm having some issues with multi-threading.

@ejmeitz ejmeitz marked this pull request as ready for review August 25, 2025 16:20
@ejmeitz
Copy link
Collaborator Author

ejmeitz commented Aug 25, 2025

@jgreener64 This is ready (save for documentation). I ran the tests manually and they work, but I'm not really sure how to setup tests for a package extension? The ase_calculator tests just don't look like they run.

@jgreener64
Copy link
Member

On balance I think this might be better off as an extension in LAMMPS.jl.

Extensions are available for testing assuming the required packages are imported. I didn't get round to setting up the ASE tests on CI.

@ejmeitz
Copy link
Collaborator Author

ejmeitz commented Aug 27, 2025

Yeah I can ask them if they'd be ok adding this there. I do still thing this interoperability should be advertised in Molly somewhere. Cause to be honest if I can't use LAMMPS through Molly, then I would never consider Molly for my research.

@jgreener64
Copy link
Member

jgreener64 commented Aug 27, 2025

Ah I thought LAMMPS.jl was your project, which was one of the reasons for suggesting it go there.

Maybe it could go in Molly, I'll take a look.

@ejmeitz
Copy link
Collaborator Author

ejmeitz commented Aug 27, 2025

I also asked them over at LAMMPS.jl as well. In principle this could be a separate package, I just don't want it lost as I think its very useful.

@jgreener64
Copy link
Member

I agree it is useful and we can document it here either way.

@jgreener64
Copy link
Member

Having had a look it seems that this is mostly independent of Molly, so it might get more use as its own package that Molly can import the calculator from. We can still have an example in the Molly docs.

I would hesitate to use step_n to avoid recomputing, since some simulators can do multiple coordinate updates each step (e.g. barostat trials). Whether to calculate the potential energy could also be an option to the calculator.

If you wanted to keep the sanity checks for Molly systems, you could have a Molly extension in the package that overloads some function check_inputs for a Molly.System.

@tjjarvinen
Copy link
Contributor

Just hopping to comment here.

IMO this would be the best to implement in LAMMPS.jl and adding full AtomsCalculators support as an extension. This way everyone would get to use it not just Molly.

@ejmeitz
Copy link
Collaborator Author

ejmeitz commented Sep 11, 2025

Yea I can discuss with them more.

I did hit a technical issue though. I dont think you can call LAMMPS without it rebuilding a neighbor list every time. This makes it like 20-50x slower than it otherwise would be just getting forces. If anyone knows a way around that I'd love to hear it. Right now I basically just set positions and call "run 0".

@tjjarvinen
Copy link
Contributor

I forgot to ask have you tried IPICalculator.jl with LAMMPS? That would the easiest way to use LAMMPS in Molly.

It might be a good idea to add a documentation page on Molly on how to use i-PI interface.

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.

3 participants