Skip to content

Commit

Permalink
Merge pull request #19 from ladisk/numpy2_0
Browse files Browse the repository at this point in the history
Numpy2 0
  • Loading branch information
jankoslavic authored Dec 23, 2024
2 parents e2f5fbb + 1470228 commit 50e4da2
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 97 deletions.
133 changes: 58 additions & 75 deletions FLife Showcase.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion FLife/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '1.4.1'
__version__ = '1.4.2'
from .spectralData import SpectralData
from .freq_domain import *
from .time_domain import *
Expand Down
2 changes: 1 addition & 1 deletion FLife/freq_domain/gao_moan.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _damage_intesity_trimodal_LF(self, m0_LF, m0_MF, m0_HF, nu_L, C, k):
# LF component pdf - rayleigh distributed
pdf_LF = lambda s: stats.rayleigh.pdf(s/np.sqrt(m0_LF)) / np.sqrt(m0_LF)
# large-amplitude cycle pdf
pdf_L = lambda s: np.convolve(pdf_M(s), pdf_LF(s)) # large cycle pdf
pdf_L = lambda s: np.convolve(pdf_M(s), pdf_LF(s))[0] # large cycle pdf

S_L = integrate.quad(lambda s: s**k * pdf_L(s), 0, np.inf)[0]
d = nu_L * S_L / C
Expand Down
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
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ build-backend = "hatchling.build"

[project]
name = "FLife"
version = "1.4.1"
version = "1.4.2"
authors = [{name = "Aleš Zorman, Matjaž Mršnik, Janko Slavič", email = "janko.slavic@fs.uni-lj.si"}]
maintainers = [{name = "Janko Slavič, Domen Gorjup", email = "janko.slavic@fs.uni-lj.si"}]
license = "MIT"
description = "Vibration Fatigue by Spectral Methods."
readme = "README.rst"
keywords = ['vibration', 'fatigue', 'spectral methods', 'structural dynamics']
requires-python = ">=3.8"
requires-python = ">=3.9"
dependencies = [
"numpy",
"scipy",
Expand All @@ -20,14 +20,14 @@ dependencies = [
"pylint",
"pytest",
"lvm_read",
"matplotlib>=3.3",
"matplotlib",
"pyExSi",
]
classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Scientific/Engineering',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
"License :: OSI Approved :: MIT License",
]

Expand Down

0 comments on commit 50e4da2

Please sign in to comment.