fit_all_damping_curves#

PySeismoSoil.helper_site_response.fit_all_damping_curves(curves: numpy.ndarray | list[numpy.ndarray], func_fit_single_layer: Callable[[Any, ...], Any], func_stress: Callable[[Any, ...], Any], 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: int = 0, show_fig: bool = False, verbose: bool = False, parallel: bool = False, n_cores: int | None = None, save_fig: bool = False, fig_filename: str | None = None, dpi: float = 100, save_txt: bool = False, txt_filename: str | None = None, sep: str = '\t', func_serialize: Callable[[Any, ...], Any] = None) list[dict[str, float]][source]#

Perform damping curve fitting for multiple damping curves using the genetic algorithm provided in DEAP.

Parameters:
  • curves (np.ndarray | list[np.ndarray]) –

    Can either be a 2D array in the “curve” format, or a list of individual damping curves. The “curve” format is as follows:

    strain [%]

    G/Gmax

    strain [%]

    damping [%]

    strain [%]

    G/Gmax

    The G/Gmax information is redundant for this function.

  • func_fit_single_layer (Callable[[Any, ...], Any]) – A function which fits the model parameters to a single layer in curves, such as hh.fit_HH_x_single_layer or mkz.fit_H4_x_single_layer.

  • func_stress (Callable[[Any, ...], Any]) – A function to calculate the shear stress from model parameters.

  • use_scipy (bool) – Whether to use the “differential_evolution” algorithm in scipy (https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.differential_evolution.html) to perform the 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 low eta will produce solutions much more different.

  • seed (int) – 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 across layers, i.e., calculate multiple layers simultaneously.

  • n_cores (int | None) – Number of CPU cores to use. If None, all cores are used. No effects if parallel is set to False.

  • save_fig (bool) – Whether to save damping fitting figures to hard drive.

  • fig_filename (str | None) – Full file name of the figure.

  • dpi (float) – Desired figure resolution. Only effective when show_fig is True.

  • save_txt (bool) – Whether to save the fitted parameters as a text file.

  • txt_filename (str | None) – The name of the text file to save the parameters to.

  • sep (str) – Delimiter to separate columns of data in the output file.

  • func_serialize (Callable[[Any, ...], Any]) – The function to serialize the parameters from a dict into a list. Can be hh.serialize_params_to_array or mkz.serialize_params_to_array.

Returns:

params – The best parameters for each layer found in the optimization.

Return type:

list[dict[str, float]]

Raises:
  • TypeError – The type of the input parameter is incorrect

  • ValueError – No function for serialization