Skip to content

Commit

Permalink
numpy 2.0 warnings handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jankoslavic committed Dec 23, 2024
1 parent 704e383 commit 43a7596
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 91 deletions.
133 changes: 58 additions & 75 deletions FLife Showcase.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions FLife/freq_domain/jiao_moan.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def get_life(self, C, k, approximation = False):
return T

def _life_NB(self, C, k):
m0H = self.spectral_data.get_spectral_moments(self.PSD_splitting, moments=[0])[0][0]
v0H = self.spectral_data.get_nup(self.PSD_splitting)[0]
m0H, = self.spectral_data.get_spectral_moments(self.PSD_splitting, moments=[0])[0][0]
v0H, = self.spectral_data.get_nup(self.PSD_splitting)[0]

# -- Define expected value of stress range ( int(S^k * p(s)) ) proces H(t), fatigue life
dNB_H = self.damage_intesity_NB(m0=m0H, nu=v0H, C=C, k=k)
Expand Down
10 changes: 2 additions & 8 deletions FLife/freq_domain/low.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,9 @@ def get_life(self, C, k):

# -- spectral moments for each narrowband
moments = self.spectral_data.get_spectral_moments(self.PSD_splitting, moments=[0])
m0L = moments[0] #spectral moments for lower band
m0H = moments[1] #spectral moments for upper band
m0L, = moments[0] #spectral moments for lower band
m0H, = moments[1] #spectral moments for upper band

if type(m0L) == np.ndarray and len(m0L) == 1:
m0L = m0L[0]
# convert m0H to scalar if it is array of length 1
if type(m0H) == np.ndarray and len(m0H) == 1:
m0H = m0H[0]

# -- positive slope zero crossing frequency
v0L, v0H = self.spectral_data.get_nup(self.PSD_splitting)
v0Small = v0H - v0L #frequency of small cycless
Expand Down
8 changes: 2 additions & 6 deletions FLife/freq_domain/zhao_baker.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ def eq(p):
3.0 * np.sqrt(np.pi/2.0) * alpha2 * (1.0 - ro)

try:
root = fsolve(eq, 0)
root = fsolve(eq, 0)[0]
except:
root = fsolve(eq, np.random.rand()*5.0)
root = fsolve(eq, np.random.rand()*5.0)[0]

a = root**(-b)
w = ( 1.0 - alpha2 ) / ( 1.0 - np.sqrt(2.0/np.pi) * gamma(1.0 + 1.0/b) * a**(-1.0/b) )
Expand Down Expand Up @@ -198,10 +198,6 @@ def get_life(self, C, k, method='method 1', integrate_pdf=False):

d = (m_p/C) * m0**(0.5*k) * ( w * a**(-k/b) * gamma(1.0+k/b) +\
(1.0-w) * 2**(0.5*k) * gamma(1.0+0.5*k) )

# convert d to scalar if it is array of length 1
if type(d) == np.ndarray and len(d) == 1:
d = d[0]

T = float(1.0/d)
return T

0 comments on commit 43a7596

Please sign in to comment.