コード例 #1
0
ファイル: test_vessel.py プロジェクト: chemgymrl/chemgymrl
 def test_heat_change(self):
     vessel = Vessel("test", materials={'H2O': [material.H2O, 100, 'mol']})
     new_vessel = Vessel("test_2",
                         materials={'H2O': [material.H2O, 100, 'mol']})
     temp = vessel.get_temperature()
     event = ["change_heat", 10, new_vessel]
     vessel.push_event_to_queue(feedback=[event], dt=0)
     self.assertLess(temp, vessel.get_temperature())
コード例 #2
0
ファイル: test_vessel.py プロジェクト: chemgymrl/chemgymrl
 def test_wait(self):
     vessel = Vessel("test", materials={'H2O': [material.H2O, 100, 'mol']})
     new_vessel = Vessel("test_2",
                         materials={'H2O': [material.H2O, 100, 'mol']})
     temp = vessel.get_temperature()
     event = ["change_heat", 10, new_vessel]
     vessel.push_event_to_queue(feedback=[event], dt=0)
     self.assertLess(temp, vessel.get_temperature())
     event = ["wait", temp, new_vessel, True]
     vessel.push_event_to_queue(feedback=[event], dt=0)
     self.assertEqual(temp, vessel.get_temperature())
     event = ["wait", temp + 30, new_vessel, False]
     vessel.push_event_to_queue(feedback=[event], dt=10)
     self.assertLess(temp, vessel.get_temperature())
コード例 #3
0
ファイル: test_vessel.py プロジェクト: chemgymrl/chemgymrl
 def test__update_temperature(self):
     vessel = Vessel("test")
     initial_temp = vessel.get_temperature()
     event = ['temperature change', 400, True]
     vessel.push_event_to_queue(feedback=[event], dt=0)
     self.assertEqual(vessel.get_temperature(), 400)
コード例 #4
0
ファイル: reaction_base.py プロジェクト: chemgymrl/chemgymrl
    def plotting_step(self, t, tmax, vessels: vessel.Vessel):
        '''
        Set up a method to handle the acquisition of the necessary plotting parameters
        from an input vessel.

        Parameters
        ---------------
        `t` : `float`
            Current amount of time
        `tmax` : `float`
            Maximum time allowed
        `vessels` : `vessel.Vessel`
            A vessel containing methods to acquire the necessary parameters

        Returns
        ---------------
        `plot_data_state` : `list`
            A list containing the states to be plotted such as time,
            temperature, volume, pressure, and reactant amounts
        `plot_data_mol` : `list`
            A list containing the molar amounts of reactants and products
        `plot_data_concentration` : `list`
            A list containing the concentration of reactants and products

        Raises
        ---------------
        None
        '''

        # acquire the necessary parameters from the vessel
        T = vessels.get_temperature()
        V = vessels.get_volume()
        # V = 0.0025

        # create containers to hold the plotting parameters
        plot_data_state = [[], [], [], []]
        plot_data_mol = [[] for _ in range(self.n.shape[0])]
        plot_data_concentration = [[] for _ in range(self.n.shape[0])]

        # Record time data
        plot_data_state[0].append(t / tmax)

        # record temperature data
        Tmin = vessels.get_Tmin()
        Tmax = vessels.get_Tmax()
        plot_data_state[1].append((T - Tmin) / (Tmax - Tmin))

        # record volume data
        Vmin = vessels.get_min_volume()
        Vmax = vessels.get_max_volume()
        plot_data_state[2].append((V - Vmin) / (Vmax - Vmin))

        # record pressure data
        P = vessels.get_pressure()
        plot_data_state[3].append(P / vessels.get_pmax())

        # calculate and record the molar concentrations of the reactants and products
        C = vessels.get_concentration(materials=self.materials)
        for j in range(self.n.shape[0]):
            plot_data_mol[j].append(self.n[j])
            plot_data_concentration[j].append(C[j])

        return plot_data_state, plot_data_mol, plot_data_concentration