def __init__(self, *, body=None, free_surface=_default_parameters['free_surface'], sea_bottom=-_default_parameters['water_depth'], omega=_default_parameters['omega'], rho=_default_parameters['rho'], g=_default_parameters['g'], wave_direction=0.0, convention=_default_parameters['convention']): self.wave_direction = wave_direction self.convention = convention super().__init__(body=body, free_surface=free_surface, sea_bottom=sea_bottom, omega=omega, rho=rho, g=g) if not (-2*np.pi-1e-3 <= self.wave_direction <= 2*np.pi+1e-3): LOG.warning(f"The value {self.wave_direction} has been provided for the wave direction, and it does not look like an angle in radians. " "The wave direction in Capytaine is defined in radians and not in degrees, so the result might not be what you expect. " "If you were actually giving an angle in radians, use the modulo operator to give a value between -2π and 2π to disable this warning.") if self.body is not None: self.boundary_condition = -( airy_waves_velocity(self.body.mesh.faces_centers, self, convention=self.convention) * self.body.mesh.faces_normals ).sum(axis=1) if len(self.body.dofs) == 0: LOG.warning(f"The body {self.body.name} used in diffraction problem has no dofs!")
def __init__(self, *, body=None, free_surface=_default_parameters['free_surface'], sea_bottom=-_default_parameters['water_depth'], omega=_default_parameters['omega'], rho=_default_parameters['rho'], g=_default_parameters['g'], wave_direction=0.0, convention=_default_parameters['convention']): self.wave_direction = wave_direction self.convention = convention super().__init__(body=body, free_surface=free_surface, sea_bottom=sea_bottom, omega=omega, rho=rho, g=g) if self.body is not None: self.boundary_condition = -(airy_waves_velocity( self.body.mesh.faces_centers, self, convention=self.convention) * self.body.mesh.faces_normals).sum( axis=1) if len(self.body.dofs) == 0: LOG.warning( f"The body {self.body.name} used in diffraction problem has no dofs!" )
def __attrs_post_init__(self): from capytaine.bem.airy_waves import airy_waves_velocity if self.body is not None: self.boundary_condition = -(airy_waves_velocity( self.body.mesh.faces_centers, self, convention=self.convention) * self.body.mesh.faces_normals).sum( axis=1) if len(self.body.dofs) == 0: LOG.warning( f"The body {self.body.name} used in diffraction problem has no dofs!" )
rad_solution = solver.solve(rad_problem) # Read mesh properties faces_centers = body.mesh.faces_centers faces_normals = body.mesh.faces_normals faces_areas = body.mesh.faces_areas from capytaine.bem.airy_waves import airy_waves_potential, airy_waves_velocity, froude_krylov_force # Computation from the diffraction solution (Capytaine) FK = froude_krylov_force(diff_problem)['Heave'] diff_force = diff_solution.forces['Heave'] # Get potentials phi_inc = airy_waves_potential(faces_centers, diff_problem) v_inc = airy_waves_velocity(faces_centers, diff_problem) phi_rad = rad_solution.potential # Indirect computation from the radiation solution, via the Haskind relation integrand = -(phi_inc * faces_normals[:, 2] - phi_rad * np.diag(v_inc @ faces_normals.T)) F_hask = 1j * omega * rho * np.sum(integrand * faces_areas) # Direct integration of the potentials diff_force_recomputed = -1j * omega * rho * np.sum( diff_solution.potential * faces_areas * faces_normals[:, 2]) FK_recomputed = -1j * omega * rho * np.sum( phi_inc * faces_areas * faces_normals[:, 2]) print('Result from Capytaine = ', FK + diff_force) print('Result from recomputed direct integration',