コード例 #1
0
ファイル: test_vessel.py プロジェクト: chemgymrl/chemgymrl
 def test__update_material_dict(self):
     vessel = Vessel("test")
     material_dict = {
         'H2O': [material.H2O, 100, 'mol'],
         'C6H14': [material.C6H14, 30, 'mol']
     }
     event = ['update material dict', material_dict]
     vessel.push_event_to_queue(feedback=[event], dt=0)
     self.assertIn('H2O', vessel.get_material_dict())
コード例 #2
0
    def update_vessel(self, new_vessel: vessel.Vessel):
        """
        Method to initialize a vessel and reset the environment to properly populate the vessel.

        Parameters
        ---------------
        `new_vessel` : `vessel.Vessel`
            The vessel that has been requested to be updated.

        Returns
        ---------------
        None

        Raises
        ---------------
        None
        """

        # set up a new, empty n array intended to contain the vessel materials
        new_n = np.zeros(self.reaction.nmax.shape[0], dtype=np.float32)

        # acquire the appropriate material dictionary from the inputted vessel
        mat_dict = util.convert_material_dict_units(
            new_vessel.get_material_dict())

        # iterate through the material dictionary populating the n array
        for i, mat in enumerate(self.reaction.materials):
            if mat in mat_dict:
                amount = mat_dict[mat][1]
                new_n[i] = amount

        # set the inputted vessel as the vessels variable
        self.vessels = new_vessel

        # modify the vessel appropriately and reset the reaction environment
        self.vessels = self.reaction.reset(self.vessels)