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

some kind of wrap function for PBC's? #9

Open
rkurchin opened this issue Oct 12, 2021 · 12 comments
Open

some kind of wrap function for PBC's? #9

rkurchin opened this issue Oct 12, 2021 · 12 comments
Labels
question Further information is requested

Comments

@rkurchin
Copy link
Collaborator

Would it make sense to have this be part of the interface? If so, we would need to be able to dispatch on boundary condition types, which might require rejiggering the type parameters of AbstractSystem...

@rkurchin rkurchin added the question Further information is requested label Oct 12, 2021
@Gregstrq
Copy link
Collaborator

Could you pleas elaborate your idea a bit more? What do you mean by wrap function?

@rkurchin
Copy link
Collaborator Author

Sorry yeah that wasn't very clear. I'll just do a concrete simplified example. Suppose you have periodic boundary conditions in 1D on a "box" of length 2. If you had a coordinate of a particle at point 3, it should "wrap" back to the point 1 (essentially just a modular arithmetic operation). This is a pretty standard thing for packages that deal with periodic BC's (e.g. Python's ASE, or the Xtals.jl package), but it's also very possible it's not actually important enough to belong in a high-level interface like this, hence I opened the issue to discuss :)

@eahenle
Copy link

eahenle commented Oct 12, 2021

From my (admittedly biased) perspective, periodic boundaries are very important. Can't handle crystalline materials without them. Molecular dynamics simulations usually use them, too.

The math is, as you say, not complicated. In Xtals we keep positions in fractional coordinates so the math simple: anything less than 0 gets 1 added to it, and anything greater than 1 gets 1 taken away. (+1.5, 0.5, -1) maps to (0.5, 0.5, 0).

@mfherbst
Copy link
Member

I think if you have PBC and you add an absolute coordinate that is "larger than the border" it should always wrap. That is the point as @eahenle has described it. If you don't want that you first "disable" periodicity and then add the position.

Naturally one could also have a function to do these subtleties (like disable wrapping and favour extension of the system), but I think this belongs to another package using this interface.

@rkurchin
Copy link
Collaborator Author

Just noting that this is probably quite related to #5

@Gregstrq
Copy link
Collaborator

Gregstrq commented Oct 19, 2021

I think if you have PBC and you add an absolute coordinate that is "larger than the border" it should always wrap. That is the point as @eahenle has described it. If you don't want that you first "disable" periodicity and then add the position.

Technically, I imagine certain subtleties associated with fast implementations. For example, it may be better first to update all the positions and then to wrap them all back inside the boundary. @jgreener64, how is it usually done in MD simulations?

By the way, how the coordinates are wrapped back if the bounding box is skewed (not rectangular)? It seems that the only approach is to convert coordinates to fractional.

@jgreener64
Copy link
Collaborator

@jgreener64, how is it usually done in MD simulations?

It depends on the software, but usually after one or all coordinates are updated as you say.

I think there might be too many subtleties to support this in a way that pleases everyone. We also haven't made setters part of the interface, I think with decent justification, so it is unclear how we would modify the coordinates of a system in a general way.

@rkurchin
Copy link
Collaborator Author

These are all fair points. I really opened this issue as a "thought that popped into my head" and have no strong feelings about whether it should be implemented here or not. Certainly given that we're not doing setters, at the most if we had it it would just return the wrapped coordinates rather than modifying them, but at that point I'm not sure there's all that much use to having it in the interface...

@mfherbst
Copy link
Member

I agree with @rkurchin and @jgreener64. I suppose we close this for now and revisit once we move towards setters.

@cortner
Copy link
Member

cortner commented May 18, 2024

It feels all these methods to manipulate systems could become part of AtomsBuilder

@rkurchin
Copy link
Collaborator Author

Agreed – I'm fine with this being closed and having an issue over there instead as a reminder

@cortner
Copy link
Member

cortner commented May 20, 2024

I'm planning to move over the rest of JuLIP functinality to AtomsBuilder over the coming week. If you file an issue there and describe how you think wrap should work then I'll try to match that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants