def test_thickness_property_collection(example_model_with_properties: Model): # Arrange grid = example_model_with_properties.grid() extent = grid.extent_kji property_collection = grid.property_collection thickness_array = np.random.random(extent) property_collection.add_cached_array_to_imported_list( thickness_array, 'test data', 'DZ', False, uom=grid.z_units(), property_kind='cell length', facet_type='direction', indexable_element='cells', facet='K') property_collection.write_hdf5_for_imported_list() property_collection.create_xml_for_imported_list_and_add_parts_to_model() if hasattr(grid, 'array_thickness'): delattr(grid, 'array_thickness') # Act thickness = cp.thickness(grid, property_collection=property_collection) # Assert np.testing.assert_array_almost_equal(thickness, thickness_array)
def test_volume_multiple_property_collection( example_model_with_properties: Model): # Arrange grid = example_model_with_properties.grid() extent = grid.extent_kji property_collection = grid.property_collection volume_array_gross = np.random.random(extent) property_collection.add_cached_array_to_imported_list( volume_array_gross, 'test data', 'DZ', property_kind='rock volume', facet_type='netgross', facet='gross') volume_array_net = np.random.random(extent) / 2 property_collection.add_cached_array_to_imported_list( volume_array_net, 'test data', 'DZ', property_kind='rock volume', facet_type='netgross', facet='net') property_collection.write_hdf5_for_imported_list() property_collection.create_xml_for_imported_list_and_add_parts_to_model() if hasattr(grid, 'array_volume'): delattr(grid, 'array_volume') # Act volume = cp.volume(grid, property_collection=property_collection) # Assert np.testing.assert_array_almost_equal(volume, volume_array_gross)
def test_face_centre_invalid_axis(example_model_with_properties: Model): # Arrange grid = example_model_with_properties.grid() cell = (1, 1, 1) axis = 4 zero_or_one = 0 # Act & Assert with pytest.raises(ValueError): ff.face_centre(grid, cell, axis, zero_or_one)
def test_volume_from_points(example_model_with_properties: Model): # Arrange grid = example_model_with_properties.grid() if hasattr(grid, 'array_volume'): delattr(grid, 'array_thickness') if hasattr(grid, 'property_volume'): delattr(grid, 'property_collection') # Act volume = cp.volume(grid) # Assert np.testing.assert_array_almost_equal(volume, 100000.0)
def test_thickness_from_points(example_model_with_properties: Model): # Arrange grid = example_model_with_properties.grid() if hasattr(grid, 'array_thickness'): delattr(grid, 'array_thickness') if hasattr(grid, 'property_collection'): delattr(grid, 'property_collection') # Act thickness = cp.thickness(grid) # Assert np.testing.assert_array_almost_equal(thickness, 20.0)
def faulted_grid(test_data_path) -> Grid: current_filename = os.path.split(getsourcefile(lambda: 0))[0] base_folder = os.path.dirname(os.path.dirname(current_filename)) epc_file = base_folder + '/test_data/wren/wren.epc' model = Model(epc_file=epc_file) return model.grid(title='faulted grid')