Ejemplo n.º 1
0
def varied_test_struc():
    struc = Structure(np.eye(3),
                      species=[1, 2, 2, 3, 3, 4, 4, 4, 4, 3],
                      positions=np.array(
                          [np.random.uniform(-1, 1, 3) for i in range(10)]))
    struc.forces = np.array([np.random.uniform(-1, 1, 3) for _ in range(10)])
    return struc
Ejemplo n.º 2
0
def test_struc_to_ase():
    uc = Structure(
        species=["Pd" for i in range(10)] + ["Ag" for i in range(10)],
        positions=np.random.rand(20, 3),
        cell=np.random.rand(3, 3),
    )

    uc.forces = np.random.randn(20, 3)
    uc.energy = np.random.rand()
    uc.stress = np.random.randn(6)

    new_atoms = Structure.to_ase_atoms(uc)
    assert np.all(uc.species_labels == new_atoms.get_chemical_symbols())
    assert np.all(uc.positions == new_atoms.get_positions())
    assert np.all(uc.cell == new_atoms.get_cell())
    assert np.all(new_atoms.get_forces() == uc.forces)
    assert np.all(new_atoms.get_potential_energy() == uc.energy)
    assert np.all(new_atoms.get_stress() == uc.stress)