def test_floating_sphere_finite_freq(): sphere = generate_sphere(radius=1.0, ntheta=6, nphi=12, clip_free_surface=True) sphere.dofs["Heave"] = sphere.faces_normals @ (0, 0, 1) solver = Nemoh() problem = RadiationProblem(body=sphere, omega=1.0, sea_bottom=-np.infty) mass, damping = solver.solve(problem, keep_details=True) assert np.isclose(mass, 1819.6, atol=1e-3 * sphere.volume * problem.rho) assert np.isclose(damping, 379.39, atol=1e-3 * sphere.volume * problem.rho) free_surface = generate_free_surface(width=125, length=125, nw=5, nl=5) eta = solver.get_free_surface(problem, free_surface, dof="Heave") ref = np.array( [[ -0.4340802E-02 - 0.4742809E-03j, -0.7986111E-03 + 0.4840984E-02j, 0.2214827E-02 + 0.4700642E-02j, -0.7986111E-03 + 0.4840984E-02j, -0.4340803E-02 - 0.4742807E-03j ], [ -0.7986111E-03 + 0.4840984E-02j, 0.5733187E-02 - 0.2179381E-02j, 0.9460892E-03 - 0.7079404E-02j, 0.5733186E-02 - 0.2179381E-02j, -0.7986110E-03 + 0.4840984E-02j ], [ 0.2214827E-02 + 0.4700643E-02j, 0.9460892E-03 - 0.7079403E-02j, -0.1381670E-01 + 0.6039315E-01j, 0.9460892E-03 - 0.7079405E-02j, 0.2214827E-02 + 0.4700643E-02j ], [ -0.7986111E-03 + 0.4840984E-02j, 0.5733186E-02 - 0.2179381E-02j, 0.9460891E-03 - 0.7079404E-02j, 0.5733187E-02 - 0.2179380E-02j, -0.7986113E-03 + 0.4840984E-02j ], [ -0.4340803E-02 - 0.4742807E-03j, -0.7986111E-03 + 0.4840984E-02j, 0.2214827E-02 + 0.4700643E-02j, -0.7986113E-03 + 0.4840983E-02j, -0.4340803E-02 - 0.4742809E-03j ]]) assert np.allclose(eta.reshape((5, 5)), ref, rtol=1e-4) problem = DiffractionProblem(body=sphere, omega=1.0, sea_bottom=-np.infty) force = Nemoh().solve(problem) assert np.isclose(force, 1834.9 * np.exp(-2.933j) * -1j, rtol=1e-3)
# Initialize mesh and solver sphere = generate_clever_sphere(radius=5, ntheta=40, nphi=40, z0=-1.0, clip_free_surface=True) solver = Nemoh() # Solve diffraction problem problem = DiffractionProblem(body=sphere, angle=0.0, omega=2.0) results = solver.solve(problem, keep_details=True) # Compute free surface elevation fs_mesh = generate_free_surface(width=100.0, length=100.0, nw=100, nl=100) fs = solver.get_free_surface(problem, fs_mesh) # Add incoming waves fs = fs + 1j * problem.omega / problem.g * problem.Airy_wave_potential( fs_mesh.faces_centers) # Plot free surface elevation X = fs_mesh.faces_centers[:, 0].reshape(100, 100) Y = fs_mesh.faces_centers[:, 1].reshape(100, 100) fs = fs.reshape(100, 100) scale = np.abs(fs).max() fig = plt.figure() ax = plt.gca() nbi = 40 # Number of images in the animation