Skip to content

Commit

Permalink
fixed transfer function matrix math errorr
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelcdevin committed Oct 31, 2023
1 parent 7a5f5bd commit 5adbf15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
12 changes: 6 additions & 6 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ def nfreq_imp():
@pytest.fixture(scope="module")
def rao(ndof_imp, nfreq_imp):
"""Synthetic RAO transfer matrix."""
rao = np.empty([ndof_imp, ndof_imp, nfreq_imp], dtype=complex)
rao[0, 0, :] = [0+1j, 0+2j]
rao[1, 0, :] = [1+1j, 11+2j]
rao[0, 1, :] = [2+1j, 22+2j]
rao[1, 1, :] = [3+1j, 33+2j]
rao = np.empty([nfreq_imp, ndof_imp, ndof_imp], dtype=complex)
rao[:, 0, 0] = [0+1j, 0+2j]
rao[:, 1, 0] = [1+1j, 11+2j]
rao[:, 0, 1] = [2+1j, 22+2j]
rao[:, 1, 1] = [3+1j, 33+2j]
return rao


Expand Down Expand Up @@ -576,7 +576,7 @@ def test_behavior(self,):
i in range(np.size(x)-1)], -1),
[np.real(z[-1]) * np.real(x[-1])],
])
Z_mimo = wot.mimo_transfer_mat(np.reshape([z], [1,1,-1]), False)
Z_mimo = wot.mimo_transfer_mat(np.reshape([z], [-1, 1,1]), False)
assert np.allclose(Z_mimo @ X, F)


Expand Down
5 changes: 2 additions & 3 deletions wecopttool/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1963,8 +1963,7 @@ def force_from_impedance(
--------
force_from_rao_transfer_function,
"""
omega0 = np.expand_dims(omega, [1,2])
return force_from_rao_transfer_function(impedance*(1j*omega0), False)
return force_from_rao_transfer_function(impedance*(1j*omega), False)


def force_from_waves(force_coeff: ArrayLike,
Expand Down Expand Up @@ -2000,7 +1999,7 @@ def inertia(
Inertia matrix.
"""
omega = np.expand_dims(frequency(f1, nfreq, False)*2*np.pi, [1,2])
inertia_matrix = np.expand_dims(inertia_matrix, -1)
inertia_matrix = np.expand_dims(inertia_matrix, 0)
rao_transfer_function = -1*omega**2*inertia_matrix + 0j
inertia_fun = force_from_rao_transfer_function(
rao_transfer_function, False)
Expand Down

0 comments on commit 5adbf15

Please sign in to comment.