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 guide for potential installation #320

Merged
merged 2 commits into from
Aug 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions atomistics/calculators/lammps/potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,34 @@
import pandas
from ase.atoms import Atoms

potential_installation = """
Potential installation guide:

1. Check whether iprpy-data is installed. If not, install it using:

`conda install -c conda-forge iprpy-data`

2. Check whether the resource path is set via:

```python
import os
print(os.environ["CONDA_PREFIX"])
```

3. If the resource path is set, you can call the potential using:

```python
from atomistics.calculators import get_potential_by_name


get_potential_by_name(
potential_name=my_potential,
resource_path=os.path.join(os.environ["CONDA_PREFIX"], "share", "iprpy"),
)
```

"""


class PotentialAbstract(object):
"""
Expand Down Expand Up @@ -124,7 +152,9 @@ def _get_potential_df(file_name_lst, resource_path):
),
},
)
raise ValueError("Was not able to locate the potential files.")
raise ValueError(
"Was not able to locate the potential files." + potential_installation
)


class LammpsPotentialFile(PotentialAbstract):
Expand Down Expand Up @@ -310,7 +340,7 @@ def get_resource_path_from_conda(
resource_path = os.path.join(env[conda_var], "share", "iprpy")
if os.path.exists(resource_path):
return resource_path
raise ValueError("No resource_path found")
raise ValueError("No resource_path found" + potential_installation)


def get_potential_dataframe(structure: Atoms, resource_path=None):
Expand Down