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

could u provide a simple code example how to call the pretrained model to prediction formation energy? #27

Open
usccolumbia opened this issue Sep 13, 2022 · 3 comments

Comments

@usccolumbia
Copy link

and other properties?

@shyuep
Copy link
Contributor

shyuep commented Sep 13, 2022

The notebooks here show how to relax a strucutre. The notebooks in the megnet repo (see https://github.com/materialsvirtuallab/megnet) provide an example code of how to predict formation energies and other properties. You simply need to relax the structure with m3gnet and then use the models from MEGNet to predict the properties.

@usccolumbia
Copy link
Author

usccolumbia commented Sep 13, 2022

Thanks for the quick update with the hint.
i tried this:
from m3gnet.utils.models import load_model, AVAILABLE_MODELS
gives error:

Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'm3gnet.utils.models'

I still recommend providing a jupyter notebook here with an example code of how to predict formation energies and other properties using this m3gnet models to make this package self-contained -:).

@JiQi535
Copy link

JiQi535 commented Sep 13, 2022

@usccolumbia
For those m3gnet property models, as described in the pretrained folder (https://github.com/materialsvirtuallab/m3gnet/blob/main/pretrained/matbench_properties.md), you need to first download them from figshare. Then loading and using them can be done with the below three lines of code:

from m3gnet.models import M3GNet
m3gnet_e_form = M3GNet.from_dir(e_form_folder)
e_form_predict = m3gnet_e_form.predict_structure(a_structure)

The a_structure should be a pymatgen structure. If you haven't worked with it, you can follow this example to get a pymatgen structure of LiFePO4: notebook

The e_form_folder is the path to the folder containing parameter files of the m3gnet property model. For example, I downloaded the pretained models into ./m3gnet_models folder, which is at same folder with my working jupyter notebook running the above three lines of codes. Then, the e_form_folder can be m3gnet_models/matbench_mp_e_form/0/m3gnet/.

You should be able to load and use those property models with the above.

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

No branches or pull requests

3 participants