Skip to content

Commit

Permalink
Correct boat_animation example (capytaine#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdillenburg authored Nov 16, 2023
1 parent 26926f1 commit f6a6e85
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions docs/user_manual/examples/boat_animation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
from numpy import pi as π
from numpy import pi

import capytaine as cpt
from capytaine.bem.airy_waves import airy_waves_free_surface_elevation
Expand Down Expand Up @@ -39,15 +38,15 @@ def setup_animation(body, fs, omega, wave_amplitude, wave_direction):
diffraction_elevation = bem_solver.compute_free_surface_elevation(fs, diffraction_result)

# Compute the wave pattern radiated by the RAO
radiation_elevations_per_dof = {res.radiating_dof: bem_solver.compute_free_surface_elevation(fs, diffraction_result) for res in radiation_results}
radiation_elevations_per_dof = {res.radiating_dof: bem_solver.compute_free_surface_elevation(fs, res) for res in radiation_results}
radiation_elevation = sum(rao.sel(omega=omega, radiating_dof=dof).data * radiation_elevations_per_dof[dof] for dof in body.dofs)

# SET UP ANIMATION
# Compute the motion of each face of the mesh for the animation
rao_faces_motion = sum(rao.sel(omega=omega, radiating_dof=dof).data * body.dofs[dof] for dof in body.dofs)

# Set up scene
animation = Animation(loop_duration=2*π/omega)
animation = Animation(loop_duration=2*pi/omega)
animation.add_body(body, faces_motion=wave_amplitude*rao_faces_motion)
animation.add_free_surface(fs, wave_amplitude * (incoming_waves_elevation + diffraction_elevation + radiation_elevation))
return animation
Expand All @@ -57,6 +56,6 @@ def setup_animation(body, fs, omega, wave_amplitude, wave_direction):
body = generate_boat()
fs = cpt.FreeSurface(x_range=(-100, 75), y_range=(-100, 75), nx=100, ny=100)

anim = setup_animation(body, fs, omega=1.5, wave_amplitude=0.5, wave_direction=π)
anim = setup_animation(body, fs, omega=1.5, wave_amplitude=0.5, wave_direction=pi)
anim.run(camera_position=(70, 70, 100), resolution=(800, 600))
anim.save("animated_boat.ogv", camera_position=(70, 70, 100), resolution=(800, 600))

0 comments on commit f6a6e85

Please sign in to comment.