root / ase / io / py.py @ 19
Historique | Voir | Annoter | Télécharger (789 octet)
1 |
from ase.atoms import Atoms |
---|---|
2 |
|
3 |
|
4 |
def write_py(fileobj, images, **kwargs): |
5 |
if isinstance(fileobj, str): |
6 |
fileobj = open(fileobj, 'w') |
7 |
|
8 |
fileobj.write('from ase import Atoms\n\n')
|
9 |
fileobj.write('import numpy as np\n\n')
|
10 |
|
11 |
if not isinstance(images, (list, tuple)): |
12 |
images = [images] |
13 |
fileobj.write('images = [\n')
|
14 |
|
15 |
for image in images: |
16 |
fileobj.write(" Atoms(symbols='%s',\n"
|
17 |
" pbc=np.%s,\n"
|
18 |
" cell=np.array(\n %s,\n"
|
19 |
" positions=np.array(\n %s),\n" % (
|
20 |
image.get_chemical_symbols(reduce=True),
|
21 |
repr(image.pbc),
|
22 |
repr(image.cell)[6:], |
23 |
repr(image.positions)[6:])) |
24 |
|
25 |
fileobj.write(']')
|