|
17 | 17 |
|
18 | 18 | import numpy as np |
19 | 19 |
|
20 | | -from vaspy import VasPy |
21 | | -from vaspy.errors import CarfileValueError |
22 | | -from vaspy.functions import * |
| 20 | +from . import VasPy |
| 21 | +from .errors import CarfileValueError |
| 22 | +from .functions import * |
| 23 | +from .elements import chem_elements |
23 | 24 |
|
24 | 25 |
|
25 | 26 | class AtomCo(VasPy): |
@@ -228,6 +229,38 @@ def get_cif_content(self): |
228 | 229 |
|
229 | 230 | return content |
230 | 231 |
|
| 232 | + def get_reaxff_content(self): |
| 233 | + """ |
| 234 | + Get ReaxFF data file content |
| 235 | + """ |
| 236 | + content = '# Created by VASPy\n\n' |
| 237 | + |
| 238 | + # Info |
| 239 | + content += '{} atoms\n{} atom types\n\n'.format(len(self.data), |
| 240 | + len(self.atom_types)) |
| 241 | + content += '0 25.000 xlo xhi\n0 25.000 ylo yhi\n0 25.000 zlo zhi\n\n' |
| 242 | + |
| 243 | + # Masses |
| 244 | + content += 'Masses\n\n' |
| 245 | + for i, element in enumerate(self.atom_types): |
| 246 | + if element not in chem_elements: |
| 247 | + raise ValueError('element {} not in elements.py'.format(element)) |
| 248 | + mass = chem_elements[element]['mass'] |
| 249 | + content += '{} {:.4f}\n'.format(i+1, mass) |
| 250 | + |
| 251 | + # Coordinate |
| 252 | + content += '\nAtoms\n\n' |
| 253 | + cart_coords = self.dir2cart(self.bases, self.data).tolist() |
| 254 | + |
| 255 | + for i, (component, coord) in enumerate(zip(self.atom_components, cart_coords)): |
| 256 | + template = '{:>4d}{:>2d}{:>4.1f}{:>9.5f}{:>11.5f}{:>11.5f}\n' |
| 257 | + idx = i+1 |
| 258 | + type_idx = self.atom_types.index(component) + 1 |
| 259 | + x, y, z = coord |
| 260 | + content += template.format(idx, type_idx, 0.0, x, y, z) |
| 261 | + |
| 262 | + return content |
| 263 | + |
231 | 264 | def get_volume(self): |
232 | 265 | """ |
233 | 266 | Get volume of slab(Angstrom^3) |
|
0 commit comments