Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lammps: Use change_box when switching from orthogonal box to triclini… #25

Merged
merged 6 commits into from
Jan 22, 2021

Conversation

jan-janssen
Copy link
Member

…c box

@@ -114,12 +114,18 @@ def interactive_cells_setter(self, cell):
warnings.warn('set_relative() is deprecated as of 2020-02-26. It is not guaranteed from pyiron_atomistics vers. 0.3')
Copy link
Member

Choose a reason for hiding this comment

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

It's totally unrelated, but since this feature is badly deprecated, I guess we shouldn't forget to erase it after this PR.

@@ -114,12 +114,18 @@ def interactive_cells_setter(self, cell):
warnings.warn('set_relative() is deprecated as of 2020-02-26. It is not guaranteed from pyiron_atomistics vers. 0.3')

if is_skewed and is_scaled:
self._interactive_lib_command(
"change_box all triclinic"
)
self._interactive_lib_command(
"change_box all x final 0 %f y final 0 %f z final 0 %f \
xy final %f xz final %f yz final %f triclinic remap units box"
Copy link
Member

Choose a reason for hiding this comment

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

If we are setting change_box all triclinic in the command above, we can probably erase triclinic here (same for the command below).

@coveralls
Copy link

coveralls commented Jan 18, 2021

Pull Request Test Coverage Report for Build 495814342

  • 2 of 6 (33.33%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.01%) to 64.615%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pyiron_atomistics/lammps/interactive.py 2 6 33.33%
Files with Coverage Reduction New Missed Lines %
pyiron_atomistics/lammps/interactive.py 2 35.42%
Totals Coverage Status
Change from base Build 495736873: -0.01%
Covered Lines: 10538
Relevant Lines: 16309

💛 - Coveralls

Copy link
Member

@samwaseda samwaseda left a comment

Choose a reason for hiding this comment

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

This doesn't work if we go from a skewed box to an orthogonal box, because the shear components will be ignored (although to be more precise, this problem was already present before this PR).

@jan-janssen
Copy link
Member Author

jan-janssen commented Jan 18, 2021

I need this fix for the old elastic constants job which is currently not working.

With the current master branch I get the following error message:

ERROR: Cannot change box tilt factors for orthogonal box (../change_box.cpp:249)

Copy link
Member

@liamhuber liamhuber left a comment

Choose a reason for hiding this comment

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

My Lammps-fu isn't good enough to just look at this and understand what the impact will be. I don't have any objections to the change, but it would be very helpful if the tests were also updated to demonstrate the behaviour you're trying to get.

@samwaseda
Copy link
Member

I need this fix for the old elastic constants job which is currently not working.

With the current master branch I get the following error message:

ERROR: Cannot change box tilt factors for orthogonal box (../change_box.cpp:249)

Sorry I don't understand what you want to say with this.

@jan-janssen
Copy link
Member Author

This doesn't work if we go from a skewed box to an orthogonal box, because the shear components will be ignored (although to be more precise, this problem was already present before this PR).

I agree that this is an issue which should be addressed but that is not part of this pull request.

@samwaseda
Copy link
Member

I agree that this is an issue which should be addressed but that is not part of this pull request.

There I would slightly (but not totally) disagree. In the previous implementation it was not possible to go from orthogonal to skewed or other way around. If you make it possible to go from orthogonal to skewed with the new implementation I would find it more logical to make it also possible to go from skewed to orthogonal. Especially regarding the fact that going from skewed to orthogonal doesn’t even raise an error, so pyiron silently gives back wrong output and the user might never know that.

@jan-janssen
Copy link
Member Author

In the previous implementation it was not possible to go from orthogonal to skewed or other way around.

In the previous implementation all structures were triclinic, this changed in pyiron/pyiron#1083 so all I want is to restore functionality we had before.

@samwaseda
Copy link
Member

In the previous implementation all structures were triclinic, this changed in pyiron/pyiron#1083 so all I want is to restore functionality we had before.

That's perfectly fine by me, but the new implementation still doesn't rectify the problem that it's not possible to go from a skewed box to an orthogonal box.

self._interactive_lib_command(
"change_box all x final 0 %f y final 0 %f z final 0 %f remap units box"
% (lx, ly, lz)
)
else: # is neither skewed nor scaled
self._interactive_lib_command(
"change_box all ortho"
Copy link
Member Author

Choose a reason for hiding this comment

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

@samwaseda Is this what you meant?

Copy link
Member

Choose a reason for hiding this comment

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

No this won't work either, because xy will still retain the previous value.

Copy link
Member Author

Choose a reason for hiding this comment

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

@samwaseda Then I am not sure what you want and prefer to merge this pull request and address your request in a separate pull request.

Copy link
Member

@samwaseda samwaseda Jan 19, 2021

Choose a reason for hiding this comment

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

Wait "I don't understand what you're saying so I'm gonna merge it" is anyway not quite acceptable. Let me explain the problem one more time and then we're gonna talk about whether to still ignore the problem and merge it or not, ok?

So what pyiron does is set lx ly lz xy xz yz if the box is skewed, and lx ly z if the box is orthogonal. Imagine we have an orthogonal box at the beginning and go through the following case:

  1. Set xy=0.1 -> run
  2. Set xy=0 -> run

What happens inside pyiron is:

  1. xy=0.1: box is skewed -> change_box lx ly lz xy xz yz -> run
  2. xy=0: box is orthogonal -> change_box lx ly lz -> run

And as you can see in the second step, xy remains untouched, while pyiron should have actively set xy=0.

I hope this explanation was clear.

Copy link
Member Author

Choose a reason for hiding this comment

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

I understand the physical implications - I just say it was not working before and I do not know how to fix it, because we would have to read the current box inside lammps and then make a decision how to change this box which most likely leads to performance penalties. Therefore I suggest to merge the current pull request because it at least fixes the old elastic constant protocol developed by yury, which is not working with the current master branch.

Copy link
Member

Choose a reason for hiding this comment

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

I have the feeling that it's better to leave it then, because, again, going from skewed to orthogonal won't raise an error, but silently returns wrong output. So by making it possible to go from orthogonal to skewed with this PR, we might be making it even more difficult to realise where the problem comes from later.

So I would say, either we solve both problems or nothing. But I'll accept also other decisions if other people prefer a different way. What do you guys think? @liamhuber @pmrv @sudarsan-surendralal

Copy link
Member

Choose a reason for hiding this comment

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

Aha. Also from your other comment I understand a bit better. Failing silently is the worst of devils and should be exorcised immediately. I agree entirely that making it work in one direction but not the other makes this an even worse trap.

We definitely don't need the functionality to work both ways, but we should make it fail ASAP, especially if we now make it work one way.

Copy link
Member

Choose a reason for hiding this comment

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

Ok then maybe the quickest solution is to set change_box orthogonal, because then LAMMPS complains, right?

Copy link
Member

Choose a reason for hiding this comment

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

because then LAMMPS complains, right?

cough need tests cough 😉

Copy link
Member

@liamhuber liamhuber left a comment

Choose a reason for hiding this comment

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

I am still not tracking the Lammps super specifically, but I am trying to follow the discussion. Below is my current understanding. Ideal would be some test to ensure the desired pyiron behaviour, but I'm not going to force that issue.

Old

EDIT: Sam corrected my understanding
EDIT again: @samwaseda is the post correct now?

  • Change skew to orthogonal) Fail with error Silently does the wrong thing -- AAAHHH!
  • Change orthogonal to skew) Fail with error Silently does the wrong thing -- AAAHHH! Fails with error

