예제 #1
0
 def test__pour_by_volume(self):
     vessel = Vessel("test", materials={"H2O": [material.H2O, 100, 'mol']})
     initial_volume = vessel.get_current_volume()
     event = ['pour by volume', Vessel('test_2'), 0.1]
     vessel.push_event_to_queue(feedback=[event], dt=0)
     final_volume = vessel.get_current_volume()
     self.assertLess(final_volume[1], initial_volume[1])
예제 #2
0
 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())
예제 #3
0
 def test_save_load(self):
     vessel = Vessel("test",
                     materials={
                         'Na': [material.Na, 1, 'mol'],
                         'H2O': [material.H2O, 1, 'mol']
                     })
     vessel.save_vessel("test")
     new_vessel = Vessel("test")
     new_vessel.load_vessel("test.pickle")
     os.remove("test.pickle")
예제 #4
0
 def test__drain_by_pixel_less(self):
     vessel = Vessel("test",
                     materials={
                         'C6H14': [material.C6H14, 1, 'mol'],
                         'H2O': [material.H2O, 1, 'mol']
                     })
     initial_volume = vessel.get_current_volume()
     vessel2 = Vessel('test_2')
     event = ['drain by pixel', vessel2, 10]
     vessel.push_event_to_queue(events=[event], dt=1)
     final_volume = vessel.get_current_volume()
     self.assertLess(final_volume[1], initial_volume[1])
예제 #5
0
 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())
예제 #6
0
 def test_get_material_position(self):
     vessel = Vessel("test",
                     materials={
                         'C6H14': [material.C6H14, 1, 'mol'],
                         'H2O': [material.H2O, 1, 'mol']
                     })
     vessel.get_material_position("H2O")
예제 #7
0
 def test__mix(self):
     vessel = Vessel("test",
                     materials={
                         'Na': [material.Na, 1, 'mol'],
                         'H2O': [material.H2O, 1, 'mol']
                     })
     event = ['mix', 10]
     vessel.push_event_to_queue(feedback=[event], dt=0)
예제 #8
0
 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())
예제 #9
0
 def test__update_solute_dict(self):
     vessel = Vessel("test",
                     materials={
                         'Na': [material.Na, 100, 'mol'],
                         'H2O': [material.H2O, 1, 'mol']
                     })
     solute_dict = {'Na': {'H2O': [material.H2O, 100, 'mol']}}
     event = ['update solute dict', solute_dict]
     vessel.push_event_to_queue(feedback=[event], dt=0)
     self.assertIn('Na', vessel.get_solute_dict())
예제 #10
0
 def create_new_vessel(self):
     """
     This function simple creates a new vessel and adds it to the shelf
     Returns
     -------
     None
     """
     index = self.open_slot
     assert index < self.max_num_vessels
     self.vessels.append(Vessel(label=index))
     self.open_slot += 1
예제 #11
0
 def __init__(self,
              max_num_vessels: int,
              vessel_paths: [np.array, list] = None):
     """
     initializes the shelf class
     Parameters
     ----------
     max_num_vessels: int: the maximum number of vessels that the shelf can store
     vessel_paths: a list of paths to vessel pickle files that are to be initialized into the shelf
     """
     # the next available slot for inserting a vessel
     self.open_slot = 0
     # maximum number of vessels that can be stored in the shelf
     self.max_num_vessels = max_num_vessels
     # a list that keeps all the vessels
     self.vessels = []
     if vessel_paths:
         for i, path in enumerate(vessel_paths):
             # function to load vessels from the path
             self.vessels[i] = Vessel(label=i)
             self.vessels[i].load_vessel(path)
         self.open_slot = len(vessel_paths)
예제 #12
0
 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)
예제 #13
0
 def test_analyze(self):
     char_bench = CharacterizationBench()
     vessel = Vessel("test", materials={'Na': [material.Na, 1, 'mol']})
     analysis = char_bench.analyze(vessel, 'spectra')
     self.assertEqual(len(analysis[0]), 200)
예제 #14
0
 def test_return_vessel_to_shelf(self):
     test_vessel = Vessel('test')
     shelf = Shelf(100)
     shelf.return_vessel_to_shelf(test_vessel)
     self.assertEqual(shelf.open_slot, 1)
     self.assertEqual(len(shelf.vessels), 1)