Esempio n. 1
0
 def __init__(self, filename, name=""):
     """
     attempts to open the given trajectory
     :param filename: the file name
     :param name: the trajectory name inside the file, as given in the simulation
     """
     assert _os.path.exists(
         filename), "The file '{}' did not exist!".format(filename)
     self._filename = filename
     self._name = name
     self._diffusion_constants = _io_utils.get_diffusion_constants(filename)
     self._particle_types = _io_utils.get_particle_types(filename)
     self._reactions = []
     self._inverse_types_map = {
         v: k
         for k, v in self.particle_types.items()
     }
     self._general = GeneralInformation(filename)
     for _, reaction in _io_utils.get_reactions(filename).items():
         info = ReactionInfo(reaction["name"], reaction["id"],
                             reaction["n_educts"], reaction["n_products"],
                             reaction["rate"], reaction["educt_distance"],
                             reaction["product_distance"],
                             reaction["educt_types"],
                             reaction["product_types"],
                             self._inverse_types_map)
         self._reactions.append(info)
Esempio n. 2
0
    def test_particle_types_info(self):
        p_types = ioutils.get_particle_types(self.fname)
        # assuming that type ids are in accordance to order of registration
        np.testing.assert_equal(p_types["A"], 0)
        np.testing.assert_equal(p_types["B"], 1)
        np.testing.assert_equal(p_types["C"], 2)

        diff_constants = ioutils.get_diffusion_constants(self.fname)
        np.testing.assert_equal(diff_constants["A"], 1.)
        np.testing.assert_equal(diff_constants["B"], 2.)
        np.testing.assert_equal(diff_constants["C"], 3.)
Esempio n. 3
0
    def test_particle_types_info(self):
        p_types = ioutils.get_particle_types(self.fname)
        # assuming that type ids are in accordance to order of registration
        np.testing.assert_equal(p_types["A"], 0)
        np.testing.assert_equal(p_types["B"], 1)
        np.testing.assert_equal(p_types["C"], 2)

        diff_constants = ioutils.get_diffusion_constants(self.fname)
        np.testing.assert_equal(diff_constants["A"], 1.)
        np.testing.assert_equal(diff_constants["B"], 2.)
        np.testing.assert_equal(diff_constants["C"], 3.)
Esempio n. 4
0
 def __init__(self, filename, name=""):
     """
     attempts to open the given trajectory
     :param filename: the file name
     :param name: the trajectory name inside the file, as given in the simulation
     """
     assert _os.path.exists(filename), "The file '{}' did not exist!".format(filename)
     self._filename = filename
     self._name = name
     self._diffusion_constants = _io_utils.get_diffusion_constants(filename)
     self._particle_types = _io_utils.get_particle_types(filename)
     self._reactions = []
     self._inverse_types_map = {v: k for k, v in self.particle_types.items()}
     self._general = GeneralInformation(filename)
     for _, reaction in _io_utils.get_reactions(filename).items():
         info = ReactionInfo(reaction["name"], reaction["id"], reaction["n_educts"],
                             reaction["n_products"], reaction["rate"], reaction["educt_distance"],
                             reaction["product_distance"], reaction["educt_types"], reaction["product_types"],
                             self._inverse_types_map)
         self._reactions.append(info)