The FKMNonlinearDetector
class
- class pylife.stress.rainflow.fkm_nonlinear.FKMNonlinearDetector(recorder, notch_approximation_law)[source]
HCM-Algorithm detector as described in FKM nonlinear.
- __init__(recorder, notch_approximation_law)[source]
Instantiate an AbstractDetector.
- Parameters:
recorder (subclass of
AbstractRecorder
) – The recorder that the detector will report to.
- interpolated_stress_strain_data(n_points_per_branch=100, only_hystereses=False)[source]
Return points on the traversed hysteresis curve, mainly intended for plotting. The curve including all hystereses, primary and secondary branches is sampled at a fixed number of points within each hysteresis branch. These points can be used for plotting.
The intended use is to generate plots as follows:
fkm_nonlinear_detector.process_hcm_first(...) sampling_parameter = 100 # choose larger for smoother plot or smaller for lower runtime plotting_data = detector.interpolated_stress_strain_data(sampling_parameter) strain_values_primary = plotting_data["strain_values_primary"] stress_values_primary = plotting_data["stress_values_primary"] hysteresis_index_primary = plotting_data["hysteresis_index_primary"] strain_values_secondary = plotting_data["strain_values_secondary"] stress_values_secondary = plotting_data["stress_values_secondary"] hysteresis_index_secondary = plotting_data["hysteresis_index_secondary"] plt.plot(strain_values_primary, stress_values_primary, "g-", lw=3) plt.plot(strain_values_secondary, stress_values_secondary, "b-.", lw=1)
- Parameters:
n_points_per_branch (int, optional) – How many sampling points to use per hysteresis branch, default 100. A larger value values means smoother curves but longer runtime.
only_hystereses (bool, optional) – Default
False
. If only graphs of the closed hystereses should be output. Note that this does not work for hysteresis that have multiple smaller hysterseses included.
- Returns:
plotting_data – A dict with the following keys:
”strain_values_primary”
”stress_values_primary”
”hysteresis_index_primary”
”strain_values_secondary”
”stress_values_secondary”
”hysteresis_index_secondary”
The values are lists of strains and stresses of the points on the stress-strain curve, separately for primary and secondary branches. The lists contain nan values whenever the curve of the same branch is discontinuous. This allows to plot the entire curve with different colors for primary and secondary branches.
The entries for hysteresis_index_primary and hysteresis_index_secondary are the row indices into the collective DataFrame returned by the recorder. This allows, e.g., to separate the output of multiple runs of the HCM algorithm or to plot the traversed paths on the stress-strain diagram for individual steps of the algorithm.
- Return type:
- process(samples, flush=False)[source]
Process a sample chunk. This method implements the actual HCM algorithm.
- Parameters:
samples (array_like, shape (N, )) – The samples to be processed
flush (bool) –
Whether to flush the cached values at the end.
If
flush=False
, the last value of a load sequence is cached for a subsequent call toprocess
, because it may or may not be a turning point of the sequence, which is only decided when the next data point arrives.Setting
flush=True
forces processing of the last value. Whenprocess
is called again afterwards with new data, two increasing or decreasing values in a row might have been processed, as opposed to only turning points of the sequence.Example: a)
process([1, 2], flush=False) # processes 1 process([3, 1], flush=True) # processes 3, 1 -> processed sequence is [1,3,1], only turning points
process([1, 2], flush=True) # processes 1, 2 process([3, 1], flush=True) # processes 3, 1 -> processed sequence is [1,2,3,1], “2” is not a turning point
process([1, 2]) # processes 1 process([3, 1]) # processes 3 -> processed sequence is [1,3], end (“1”) is missing
process([1, 2]) # processes 1 process([3, 1]) # processes 3 flush() # process 1 -> processed sequence is [1,3,1]
- Returns:
self – The
self
object so that processing can be chained- Return type:
- process_hcm_first(samples)[source]
Perform the HCM algorithm for the first time. This processes the given samples accordingly, only considering “turning points”, neglecting consecutive duplicate values, making sure that the beginning starts with 0.
- process_hcm_second(samples)[source]
Perform the HCM algorithm for the second time, after it has been executed with
process_hcm_first
. This processes the given samples accordingly, only considering “turning points”, neglecting consecutive duplicate values, making sure that the beginning of the sequence is properly fitted to the samples of the first run, such that no samples are lost and no non-turning points are introducted between the two runs.
- property strain_values
Get the strain values of the turning points in the stress-strain diagram. They are needed in the FKM nonlinear roughness & surface layer algorithm, which adds residual stresses in another pass of the HCM algorithm.
- property strain_values_first_run
Get the strain values of the turning points in the stress-strain diagram, for the first run of the HCM algorithm. They are needed in the FKM nonlinear roughness & surface layer algorithm, which adds residual stresses in another pass of the HCM algorithm.
- property strain_values_second_run
Get the strain values of the turning points in the stress-strain diagram, for the second and any further run of the HCM algorithm. They are needed in the FKM nonlinear roughness & surface layer algorithm, which adds residual stresses in another pass of the HCM algorithm.