Skip to content

Conversation

@V-Francois
Copy link
Contributor

Summary
This PR enables users to setup DiscreteSwap moves in their input toml file.

This move is a bit different than the others, as it requires knowledge of the number of particles of each species in the system. Its instantiation can therefore only be done after the system has been setup.

If in the future some moves that change the number of particles of each species are implemented (something like grand canonical moves for instance), then the current implementation of DiscreteSwap will produce spurious results (but won't raise an error).

Alternative implementation
I kept the existing implementation of the DiscreteSwap struct intact, and only added a new constructor.
Alternatively, the number of particle per species could be a parameter (the vector passed to the actions) rather than a field of the class.

It's a bit unclear to me why some things are fields, and others are parameters. I think parameters are in a sense controlled by the simulation rather than the action (for things like policy guided MC).
If that is indeed the case, it could make sense to refactor the DiscreteSwap struct, to have the number of particles per species as a parameter, as it's "system dependent" and not so much "action dependent".

Test plan
The validation test for binary mixtures of LJ has been updated to include swap moves, and still recovers published results. So the action works as intended.
Also, I manually checked that the acceptance rate is > 0 (so moves do happen), and that in the final configurations, the species of some particles changed. I also checked with a system with 3 species that allowing 1<->2 swaps doesn't change any of the 3s.

@V-Francois
Copy link
Contributor Author

@romainljsimon , @leonardogalliano for visibility

@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/ParticlesMC.jl 0.00% 14 Missing ⚠️
src/moves.jl 0.00% 4 Missing ⚠️
Files with missing lines Coverage Δ
src/moves.jl 53.04% <0.00%> (-1.92%) ⬇️
src/ParticlesMC.jl 9.00% <0.00%> (-1.12%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@romainljsimon romainljsimon self-requested a review January 16, 2026 11:30
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