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

Add the calculation of the minimum interatomic distance #890

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

tang070205
Copy link
Contributor

@tang070205 tang070205 commented Jan 27, 2025

Add a new file check_distance.cu to the model folder to check if there are any two atoms with a spacing less than 1 angstrom in the model.xyz file at the beginning of the calculation.

For orthogonal lattices, firstly, using the example of hnemd, the original model.xyz file will not report errors, but it will print out which two atoms are closest to each other normally. The atomic number starts from index 0 and serves only as a prompt, as shown in the following figure.
image

Then, I changed the coordinates of atom 0 to 0 0 0, so that it differs from atom 1 only by 0.71 angstroms in the y direction. This will result in an error message as shown in the following figure and prompt as an input error.
image

Finally, there are periodic boundary conditions, as shown in the figure below. The left figure represents a non periodic boundary condition in the z-direction, while the right figure represents a periodic boundary condition. Non periodic boundary conditions do not generate errors, while periodic boundary conditions result in 3.35=0 in the z-direction, which is the same as the situation in the above figure.
image

For non orthogonal lattices, I used a two-dimensional material that I had manually rubbed myself, and applied a vacuum layer of 20 angstroms to the original cell.
Similarly, a normal structure will not produce errors, only prompts. You will find atom 1 Si and atom 4 N, where 1 and 4 start from the third line index of 0 in the model.xyz file, line by line, from 0 to N-1 (N is the total number of atoms in the structure)
image

Next, we will still use these two atoms. I want to change the xy coordinate of N atom to be the same as that of Si atom, and there will be an error message after execution.
image

Finally, it is still a periodic issue, due to the presence of a large vacuum layer in the z-direction, I applied non periodic boundary conditions in the x-direction and doubled the expansion in the x-direction.Here, two Mo atoms are used as a demonstration, and the abscissa of the last Mo atom is added by 2 angstroms.
image

I also tested a structure with 10 million atoms, which only takes about ten seconds. From the initial screen printing to the red box in the picture, it takes about half a minute. However, when checking the atomic distance, it only takes a little over ten seconds.
image

@brucefan1983
Copy link
Owner

This is too slow for big systems.

@brucefan1983
Copy link
Owner

You need to study the MD book more carefully :)

@tang070205
Copy link
Contributor Author

Ok, I'll learn from the MD book and change it to cuda.

@brucefan1983
Copy link
Owner

Ok, I'll learn from the MD book and change it to cuda.

It is not about CUDA, but about $O(N)$ vs $O(N^2)$ algorithms. For a system with $10^8$ atoms, even CUDA cannot make it fast enough with an $O(N^2)$ algorithm.

@tang070205 tang070205 marked this pull request as ready for review January 29, 2025 12:55
@brucefan1983 brucefan1983 marked this pull request as draft January 29, 2025 14:10
double min_distance = 5.0;
int min_n1 = -1, min_n2 = -1;

double thickness[3];
Copy link
Owner

@brucefan1983 brucefan1983 Jan 31, 2025

Choose a reason for hiding this comment

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

The thicknesses are not correctly calculated.

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