Example #1
0
def test_two_distant_spheres_in_finite_depth():
    radius = 0.5
    resolution = 4
    perimeter = 2 * np.pi * radius
    buoy = Sphere(radius=radius,
                  center=(0.0, 0.0, 0.0),
                  ntheta=int(perimeter * resolution / 2),
                  nphi=int(perimeter * resolution),
                  clip_free_surface=True,
                  clever=False,
                  name="buoy")
    other_buoy = buoy.translated_x(20, name="other_buoy")
    both_buoys = buoy.join_bodies(other_buoy)
    both_buoys.add_translation_dof(name="Surge")
    problem = RadiationProblem(body=both_buoys,
                               radiating_dof="Surge",
                               sea_bottom=-10,
                               omega=7.0)
    result = solver.solve(problem)

    total_volume = 2 * 4 / 3 * np.pi * radius**3
    assert np.isclose(result.added_masses['Surge'],
                      124.0,
                      atol=1e-3 * total_volume * problem.rho)
    assert np.isclose(result.radiation_dampings['Surge'],
                      913.3,
                      atol=1e-3 * total_volume * problem.rho)
Example #2
0
def test_low_rank_matrices():
    radius = 1.0
    resolution = 2
    perimeter = 2 * np.pi * radius
    buoy = Sphere(radius=radius,
                  center=(0.0, 0.0, 0.0),
                  ntheta=int(perimeter * resolution / 2),
                  nphi=int(perimeter * resolution),
                  clip_free_surface=True,
                  clever=False,
                  name=f"buoy")
    buoy.add_translation_dof(name="Heave")
    two_distant_buoys = FloatingBody.join_bodies(buoy, buoy.translated_x(20))
    two_distant_buoys.mesh._meshes[1].name = "other_buoy_mesh"

    S, V = solver_with_sym.build_matrices(two_distant_buoys.mesh,
                                          two_distant_buoys.mesh)
    assert isinstance(S.all_blocks[0, 1], LowRankMatrix)
    assert isinstance(S.all_blocks[1, 0], LowRankMatrix)
    # S.plot_shape()

    problem = RadiationProblem(body=two_distant_buoys,
                               omega=1.0,
                               radiating_dof="buoy__Heave")
    result = solver_with_sym.solve(problem)
    result2 = solver_without_sym.solve(problem)

    assert np.isclose(result.added_masses['buoy__Heave'],
                      result2.added_masses['buoy__Heave'],
                      atol=10.0)
    assert np.isclose(result.radiation_dampings['buoy__Heave'],
                      result2.radiation_dampings['buoy__Heave'],
                      atol=10.0)