Skip to content

Allow non-conservative simulations without stress#47

Open
PicoCentauri wants to merge 1 commit intometatomicfrom
fix-nc-stress
Open

Allow non-conservative simulations without stress#47
PicoCentauri wants to merge 1 commit intometatomicfrom
fix-nc-stress

Conversation

@PicoCentauri
Copy link
Copy Markdown

This is a bit delicate. The problem seems to be that the vflag_global is kind of always set. I tried a minimal NVE simulation and a thermo_style where there is no pressure output. But even during this run, the flag is set to true.

The only workaround I see is to warn the user at init time and unfortunately silently ignore the pressure output during the run.

I am open to any better suggestions. @Luthaf or @HaoZeke.

@PicoCentauri PicoCentauri changed the title Allow nc simulations without stress Allow non-conservative simulations without stress Apr 2, 2026
@Luthaf
Copy link
Copy Markdown
Member

Luthaf commented Apr 2, 2026

If vflag_global is set, I think we should compute the virial. One solution if the model does not have non_conservative_stress would then be to fallback to backward propagation for this. So if the user sets non_conservative on, we try to use both nc_forces and nc_stress, falling back to conservative forces/stress if one of them is missing. If both are missing it should be an error IMO.

Alternatively, we could allow non_conservative forces/non_conservative stress in the lammps input to only use one of them.

I don't have strong feeling here, we can either automatically use autodiff when the non_conservative output does not exists; or force the user to tell us and have non_conservative on mean we use non-conservative for everything.

@PicoCentauri
Copy link
Copy Markdown
Author

I think a fallback to autodiff and write a warning might not be read by the user. I am more in favour of raising an error if either non_conservative_forces or non_conservative_stress is not existing and forcing them to manually set the value of non_conservative. We could go for the options as you suggest @Luthaf:

  1. non_conservative_forces - stress and forces are nc
  2. non_conservative_force - forces are nc, stress is ad
  3. non_conservative_stress - forces are ad, stress is nc

@Luthaf
Copy link
Copy Markdown
Member

Luthaf commented Apr 7, 2026

I'm fine with the error, but it seems that there is a typo (_ instead of ) in your example? I can see the following options in the LAMMPS input file:

  • non_conservative off default, do not use any non-conservative output
  • non_conservative on use both nc stress and forces
  • non_conservative forces use nc forces and conservative stress
  • non_conservative stress use nc stress and conservative forces

@PicoCentauri
Copy link
Copy Markdown
Author

Yes sorry for the typo. Okay let's do this options.

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