-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask.py
116 lines (102 loc) · 3.04 KB
/
Task.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
104
105
106
107
108
109
110
111
112
113
114
115
from abc import ABC,abstractmethod
class Task(ABC):
@abstractmethod
def __init__ (self,
inter_parameter,
path_to_poscar) :
"""
Constructor
Parameters
----------
inter_parameter : dict
A dict that specifies the interaction.
path_to_poscar : str
The path to POSCAR. Indicating in which system the task will be initialized.
"""
pass
@abstractmethod
def make_potential_files(self,
output_dir):
"""
Prepare potential files for a computational task.
For example, the VASP prepares POTCAR.
DeePMD prepares frozen model(s).
IMPORTANT: Interaction should be stored in output_dir/inter.json
Parameters
----------
output_dir : str
The directory storing the potential files.
Outputs
-------
inter.json: output file
The task information is stored in `output_dir/inter.json`
"""
pass
@abstractmethod
def make_input_file(self,
output_dir,
task_type,
task_param):
"""
Prepare input files for a computational task
For example, the VASP prepares INCAR.
LAMMPS (including DeePMD, MEAM...) prepares in.lammps.
Parameters
----------
output_dir : str
The directory storing the input files.
task_type : str
Can be
- "relaxation:": structure relaxation
- "static": static computation calculates the energy, force... of a strcture
task_parame: dict
The parameters of the task.
For example the VASP interaction can be provided with
{ "ediff": 1e-6, "ediffg": 1e-5 }
"""
pass
@abstractmethod
def compute (self,
output_dir):
"""
Compute output of the task.
IMPORTANT: The output configuration should be converted and stored in a CONTCAR file.
Parameters
----------
output_dir : str
The directory storing the input and output files.
Returns
-------
result_dict: dict
A dict that storing the result. For example:
{ "energy": xxx, "force": [xxx] }
Outputs
-------
CONTCAR: output file
The output configuration is converted to CONTCAR and stored in the `output_dir`
"""
pass
@property
@staticmethod
@abstractmethod
def forward_files(self):
"""
Return forward files.
"""
pass
@property
@staticmethod
@abstractmethod
def forward_common_files(self):
"""
Return forward common files.
"""
pass
@property
@staticmethod
@abstractmethod
def backward_files(self):
"""
Return backward files.
"""
pass