Example #1
0
logging.basicConfig(level=logging.INFO,
                    format="%(levelname)s:\t%(message)s")

# Generate body
body = cpt.HorizontalCylinder(
    length=3.0, radius=1.0,  # Dimensions
    center=(0, 0, -1.01),     # Position
    nr=5, nx=15, ntheta=30,   # Fineness of the mesh
)
body.add_translation_dof(name="Heave")

test_matrix = xr.Dataset(coords={
    'omega': np.linspace(0.5, 4, 40),
    'radiating_dof': list(body.dofs.keys()),
})

ds2 = cpt.BEMSolver(green_function=cpt.XieDelhommeau()).fill_dataset(test_matrix, body)
ds1 = cpt.BEMSolver(green_function=cpt.Delhommeau()).fill_dataset(test_matrix, body)

plt.figure()
ds1['added_mass'].plot(x='omega', label='Delhommeau')
ds2['added_mass'].plot(x='omega', label='XieDelhommeau')
plt.legend()

plt.figure()
ds1['radiation_damping'].plot(x='omega', label='Delhommeau')
ds2['radiation_damping'].plot(x='omega', label='XieDelhommeau')
plt.legend()

plt.show()
Example #2
0
    length=3.0,
    radius=1.0,  # Dimensions
    center=(0, 0, -1.01),  # Position
    nr=5,
    nx=15,
    ntheta=30,  # Fineness of the mesh
)
body.add_translation_dof(name="Heave")

test_matrix = xr.Dataset(coords={
    'omega': np.linspace(0.5, 4, 40),
    'radiating_dof': list(body.dofs.keys()),
})

ds2 = cpt.BEMSolver(green_function=cpt.XieDelhommeau()).fill_dataset(
    test_matrix, [body])
ds1 = cpt.BEMSolver(green_function=cpt.Delhommeau()).fill_dataset(
    test_matrix, [body])

plt.figure()
ds1['added_mass'].plot(x='omega', label='Delhommeau')
ds2['added_mass'].plot(x='omega', label='XieDelhommeau')
plt.legend()

plt.figure()
ds1['radiation_damping'].plot(x='omega', label='Delhommeau')
ds2['radiation_damping'].plot(x='omega', label='XieDelhommeau')
plt.legend()

plt.show()
Example #3
0
import numpy as np
import capytaine as cpt

# Generate the mesh of a cylinder
cylinder = cpt.HorizontalCylinder(
    length=10.0,
    radius=1.0,  # Dimensions
    center=(0, 0, -2),  # Position
    nr=1,
    nx=8,
    ntheta=6,  # Fineness of the mesh
)

engine = cpt.BasicMatrixEngine()
green_function = cpt.Delhommeau()

S, K = engine.build_matrices(
    cylinder.mesh,
    cylinder.mesh,
    free_surface=0.0,
    sea_bottom=-np.infty,
    wavenumber=1.0,
    green_function=green_function,
)

# Plot the absolute value of the matrix S
import matplotlib.pyplot as plt
plt.imshow(abs(S.full_matrix()))
plt.colorbar()
plt.title("$|S|$")
Example #4
0
import numpy as np
import capytaine as cpt

vert = np.array([
    0.0, 0.0, -1.0, 1.0, 0.0, -1.0, 1.0, 1.0, -1.0, 0.0, 1.0, -1.0, 1.0, 0.0,
    -1.0, 2.0, 0.0, -1.0, 2.0, 1.0, -1.0, 1.0, 1.0, -1.0
]).reshape((8, 3))
faces = np.arange(0, 8).reshape(2, 4)
mesh = cpt.Mesh(vert, faces)
S, K = cpt.Delhommeau().evaluate(mesh,
                                 mesh,
                                 sea_bottom=-np.infty,
                                 wavenumber=1.0)
print(S)
print(K)