コード例 #1
0
def test_potential():
    sphere = cpt.Sphere(radius=1.0, ntheta=3, nphi=12, clip_free_surface=True)
    sphere.add_translation_dof(name="Heave")
    solver = cpt.BEMSolver()
    result = solver.solve(cpt.RadiationProblem(body=sphere, omega=1.0), keep_details=True)
    free_surface = cpt.FreeSurface(x_range=(-100, 100), nx=5, y_range=(-100, 100), ny=5)
    eta = solver.get_potential_on_mesh(result, free_surface.mesh, chunk_size=3)
コード例 #2
0
# Set up and solve problem
solver = cpt.BEMSolver()

diffraction_problem = cpt.DiffractionProblem(body=sphere,
                                             wave_direction=0.0,
                                             omega=2.0)
diffraction_result = solver.solve(diffraction_problem)

radiation_problem = cpt.RadiationProblem(body=sphere,
                                         radiating_dof="Heave",
                                         omega=2.0)
radiation_result = solver.solve(radiation_problem)

# Define a mesh of the free surface and compute the free surface elevation
free_surface = cpt.FreeSurface(x_range=(-50, 50),
                               y_range=(-50, 50),
                               nx=150,
                               ny=150)
diffraction_elevation_at_faces = solver.get_free_surface_elevation(
    diffraction_result, free_surface)
radiation_elevation_at_faces = solver.get_free_surface_elevation(
    radiation_result, free_surface)

# Add incoming waves
diffraction_elevation_at_faces = diffraction_elevation_at_faces + free_surface.incoming_waves(
    diffraction_result)

# Run the animations
# animation = Animation(loop_duration=diffraction_result.period)
# animation.add_body(full_sphere, faces_motion=None)
# animation.add_free_surface(free_surface, faces_elevation=0.5*diffraction_elevation_at_faces)
# animation.run(camera_position=(-30, -30, 30))  # The camera is oriented towards (0, 0, 0) by default.
コード例 #3
0
    # SET UP ANIMATION
    animation = Animation(loop_duration=2 * pi / omega)
    animation.add_body(body.full_body,
                       faces_motion=wave_amplitude * rao_faces_motion)
    animation.add_free_surface(
        fs,
        wave_amplitude * (incoming_waves_elevation + diffraction_elevation +
                          rao_radiation_elevation))
    return animation


if __name__ == '__main__':
    body = generate_boat()
    fs = cpt.FreeSurface(x_range=(-100, 100),
                         y_range=(-100, 100),
                         nx=100,
                         ny=100)

    wave_direction = 0.0
    omega = 1.5

    anim = setup_animation(body,
                           fs,
                           omega=omega,
                           wave_amplitude=0.5,
                           wave_direction=wave_direction)
    anim.run(camera_position=(-60, -60, 90), resolution=(800, 600))

    filename = f"{body.name}__omega_{omega:.2f}__beta_{wave_direction:.2f}.ogv"
    filepath = Path.cwd() / filename
    # anim.save(str(filepath), camera_position=(60, 60, 90), resolution=(800, 600))