Beispiel #1
0
 def test_bond_to_json_loop(self, typed_ethane, are_equivalent_atoms):
     for bond in typed_ethane.bonds:
         bond_json = bond.json()
         bond_copy = Bond.parse_raw(bond_json)
         assert bond_copy.name == bond.name
         for member1, member2 in zip(bond.connection_members,
                                     bond_copy.connection_members):
             assert are_equivalent_atoms(member1, member2)
         assert bond_copy.bond_type == bond.bond_type
Beispiel #2
0
    def test_bond_every_field_set(self, full_atom_type, are_equivalent_atoms):
        atom1 = Atom(
            name="test_atom1",
            label="test_label1",
            position=[0.0, 0.0, 0.0],
            charge=1.5,
            mass=2.0,
            element=element_by_symbol("C"),
            atom_type=full_atom_type,
        )

        atom2 = Atom(
            name="test_atom1",
            label="test_label1",
            position=[0.1, 0.4, 0.5],
            charge=5,
            mass=2.6,
            element=element_by_symbol("H"),
            atom_type=full_atom_type,
        )

        bond = Bond(name="test_bond1", connection_members=(atom1, atom2))

        bond_type = BondType(
            name="test_bond_type",
            expression="a*b+c**2",
            parameters={
                "a": 10 * u.nm,
                "b": 20 * u.angstrom
            },
            independent_variables={"c"},
        )

        bond_copy = Bond.parse_raw(bond.json())
        assert bond_copy.name == bond.name
        for member1, member2 in zip(bond.connection_members,
                                    bond_copy.connection_members):
            assert are_equivalent_atoms(member1, member2)
        assert bond_copy.bond_type == bond.bond_type