Parameter#
- class PySeismoSoil.class_parameters.Parameter(param_dict: dict[str, float], *, allowable_keys: set[str] | None = None, func_stress: Optional[Callable[[dict[str, float], ...], ndarray]] = None)[source]#
Bases:
UserDict
Class implementation of parameters for different soil constitutive models. Its objects have dictionary-like behaviors. The keys in the dictionary are the parameter names (such as “gamma_ref”, “Gmax”).
Inheriting from this base class provides you the ability to control the allowable keys that a potential user may provide, making it safer for subsequent computations.
- Parameters:
param_dict (dict[str, float]) – Name-value pairs of the parameters.
allowable_keys (set[str] | None) – The allowable parameter names of the constitutive model.
func_stress (Callable[[dict[str, float], ...], np.ndarray] | None) – A function to calculate shear stress from the parameters.
- data#
The original data, stored as a regular dictionary.
- Type:
dict[str, float]
- allowable_keys#
Same as the input parameter.
- Type:
set[str] | None
- Raises:
TypeError – When input arguments have invalid types
KeyError – When keys outside
allowable_keys
exist inparam_dict
Methods Summary
clear
()copy
()fromkeys
(iterable[, value])get
(k[,d])get_GGmax
([strain_in_pct])Get the G/Gmax array inferred from the set of parameters
get_damping
([strain_in_pct])Get the damping array inferred from the set of parameters
get_stress
([strain_in_pct])Get the shear stress array inferred from the set of parameters
items
()keys
()plot_curves
([figsize, dpi])Plot G/Gmax and damping curves from the model parameters
pop
(k[,d])If key is not found, d is returned if given, otherwise KeyError is raised.
popitem
()as a 2-tuple; but raise KeyError if D is empty.
Serialize the parameter values into an array of floats.
setdefault
(k[,d])update
([E, ]**F)If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
values
()Methods Documentation
- clear() None. Remove all items from D. #
- copy()#
- classmethod fromkeys(iterable, value=None)#
- get(k[, d]) D[k] if k in D, else d. d defaults to None. #
- get_GGmax(strain_in_pct: ndarray = array([0.01, 0.01151395, 0.01325711, 0.01526418, 0.01757511, 0.0202359, 0.02329952, 0.02682696, 0.03088844, 0.0355648, 0.04094915, 0.04714866, 0.05428675, 0.06250552, 0.07196857, 0.08286428, 0.09540955, 0.10985411, 0.12648552, 0.14563485, 0.16768329, 0.19306977, 0.22229965, 0.25595479, 0.29470517, 0.33932218, 0.39069399, 0.44984327, 0.51794747, 0.59636233, 0.68664885, 0.79060432, 0.91029818, 1.04811313, 1.20679264, 1.38949549, 1.59985872, 1.84206997, 2.12095089, 2.44205309, 2.8117687, 3.23745754, 3.72759372, 4.29193426, 4.94171336, 5.68986603, 6.55128557, 7.54312006, 8.68511374, 10.])) ndarray [source]#
Get the G/Gmax array inferred from the set of parameters
- Parameters:
strain_in_pct (np.ndarray) – Strain array. Must be a 1D numpy array. Unit: %
- Returns:
result – The G/Gmax array, with the same shape as the strain array.
- Return type:
np.ndarray
- get_damping(strain_in_pct: ndarray = array([0.01, 0.01151395, 0.01325711, 0.01526418, 0.01757511, 0.0202359, 0.02329952, 0.02682696, 0.03088844, 0.0355648, 0.04094915, 0.04714866, 0.05428675, 0.06250552, 0.07196857, 0.08286428, 0.09540955, 0.10985411, 0.12648552, 0.14563485, 0.16768329, 0.19306977, 0.22229965, 0.25595479, 0.29470517, 0.33932218, 0.39069399, 0.44984327, 0.51794747, 0.59636233, 0.68664885, 0.79060432, 0.91029818, 1.04811313, 1.20679264, 1.38949549, 1.59985872, 1.84206997, 2.12095089, 2.44205309, 2.8117687, 3.23745754, 3.72759372, 4.29193426, 4.94171336, 5.68986603, 6.55128557, 7.54312006, 8.68511374, 10.])) ndarray [source]#
Get the damping array inferred from the set of parameters
- Parameters:
strain_in_pct (np.ndarray) – Strain array. Must be a 1D numpy array. Unit: %
- Returns:
result – The damping array (unit: %), with the same shape as the strain array
- Return type:
np.ndarray
- get_stress(strain_in_pct: ndarray = array([0.01, 0.01151395, 0.01325711, 0.01526418, 0.01757511, 0.0202359, 0.02329952, 0.02682696, 0.03088844, 0.0355648, 0.04094915, 0.04714866, 0.05428675, 0.06250552, 0.07196857, 0.08286428, 0.09540955, 0.10985411, 0.12648552, 0.14563485, 0.16768329, 0.19306977, 0.22229965, 0.25595479, 0.29470517, 0.33932218, 0.39069399, 0.44984327, 0.51794747, 0.59636233, 0.68664885, 0.79060432, 0.91029818, 1.04811313, 1.20679264, 1.38949549, 1.59985872, 1.84206997, 2.12095089, 2.44205309, 2.8117687, 3.23745754, 3.72759372, 4.29193426, 4.94171336, 5.68986603, 6.55128557, 7.54312006, 8.68511374, 10.])) numpy.ndarray | None [source]#
Get the shear stress array inferred from the set of parameters
- Parameters:
strain_in_pct (np.ndarray) – Strain array. Must be a 1D numpy array. Unit: %
- Returns:
result – The shear stress array, with the same shape as the strain array. Its unit is identical to the unit of Gmax (one of the HH parameters).
- Return type:
np.ndarray | None
- items() a set-like object providing a view on D's items #
- keys() a set-like object providing a view on D's keys #
- plot_curves(figsize: tuple[float, float] = None, dpi: float = 100, **kwargs_to_matplotlib: dict[Any, Any]) tuple[matplotlib.figure.Figure, list[matplotlib.axes._axes.Axes]] [source]#
Plot G/Gmax and damping curves from the model parameters
- Parameters:
figsize (tuple[float, float]) – Figure size in inches, as a tuple of two numbers. If
None
, use (3, 6).dpi (float) – Figure resolution. If
None
, use 100.**kwargs_to_matplotlib (dict[Any, Any]) – Keyword arguments to be passed to
matplotlib.pyplot.plot()
.
- Returns:
fig (Figure) – The figure object.
ax (list[Axes]) – A list of two axes objects.
- pop(k[, d]) v, remove specified key and return the corresponding value. #
If key is not found, d is returned if given, otherwise KeyError is raised.
- popitem() (k, v), remove and return some (key, value) pair #
as a 2-tuple; but raise KeyError if D is empty.
- serialize() ndarray [source]#
Serialize the parameter values into an array of floats. The order of the parameters are arbitrary, so any subclass of this class is recommended to override this method.
- Returns:
result – Serialized parameters.
- Return type:
np.ndarray
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D #
- update([E, ]**F) None. Update D from mapping/iterable E and F. #
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
- values() an object providing a view on D's values #