root / ase / io / mol.py @ 14
Historique | Voir | Annoter | Télécharger (591 octet)
| 1 |
from math import pi, cos, sin, sqrt, acos |
|---|---|
| 2 |
|
| 3 |
from ase.atoms import Atoms |
| 4 |
from ase.parallel import paropen |
| 5 |
|
| 6 |
|
| 7 |
def read_mol(fileobj, index=-1): |
| 8 |
if isinstance(fileobj, str): |
| 9 |
fileobj = open(fileobj)
|
| 10 |
|
| 11 |
lines = fileobj.readlines() |
| 12 |
del(lines[:3]) |
| 13 |
L1 = lines[0].split()
|
| 14 |
del(lines[0]) |
| 15 |
natoms = int(L1[0]) |
| 16 |
positions = [] |
| 17 |
symbols = [] |
| 18 |
for line in lines[:natoms]: |
| 19 |
x, y, z, symbol = line.split()[:4]
|
| 20 |
symbols.append(symbol) |
| 21 |
positions.append([float(x), float(y), float(z)]) |
| 22 |
return Atoms(symbols=symbols, positions=positions)
|
| 23 |
|