Commit 226f8dc6 authored by Ask Hjorth Larsen's avatar Ask Hjorth Larsen
Browse files

move delta-ml beaker files to this git repo

parent 1edbd392
docker cp $container:/home/beaker/notebooks/ex1-molecules/molkrr/ml_chemical_space.bkr python-modules/molkrr/
docker cp python-modules/molkrr $container:/home/beaker/notebooks/ex1-molecules/
docker exec $container chown -R beaker.beaker /home/beaker/notebooks/ex1-molecules/molkrr
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# ----- Experimental code taken from ASE -----
from ase import Atoms
class XYZError(IOError):
def iterchunks(fd):
"""Yield unprocessed chunks (header, lines) for each xyz image."""
while True:
line = next(fd).strip() # Raises StopIteration on empty file
natoms = int(line)
except ValueError:
raise XYZError('Expected integer, found "{0}"'.format(line))
header = next(fd)
lines = [next(fd) for _ in range(natoms)]
except StopIteration:
raise XYZError('Incomplete XYZ chunk')
yield header, lines
def chunk2atoms(header, lines):
"""Convert unprocessed chunk into Atoms."""
symbols = []
positions = []
for line in lines:
tokens = line.split()
positions.append([float(x) for x in tokens[1:]])
if len(symbols) > 0 and symbols[0].isdigit():
numbers = symbols
symbols = None
numbers = None
return Atoms(symbols=symbols, numbers=numbers, positions=positions)
def iread_xyz(fd):
"""Yield all images from file."""
for header, lines in iterchunks(fd):
yield chunk2atoms(header, lines)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment