Skip to content

Commit

Permalink
change from_ase_atoms to cast
Browse files Browse the repository at this point in the history
  • Loading branch information
YuuuXie committed Oct 19, 2020
1 parent f577a67 commit af8947d
Showing 1 changed file with 3 additions and 32 deletions.
35 changes: 3 additions & 32 deletions flare/ase/atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,9 @@ def from_ase_atoms(atoms):
Args:
atoms (ASE Atoms): the ase atoms to build from
"""
kw = [
"symbols", # use either "symbols" or "number"
"positions",
"tags",
"momenta",
"masses",
"magmoms",
"charges",
"scaled_positions",
"cell",
"pbc",
"celldisp",
"constraint",
"calculator",
"info",
"velocities",
]

# The keywords are either the attr of atoms, or in dict atoms.arrays
kwargs = {}
for key in kw:
try:
kwargs[key] = getattr(atoms, key)
except:
if key in atoms.arrays:
kwargs[key] = atoms.get_array(key)
kwargs["calculator"] = atoms.calc
new_atoms = FLARE_Atoms(**kwargs)

for key in atoms.arrays:
new_atoms.set_array(key, atoms.get_array(key))

new_atoms = deepcopy(atoms)
new_atoms.__class__ = FLARE_Atoms
new_atoms.prev_positions = np.zeros_like(new_atoms.positions)
return new_atoms

@property
Expand Down

0 comments on commit af8947d

Please sign in to comment.