forked from aiidaplugins/aiida-lammps
/
launch_lammps_optimization_lj.py
103 lines (82 loc) · 2.9 KB
/
launch_lammps_optimization_lj.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from aiida.common.extendeddicts import AttributeDict
from aiida.engine import run_get_node
from aiida.orm import Code, Dict, StructureData
from aiida.plugins import CalculationFactory
import numpy as np
from aiida_lammps.data.potential import EmpiricalPotential
if __name__ == "__main__":
from aiida import load_profile # noqa: F401
load_profile()
codename = "lammps_optimize@stern"
############################
# Define input parameters #
############################
cell = [
[3.987594, 0.000000, 0.000000],
[-1.993797, 3.453358, 0.000000],
[0.000000, 0.000000, 6.538394],
]
symbols = ["Ar"] * 2
scaled_positions = [(0.33333, 0.66666, 0.25000), (0.66667, 0.33333, 0.75000)]
structure = StructureData(cell=cell)
positions = np.dot(scaled_positions, cell)
for i, scaled_position in enumerate(scaled_positions):
structure.append_atom(
position=np.dot(scaled_position, cell).tolist(), symbols=symbols[i]
)
structure.store()
# Example LJ parameters for Argon. These may not be accurate at all
potential = {
"pair_style": "lennard_jones",
# epsilon, sigma, cutoff
"data": {
"1 1": "0.01029 3.4 2.5",
# '2 2': '1.0 1.0 2.5',
# '1 2': '1.0 1.0 2.5'
},
}
lammps_machine = {"num_machines": 1, "parallel_env": "mpi*", "tot_num_mpiprocs": 16}
parameters_opt = {
"units": "metal",
"relax": {
"type": "tri", # iso/aniso/tri
"pressure": 0.0, # bars
"vmax": 0.000001, # Angstrom^3
},
"minimize": {
"style": "cg",
"energy_tolerance": 1.0e-25, # eV
"force_tolerance": 1.0e-25, # eV angstrom
"max_evaluations": 1000000,
"max_iterations": 500000,
},
}
LammpsOptimizeCalculation = CalculationFactory("lammps.optimize")
inputs = LammpsOptimizeCalculation.get_builder()
# Computer options
options = AttributeDict()
options.account = ""
options.qos = ""
options.resources = {
"num_machines": 1,
"num_mpiprocs_per_machine": 1,
"parallel_env": "localmpi",
"tot_num_mpiprocs": 1,
}
# options.queue_name = 'iqtc04.q'
options.max_wallclock_seconds = 3600
inputs.metadata.options = options
# Setup code
inputs.code = Code.get_from_string(codename)
# setup nodes
inputs.structure = structure
inputs.potential = EmpiricalPotential(
structure=structure, type="lennard_jones", data={"1 1": "0.01029 3.4 2.5"}
)
inputs.parameters = Dict(dict=parameters_opt)
# run calculation
result, node = run_get_node(LammpsOptimizeCalculation, **inputs)
print("results:", result)
print("node:", node)
# submit to deamon
# submit(LammpsOptimizeCalculation, **inputs)