def test_Atoms_copy_from_aseAtoms(): """Tests the mothed Atoms.copy_from() to copy from an ase.atoms """ from ase.atoms import Atoms as aseAtoms from matdb.atoms import Atoms from numpy import array_equal at1 = aseAtoms("Co3W2V3",positions=[[0,0,0],[0.25,0.25,0.25],[0.5,0.5,0],[1.75,1.75,1.25], [1.5,1,1.5],[2.75,2.25,2.75],[2,2.5,2.5],[2.25,2.75,2.75]], cell=[5.43,5.43,5.43]) at1.info['nneightol'] = 1112 at1.info['cutoff'] = 521 at1.info['cutoff_break'] = 1042 at2 = Atoms() at2.copy_from(at1) assert at2.info["params"]['nneightol'] == at1.info['nneightol'] assert at2.info["params"]['cutoff'] == at1.info['cutoff'] assert at2.info["params"]['cutoff_break'] == at1.info['cutoff_break'] # make sure the symbols and positions are still match assert at1.get_chemical_symbols() == at2.get_chemical_symbols() assert array_equal(at1.positions, at2.positions) assert array_equal(at1.cell, at2.cell)
def test_Atoms_copy_from(): """Tests the mothed Atoms.copy_from to copy from an matdb.atoms """ from matdb.atoms import Atoms from numpy import array_equal at1 = Atoms("Co3W2V3",positions=[[0,0,0],[0.25,0.25,0.25],[0.5,0.5,0],[1.75,1.75,1.25], [1.5,1,1.5],[2.75,2.25,2.75],[2,2.5,2.5],[2.25,2.75,2.75]], cell=[5.43,5.43,5.43],info={"rand":10, "params":{"vasp_energy": 1234}, "properties":{}}) at1.__setattr__("magnetic_moments", [1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9]) at2 = Atoms() at2.copy_from(at1) assert at1.info["params"] == at2.info["params"] assert at1.info["properties"] == at2.info["properties"] # make sure the symbols and positions are still match assert at1.get_chemical_symbols() == at2.get_chemical_symbols() assert array_equal(at1.positions, at2.positions) assert array_equal(at1.cell, at2.cell)