tdep-developers / tdep

The Temperature Dependent Effective Potentials (TDEP) code
MIT License
58 stars 22 forks source link

Using LAMMPS as the force calculator #58

Closed antonf-ekb closed 5 months ago

antonf-ekb commented 5 months ago

As far as I understand, there is no official support of LAMMPS as a force calculator for TDEP. Here I've found some information on how to run LAMMPS simulation and postprocess the output to obtain TDEP input data. Nevertheless, I guess I do something wrong since running extract_forceconstants -rc2 0 2>&1 | tee extract_forceconstants.log (just following [this tutorial)](https://github.com/tdep-developers/tdep-tutorials/tree/main/02_sampling/sTDEP for my system) I obtain very low R^2 value, unphysical elastic constants and dispersion curves. May be there are some new scripts/input files that correctly glue LAMMPS and TDEP? I attach my extract_forceconstants.log and can provide additional files of the calculation if needed.

extract_forceconstants.log Best regards, Anton.

OrbitalC commented 5 months ago

Hello,

Looking at the log, you have results close to what would one obtain using random numbers for the forces/positions. The first thing to check is if your system has not melted as TDEP cannot be applied on liquids.

Or it might a subtlety from LAMMPS itself. When using MPI, LAMMPS dumps atomic informations (positions and forces for instance) as they arrive - which will depend on the MPI rank and is random in the end. So if you used MPI for LAMMPS, you might have the data in the infile.positions and infile.forces forces completely shuffled (atom 1 in the file is not atom 1 in the infile.poscar and changes for each configuration) which would require to reorder them as explained here

Best regards

flokno commented 5 months ago

Hi @antonf-ekb , despite checking @OrbitalC , it would be beneficial to share the input files you used. Our parsing infrastructure (https://github.com/tdep-developers/tdep-tutorials/blob/main/00_preparation/parsing/README.md) relies on ASE and should therefore be able to understand certain types of LAMMPS output, but it depends on the details.

Despite of that, writing your own parser to provide the (plain text) input files should also be a straightforward task, see https://tdep-developers.github.io/tdep/files/

antonf-ekb commented 5 months ago

Dear @OrbitalC and @flokno ! Thank you for the answers. @OrbitalC , indeed I used an MPI version of LAMMPS and infile.positions/infile.forces data might be shuffled. However, I don't know how I can check it, therefore I attach a link to an archive containing LAMMPS dump files and all other files of my calculation. I'd be grateful if you could have a look. Considering melting, I think this is not the case since the temperature of simulation was 400 K, which is 3 times lower then the melting T of the system. Briefly speaking, I use LAMMPS input file in.tdep, to_lammps.py script is used to convert LAMMPS output to TDEP input and the structure file is called SnSe (obtained from the canonical_configuration command) - may be the mistake somewhere in these files?

OrbitalC commented 5 months ago

I tried to run your inputs and as I expected, the atoms are completely shuffled in the infile.positions and infile.forces files. This is due to how LAMMPS prints things in the dump files and you can solve this by simply adding a dump_modify sort command in you LAMMPS input (for more information on this, you can have a look at the LAMMPS documentation) When doing so I got perfectly fine IFC and phonons.

Also, just a word of caution, for this system, setting rc2 to 0 will give weirds results no matter what since you have a lot of atoms in your unitcell. Even just for testing purposes you should try a slightly larger rc2 to have more interactions in your IFC.

antonf-ekb commented 5 months ago

Dear @OrbitalC, You are correct - after adding dump_modify sort command, the result changed dramatically - now it shows correct elastic constants and reasonable R^2 - around 0.81 (I've also changed -rc from 0 to 7) . However, while going from iteration 0 to iteration 1 R^2 slightly decreases - is it OK or should it only increase if the sampling process is going as it is expected?

I have some suggestions (probably for @flokno ) for enhancing this webpage on LAMMPS for TDEP. Apart from the need for dump_modify sort there have been some modifications for dump_modify format command, so the correct bottom block of LAMMPS input now looks like fix statdump all print 100 "${st} ${tm} ${Et} ${Ep} ${Ek} ${tmp} ${pr} ${sxx} ${syy} ${szz} ${sxy} ${sxz} ${syz}" screen no file dump.stat dump posdump all custom 100 dump.positions xs ys zs dump forcedump all custom 100 dump.forces fx fy fz dump_modify posdump format line "%20.15e %20.15e %20.15e" dump_modify forcedump format line "%20.15e %20.15e %20.15e" dump_modify posdump sort id dump_modify forcedump sort id

May be it is worth updating the page? In addition, there are no reccomendations on the nvt/npt fix and the number of steps (I used nvt for 200000 steps). The python script on the above mentioned page does not prepare infile.meta file (I made it by hand). Finally, one can add a note that a POSCAR file could be transformed to LAMMPS structure format via ase convert contcar_conf0001 -i vasp lammps.in -o lammps-data

Best regards, Anton.