API

The API (application programming interface) is described here with the documentation of the Solver class and its methods.

class saenopy.solver.Solver(**kwargs)[source]
get_max_tet_stiffness() NDArray[Shape[N_t], float64][source]

Calculates the stiffness matrix K_ij, the force F_i and the energy E of each node.

preprocessing = None
preprocessing = [

“load_stack”: [“1_*.tif”, “2_*.tif”, voxel_sixe], “3D_piv”: [overlap, windowsize, signoise, drifcorrection], “iterpolate_mesh”: [],

]

set_beams(beams: int | NDArray[Shape[N_b, 3], float64] = 300)[source]

Sets the beams for the calculation over the whole solid angle.

Parameters:

beams (int, ndarray) – Either an integer which defines in how many beams to discretize the whole solid angle or an ndarray providing the beams, dimensions Nx3, default 300

set_boundary_condition(displacements: NDArray[Shape[N_c, 3], float64] | None = None, forces: NDArray[Shape[N_c, 3], float64] | None = None)[source]

Provide the boundary condition for the mesh, to be used with solve_nonregularized().

Parameters:
  • displacements (ndarray, optional) – If the displacement of a node is not nan, it is treated as a Dirichlet boundary condition and the displacement of this node is kept fixed during solving. Dimensions Nx3

  • forces (ndarray, optional) – If the force of a node is not nan, it is treated as a von Neumann boundary condition and the solver tries to match the force on the node with the here given force. Dimensions Nx3

set_initial_displacements(displacements: NDArray[Shape[N_c, 3], float64])[source]

Provide initial displacements of the nodes. For fixed nodes these displacements are ignored.

Parameters:

displacements (ndarray) – The list of displacements. Dimensions Nx3

set_material_model(material: Material, generate_lookup=True)[source]

Provides the material model.

Parameters:

material (Material) – The material, must be of a subclass of Material.

set_nodes(data: NDArray[Shape[N_c, 3], float64])[source]

Provide mesh coordinates.

Parameters:

data (ndarray) – The coordinates of the vertices. Dimensions Nx3

set_target_displacements(displacement: NDArray[Shape[N_c, 3], float64], reg_mask: NDArray[Shape[N_c], bool_] | None = None)[source]

Provide the displacements that should be fitted by the regularization.

Parameters:

displacement (ndarray) – If the displacement of a node is not nan, it is The displacements for each node. Dimensions N x 3

set_tetrahedra(data: NDArray[Shape[N_t, 4], integer])[source]

Provide mesh connectivity. Nodes have to be connected by tetrahedra. Each tetraherdon consts of the indices of the 4 vertices which it connects.

Parameters:

data (ndarray) – The node indices of the 4 corners. Dimensions Nx4

solve_boundarycondition(step_size: float = 0.066, max_iterations: int = 300, i_min: int = 12, rel_conv_crit: float = 0.01, relrecname: str | None = None, verbose: bool = False, callback: callable | None = None)[source]

Solve the displacement of the free nodes constraint to the boundary conditions.

Parameters:
  • step_size (float, optional) – How much of the displacement of each conjugate gradient step to apply. Default 0.066

  • max_iterations (int, optional) – The maximal number of iterations for the relaxation. Default 300

  • i_min (int, optional) – The minimal number of iterations for the relaxation. Minimum value is 6. Default is 12

  • rel_conv_crit (float, optional) – If the relative standard deviation of the last 6 energy values is below this threshold, finish the iteration. Default 0.01

  • relrecname (string, optional) – If a filename is provided, for every iteration the displacement of the conjugate gradient step, the global energy and the residuum are stored in this file.

  • verbose (bool, optional) – If true print status during optimisation

  • callback (callable, optional) – A function to call after each iteration (e.g. for a live plot of the convergence)

solve_regularized(step_size: float = 0.33, solver_precision: float = 1e-18, max_iterations: int = 300, i_min: int = 12, rel_conv_crit: float = 0.01, alpha: float = 10000000000.0, method: str = 'huber', relrecname: str | None = None, verbose: bool = False, callback: callable | None = None)[source]

Fit the provided displacements. Displacements can be provided with setTargetDisplacements().

Parameters:
  • step_size (float, optional) – How much of the displacement of each conjugate gradient step to apply. Default 0.33

  • solver_precision (float, optional) – The tolerance for the conjugate gradient step. Will be multiplied by the number of nodes. Default 1e-18.

  • max_iterations (int, optional) – The maximal number of iterations for the regularisation. Default 300

  • i_min (int, optional) – The minimal number of iterations for the relaxation. Minimum value is 6. Default is 12.

  • rel_conv_crit (float, optional) – If the relative standard deviation of the last 6 energy values is below this threshold, finish the iteration. Default 0.01

  • alpha (float, optional) – The regularisation parameter. How much to weight the suppression of forces against the fitting of the measured displacement. Default 3e9

  • method (string, optional) –

    The regularisation method to use:

    ”huber” “bisquare” “cauchy” “singlepoint”

  • relrecname (string, optional) – The filename where to store the output. Default is to not store the output, just to return it.

  • verbose (bool, optional) – If true print status during optimisation

  • callback (callable, optional) – A function to call after each iteration (e.g. for a live plot of the convergence)