New (unacceptable)

  • Change skew to orthogonal) Silently does the wrong thing
  • Change orthogonal to skew) Works

Requested

  • Change skew to orthogonal) Fails with error
  • Change orthogonal to skew) Works

@samwaseda
Copy link
Member

Old

  • Change skew to orthogonal) Fail with error

No the old version also does the wrong thing silently.

@jan-janssen
Copy link
Member Author

This starts to get fundamental. This pull request addresses one part of the issue above:

Old

  • Change orthogonal to skew - fails

New

  • Change orthogonal to skew - works

While the other changes would be nice to have they are not part of this pull request, mainly because I do not know how to get the information about the current structure from LAMMPS in an efficient way.

The tests for this part would require running lammps and I thought we agreed that we do not want to run simulation codes in the regular unit tests.

@samwaseda
Copy link
Member

Old

EDIT: Sam corrected my understanding

  • Change orthogonal to skew) Fail with error Silently does the wrong thing -- AAAHHH!

No, there it fails 😎

@jan-janssen
Copy link
Member Author

The failing unit tests are addressed in #28

@liamhuber
Copy link
Member

This starts to get fundamental. This pull request addresses one part of the issue above:

My argument is that these parts are not necessarily separable issues.

(A,B):Fails silently, (B,A):Fails <-- Bad

