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 interface for CHGNet #57

Open
advancesoftcorp opened this issue Aug 7, 2023 · 29 comments
Open

LAMMPS interface for CHGNet #57

advancesoftcorp opened this issue Aug 7, 2023 · 29 comments
Labels
api Application programming interface enhancement New feature or request

Comments

@advancesoftcorp
Copy link

Dear developers of CHGNet,

We have developed the interface of LAMMPS for CHGNet: https://github.com/advancesoftcorp/lammps/tree/based-on-lammps_2Jun2022/src/ML-CHGNET
It would be great that it will interest you.

Best Regards,
Satomichi Nishihara
AdvanceSoft Corp.

@bowen-bd bowen-bd added the enhancement New feature or request label Aug 7, 2023
@bowen-bd
Copy link
Collaborator

bowen-bd commented Aug 7, 2023

Thanks a lot!
We appreciate your efforts.
This will be very valuable to users familiar with lammps.

@janosh
Copy link
Collaborator

janosh commented Aug 7, 2023

@advancesoftcorp Thank you very much! I assume you've tested the CHGNet interface on an example system? Are you able the share the code for that? We'd be happy to add that to our example notebooks as a starting guide for LAMMPS users.

@janosh janosh added the api Application programming interface label Aug 7, 2023
@advancesoftcorp
Copy link
Author

We have tested the CHGNet interface for ZrO2, which input file is here: https://github.com/advancesoftcorp/lammps/tree/based-on-lammps_2Jun2022/examples/CHGNET

@bowen-bd
Copy link
Collaborator

bowen-bd commented Aug 7, 2023

@advancesoftcorp
Thanks again!
I see the CHGNet driver file has a input argument for loading different CHGNet weights.
def chgnet_initialize(model_name = None, dftd3 = False, gpu = True):

Say, now we have another CHGNet that can be loaded like myCHGNet = CHGNet.load('new_model')
Could you please share how is it possible to use this model_name key to load different CHGNet in the inp.lammps input file?

@advancesoftcorp
Copy link
Author

@advancesoftcorp
Copy link
Author

Now, we have already developed the GUI of LAMMPS/CHGNet as the following figure.
Please let us know the name of "new_model", if you have already defined it.
The GUI is our product of Advance/NanoLabo: https://www.nanolabo.advancesoft.jp/en/

WS000000

@bowen-bd
Copy link
Collaborator

bowen-bd commented Aug 7, 2023

@advancesoftcorp
Currently CHGNet.load() method only supports loading the MPtrj pretrained CHGNet.
When users load their own fine-tuned model, it's loaded through CHGNet.from_file('weight_path')
If there can be an interface to load CHGNet from a local path with CHGNet.from_file in the inp.lammps that will be helpful.

@bowen-bd
Copy link
Collaborator

bowen-bd commented Aug 7, 2023

This looks great, thanks!

@FuXiao-153
Copy link

@advancesoftcorp Thank you very much for developing this interface! When I installed the 2JUN2022 version of LAMMPS, some problems occurred. I can run the program using other pair style, but CHGNet fails. I was wondering if the installation of this version is different from the installation of other versions of LAMMPS?

@advancesoftcorp
Copy link
Author

Did you make yes-ML-CHGNET, before compile LAMMPS ?

@FuXiao-153
Copy link

@advancesoftcorp
yes,before compiling LAMMPS,we completed making yes-[KSPACE/ MANYBODY/ ML-CHGNET/ MOLECULE/ PYTHON/ RIGID].

@advancesoftcorp
Copy link
Author

It seems you did not set LD_LIBRARY_PATH for python or compilation was not correct.

@FuXiao-153
Copy link

@advancesoftcorp
Sorry to bother you again, we set LD_LIBRARY_PATH for python in .bashrc and have tried different ways of compilation, the program still reported the same error:

LAMMPS (2 Jun 2022)
  using 1 OpenMP thread(s) per MPI task
Reading data file ...
  triclinic box = (0 0 0) to (25.256318 25.844557 25.363354) with tilt (0.997650                                                       81 -1.0715861 1.0101746)
  1 by 1 by 1 MPI processor grid
  reading atoms ...
  1280 atoms
  read_data CPU = 0.036 seconds
Segmentation fault

Could you please help us check the cause of the error? Thank you very much

@advancesoftcorp
Copy link
Author

You have to resolve the problem by yourself, because I cannot see what you see.

@mhsiron
Copy link

mhsiron commented Nov 1, 2023

