-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from pyiron/structure_optimization
Implement structure optimization protocol
- Loading branch information
Showing
14 changed files
with
240 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ dependencies: | |
- lammps =2023.08.02 | ||
- pandas =2.1.3 | ||
- pylammpsmpi =0.2.5 | ||
- jinja2 =3.1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def optimize_positions_and_volume(structure): | ||
return {"optimize_positions_and_volume": structure} | ||
|
||
|
||
def optimize_positions(structure): | ||
return {"optimize_positions": structure} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import numpy as np | ||
from ase.build import bulk | ||
from ase.calculators.emt import EMT | ||
from ase.optimize import BFGS | ||
import unittest | ||
|
||
from atomistics.calculators.ase import evaluate_with_ase | ||
from atomistics.workflows.structure_optimization.workflow import optimize_positions | ||
|
||
|
||
class TestOptimizePositionsEMT(unittest.TestCase): | ||
def test_optimize_positions(self): | ||
structure = bulk("Al", a=4.0, cubic=True) | ||
positions_before_displacement = structure.positions.copy() | ||
structure.positions[0] += [0.01, 0.01, 0.01] | ||
task_dict = optimize_positions(structure=structure) | ||
result_dict = evaluate_with_ase( | ||
task_dict=task_dict, | ||
ase_calculator=EMT(), | ||
ase_optimizer=BFGS, | ||
ase_optimizer_kwargs={"fmax": 0.000001} | ||
) | ||
structure_optimized = result_dict["structure_with_optimized_positions"] | ||
self.assertTrue( | ||
all(np.isclose( | ||
positions_before_displacement, | ||
structure_optimized.positions-structure_optimized.positions[0], | ||
).flatten()) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
|
||
from ase.build import bulk | ||
import numpy as np | ||
import unittest | ||
|
||
from atomistics.workflows.structure_optimization.workflow import optimize_positions | ||
|
||
try: | ||
from atomistics.calculators.lammps import ( | ||
evaluate_with_lammps, get_potential_dataframe | ||
) | ||
|
||
skip_lammps_test = False | ||
except ImportError: | ||
skip_lammps_test = True | ||
|
||
|
||
@unittest.skipIf( | ||
skip_lammps_test, "LAMMPS is not installed, so the LAMMPS tests are skipped." | ||
) | ||
class TestOptimizePositionsLAMMPS(unittest.TestCase): | ||
def test_optimize_positions(self): | ||
potential = '1999--Mishin-Y--Al--LAMMPS--ipr1' | ||
resource_path = os.path.join(os.path.dirname(__file__), "static", "lammps") | ||
structure = bulk("Al", cubic=True) | ||
positions_before_displacement = structure.positions.copy() | ||
structure.positions[0] += [0.01, 0.01, 0.01] | ||
df_pot = get_potential_dataframe( | ||
structure=structure, | ||
resource_path=resource_path | ||
) | ||
df_pot_selected = df_pot[df_pot.Name == potential].iloc[0] | ||
task_dict = optimize_positions(structure=structure) | ||
result_dict = evaluate_with_lammps( | ||
task_dict=task_dict, | ||
potential_dataframe=df_pot_selected, | ||
lmp_optimizer_kwargs={"ftol": 0.000001}, | ||
) | ||
structure_optimized = result_dict["structure_with_optimized_positions"] | ||
self.assertTrue( | ||
all(np.isclose( | ||
positions_before_displacement, | ||
structure_optimized.positions-structure_optimized.positions[0], | ||
).flatten()) | ||
) | ||
|
Oops, something went wrong.