Skip to content

Commit

Permalink
Merge pull request #2 from usnistgov/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
knc6 committed Apr 13, 2024
2 parents 4bf526b + eb5d4a4 commit a05d9f1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![alt text](https://github.com/usnistgov/intermat/actions/workflows/main.yml/badge.svg)

[![name](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/gist/knc6/0d9aa89f671687c6e925eea2be9b824a/intermat_gettingstarted.ipynb)
<!-- [![name](https://colab.research.google.com/assets/colab-badge.svg)](https://gist.github.com/knc6/c00ee48c524f5000e7f80a974bc6dc71)
[![name](https://colab.research.google.com/assets/colab-badge.svg)](https://gist.github.com/knc6/debf9cbefa9a290502d73fd3cbc4fd69)
[![name](https://colab.research.google.com/assets/colab-badge.svg)](https://gist.github.com/knc6/7492b51b371a8e9dbaa01d76bb438467) -->
Expand Down
13 changes: 8 additions & 5 deletions intermat/calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from jarvis.tasks.qe.qe import QEjob
import numpy as np
from jarvis.core.atoms import Atoms, ase_to_atoms
from ase.optimize.fire import FIRE
from ase.constraints import ExpCellFilter
from jarvis.db.jsonutils import loadjson


Expand Down Expand Up @@ -216,9 +214,9 @@ def predict(
if "potential" not in self.extra_params:
# Download from
# https://doi.org/10.6084/m9.figshare.24187602
self.extra_params["potential"] = (
"Mishin-Ni-Al-Co-2013.eam.alloy"
)
self.extra_params[
"potential"
] = "Mishin-Ni-Al-Co-2013.eam.alloy"

from ase.calculators.eam import EAM

Expand Down Expand Up @@ -308,6 +306,8 @@ def predict(
info["atoms"] = ase_to_atoms(atoms)
return info # ,forces,stress
elif self.relax_atoms and not self.relax_cell:
from ase.optimize.fire import FIRE

optimizer = FIRE
dyn = optimizer(atoms)
dyn.run(fmax=self.fmax, steps=self.steps)
Expand All @@ -317,6 +317,9 @@ def predict(
info["atoms"] = atoms
return info # ,forces,stress
elif self.relax_cell:
from ase.optimize.fire import FIRE
from ase.constraints import ExpCellFilter

atoms = ExpCellFilter(atoms)
optimizer = FIRE
dyn = optimizer(atoms)
Expand Down
2 changes: 1 addition & 1 deletion intermat/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
maxiter=100,
convergence={"energy": 1},
# convergence={"density": 1e-12, "energy": 1e-1},
eigensolver=Davidson(niter=2),
# eigensolver=Davidson(niter=2),
out_file="gs.out",
out_gpw="out.gpw",
kp_length=10,
Expand Down
37 changes: 26 additions & 11 deletions intermat/run_intermat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from intermat.config import IntermatConfig
from jarvis.db.jsonutils import loadjson
from jarvis.db.figshare import get_jid_data
from jarvis.db.jsonutils import dumpjson


def main(config_file_or_dict):
Expand All @@ -21,17 +22,24 @@ def main(config_file_or_dict):
else:
config_dat = loadjson(config_file_or_dict)
# A few default setting check
if not os.path.exists(config_dat["lammps_params"]["pair_coeff"]):
pprint.pprint(config_dat)
if "lammps_params" in config_dat and not os.path.exists(
config_dat["lammps_params"]["pair_coeff"]
):
config_dat["lammps_params"]["pair_coeff"] = os.path.join(
os.path.dirname(__file__),
"tests",
"Mishin-Ni-Al-Co-2013.eam.alloy",
)
if not os.path.exists(config_dat["lammps_params"]["control_file"]):
if "lammps_params" in config_dat and not os.path.exists(
config_dat["lammps_params"]["control_file"]
):
config_dat["lammps_params"]["control_file"] = os.path.join(
os.path.dirname(__file__), "tests", "relax.mod"
)
if not os.path.exists(config_dat["potential"]):
if "potential" in config_dat and not os.path.exists(
config_dat["potential"]
):
config_dat["potential"] = os.path.join(
os.path.dirname(__file__),
"tests",
Expand Down Expand Up @@ -87,6 +95,7 @@ def main(config_file_or_dict):
+ " It might be energetically very high/less stable."
)
print(combined_atoms[0])
combined_atoms = combined_atoms[0]
else:
if config.verbose:
for ii, i in enumerate(combined_atoms):
Expand All @@ -96,7 +105,7 @@ def main(config_file_or_dict):
wads = ""
if config.calculator_method != "":
# print("combined_atoms", combined_atoms)

print("config.calculator_method", config.calculator_method)
wads = x.calculate_wad(
method=config.calculator_method,
do_surfaces=config.do_surfaces,
Expand All @@ -108,12 +117,14 @@ def main(config_file_or_dict):
combined_atoms = Atoms.from_dict(
x.generated_interfaces[index]["generated_interface"]
)
print("Generated interface:\n", combined_atoms)
if config.plot_wads:

# print("Generated interface:\n", combined_atoms)
if config.plot_wads and config.disp_intvl != 0:
# xy = np.array(x.xy)
# print('xy', xy)
X = x.X
Y = x.Y

# X = xy[:,0]
# Y = xy[:,1]
wads = np.array(wads).reshape(len(X), len(Y))

fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
Expand All @@ -126,13 +137,16 @@ def main(config_file_or_dict):
# import plotly.graph_objects as go
# fig = go.Figure(data=[go.Surface(z=wads, x=X, y=Y)])
# fig.show()
wads = wads.tolist()
t2 = time.time()
print("Time taken:", t2 - t1)
info = {}
info["syste"] = combined_atoms
# print("combined_atoms", combined_atoms)
info["systems"] = combined_atoms.to_dict()
info["time_taken"] = t2 - t1
info["wads"] = wads
return wads
print("info", info)
return info


if __name__ == "__main__":
Expand All @@ -145,4 +159,5 @@ def main(config_file_or_dict):
help="Settings file for intermat.",
)
args = parser.parse_args(sys.argv[1:])
main(config_file=args.config_file)
results = main(config_file_or_dict=args.config_file)
dumpjson(data=results, filename="intermat_results.json")
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"numpy>=1.22.0",
"scipy>=1.6.3",
"jarvis-tools>=2021.07.19",
"alignn",
"pydantic_settings",
# "alignn",
],
long_description=long_description,
long_description_content_type="text/markdown",
Expand All @@ -24,5 +25,8 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
scripts=[
"intermat/run_intermat.py",
],
python_requires=">=3.8",
)

0 comments on commit a05d9f1

Please sign in to comment.