diff --git a/pCrunch/aeroelastic_output.py b/pCrunch/aeroelastic_output.py index 05fc2d0..57e2362 100644 --- a/pCrunch/aeroelastic_output.py +++ b/pCrunch/aeroelastic_output.py @@ -446,14 +446,14 @@ def kurtosis(self): @dataproperty def integrated(self): - return np.trapz(self.data, self.time, axis=0) + return np.trapezoid(self.data, self.time, axis=0) def compute_energy(self, pwrchan): - return np.trapz(self[pwrchan], self.time) + return np.trapezoid(self[pwrchan], self.time) def total_travel(self, chanstr): dchan = np.gradient(self[chanstr], self.time) - return np.trapz(np.abs(dchan), self.time) + return np.trapezoid(np.abs(dchan), self.time) def histogram(self, chanstr, bins=15): return np.histogram(self[chanstr], bins=bins, density=False) diff --git a/pCrunch/fatigue.py b/pCrunch/fatigue.py index 04832d7..f264cb6 100644 --- a/pCrunch/fatigue.py +++ b/pCrunch/fatigue.py @@ -298,12 +298,17 @@ def get_rainflow_counts(self, chan, bins, S_ult=None, goodman=False): Default: False S_ult: float (optional) Ultimate stress/load for the material + + Returns + ------- + N, S : 1darray + The count and the characteristic value for the ranges. """ try: - S, Mrf = fatpack.find_rainflow_ranges(chan, k=256, return_means=True) + ranges, Mrf = fatpack.find_rainflow_ranges(chan, k=256, return_means=True) except Exception: - S = Mrf = np.zeros(1) + ranges = Mrf = np.zeros(1) if goodman: if S_ult is None: @@ -312,9 +317,23 @@ def get_rainflow_counts(self, chan, bins, S_ult=None, goodman=False): if S_ult == 0.0: raise ValueError('Must specify an ultimate_stress to use Goodman correction') - S = fatpack.find_goodman_equivalent_stress(S, Mrf, S_ult) - - return fatpack.find_range_count(S, bins) + ranges = fatpack.find_goodman_equivalent_stress(ranges, Mrf, S_ult) + + success = False + while not success: + try: + N, S = fatpack.find_range_count(ranges, bins) + success = True + except ValueError: + bins *= 0.5 + if bins < 1: + print(ranges) + print(bins) + raise Exception("Failed to find bins for ranges") + else: + bins = int(bins) + + return N, S def compute_del(self, chan, elapsed_time, **kwargs): diff --git a/pyproject.toml b/pyproject.toml index 550a5de..6acd298 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pCrunch" -version = "2.1.3" +version = "2.1.4" description = "IO and Post Processing for generic time series data of multibody aeroelastic wind turbine simulations." readme = "README.rst" requires-python = ">=3.9"