Ejemplo n.º 1
0
def test_lmp_parse_image_skew_fail():
    name = 'lmp_parse_other'
    target = ["\n",
              "4 atoms\n",
              "2 atom types\n",
              "\n",
              "0 5 xlo xhi\n",
              "0 5 ylo yhi\n",
              "0 5 zlo zhi\n",
              "1 2 3 xy xz yz\n",
              "\n",
              "Masses\n",
              "\n",
              "1 22.99 #Na\n",
              "2 34.99 #Cl\n",
              "\n",
              "Atoms\n",
              "\n",
              "1 1 0.0 0.0 0.0 0 0 0\n",
              "2 1 2.5 2.5 0.0 0 0 0\n",
              "3 2 0.0 2.5 0.0 0 0 0\n",
              "4 2 2.5 0.0 0.0 0 0 0\n",
              "\n"]
    Mol, _ = lammpsData.parser(name, target)
    assert Mol.nat == 4
    assert float_equal(Mol.getCellDim(fmt='angstrom'), 1)
    assert vec_equal(Mol.getVec(), ((5, 0, 0), (1, 5, 0), (2, 3, 5)))
    failtarget = ["\n",
                  "4 atoms\n",
                  "2 atom types\n",
                  "\n",
                  "0 5 xlo xhi\n",
                  "0 5 ylo yhi\n",
                  "0 5 zlo zhi\n",
                  "1 2 3 xy xz yz\n",
                  "\n",
                  "Masses\n",
                  "\n",
                  "1 22.99\n",
                  "2 34.99\n",
                  "\n",
                  "Atoms\n",
                  "\n",
                  "1 1 0.0 0.0 0.0 0 0 0\n",
                  "2 1 2.5 2.5 0.0 0 0 0\n",
                  "3 2 0.0 2.5 0.0 0 0 0\n",
                  "4 2 2.5 0.0 0.0 0 0 0\n",
                  "\n"]
    try:
        Mol, _ = lammpsData.parser(name, failtarget)
    except NotImplementedError:
        assert True
    except:
        assert False
    else:
        assert False
Ejemplo n.º 2
0
def test_lmp_parse_atomstyles():
    name = "lmp_parse"
    head = ["\n",
            "4 atoms\n",
            "2 atom types\n",
            "\n",
            "0 5 xlo xhi\n",
            "0 5 ylo yhi\n",
            "0 5 zlo zhi\n",
            "\n",
            "Masses\n",
            "\n",
            "1 22.99 #Na\n",
            "2 34.99 #Cl\n",
            "\n"]
    atoms = [["Atoms # atomic\n",
              "\n",
              "1 1 0.0 0.0 0.0\n",
              "2 1 2.5 2.5 0.0\n",
              "3 2 0.0 2.5 0.0\n",
              "4 2 2.5 0.0 0.0\n",
              "\n"],
             ["Atoms\n",
              "\n",
              "1 1 0.0 0.0 0.0\n",
              "2 1 2.5 2.5 0.0\n",
              "3 2 0.0 2.5 0.0\n",
              "4 2 2.5 0.0 0.0\n",
              "\n"],
             ["Atoms\n",
              "\n",
              "1 1 1 0.0 0.0 0.0\n",
              "2 1 1 2.5 2.5 0.0\n",
              "3 1 2 0.0 2.5 0.0\n",
              "4 1 2 2.5 0.0 0.0\n",
              "\n"],
             ["Atoms # bond\n",
              "\n",
              "1 1 1 0.0 0.0 0.0\n",
              "2 1 1 2.5 2.5 0.0\n",
              "3 1 2 0.0 2.5 0.0\n",
              "4 1 2 2.5 0.0 0.0\n",
              "\n"],
             ["Atoms\n",
              "\n",
              "1 1 1  1 0.0 0.0 0.0\n",
              "2 1 1  1 2.5 2.5 0.0\n",
              "3 1 2 -1 0.0 2.5 0.0\n",
              "4 1 2 -1 2.5 0.0 0.0\n",
              "\n"],
             ["Atoms # full\n",
              "\n",
              "1 1 1  1 0.0 0.0 0.0\n",
              "2 1 1  1 2.5 2.5 0.0\n",
              "3 1 2 -1 0.0 2.5 0.0\n",
              "4 1 2 -1 2.5 0.0 0.0\n",
              "\n"],
             ]
    for a in atoms:
        Mol, _ = lammpsData.parser(name, head + a)
        assert Mol.nat == 4
        assert Mol.ntyp == 2
        assert Mol.getTypes() == ['Na', 'Cl']
        assert Mol.pse['Cl']['m'] == 34.99
        assert float_equal(Mol.getCellDim(fmt='angstrom'), 1)
        assert vec_equal(Mol.getVec(), ((5, 0, 0), (0, 5, 0), (0, 0, 5)))
        assert list(map(len, Mol.getBonds(1.1))) == [4, 2, 2, 0, 0, 0, 0, 0]
        assert atom_equal(Mol.getAtom(0), ['Na', [0, 0, 0]])
        assert atom_equal(Mol.getAtom(1), ['Na', [2.5, 2.5, 0]])
        assert atom_equal(Mol.getAtom(2), ['Cl', [0, 2.5, 0]])
        assert atom_equal(Mol.getAtom(3), ['Cl', [2.5, 0, 0]])
    assert atom_equal(Mol.getAtom(0, charge=True), ['Na', [0, 0, 0], 1.])
    assert atom_equal(Mol.getAtom(2, charge=True), ['Cl', [0, 2.5, 0], -1.0])