Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

actually test power solution for irregular wave #327

Merged
Merged
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a5459a6
Merge commit 'd3497e352a069470cba8645444e52958a9b4400f'
ryancoe Mar 16, 2022
dc63ad8
Merge commit '6f11bd30fa0fcde98a0c67ecb41b8407a20fe381'
ryancoe Mar 23, 2022
4671cde
Merge remote-tracking branch 'upstream/main'
ryancoe Apr 7, 2022
91bf3e2
Merge commit '7132f8ea404dc5f006b7191164e70794eb767c5f'
ryancoe Apr 12, 2022
ae4a807
Merge remote-tracking branch 'upstream/main'
ryancoe Jun 16, 2022
5f36d5b
Merge remote-tracking branch 'upstream/main'
ryancoe Oct 25, 2022
5dc756d
Merge remote-tracking branch 'upstream/main'
ryancoe Nov 1, 2022
06b0650
Merge remote-tracking branch 'upstream/main'
ryancoe Nov 2, 2022
0c043f6
Merge remote-tracking branch 'upstream/main'
ryancoe Nov 22, 2022
e6e9a5a
Merge remote-tracking branch 'upstream/main'
ryancoe Nov 23, 2022
f599401
Merge remote-tracking branch 'upstream/main'
ryancoe Dec 8, 2022
828b26a
Merge remote-tracking branch 'upstream/main'
ryancoe Dec 16, 2022
d53fefe
Merge commit 'abb2097c910db0aac04e398acd6bc29a240adde6'
ryancoe Dec 28, 2022
84de794
Merge remote-tracking branch 'upstream/main'
ryancoe Jan 4, 2023
f11963f
Merge remote-tracking branch 'upstream/main'
ryancoe Jan 31, 2023
fdbd233
Merge remote-tracking branch 'upstream/main'
ryancoe Feb 22, 2023
76f1eaa
Merge remote-tracking branch 'upstream/main'
ryancoe Apr 11, 2023
c83bc45
Merge remote-tracking branch 'upstream/main'
ryancoe Apr 13, 2023
cdd3aa5
Merge remote-tracking branch 'upstream/main'
ryancoe May 5, 2023
b48465c
Merge remote-tracking branch 'sandialabs/main'
ryancoe May 25, 2023
84793cc
Merge remote-tracking branch 'sandialabs/main'
ryancoe Jul 13, 2023
6c9b852
Merge remote-tracking branch 'upstream/main'
ryancoe Oct 6, 2023
c36083a
Merge commit 'c74e4fcb1084d1a21c1709aee38005da935194a7'
ryancoe Oct 19, 2023
0d04f32
Merge commit 'e5e291f848f41589e0b63affe04726d1b49720c5'
ryancoe Nov 1, 2023
eeed5a9
Merge commit '618d7ebad0166cbc3a62371c3713bba8bc2348e1'
ryancoe Nov 13, 2023
2ef25f4
Merge remote-tracking branch 'upstream/main'
ryancoe Feb 5, 2024
7c7f452
use long_crested irregular wave
ryancoe Apr 2, 2024
4099c1f
loosen tolerance
ryancoe Apr 2, 2024
0b489f7
update docstring
ryancoe Apr 2, 2024
f462c68
remove unused argument
ryancoe Apr 2, 2024
561e1aa
Merge remote-tracking branch 'upstream/dev' into test_unstructured_co…
ryancoe Apr 2, 2024
014ca33
use consistent damping shift
ryancoe Apr 2, 2024
2e4f4c4
Merge commit '775d2734de3e1280e52675cbeaa1ab6192af0eb9' into test_uns…
ryancoe Apr 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,18 @@ def regular_wave(f1, nfreq):


@pytest.fixture(scope='module')
def irregular_wave(f1, nfreq):
def long_crested_wave(f1, nfreq):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this is actually a long_crested_wave in our nomenclature

"""Idealized (Pierson-Moskowitz) spectrum wave"""
freq = wot.frequency(f1, nfreq, False)
fp = 0.3
hs = 0.0625*1.9
spec = wot.waves.pierson_moskowitz_spectrum(freq, fp, hs)
waves = wot.waves.long_crested_wave(spec)
spec_fun = lambda f: wot.waves.pierson_moskowitz_spectrum(freq=f,
fp=fp,
hs=hs)
efth = wot.waves.omnidirectional_spectrum(f1=f1, nfreq=nfreq,
spectrum_func=spec_fun,
)
waves = wot.waves.long_crested_wave(efth, nrealizations=1)
return waves


Expand Down Expand Up @@ -234,7 +239,9 @@ def hstiff(self, fb):
def hydro_impedance(self, bem):
"""Intrinsic hydrodynamic impedance"""
hd = wot.add_linear_friction(bem)
hd = wot.check_linear_damping(hd)
rad = bem['radiation_damping']
min_damping = rad.where(rad>0)[-25:].mean()
hd = wot.check_linear_damping(hd, min_damping=min_damping)
ryancoe marked this conversation as resolved.
Show resolved Hide resolved
Zi = wot.hydrodynamic_impedance(hd)
return Zi

Expand Down Expand Up @@ -301,11 +308,12 @@ def test_pi_controller_regular_wave(self,
power_optimal = (np.abs(Fex)**2/8 / np.real(hydro_impedance.squeeze())
).squeeze().sum('omega').item()

assert power_sol == approx(power_optimal, rel=1e-4)
def test_unstructured_controller_irregular_wave(self,
assert power_sol == approx(power_optimal, rel=1e-1)
ryancoe marked this conversation as resolved.
Show resolved Hide resolved

def test_unstructured_controller_long_crested_wave(self,
fb,
bem,
regular_wave,
long_crested_wave,
pto,
nfreq,
hydro_impedance):
Expand All @@ -315,7 +323,7 @@ def test_unstructured_controller_irregular_wave(self,
f_add = {"PTO": pto.force_on_wec}
wec = wot.WEC.from_bem(bem, f_add=f_add)

res = wec.solve(waves=regular_wave,
res = wec.solve(waves=long_crested_wave,
obj_fun=pto.average_power,
nstate_opt=2*nfreq,
x_wec_0=1e-1*np.ones(wec.nstate_wec),
Expand All @@ -326,13 +334,15 @@ def test_unstructured_controller_irregular_wave(self,

power_sol = -1*res[0]['fun']

res_fd, _ = wec.post_process(res[0], regular_wave.sel(realization=0), nsubsteps=1)
res_fd, _ = wec.post_process(res[0],
long_crested_wave.sel(realization=0),
nsubsteps=1)
Fex = res_fd.force.sel(
type=['Froude_Krylov', 'diffraction']).sum('type')
power_optimal = (np.abs(Fex)**2/8 / np.real(hydro_impedance.squeeze())
).squeeze().sum('omega').item()

assert power_sol == approx(power_optimal, rel=1e-3)
assert power_sol == approx(power_optimal, rel=1e-1)

def test_saturated_pi_controller(self,
bem,
Expand Down