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 a new command #861

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Conversation

dongxianchao
Copy link

mc local_minimize mc_trials scale_factor force_tolerance maximal_number_of_relaxation_steps [group grouping_method group_id]
This can perform simple mc and local relaxation.

Previously, we need to write a python jobscript to do the work, randomly select two atoms and swap - relax the structure - get the energy difference to calculate the probability of swap.
Now the work flow has been implemented in GPUMD, although there still need some modification. The local relaxation method has been implemented, which means each time swap 2 atoms, we don't need to relax the whole system to get the energy, and the volumn of relax area can be controlled by the scale factor. The sphere area with radius scale_factor radial_cutoff will be calculated.
In mcmd.out file, the Maximum displacement, Average displacement and Accept ratio will be calculated. The two displacement value are calculated from the atoms falls in the range from (scale_factor - 1) * cutoff_radius to scale_factor * cutoff_radius, where is the edge of the sphere we are going to relax. One can adjust the scale factor to a reasonable value according to this. The smaller they are, the smaller the energy difference with the global relaxation will be.

TO DO: modify the output file
modify the code structure

@brucefan1983 brucefan1983 marked this pull request as draft January 8, 2025 18:21
@brucefan1983
Copy link
Owner

brucefan1983 commented Jan 8, 2025

This is a very specialized feature, so I suggest you make your code localized. You should nearly not touch the existing files, but just create new files.

@dongxianchao
Copy link
Author

This is a very specialized feature, so I suggest you make your code localized. You should nearly not touch the existing files, but just create new files.

How about write a new key word like mc_local, and construct that class totally independent of mc, but still depend on nep_energy? The minimize part, I write a new function in minimize_fire which can only update the labelled atoms by input an array like [0, 0, 1, 1, 0......], 1 means the atoms need to update and 0 means not change. I'm not sure if it's useful for other function, if it is we may keep it in minimize to increase code reusability.

@brucefan1983
Copy link
Owner

You can create a new folder mc_minimize/ and put all the new code there. The function added to the fire minimizer class is ok.

@brucefan1983
Copy link
Owner

mc_minimize is at the same level of mc

@brucefan1983
Copy link
Owner

Good change. Now you need to resotre the residual changes in the files within the mc/ folder.

You can view the changes online. For example:

image

@dongxianchao
Copy link
Author

Hi Prof. Fan,

I've finished the major part work. I add a new key word "mc_minimize", and you can use command
mc_minimize global mc_trials force_tolerance maximal_number_of_relaxation_steps [group grouping_method group_id]
for a simple MC with global relaxation. For local relaxation, here is the command
mc_minimize local mc_trials force_tolerance maximal_number_of_relaxation_steps scale_factor [group grouping_method group_id].

Now this part is highly modular. It's independent of nep_energy in mc, instead, I use the potential.cuh directly to calculate the force and energy. It's not that beautiful in minimize part. The code still use Minimizer_fire object directly. Later I may try to modify this part if there is any requirement. I feel it's better to use the interface of minimizer. But till now, the fire method seems enough for relaxation.

@brucefan1983
Copy link
Owner

Also modify makefile.hip similarly.

@brucefan1983
Copy link
Owner

Hi Prof. Fan,

I've finished the major part work. I add a new key word "mc_minimize", and you can use command mc_minimize global mc_trials force_tolerance maximal_number_of_relaxation_steps [group grouping_method group_id] for a simple MC with global relaxation. For local relaxation, here is the command mc_minimize local mc_trials force_tolerance maximal_number_of_relaxation_steps scale_factor [group grouping_method group_id].

Now this part is highly modular. It's independent of nep_energy in mc, instead, I use the potential.cuh directly to calculate the force and energy. It's not that beautiful in minimize part. The code still use Minimizer_fire object directly. Later I may try to modify this part if there is any requirement. I feel it's better to use the interface of minimizer. But till now, the fire method seems enough for relaxation.

How about speed, fast enough for you?

@dongxianchao
Copy link
Author

I've updated makefile.hip. The main calculation cost lies in minimize algorithm. I tested a 640000 atoms system with box length 117A, and if we use a radius of 21 A for local relaxation sphere, the speed can be 5 times faster. And the major benefit is that, the relaxation is localized, so with the increase of the system, there will be little increase in running time for same trial steps. With this feature we can calculate very large system efficiently.

src/makefile Outdated Show resolved Hide resolved
src/makefile Outdated Show resolved Hide resolved
src/mc_minimize/mc_minimizer_local.cu Outdated Show resolved Hide resolved
@brucefan1983
Copy link
Owner

A final question: do you want to document this feature now or leave if for the future, such as when you have a paper submitted to arxiv.

@dongxianchao
Copy link
Author

I'm not sure, let me ask Shunda.

@brucefan1983 brucefan1983 marked this pull request as ready for review January 10, 2025 16:16
@brucefan1983 brucefan1983 requested a review from shdchen January 10, 2025 16:19
@dongxianchao
Copy link
Author

I've updated makefile.hip. The main calculation cost lies in minimize algorithm. I tested a 640000 atoms system with box length 117A, and if we use a radius of 21 A for local relaxation sphere, the speed can be 5 times faster. And the major benefit is that, the relaxation is localized, so with the increase of the system, there will be little increase in running time for same trial steps. With this feature we can calculate very large system efficiently.

I typed it wrong it's 64000 atoms

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