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

move delta-ml beaker files to this git repo

parent 1edbd392
container=ae5fbce12ee3
docker cp $container:/home/beaker/notebooks/ex1-molecules/molkrr/ml_chemical_space.bkr python-modules/molkrr/
container=ae5fbce12ee3
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 source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
# ----- Experimental code taken from ASE -----
from ase import Atoms
class XYZError(IOError):
pass
def iterchunks(fd):
"""Yield unprocessed chunks (header, lines) for each xyz image."""
while True:
line = next(fd).strip() # Raises StopIteration on empty file
try:
natoms = int(line)
except ValueError:
raise XYZError('Expected integer, found "{0}"'.format(line))
try:
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()
symbols.append(tokens[0])
positions.append([float(x) for x in tokens[1:]])
if len(symbols) > 0 and symbols[0].isdigit():
numbers = symbols
symbols = None
else:
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