From 9f1046f0e40cd31e1004ec94f68b9a9c567c688a Mon Sep 17 00:00:00 2001 From: Lucas-Carmo Date: Fri, 8 Nov 2024 11:05:22 -0700 Subject: [PATCH 1/3] Replacing np.complex_ by np.complex128 Due to AttributeError: `np.complex_` was removed in the NumPy 2.0 release. Use `np.complex128` instead. --- .github/workflows/CI_RAFT.yml | 4 ++-- raft/raft_rotor.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI_RAFT.yml b/.github/workflows/CI_RAFT.yml index 8e42ff8..9391a35 100644 --- a/.github/workflows/CI_RAFT.yml +++ b/.github/workflows/CI_RAFT.yml @@ -15,8 +15,8 @@ jobs: strategy: fail-fast: false #true matrix: - os: ["ubuntu-latest", "macOS-latest", "windows-latest"] - python-version: ["3.10", "3.11"] + os: ["ubuntu-latest"] + python-version: ["3.10"] steps: - name: checkout repository diff --git a/raft/raft_rotor.py b/raft/raft_rotor.py index 2785ec2..56743c1 100644 --- a/raft/raft_rotor.py +++ b/raft/raft_rotor.py @@ -870,7 +870,7 @@ def calcAero(self, case, current=False, display=0): b_inflow[0,0,:] = dT_dU # Excitation vector - f_inflow = np.zeros([6,len(self.w)], dtype=np.complex_) + f_inflow = np.zeros([6,len(self.w)], dtype=np.complex128) f_inflow[0,:] = dT_dU*self.V_w # Rotate to global orientations @@ -895,10 +895,10 @@ def calcAero(self, case, current=False, display=0): a_aer = np.zeros_like(self.w) b_aer = np.zeros_like(self.w) - C = np.zeros_like(self.w,dtype=np.complex_) - C2 = np.zeros_like(self.w,dtype=np.complex_) - D = np.zeros_like(self.w,dtype=np.complex_) - E = np.zeros_like(self.w,dtype=np.complex_) + C = np.zeros_like(self.w,dtype=np.complex128) + C2 = np.zeros_like(self.w,dtype=np.complex128) + D = np.zeros_like(self.w,dtype=np.complex128) + E = np.zeros_like(self.w,dtype=np.complex128) # Roots of characteristic equation, helps w/ debugging # p = np.array([-self.I_drivetrain, (dQ_dOm + self.kp_beta * dQ_dPi - self.Ng * kp_tau), self.ki_beta* dQ_dPi - self.Ng * ki_tau]) From 331f82564ead61efb9c097bb21b77eaf7654ff1e Mon Sep 17 00:00:00 2001 From: Lucas-Carmo Date: Fri, 8 Nov 2024 11:41:05 -0700 Subject: [PATCH 2/3] Interp2d deprecated. Replaced by RegularGridInterpolator Maybe there's a better option? RegularGridInterpolator is more convoluted than Interp2d --- raft/raft_fowt.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/raft/raft_fowt.py b/raft/raft_fowt.py index 8db58fe..e31242b 100644 --- a/raft/raft_fowt.py +++ b/raft/raft_fowt.py @@ -3,7 +3,7 @@ import os import matplotlib.pyplot as plt import numpy as np -from scipy.interpolate import interp1d, interp2d, griddata +from scipy.interpolate import interp1d, RegularGridInterpolator, griddata import raft.member2pnl as pnl from raft.helpers import * @@ -1788,10 +1788,15 @@ def calcHydroForce_2ndOrd(self, beta, S0, iCase=None, iWT=None, interpMode='qtf' else: f = np.zeros([self.nDOF, self.nw]) # Force amplitude for idof in range(0,self.nDOF): - # Interpolate the QTF matrix to the same frequencies as the wave spectrum. Need to interpolate real and imaginary part separately. - qtf_interp_Re = interp2d(self.w1_2nd, self.w1_2nd, qtf_interpBeta[:,:, idof].real, bounds_error=False, fill_value=(0))(self.w, self.w) - qtf_interp_Im = interp2d(self.w1_2nd, self.w1_2nd, qtf_interpBeta[:,:, idof].imag, bounds_error=False, fill_value=(0))(self.w, self.w) - qtf_interp = qtf_interp_Re + 1j*qtf_interp_Im + qtf_interp_Re_interpolator = RegularGridInterpolator((self.w1_2nd, self.w1_2nd), qtf_interpBeta[:, :, idof].real, bounds_error=False, fill_value=0) + qtf_interp_Im_interpolator = RegularGridInterpolator((self.w1_2nd, self.w1_2nd), qtf_interpBeta[:, :, idof].imag, bounds_error=False, fill_value=0) + + w_mesh = np.meshgrid(self.w, self.w, indexing='ij') + points = np.array([w_mesh[0].ravel(), w_mesh[1].ravel()]).T + + qtf_interp_Re = qtf_interp_Re_interpolator(points).reshape(len(self.w), len(self.w)) + qtf_interp_Im = qtf_interp_Im_interpolator(points).reshape(len(self.w), len(self.w)) + qtf_interp = qtf_interp_Re + 1j * qtf_interp_Im for imu in range(1, self.nw): # Loop the difference frequencies Saux = np.zeros(self.nw) From 9b9aabb30bcc0fec769c98b00bdb932555f2dfc1 Mon Sep 17 00:00:00 2001 From: Lucas-Carmo Date: Fri, 8 Nov 2024 11:44:58 -0700 Subject: [PATCH 3/3] Removed MacOS and Windows from tests by mistake. Fixing that. --- .github/workflows/CI_RAFT.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI_RAFT.yml b/.github/workflows/CI_RAFT.yml index 9391a35..3e8cce5 100644 --- a/.github/workflows/CI_RAFT.yml +++ b/.github/workflows/CI_RAFT.yml @@ -15,8 +15,9 @@ jobs: strategy: fail-fast: false #true matrix: - os: ["ubuntu-latest"] - python-version: ["3.10"] + os: ["ubuntu-latest", "macOS-latest", "windows-latest"] + python-version: ["3.10", "3.11"] + steps: - name: checkout repository