pyHarm¶
The pyHarm package is the core of pyHarm. It contains every modules and subpackages for pyHarm to be runnning an analysis.
Submodules¶
- pyHarm.Analysis
- pyHarm.BaseUtilFuncs
- pyHarm.CoordinateSystem
- pyHarm.Correctors
- pyHarm.DynamicOperator
- pyHarm.Elements
- pyHarm.KinematicConditions
- pyHarm.Maestro
- pyHarm.NonLinearSolver
- pyHarm.Predictors
- pyHarm.Reductors
- pyHarm.Solver
- pyHarm.StepSizeRules
- pyHarm.StopCriterion
- pyHarm.Substructures
- pyHarm.Systems
- pyHarm._version
Attributes¶
Dictionary containing the ABCCorrector subclasses as values and their factory_keyword as key. |
|
Dictionary of available ABCElement as values and their factory_keyword as key. |
|
Dictionary that contains ABCPredictor objects as values and their factory_keyword attribute as their key. |
|
Dictionary containing availabe ABCReductors as values and their factoryu keyword as key. |
|
Dictionary containing the factory keywords and their associated class of ABCStepSizeRule objects. |
|
Dictionary containing all the StopCriterions available. |
|
Dictionary containing the available ABCSystem in pyHarm for creation as values and their factory_keyword as keys. |
|
Dictionary containing ABCKinematic as values and their factory_keyword attribute as key. |
|
Dictionary containing all the available ABCNLSolvers as values, and their factory_keyword attribute as key. |
|
List of available ABCSubstructure subclasses available for creation. |
|
Dictionary of available Substructure readers subclasses as values and their factory_keyword as key. |
|
Dictionary linking the abstract classes defined in every available subpackages and their factory dictionary. |
Classes¶
This is the abstract class ruling the corrector class. The system is responsible for adding the correction residual equation to the augmented system. |
|
This is the abstract class ruling the element class. |
|
Abstract class for the predictor: Any added predictor shall be constructed from this class. |
|
This is the abstract class ruling the reducers class. The reducer is responsible for reducing the size of the system to be solved based on different hypotheses. |
|
This is the abstract class ruling the stepsize rules class. The step size rules are responsible for adjusting the step size of the analysis depending on the given inputs. |
|
Abstract class for the stopping criterion. Any stopping criterion code |
|
This is the abstract class ruling the kinematic conditions class. The kinematic conditions are responsible to impose kinematic on dofs of the system and transfer the residuals. |
|
This is the abstract class ruling the solver class. The system is responsible of solving the system starting at a given starting point. |
|
This is the abstract class ruling the reader class for substructure. The reader is responsible for reading, parsing and completing an input dictionary from a external file to comply with pyHarm. |
|
Class that reads and launches the pyHarm analysis contained in the provided input file. |
Functions¶
|
Given a custom option dictionary and a default option dictionary, |
|
Uses an explicit dof vector and returns an array of indices corresponding to the required dofs. |
|
Plugin function for the pyHarm module. Allows registering a class in the pyHarm factories. |
Package Contents¶
- pyHarm.__version__¶
- pyHarm.__package_name__ = 'pyHarm'¶
- pyHarm.getCustomOptionDictionary(custom_options: dict, default_options: dict)¶
Given a custom option dictionary and a default option dictionary, returns a new dictionary containing all the custom information along with the missing mandatory ones from the default dictionary.
- Parameters:
custom_options (dict) – A dictionary containing custom options.
default_options (dict) – A dictionary containing default options.
- Returns:
A new dictionary combining the custom options with the default options.
- Return type:
dict
- pyHarm.getIndexfromExpldofs(expl_dofs: pandas.DataFrame, list_of_caracteristics: list[tuple[str, int, list[int]]])¶
Uses an explicit dof vector and returns an array of indices corresponding to the required dofs. Takes a list of tuples [(substructure_name[str], node_number[int], dir_num[list[int]]), …]. If None is given as input for the directions, then all the dofs from the node are returned.
- Parameters:
expl_dofs (pd.DataFrame) – A DataFrame representing the explicit representation of the degree of freedom vector.
list_of_caracteristics (list[tuple[str,int,list[int]]]) – A list of tuples specifying the substructure name, node number, and direction numbers.
- Returns:
An array of indices corresponding to the required dofs, sorted in ascending order.
- Return type:
np.ndarray
- class pyHarm.ABCCorrector(**kwargs)¶
Bases:
abc.ABCThis is the abstract class ruling the corrector class. The system is responsible for adding the correction residual equation to the augmented system.
- property factory_keyword: str¶
- Abstractmethod:
name of the class to call in the factory in order to create an instance of the class.
- Type:
str
- abstractmethod ClosureEquation(solx: numpy.ndarray, sol: pyHarm.Solver.SystemSolution, sollist: list[pyHarm.Solver.SystemSolution]) numpy.ndarray¶
Computes the residual contribution of the correction equation.
- Parameters:
solx (np.ndarray) – actual displacement vector.
sol (SystemSolution) – actual SystemSolution that contains the starting point.
sollist (list[SystemSolution]) – list of SystemSolutions from previous analysis steps.
- abstractmethod ClosureJacobian(solx: numpy.ndarray, sol: pyHarm.Solver.SystemSolution, sollist: list[pyHarm.Solver.SystemSolution]) tuple[numpy.ndarray, numpy.ndarray]¶
Computes the jacobian contribution of the correction equation.
- Parameters:
solx (np.ndarray) – actual displacement vector.
sol (SystemSolution) – actual SystemSolution that contains the starting point.
sollist (list[SystemSolution]) – list of SystemSolutions from previous analysis steps.
- pyHarm.Corrector_dico¶
Dictionary containing the ABCCorrector subclasses as values and their factory_keyword as key.
- Type:
dict[str, ABCCorrector]
- class pyHarm.ABCElement(nh: int, nti: int, name: str, data: dict, CS: pyHarm.CoordinateSystem.CoordinateSystem)¶
Bases:
abc.ABCThis is the abstract class ruling the element class.
An element consists in an elementary contribution to the residual equations.
- Parameters:
nh (int) – number of harmonics.
nti (int) – number of time steps.
name (str) – name given to the kinematic condition.
data (dict) – dictionary containing all the definition information of the kinematic condition.
CS (CoordinateSystem) – local or global coordinate system the kinematic condition is defined on.
- flag_nonlinear¶
if True, the element is nonlinear.
- Type:
bool
- flag_AFT¶
if True, the element requires an alternating frequency/time domain procedure for computing residuals.
- Type:
bool
- flag_extforcing¶
if True, the element is an external forcing.
- Type:
bool
- flag_DLFT¶
if True, the element uses the dynamic Lagrangian method for computing the residuals.
- Type:
bool
- flag_adim¶
if True, the element is adimentioned.
- Type:
bool
- nh¶
number of harmonics.
- Type:
int
- nti¶
number of time steps.
- Type:
int
- D¶
Dynamic operators containing inverse discrete Fourier transform and discrete Fourier transform.
- Type:
dict[np.ndarray,np.ndarray]
- nabla¶
Derivation operator.
- Type:
np.ndarray
- abstract property factory_keyword¶
- __init_flags__()¶
- __init_harmonic_operators__(nh, nti)¶
- __repr__()¶
- __post_init__(*args)¶
- __flag_update__(*args)¶
- abstractmethod __init_data__(name, data, CS)¶
- abstractmethod __str__()¶
- abstractmethod generateIndices(expl_dofs: pandas.DataFrame)¶
- abstractmethod adim(lc, wc)¶
Modifies the element properties according to the characteristic length and angular frequency.
- Parameters:
lc (float) – characteristic length value.
wc (float) – characteristic angular frequency value.
- abstractmethod evalResidual(x, om)¶
Computes the residual.
- Parameters:
x (np.ndarray) – full displacement vector.
om (float) – angular frequency value.
- abstractmethod evalJacobian(x, om)¶
Computes the jacobians.
- Parameters:
x (np.ndarray) – full displacement vector.
om (float) – angular frequency value.
- pyHarm.ElementDictionary¶
Dictionary of available ABCElement as values and their factory_keyword as key.
- Type:
dict[str, ABCElement]
- class pyHarm.ABCPredictor(sign_ds, **kwargs)¶
Bases:
abc.ABCAbstract class for the predictor: Any added predictor shall be constructed from this class.
- Parameters:
sign_ds (float) – if -1 predict in the direction of decreasing angular frequency, if 1 the opposite direction
- flag_print¶
information are printed during the analysis if True.
- Type:
bool
- predictor_options¶
dictionary containing the kwargs and competed using the default options if the keywords are missing.
- Type:
dict
- property factory_keyword: str¶
- Abstractmethod:
Returns: str: keyword that is used to call the creation of this class in the system factory.
- default_options¶
set of default parameters for the system class if not given in the input argument.
It contains a normalisation parameter using the keyword ‘norm’ that can be set to either ‘norm1’ (default) if the direction is normed to 1 or ‘om’ if the direction is normed to 1 only for the angular frequency. It contains a bifurcation detection using the ‘bifurcation_detect’ keyword that can be set to True (default) if detection is needed. It contains a ‘verbose’ keyword that can be set to True (default) if information about detection of bifurcations is to be displayed during solving.
- Type:
dict
- sign_ds_init¶
- sign_ds¶
- predictor_options¶
- flag_print¶
- abstractmethod predict(sollist: list[pyHarm.Solver.SystemSolution], ds: float) tuple[numpy.ndarray, pyHarm.Solver.SystemSolution, float]¶
Predicts the next strating point.
- Parameters:
sollist (list[SystemSolution]) – list of SystemSolution already solved during the analysis.
ds (float) – step size for the prediction.
- bifurcation_detect(lstpt: pyHarm.Solver.SystemSolution)¶
Makes a bifurcation detection analysis computing determinant of jacobian matrix and analysing change of sign.
- Parameters:
lstpt (SystemSolution) – previously accepted point in direct link with the actual solved point.
- sign_ds¶
Attribute is modified if a turning point is detected.
- Type:
float
- getPointerToSolution(sollist: list[pyHarm.Solver.SystemSolution], k_imposed=None) pyHarm.Solver.SystemSolution¶
Gets the last accepted solution in direct link with the studied point.
- Parameters:
sollist (list[SystemSolution]) – list of SystemSolution already solved during the analysis.
k_imposed (None|int) – if not None then the provided index is used as the last accepted point.
- Returns:
last accepted point.
- Return type:
- norm_dir(dir: float) float¶
Normalises the direction according to the choice of norm given in the class attributes.
- Parameters:
dir (np.ndarray) – prediction direction.
- Returns:
normalized prediction direction.
- Return type:
np.ndarray
- pyHarm.Predictor_dico¶
Dictionary that contains ABCPredictor objects as values and their factory_keyword attribute as their key.
- Type:
dict
- class pyHarm.ABCReductor(data: dict, expl_dofs: pandas.DataFrame, *args)¶
Bases:
abc.ABCThis is the abstract class ruling the reducers class. The reducer is responsible for reducing the size of the system to be solved based on different hypotheses.
- Parameters:
data (dict) – A dictionary containing the reducers parameters.
expl_dofs (pd.DataFrame) – DataFrame describing the positioning of dofs. It is generated by ABCSystem objects.
- expl_dofs¶
DataFrame describing the positioning of dofs. It is generated by ABCSystem objects.
- Type:
pd.DataFrame
- property factory_keyword: str¶
- Abstractmethod:
Returns: str: keyword that is used to call the creation of this class in the system factory.
- data¶
- expl_dofs¶
- __post_init__(*args)¶
A post init method to be customized if needed when building new class.
- output_expl_dofs() pandas.DataFrame¶
Returns the explicit dof list after transformation by the reducer.
- Returns:
reduced explicit dof DataFrame after passing through the reducer.
- Return type:
pd.DataFrame
- reduce_vectorx(q: numpy.ndarray) numpy.ndarray¶
Applies the reduce_vector method to the input vector of displacement.
- Parameters:
q (np.ndarray) – vector of displacement of full size.
- Returns:
reduced vector of displacement.
- Return type:
np.ndarray
- abstractmethod update_reductor(*args) None¶
Using the given parameters, performs an update of the reductor and generates its new transformation matrix
- abstractmethod expand(q: numpy.ndarray) numpy.ndarray¶
From reduced vector, performs the inverse transformation to retrieve the original vector.
- Parameters:
q (np.ndarray) – reduced vector of displacement
- Returns:
full size vector of displacement.
- Return type:
np.ndarray
- abstractmethod reduce_vector(x: numpy.ndarray) numpy.ndarray¶
From original vector, performs the transformation to get the reduced vector.
- Parameters:
x (np.ndarray) – full size vector.
- Returns:
reduced vector.
- Return type:
np.ndarray
- abstractmethod reduce_matrix(dJdx: numpy.ndarray) numpy.ndarray¶
From original matrix, perform the transformation to get the reduced matrix.
- Parameters:
dJdx (np.ndarray) – full size jacobian matrix with respect to displacement.
- Returns:
reduced size jacobian matrix with respect to displacement.
- Return type:
np.ndarray
- pyHarm.Reductor_dico¶
Dictionary containing availabe ABCReductors as values and their factoryu keyword as key.
- Type:
dict
- class pyHarm.ABCStepSizeRule(bounds: list[float, float], **kwargs)¶
Bases:
abc.ABCThis is the abstract class ruling the stepsize rules class. The step size rules are responsible for adjusting the step size of the analysis depending on the given inputs.
- Parameters:
bounds (list[float,float]) – List containing the step size bounds [min_step, max_step].
- ds_min¶
min step size.
- Type:
float
- ds_max¶
max step size.
- Type:
float
- property factory_keyword: str¶
- Abstractmethod:
Returns: str: keyword that is used to call the creation of this class in the system factory.
- ds_min¶
- ds_max¶
- abstractmethod getStepSize(ds: float, sollist: list[pyHarm.Solver.SystemSolution], **kwargs) float¶
Returns the step size to be used for the prediction step of the analysis.
- ProjectInBounds(ds: float) float¶
Projects the step-size onto the bounds if the step-size is out of the required bounds.
- Parameters:
ds (float) – step-size.
- Returns:
step-size projected onto the bounds if it is out of the bounds.
- Return type:
float
- pyHarm.StepSizer_dico¶
Dictionary containing the factory keywords and their associated class of ABCStepSizeRule objects.
- Type:
dict
- class pyHarm.ABCStopCriterion(bounds: list[float, float], ds_min: float, **kwargs)¶
Bases:
abc.ABCAbstract class for the stopping criterion. Any stopping criterion code shall inherit from this class.
- Parameters:
bounds (list[float, float]) – A list of upper and lower bounds.
ds_min – The minimum step size.
**kwargs – Additional keyword arguments.
- Raises:
NotImplementedError – If the subclass lacks the factory_keyword class attribute.
TypeError – If the factory_keyword is not a string value.
- property factory_keyword: str¶
- Abstractmethod:
Returns: str: keyword that is used to call the creation of this class in the system factory.
- puls_inf¶
- puls_sup¶
- epsilon_bounds¶
- bound_inf¶
- bound_sup¶
- ds_min¶
- abstractmethod getStopCriterionStatus(sol: pyHarm.Solver.SystemSolution, sollist: list, **kwargs) bool¶
Abstract method to get the stop criterion status.
- Parameters:
sol (SystemSolution) – A SystemSolution object.
sollist (list) – A list of solutions.
**kwargs – Additional keyword arguments.
- Raises:
None. –
- pyHarm.Stopper_dico¶
Dictionary containing all the StopCriterions available.
- Type:
dict[str,ABCStopCriterion]
- pyHarm.System_dico¶
Dictionary containing the available ABCSystem in pyHarm for creation as values and their factory_keyword as keys.
- Type:
dict[str,ABCSystem]
- class pyHarm.ABCKinematic(nh: int, nti: int, name: str, data: dict, CS: pyHarm.CoordinateSystem.CoordinateSystem)¶
Bases:
abc.ABCThis is the abstract class ruling the kinematic conditions class. The kinematic conditions are responsible to impose kinematic on dofs of the system and transfer the residuals.
- Parameters:
nh (int) – number of harmonics.
nti (int) – number of time steps.
name (str) – name given to the kinematic condition.
data (dict) – dictionary containing all the definition information of the kinematic condition.
CS (CoordinateSystem) – local or global coordinate system the kinematic condition is defined on.
- nh¶
number of harmonics.
- Type:
int
- nti¶
number of time steps.
- Type:
int
- D¶
Dynamic operators containing inverse discrete Fourier transform and discrete Fourier transform.
- Type:
dict[np.ndarray,np.ndarray]
- nabla¶
Derivation operator.
- Type:
np.ndarray
- indices¶
index of the dofs that the kinematic conditions needs.
- Type:
np.ndarray
- Pdir¶
a slice of first dimension is a transformation matrix to a direction in local coordinate system.
- Type:
np.ndarray
- Pslave¶
selection array that selects the slave dofs of the kinematic condition.
- Type:
np.ndarray
- Pmaster¶
selection array that selects the master dofs of the kinematic condition.
- Type:
np.ndarray
- subs¶
list containing the name of the substructures that are involved.
- Type:
list[str]
- nbSub¶
number of substructure involved.
- Type:
int
- nodes¶
list of list of nodes the kinematic conditions act on.
- Type:
list[list]
- nbdofi¶
number of nodes involved per substructure.
- Type:
int
- abstract property factory_keyword¶
- __init_flags__()¶
- __init_harmonic_operators__(nh, nti)¶
- __init_data__(name, data, CS)¶
- __str__()¶
- __repr__()¶
- __post_init__(*args)¶
- __flag_update__(*args)¶
- generateIndices(expl_dofs: pandas.DataFrame)¶
From the explicit dof DataFrame, generates the index of dofs concerned by the kinematic condition.
- Parameters:
expl_dofs (pd.DataFrame) – explicit dof DataFrame from the studied system.
- indices¶
index of the dofs that the kinematic conditions needs.
- Type:
np.ndarray
- Pdir¶
a slice of first dimension is a transformation matrix to a direction in local coordinate system.
- Type:
np.ndarray
- Pslave¶
selection array that selects the slave dofs of the kinematic condition.
- Type:
np.ndarray
- Pmaster¶
selection array that selects the master dofs of the kinematic condition.
- Type:
np.ndarray
- _generateMatrices(sub_expl_dofs)¶
- abstractmethod adim(lc, wc)¶
Using adim parameters, modifies the kinematic conditions accordingly.
- Parameters:
lc (float) – characteristic length.
wc (float) – characteristic angular frequency.
- abstractmethod complete_x(x, om)¶
Returns a vector x_add of same size of x that completes the vector of displacement x = x + x_add.
- Parameters:
x (np.ndarray) – displacement vector.
om (float) – angular frequency.
- abstractmethod complete_R(R, x)¶
Returns a vector R_add of same size of R that completes the vector of residual R = R + R_add
- Parameters:
R (np.ndarray) – residual vector.
x (np.ndarray) – displacement vector.
- abstractmethod complete_J(Jx, Jom, x)¶
Returns a vector Jx_add and Jom_add of same size of Jx and Jom that completes the Jacobian
- Parameters:
Jx (np.ndarray) – jacobian matrix with respect to displacement.
Jom (np.ndarray) – jacobian matrix with respect to angular frequency.
x (np.ndarray) – displacement vector.
- pyHarm.Kinematic_dico¶
Dictionary containing ABCKinematic as values and their factory_keyword attribute as key.
- Type:
dict
- class pyHarm.ABCNLSolver(residual, jacobian, solver_options)¶
Bases:
abc.ABCThis is the abstract class ruling the solver class. The system is responsible of solving the system starting at a given starting point.
- Parameters:
solver_options (dict) – dictionary containing other options for creation of the solver class.
residual (Callable) – function that returns the residual vector of the system to be solved.
jacobian (Callable) – function that returns the jacobian matrix of the system to be solved.
- property factory_keyword: str¶
- Abstractmethod:
keyword that is used to call the creation of this class in the system factory.
- solver_options¶
- residual¶
- jacobian¶
- __post_init__()¶
- abstractmethod Solve(system_solution: pyHarm.Solver.SystemSolution) pyHarm.Solver.SystemSolution¶
Runs the solver.
- Parameters:
system_solution (SystemSolution) – SystemSolution that contains the starting point.
- pyHarm.Solver_dico¶
Dictionary containing all the available ABCNLSolvers as values, and their factory_keyword attribute as key.
- Type:
dict
- pyHarm.SubstructureDico¶
List of available ABCSubstructure subclasses available for creation.
- Type:
dict[str,ABCSubstructure]
- pyHarm.SubstructureReaderDictionary¶
Dictionary of available Substructure readers subclasses as values and their factory_keyword as key.
- Type:
dict[str, ABCReader]
- class pyHarm.ABCReader¶
Bases:
abc.ABCThis is the abstract class ruling the reader class for substructure. The reader is responsible for reading, parsing and completing an input dictionary from a external file to comply with pyHarm.
- abstract property factory_keyword¶
Factory keyword to be used when instantiating a reader
- abstractmethod data_complete(data: dict) dict¶
Reads and completes the input dictionary from the file.
- pyHarm.Dico_ABCClass_factory_keyword¶
Dictionary linking the abstract classes defined in every available subpackages and their factory dictionary.
- Type:
dict
- pyHarm.pyHarm_plugin(cls)¶
Plugin function for the pyHarm module. Allows registering a class in the pyHarm factories.
- Parameters:
cls – A class to be registered in one of the pyHarm factories.
- class pyHarm.Maestro(idata: dict)¶
Class that reads and launches the pyHarm analysis contained in the provided input file.
The class is in charge of reading the input file and build the system and the analysis that are requested by the input file. The class is in charge of loading the plugins beforehand if some plugins are requested by the input file. When operated, the class runs a loop over the analysis required and solve them.
- Parameters:
idata (dict) – input dictionary describing all the necessary component (analysis, system composition).
- default¶
- inputData¶
- system¶
- nls¶
- operate(x0=None, **kwargs)¶
Loops over the analysis and runs the Solve method associated with the analysis.
- Parameters:
x0 (None | np.ndarray | str) – initial point from which running the analysis.
kwargs – additional keyword arguments.
- getIndex(sub: str, node: int, dir_num: int) numpy.ndarray¶
From a substructure name, a node number, and a direction; returns the index of the required dof into the explicit dof vector of the system.
- Parameters:
sub (str) – name of the substructure.
node (int) – node number.
dir_num (int) – direction number.
- Returns :
np.ndarray : sorted array of the dof index associated with the input in the explicit dof DataFrame of the system.