def read_atoms(fn, cycfn=None, pos_only=False, conv=<NUM_LIT:1.0>):
f = paropen(fn, "<STR_LIT:r>")<EOL>l = f.readline().lstrip()<EOL>while len(l) > <NUM_LIT:0> and ( l[<NUM_LIT:0>] == '<STR_LIT:#>' or l[<NUM_LIT:0>] == '<STR_LIT:<>' ):<EOL><INDENT>l = f.readline().lstrip()<EOL><DEDENT>n_atoms = int(l)<EOL>l = f.readline().lstrip()<EOL>while len(l) > <NUM_LIT:0> and ( l[<NUM_LIT:0>] == '<STR_LIT:#>' or l[<NUM_LIT:0>] == '<STR_LIT:<>' ):<EOL><INDENT>l = f.readline().lstrip()<EOL><DEDENT>l = f.readline().lstrip()<EOL>while len(l) > <NUM_LIT:0> and ( l[<NUM_LIT:0>] == '<STR_LIT:#>' or l[<NUM_LIT:0>] == '<STR_LIT:<>' ):<EOL><INDENT>l = f.readline().lstrip()<EOL><DEDENT>forces = np.zeros( [ n_atoms, <NUM_LIT:3> ] )<EOL>groups = np.zeros( [ n_atoms ] )<EOL>gamma  = np.zeros( [ n_atoms ] )<EOL>T      = np.zeros( [ n_atoms ] )<EOL>ats = [ ]<EOL>for i in range(n_atoms):<EOL><INDENT>s = l.split()<EOL>sym = None<EOL>try:<EOL><INDENT>Z    = int(s[<NUM_LIT:0>])<EOL>sym  = ase.data.chemical_symbols[Z]<EOL><DEDENT>except:<EOL><INDENT>sym  = s[<NUM_LIT:0>]<EOL><DEDENT>a = ase.Atom(sym, ( float(s[<NUM_LIT:2>])*conv, float(s[<NUM_LIT:3>])*conv, float(s[<NUM_LIT:4>])*conv ) )<EOL>groups[i] = int(s[<NUM_LIT:5>])<EOL>gamma[i]  = float(s[<NUM_LIT:6>])<EOL>T[i]      = float(s[<NUM_LIT:7>])<EOL>ats += [ a ]<EOL>l = f.readline()<EOL><DEDENT>this = ase.Atoms(ats, pbc=True)<EOL>if not pos_only:<EOL><INDENT>while l and l == "<STR_LIT>":<EOL><INDENT>l = f.readline().strip()<EOL><DEDENT>while l:<EOL><INDENT>key = l.strip("<STR_LIT>")<EOL>if key.upper() == "<STR_LIT>":<EOL><INDENT>for i in range(n_atoms):<EOL><INDENT>s = f.readline().split()<EOL>m = this[i].mass<EOL>if m is None:<EOL><INDENT>m = ase.data.atomic_masses[ase.data.chemical_symbols.index(this[i].symbol)]<EOL><DEDENT>this[i].momentum = ( m*float(s[<NUM_LIT:0>]), m*float(s[<NUM_LIT:1>]), m*float(s[<NUM_LIT:2>]) )<EOL><DEDENT>l = None<EOL><DEDENT>elif key.upper() == "<STR_LIT>":<EOL><INDENT>for i in range(n_atoms):<EOL><INDENT>s = f.readline().split()<EOL>forces[i] =  np.array( [ float(s[<NUM_LIT:0>]), float(s[<NUM_LIT:1>]), float(s[<NUM_LIT:2>]) ] )<EOL><DEDENT>l = None<EOL><DEDENT>elif key.upper() == "<STR_LIT>":<EOL><INDENT>for i in this:<EOL><INDENT>l = f.readline()<EOL>if l and len(l.split()) == <NUM_LIT:1>:<EOL><INDENT>i.charge = float(l)<EOL><DEDENT><DEDENT>l = None<EOL><DEDENT>elif key.upper() == "<STR_LIT>" or key.upper().split()[<NUM_LIT:0>:<NUM_LIT:2>] == ("<STR_LIT>", "<STR_LIT>" ):<EOL><INDENT>l1 = f.readline()<EOL>l2 = f.readline()<EOL>l3 = f.readline()<EOL>this.set_cell( [ [float(x) for x in l1.split()],<EOL>[float(x) for x in l2.split()],<EOL>[float(x) for x in l3.split()] ] )<EOL>l = None<EOL><DEDENT>else:<EOL><INDENT>aux = [ ]<EOL>l = f.readline().strip()<EOL>while l and l[<NUM_LIT:0>] not in [ '<STR_LIT:<>', '<STR_LIT:#>' ]:<EOL><INDENT>s = l.split()<EOL>aux += [ [float(x) for x in s] ]<EOL>l = f.readline().strip()<EOL><DEDENT>if len(aux) == n_atoms:<EOL><INDENT>this.set_array(key, np.asarray(aux))<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>" % key)<EOL><DEDENT><DEDENT>if l is None:<EOL><INDENT>l = f.readline().strip()<EOL><DEDENT>while l and l == "<STR_LIT>":<EOL><INDENT>l = f.readline().strip()<EOL><DEDENT><DEDENT><DEDENT>f.close()<EOL>this.set_array("<STR_LIT>", forces)<EOL>this.set_array("<STR_LIT>", groups)<EOL>this.set_array("<STR_LIT>", gamma)<EOL>this.set_array("<STR_LIT:T>", T)<EOL>if cycfn:<EOL><INDENT>read_cyc(this, cycfn, conv=conv)<EOL><DEDENT>return this<EOL>
Read atom information from an atoms.dat file (i.e., tblmd, MDCORE input file)