def test_fill_dataset_with_kochin_functions(): solver = Nemoh() test_matrix = xr.Dataset( coords={ 'omega': [1.0], 'theta': np.linspace(0, 2 * pi, 5), 'radiating_dof': list(sphere.dofs.keys()), }) ds = solver.fill_dataset(test_matrix, [sphere]) assert 'theta' in ds.coords assert 'kochin' in ds
def test_fill_dataset(): solver = Nemoh() test_matrix = xr.Dataset( coords={ 'omega': np.linspace(0.1, 4.0, 3), 'wave_direction': np.linspace(0.0, pi, 3), 'radiating_dof': list(sphere.dofs.keys()), 'rho': [1025.0], 'water_depth': [np.infty, 10.0] }) dataset = solver.fill_dataset(test_matrix, [sphere]) # Tests on the coordinates assert list(dataset.coords['influenced_dof']) == list( dataset.coords['radiating_dof']) == list(sphere.dofs.keys()) assert dataset.body_name == sphere.name assert dataset.rho == test_matrix.rho # Tests on the results assert 'added_mass' in dataset assert 'radiation_damping' in dataset assert 'Froude_Krylov_force' in dataset assert 'diffraction_force' in dataset # Test the attributes assert dataset.attrs['capytaine_version'] == __version__ assert 'start_of_computation' in dataset.attrs assert 'cache_rankine_matrices' in dataset.attrs assert 'incoming_waves_convention' in dataset.attrs # Try to strip out the outputs and recompute naked_data = dataset.drop([ "added_mass", "radiation_damping", "diffraction_force", "Froude_Krylov_force" ]) recomputed_dataset = solver.fill_dataset(naked_data, [sphere]) assert recomputed_dataset.rho == dataset.rho assert "added_mass" in recomputed_dataset assert np.allclose(recomputed_dataset["added_mass"].data, dataset["added_mass"].data)