def write_atoms(fn, this, cycfn=None, conv=<NUM_LIT:1.0>, symbols=True):
f = paropen(fn, "<STR_LIT:w>")<EOL>f.write("<STR_LIT>")<EOL>f.write("<STR_LIT>" % len(this))<EOL>f.write("<STR_LIT>")<EOL>f.write("<STR_LIT>" % <NUM_LIT:0.0>)<EOL>f.write("<STR_LIT>")<EOL>groups = None<EOL>if this.has("<STR_LIT>"):<EOL><INDENT>groups = this.get_array("<STR_LIT>")<EOL><DEDENT>gamma = None<EOL>if this.has("<STR_LIT>"):<EOL><INDENT>gamma = this.get_array("<STR_LIT>")<EOL><DEDENT>T = None<EOL>if this.has("<STR_LIT:T>"):<EOL><INDENT>T = this.get_array("<STR_LIT:T>")<EOL><DEDENT>for idx, i in enumerate(this):<EOL><INDENT>group_str = "<STR_LIT:1>"<EOL>if groups is not None:<EOL><INDENT>group_str = "<STR_LIT>" % groups[idx]<EOL><DEDENT>gamma_str = "<STR_LIT>"<EOL>if gamma is not None:<EOL><INDENT>gamma_str = "<STR_LIT>" % gamma[idx]<EOL><DEDENT>T_str = "<STR_LIT>"<EOL>if T is not None:<EOL><INDENT>T_str = "<STR_LIT>" % T[idx]<EOL><DEDENT>sym = i.symbol<EOL>r = i.position<EOL>if symbols:<EOL><INDENT>f.write("<STR_LIT>" % (sym, ase.data.atomic_masses[ase.data.chemical_symbols.index(sym)], r[<NUM_LIT:0>]*conv, r[<NUM_LIT:1>]*conv, r[<NUM_LIT:2>]*conv, group_str, gamma_str, T_str))<EOL><DEDENT>else:<EOL><INDENT>f.write("<STR_LIT>" % (ase.data.chemical_symbols.index(sym), ase.data.atomic_masses[ase.data.chemical_symbols.index(sym)], r[<NUM_LIT:0>]*conv, r[<NUM_LIT:1>]*conv, r[<NUM_LIT:2>]*conv, group_str, gamma_str, T_str))<EOL><DEDENT><DEDENT>f.write("<STR_LIT>")<EOL>for i in this:<EOL><INDENT>m = i.mass<EOL>if m is None:<EOL><INDENT>m = ase.data.atomic_masses[ase.data.chemical_symbols.index(i.symbol)]<EOL><DEDENT>if i.momentum is not None:<EOL><INDENT>v = i.momentum/m<EOL><DEDENT>else:<EOL><INDENT>v = [ <NUM_LIT:0.0>, <NUM_LIT:0.0>, <NUM_LIT:0.0> ]<EOL><DEDENT>f.write("<STR_LIT>" % ( v[<NUM_LIT:0>], v[<NUM_LIT:1>], v[<NUM_LIT:2>] ))<EOL><DEDENT>f.write("<STR_LIT>")<EOL>for i in this:<EOL><INDENT>f.write("<STR_LIT>")<EOL><DEDENT>f.write("<STR_LIT>")<EOL>cell = this.get_cell()<EOL>f.write("<STR_LIT>" % tuple(cell[<NUM_LIT:0>, :]))<EOL>f.write("<STR_LIT>" % tuple(cell[<NUM_LIT:1>, :]))<EOL>f.write("<STR_LIT>" % tuple(cell[<NUM_LIT:2>, :]))<EOL>for name, aux in this.arrays.items():<EOL><INDENT>if not name in atoms_default_fields:<EOL><INDENT>f.write("<STR_LIT>" % name)<EOL>if aux.dtype == int:<EOL><INDENT>if len(aux.shape) == <NUM_LIT:1>:<EOL><INDENT>for i in this:<EOL><INDENT>f.write("<STR_LIT>" % aux[i.index])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for i in this:<EOL><INDENT>f.write(( aux.shape[<NUM_LIT:1>]*"<STR_LIT>" + "<STR_LIT:\n>" ) % tuple(aux[i.index].tolist()))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if len(aux.shape) == <NUM_LIT:1>:<EOL><INDENT>for i in this:<EOL><INDENT>f.write("<STR_LIT>" % aux[i.index])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for i in this:<EOL><INDENT>f.write(( aux.shape[<NUM_LIT:1>]*"<STR_LIT>" + "<STR_LIT:\n>" ) % tuple(aux[i.index].tolist()))<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>f.close()<EOL>if cycfn:<EOL><INDENT>write_cyc(cycfn, this, conv=conv)<EOL><DEDENT>
Write atom information to an atoms.dat file (i.e., tblmd, MDCORE input file)