pyHarm.Solver

Classes

SystemSolution

Class that represents a solution of the system to be solved.

FirstSolution

Inherits from the SystemSolution class with one major difference: there is no previous SystemSolution point

Module Contents

class pyHarm.Solver.SystemSolution(xs: numpy.ndarray, last_solution_pointer=None, **kwargs)

Class that represents a solution of the system to be solved.

This class is the main object that transits in the analysis process while solving a problem. The object contains information about its starting point, the previous SystemSolution it is linked to and the actual point the solver is studying. Once the solver has converged, the values of the residual and the solution point are stored in some of the attributes.

Parameters:
  • xs (np.ndarray) – An array representing the starting point.

  • last_solution_pointer – A pointer to the last converged solution object.

  • **kwargs – Additional keyword arguments.

flag_restart

Flag indicating if the solution is a restart (last_solution_pointer != index - 1).

Type:

bool

flag_accepted

Flag indicating if the solution is considered valid.

Type:

bool

flag_bifurcation

Flag indicating if a bifurcation has been detected at this point.

Type:

bool

flag_solved

Flag indicating if the solution is complete and valid.

Type:

bool

flag_intosolver

Flag indicating if the solution has gone through the solver.

Type:

bool

flag_R

Flag indicating the presence of a residual result.

Type:

bool

flag_J

Flag indicating the presence of a Jacobian result.

Type:

bool

flag_J_qr

Flag indicating the availability of the Jacobian with QR decomposition.

Type:

bool

flag_J_lu

Flag indicating the availability of the Jacobian with LU decomposition.

Type:

bool

flag_J_f

Flag indicating the availability of the full-size Jacobian.

Type:

bool

index_insolve

The index of the solution within the solver.

Type:

int

ds

The step size for the continuation.

Type:

float

sign_ds

Sign of the step size.

Type:

int

x_start

An array representing the starting point.

Type:

np.ndarray

x

An array representing the current solution point.

Type:

np.ndarray

x_pred

An array representing the prediction point during continuation.

Type:

np.ndarray

R

Residual values.

J_f

Full-size Jacobian.

J_lu

Jacobian with LU decomposition.

J_qr

Jacobian with QR decomposition.

precedent_solution

A pointer to the last converged solution.

index_insolve = 0
ds = 0.0
sign_ds = 1.0
x_start
x
x_pred
R = None
J_f = None
J_lu = None
J_qr = None
precedent_solution = None
_init_flags()

Initialise the different flag attributes of the class.

CheckComplete()

Checks if all elements required to proceed are present in the SystemSolution object.

Returns:

True if the solution is considered valid.

Return type:

bool

SaveSolution(List: list)

Saves the SystemSolution object in the provided list if it is complete.

Parameters:

List (list) – A list to save the SystemSolution object.

Raises:

ValueError – If the SystemSolution is not complete.

getJacobian(format: str = 'full', dump: bool = False) numpy.ndarray

Returns the Jacobian in the specified format.

Parameters:
  • format (str) – The format of the Jacobian. Options: “full”, “qr”, “lu” (default: “full”).

  • dump (bool) – If True, erases the Jacobian result with the format_in (default: False).

Returns:

The Jacobian in the requested format, or None if the Jacobian is not available.

Return type:

np.ndarray

Raises:

ValueError – If the format is not compatible.

convertJacobian(format_in, format_out, dump=False)

Converts the Jacobian format from format_in to format_out.

Parameters:
  • format_in (str) – The current format of the Jacobian.

  • format_out (str) – The desired format of the Jacobian.

  • dump (bool) – If True, erases the Jacobian result with the format_in (default: False).

Returns:

The updated flags and Jacobian data.

Return type:

tuple

Raises:

ValueError – If the format is not compatible.

class pyHarm.Solver.FirstSolution(xs)

Bases: SystemSolution

Inherits from the SystemSolution class with one major difference: there is no previous SystemSolution point for this class.

Parameters:

xs (np.ndarray) – An array representing the starting point.

x
x_pred