def test_region_properties(self): region = Region(parent=None, name="Test Region") property = MockProperty() region.add_property(property) self.assertEqual(len(region.properties), 1) self.assertRaises(KeyError, region.add_property, property)
def test_oil_in_place_calculation(self): seed = 300 n = 1 model = Model("Simple Model", 666) area = RandomProperty(name="Area", n=n, random_number_function=mock_random) porosity = RandomProperty(name="Porosity", n=n, random_number_function=mock_random) sw = RandomProperty(name="Sw", n=n, random_number_function=mock_random) config = {"Region A": {"Area": {"value": 2.0}, "Porosity": {"value": 0.5}, "Sw": {"value": 0.1}}, "Region B": {"Area": {"value": 1.0}, "Porosity": {"value": 0.5}, "Sw": {"value": 0.1}}} #oil in place region a should be 2.0*0.5*(1-0.1) = 1.0*0.9 = 0.9 #oil in place region b should be 1.0*0.5*(1-0.1) = 0.5*0.9 = 0.45 model.add_property(area) model.add_property(porosity) model.add_property(sw) region_a = Region(name="Region A") region_b = Region(name="Region B") model.add_region(region_a) model.add_region(region_b) model.add_defined_properties_to_regions() model.run(config) model.add_regional_property("ooip", OriginalOilInPlace) for region_name, region in model.regions.items(): if region_name is "Region A": self.assertAlmostEqual(np.sum(region.properties["ooip"].values), n*0.9, 4) else: self.assertAlmostEqual(np.sum(region.properties["ooip"].values), n*0.45, 4) region.properties["ooip"].calculate_property_statistics() self.assertNotEqual(region.properties["ooip"].p10, None) self.assertNotEqual(region.properties["ooip"].p50, None) self.assertNotEqual(region.properties["ooip"].p90, None) ooip = ModelOriginalOilInPlace(model) ooip.generate_values() self.assertAlmostEqual(np.sum(ooip.values), n*(0.9+0.45), 4) ooip.calculate_property_statistics() self.assertNotEqual(ooip.p10, None) self.assertNotEqual(ooip.p50, None) self.assertNotEqual(ooip.p90, None)
def test_region(self): # Test Basic Functionality parent_a = Region(parent=None, name="Test Region") self.assertEquals(parent_a.name, "Test Region") self.assertEquals(parent_a.parent, None) child = Region(parent=parent_a, name="Child Region") self.assertEquals(child.parent, parent_a) parent_b = Region(parent=None, name="Test Region B") child.parent = parent_b self.assertNotEqual(child.parent, parent_a) self.assertEqual(child.parent, parent_b)
def test_region_output(self): region = Region(parent=None, name="Test Region") self.assertEqual(region.__str__(), "Region Name: Test Region")
def __init__(self, *args, **kwargs): Region.__init__(self, *args, **kwargs)