示例#1
0
def test_serialization():
    cl = Molecule([Atom.from_fields(type='Cl', r=[0.0, 0.0, 0.0])])
    jsonstr =  cl.tojson()
    assert Molecule.from_json(jsonstr).tojson() == jsonstr

    na = Molecule([Atom('Na', [0.0, 0.0, 0.0])])
    cl = Molecule([Atom('Cl', [0.0, 0.0, 0.0])])

    # Fract position of Na and Cl, space group 255
    tsys = crystal([[0.0, 0.0, 0.0],[0.5, 0.5, 0.5]], [na, cl], 225, repetitions=[3,3,3])
    jsonstr = tsys.tojson()

    assert System.from_json(jsonstr).tojson() == jsonstr
示例#2
0
def test_serialization():
    cl = Molecule([Atom.from_fields(type="Cl", r=[0.0, 0.0, 0.0])])
    jsonstr = cl.to_json()
    m = Molecule.from_json(jsonstr)
    eq_(Molecule.from_json(jsonstr).to_json(), jsonstr)

    na = Molecule([Atom("Na", [0.0, 0.0, 0.0])])
    cl = Molecule([Atom("Cl", [0.0, 0.0, 0.0])])

    # Fract position of Na and Cl, space group 255
    tsys = crystal([[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]], [na, cl], 225, repetitions=[3, 3, 3])
    jsonstr = tsys.to_json()

    eq_(System.from_json(jsonstr).to_json(), jsonstr)
示例#3
0
def test_serialization():
    cl = Molecule([Atom.from_fields(type='Cl', r=[0.0, 0.0, 0.0])])
    jsonstr = cl.tojson()
    assert Molecule.from_json(jsonstr).tojson() == jsonstr

    na = Molecule([Atom('Na', [0.0, 0.0, 0.0])])
    cl = Molecule([Atom('Cl', [0.0, 0.0, 0.0])])

    # Fract position of Na and Cl, space group 255
    tsys = crystal([[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]], [na, cl],
                   225,
                   repetitions=[3, 3, 3])
    jsonstr = tsys.tojson()

    assert System.from_json(jsonstr).tojson() == jsonstr
示例#4
0
def test_serialization():
    cl = Molecule([Atom.from_fields(type='Cl', r=[0.0, 0.0, 0.0])])
    jsonstr = cl.to_json()
    m = Molecule.from_json(jsonstr)
    eq_(Molecule.from_json(jsonstr).to_json(), jsonstr)

    na = Molecule([Atom('Na', [0.0, 0.0, 0.0])])
    cl = Molecule([Atom('Cl', [0.0, 0.0, 0.0])])

    # Fract position of Na and Cl, space group 255
    tsys = crystal([[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]], [na, cl],
                   225,
                   repetitions=[3, 3, 3])
    jsonstr = tsys.to_json()

    npeq_(System.from_json(jsonstr).r_array, tsys.r_array)