(A,B):Fails silently, (B,A):Works <-- much worse

Silent failures should be high priority to squash. Making a reverse operation fully functional only exacerbates the problem and raises the priority. The reverse doesn't need to work, it just needs to fail cleanly.

The tests for this part would require running lammps and I thought we agreed that we do not want to run simulation codes in the regular unit tests.

Agreed, we should probably avoid this in the regular unit tests, which is why I'm absolutely not going to insist such a test be part of this PR. However, this PR definitely highlights the need for tests, be they unit or integration.

@jan-janssen
Copy link
Member Author

If we do not fix this the calculation of elastic constants using the old class from Yury does not work in interactive mode. But this class is already used in current high through projects like http://atomistictools.org . This functionality was broken when we moved away from having triclinic cells as the default. I am against dropping existing functionality in favour of abstract ideals.

@samwaseda
Copy link
Member

If we do not fix this the calculation of elastic constants using the old class from Yury does not work in interactive mode. But this class is already used in current high through projects like http://atomistictools.org . This functionality was broken when we moved away from having triclinic cells as the default. I am against dropping existing functionality in favour of abstract ideals.

  • It should still work if the job is static.
  • Whether it works or not in the interactive mode depends also on the order of execution: if the orthogonal box doesn't happen to be the very first run, then it returns wrong results silently, which is even worse than now.

And I wouldn't call it an "abstract ideal". It's a real problem.

@jan-janssen
Copy link
Member Author

So then the solution is to reset xy, xz and yz to 0.0 and afterwards change the box to orthogonal?

@liamhuber
Copy link
Member

So then the solution is to reset xy, xz and yz to 0.0 and afterwards change the box to orthogonal?

Shouldn't they be none for orthogonal?

@jan-janssen
Copy link
Member Author

Shouldn't they be none for orthogonal?

I do not think LAMMPS supports none here that is why afterwards I change the cell to orthogonal.

@samwaseda
Copy link
Member

I guess the first thing we can try is to set change_box orthogonal as you did in one of the commits and hope that LAMMPS complains if we go from triclinic to orthogonal. If it doesn't complain, we probably have to find a different solution...

@liamhuber
Copy link
Member

I guess the first thing we can try is to set change_box orthogonal as you did in one of the commits and hope that LAMMPS complains if we go from triclinic to orthogonal. If it doesn't complain, we probably have to find a different solution...

The Lammps-crash error message is a little cryptic, but if this does manage to crash things I'd put this in the "good enough" category.

Since the check needs to be performed anyway, it would be lovely to have it codified as a tiny integration test.

@jan-janssen
Copy link
Member Author

I guess the first thing we can try is to set change_box orthogonal as you did in one of the commits and hope that LAMMPS complains if we go from triclinic to orthogonal. If it doesn't complain, we probably have to find a different solution...

That is what is used in the current version, first I resent xy, xz and yz to 0.0 and then I switch to ortho

@liamhuber
Copy link
Member

Then is Lammps crashing on the reverse transformation as hoped? If not some further change to force the crash (either in pyiron or just directly in lammps) is still needed

@jan-janssen
Copy link
Member Author

Then is Lammps crashing on the reverse transformation as hoped? If not some further change to force the crash (either in pyiron or just directly in lammps) is still needed

No, also the second part is now fixed.

Copy link
Member

@liamhuber liamhuber left a comment

Choose a reason for hiding this comment

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

I won't insist on it, but I think it would be excellent if you included whatever code you're currently using to verify the forward and backward transitions as an integration test (might need to make a new folder for it, but can follow the same format as contrib; also no immediate need to get integration in the ci as even having it there for manual running would be super helpful IMO)

@samwaseda
Copy link
Member

That is what is used in the current version, first I resent xy, xz and yz to 0.0 and then I switch to ortho

Ah now I get it. I also thought about this possibility, but wasn’t sure if the performance is not badly affected by it. The question is also whether it really makes sense to use both triclinic and orthogonal, or we simply use only triclinic with all shear components equal to zero. Anyway, for now I would accept the solution you suggested (although again I think we should do a performance test).

@jan-janssen jan-janssen merged commit bc4c321 into master Jan 22, 2021
@delete-merged-branch delete-merged-branch bot deleted the lammps_triclinic branch January 22, 2021 16:57
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.

None yet

4 participants