Hello @advancesoftcorp I am using CHGnet plug-in that you have built in LAMMPS mostly successfully. However when the amount of atoms changes such as with a fix dep command (like so):
fix dep0 adatom deposit 100 0 20 7087 region deposregion near 3 mol molec vz -410.8341 -502.1306 vx -0.0 -0.0 vy -0.0 -0.0

I run into the following error due to the number of atoms changing:

ValueError: Array "numbers" has wrong shape (772,) != (768,).
ERROR: Cannot calculate energy, forces and stress by python of CHGNet. (src/ML-CHGNET/pair_chgnet.cpp:672)

I was able to get the code to still work by changing line 92 in chgnet_driver.py from:
global myAtoms
to
myAtoms = None

I'm wondering if there is any downstream effect you suspect from this and why myAtoms was made a global variable?

@advancesoftcorp
Copy link
Author

@mhsiron
Thank you for pointing out the bug. As you said, chgnet_driver.py did not support atomic depositions or grand canonical ensembles. But I fix it now:
https://github.com/advancesoftcorp/lammps/blob/d3dc7730a0f2640eb725015e9edaa0b74b222d81/src/ML-CHGNET/chgnet_driver.py#L96

myAtoms is still a global variable, to avoid multiply creating instances of ase.Atoms for speed-up.

@heroiciota
Copy link

heroiciota commented Nov 28, 2023

@advancesoftcorp Hi, When I use your software named Nanalabo pro, which I got licence from your guys days before, to run my own cif structrue, it reminds me
"Traceback (most recent call last):File "C:\Program Files\AdvanceSoft\NanoLabo\chgnet\chgnet_driver.py", line 11, in from chgnet.model import CHGNet, CHGNetCalculator
ModuleNotFoundError: No module named 'chgnet.model',
And I went to log file , there is an ERROR: 'Cannot initialize python for pair_coeff of CHGNet. (../pair_chgnet.cpp:503)' hope to get you guys reply sooner, thx you anyway.

@advancesoftcorp
Copy link
Author

@heroiciota
It seems that you did not install chgnet into your machine.
Do "pip install chgnet".

@heroiciota
Copy link

@advancesoftcorp Thx!Actually,I have had chgnet installed. But somehow my system can't point to the right environment. I am struggling with it, hopefully I would fix it today.

@heroiciota
Copy link

@FuXiao-153 @advancesoftcorp I met the same problem :unrecognized pair style 'chgnet/d3' is part of the ML-CHGNET package which is not enabled in this LAMMPS binary. (../force.cpp:271)Last command: pair_style chgnet/d3 ../../potentials/CHGNET
I wonder did any one succeed in running the example? Can anyone share the experience of it . Also , I have my ML-CHGNET package installed too. Appreciate.

@Mofahdi
Copy link

Mofahdi commented May 4, 2024

I have an error here:
it seems that
TypeError: chgnet_initialize() takes from 0 to 3 positional arguments but 4 were given

This is what I wrote in my input file which is the same as the tutorial
ERROR: Cannot initialize python for pair_coeff of CHGNet. (src/lammps_releases/advancesoftcorp/lammps/src/ML-CHGNET/pair_chgnet.cpp:519)
Last command: pair_coeff * * 0.3.0 Zr O
How can I solve this issue?

@advancesoftcorp
Copy link
Author

@heroiciota
it seems you did NOT make yes-ML-CHGNET.

@advancesoftcorp
Copy link
Author

@Mofahdi
the chgnet_driver.py that you had used may be broken.

@naji-usr
Copy link

@advancesoftcorp Thank you!If installed in HPC, how can I run parallel calculations (at least is there any way to speed it up!) .

@advancesoftcorp
Copy link
Author

@naji-usr you cannot use MPI parallel. but OpenMP is available.

@naji-usr
Copy link

Thank you @advancesoftcorp it works.

@ankit213910
Copy link

ankit213910 commented Dec 9, 2024

@bowen-bd @advancesoftcorp Hello, I ran CHGNet on LiAlO2. It ran successfully. My goal is to generate a LAMMPS usable potential file. Are you able to help me with that? I see that this link has code that uses a file
pair_coeff * * MPtrj-efsm Zr O
https://github.com/advancesoftcorp/lammps/blob/1ab512916a99e38b46d1d8a6660b0212da95592f/examples/CHGNET/inp.lammps
How to generate the MPtrj-efsm file from the CHGNet code on colab? Also I have lammps Aug 2023 but I dont see the CHGnet module in it.

@advancesoftcorp
Copy link
Author

The file of the pretrained model is here:
https://github.com/CederGroupHub/chgnet/tree/main/chgnet/pretrained

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Application programming interface enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

9 participants