Damping_Curve#
- class PySeismoSoil.class_curves.Damping_Curve(data: ndarray, *, strain_unit: Literal['1', '%'] = '%', damping_unit: Literal['1', '%'] = '%', interpolate: bool = False, min_strain: float = 0.0001, max_strain: float = 10.0, n_pts: int = 50, log_scale: bool = True, check_values: bool = True)[source]#
Bases:
Curve
Class implementation of a damping curve, as a function of shear strain.
- Parameters:
data (np.ndarray) – A 2D numpy array with 2 columns. Its 0th column contains the strain array, and the 1st column contains the damping values.
strain_unit (Literal['1', '%']) – The unit of the strain.
damping_unit (Literal['1', '%']) – The unit of damping.
interpolate (bool) – Whether to interpolate the input curve or not. If
False
, the following several parameters (min_strain
,max_strain
,n_pts
,log_scale
) have no effects.min_strain (float) – Minimum strain value of the strain array. If
interpolate
isTrue
, the rawdata
will be internally interpolated at a strain array defined bymin_strain
,max_strain
, andn_pts
.max_strain (float) – Maximum strain value of the strain array. Only effective when
interpolate
is set toTrue
.n_pts (int) – Number of points of the desired strain array to do the interpolation. Only effective when
interpolate
is set toTrue
.log_scale (bool) – Whether the strain array for interpolation is in log scale (or linear scale). Only effective when
interpolate
is set toTrue
.check_values (bool) – Whether to automatically check the validity of the damping values (i.e., between 0 and 1).
- raw_data#
The raw data that the user passed in.
- Type:
np.ndarray
- strain#
The strain array at which interpolation happens, a 1D numpy array of shape (
n_pts
, ). The unit is percent (unit conversion happens internally if applicable).- Type:
np.ndarray
- damping#
The interpolated damping values; same shape as
strain
. The unit is percent (unit conversion happens internally if applicable).- Type:
np.ndarray
- Raises:
ValueError – When the provided damping values are not within [0, 100]
Methods Summary
get_H4_x_param
([use_scipy, pop_size, n_gen, ...])Obtain the HH_x parameters from the damping curve data, using the genetic algorithm provided in DEAP.
get_HH_x_param
([use_scipy, pop_size, n_gen, ...])Obtain the HH_x parameters from the damping curve data, using the genetic algorithm provided in DEAP.
plot
([plot_interpolated, fig, ax, title, ...])Plot the curve (y axis: values, x axis: strain)
Methods Documentation
- get_H4_x_param(use_scipy: bool = True, pop_size: int = 800, n_gen: int = 100, lower_bound_power: float = - 4, upper_bound_power: float = 6, eta: float = 0.1, seed: float = 0, show_fig: bool = False, verbose: bool = False, parallel: bool = False, n_cores: int | None = None) MKZ_Param [source]#
Obtain the HH_x parameters from the damping curve data, using the genetic algorithm provided in DEAP.
- Parameters:
use_scipy (bool) – Whether to use the “differential_evolution” algorithm implemented in scipy (https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.differential_evolution.html) to perform optimization. If
False
, use the algorithm in the DEAP package.pop_size (int) – The number of individuals in a generation
n_gen (int) – Number of generations that the evolution lasts
lower_bound_power (float) – The 10-based power of the lower bound of all the 9 parameters. For example, if your desired lower bound is 0.26, then set this parameter to be numpy.log10(0.26)
upper_bound_power (float) – The 10-based power of the upper bound of all the 9 parameters.
eta (float) – Crowding degree of the mutation or crossover. A high
eta
will produce children resembling to their parents, while a loweta
will produce solutions much more different.seed (float) – Seed value for the random number generator.
show_fig (bool) – Whether to show the curve fitting results as a figure.
verbose (bool) – Whether to display information (statistics of the loss in each generation) on the console.
parallel (bool) – Whether to use parallel computing to simultaneously evaluate different individuals in a population. Note that different generations still evolve one after another. Only effective for the differential evolution for now. Also note that if using parallelization in differential evolution, you may need more generations to achieve the same optimization loss, because the best solution is being updated only once per generation.
n_cores (int | None) – Number of CPU cores to use. If
None
, all cores are used. No effects ifparallel
is set toFalse
.
- Returns:
H4_x_param – The best parameters found in the optimization.
- Return type:
- get_HH_x_param(use_scipy: bool = True, pop_size: int = 800, n_gen: int = 100, lower_bound_power: float = - 4, upper_bound_power: float = 6, eta: float = 0.1, seed: float = 0, show_fig: bool = False, verbose: bool = False, parallel: bool = False, n_cores: int | None = None) HH_Param [source]#
Obtain the HH_x parameters from the damping curve data, using the genetic algorithm provided in DEAP.
- Parameters:
use_scipy (bool) – Whether to use the “differential_evolution” algorithm implemented in scipy (https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.differential_evolution.html) to perform optimization. If
False
, use the algorithm in the DEAP package.pop_size (int) – The number of individuals in a generation.
n_gen (int) – Number of generations that the evolution lasts.
lower_bound_power (float) – The 10-based power of the lower bound of all the 9 parameters. For example, if your desired lower bound is 0.26, then set this parameter to be numpy.log10(0.26).
upper_bound_power (float) – The 10-based power of the upper bound of all the 9 parameters.
eta (float) – Crowding degree of the mutation or crossover. A high
eta
will produce children resembling to their parents, while a loweta
will produce solutions much more different.seed (float) – Seed value for the random number generator.
show_fig (bool) – Whether to show the curve fitting results as a figure.
verbose (bool) – Whether to display information (statistics of the loss in each generation) on the console.
parallel (bool) – Whether to use parallel computing to simultaneously evaluate different individuals in a population. Note that different generations still evolve one after another. Only effective for the differential evolution for now. Also note that if using parallelization in differential evolution, you may need more generations to achieve the same optimization loss, because the best solution is being updated only once per generation.
n_cores (int | None) – Number of CPU cores to use. If
None
, all cores are used. No effects ifparallel
is set toFalse
.
- Returns:
HH_x_param – The best parameters found in the optimization.
- Return type:
- plot(plot_interpolated: bool = True, fig: matplotlib.figure.Figure | None = None, ax: matplotlib.axes._axes.Axes | None = None, title: str | None = None, xlabel: str | None = 'Strain [%]', ylabel: str | None = None, figsize: tuple[float, float] = (3, 3), dpi: float = 100, **kwargs_to_matplotlib: dict[Any, Any]) tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes] #
Plot the curve (y axis: values, x axis: strain)
- Parameters:
plot_interpolated (bool) – Whether to plot the interpolated curve or the raw data.
fig (Figure | None) – Figure object. If None, a new figure will be created.
ax (Axes | None) – Axes object. If None, a new axes will be created.
title (str | None) – Title of plot.
xlabel (str | None) – X label of plot.
ylabel (str | None) – Y label of plot.
figsize (tuple[float, float]) – Figure size in inches, as a tuple of two numbers. The figure size of
fig
(if notNone
) will override this parameter.dpi (float) – Figure resolution. The dpi of
fig
(if notNone
) will override this parameter.**kwargs_to_matplotlib (dict[Any, Any]) – Keyword arguments to be passed to
matplotlib.pyplot.plot()
.
- Returns:
fig (Figure) – The figure object being created or being passed into this function.
ax (Axes) – The axes object being created or being passed into this function.