trusspy.solvers.tpsolver module#

title: TrussPy - Truss Solver for Python author: Andreas Dutzler year: 2023

trusspy.solvers.tpsolver.dfdx(Vred, V0red, j, Vmax, equilibrium, stiffness, analysis=None, statev_write=False)[source]#

stiffness matrix, extended to (nDOF+1,nDOF+1)

trusspy.solvers.tpsolver.dxmax_control(dxmax, dxmax0, j, j0, z, cycl, nr_success, b, n, nfev, minfac=1e-06, maxfac=10, reduce=8.0, increase=0.5, verbose=2)[source]#

Automatic control for incremental limit of system vector x. Based on the success of the nonlinear solution process the incremental limit will be either increased or decreased. If the newton iterations in the current inc. converged and the last 3 increments were successful (without any recycle) an increase of dxmax is performed. The amount of successful increments before the current one is read by the parameter b. The increase factor is based on a constant value increase and on the convergence rate of the current increment. The total increase factor is calculated as increase_total = 1 + (nfev-n)/nfev * increase. On the other hand, if the current increment did not converge, dxmax will be reduced by a given value decrease. Both an increase and decrease is only performed inside the interval minfac*dxmax0 <= dxmax <= maxfac*dxmax0.

Parameters:
  • dxmax (ndarray) – current incremental limit of system vector x

  • dxmax0 (ndarray) – initial incremental limit of system vector x

  • j (int) – current control component of x

  • j0 (int) – initial control component of x (at the beginning of the inc.)

  • z (int) – number of recycles in current increment

  • cycl (int) – max. number of recycles

  • nr_success (bool) – flag to check if nonlinear solution process converged

  • b (int) – number of converged increments before this increment

  • n (int) – number of newton iterations until convergence was reached

  • nfev (int) – allowed number of newton iterations

  • minfac (float, optional) – minimum factor of dxmax0 where a decrease of dxmax is performed (minfac*dxmax0 <= dxmax <= maxfac*dxmax0)

  • maxfac (float, optional) – minimum factor of dxmax0 where a decrease of dxmax is performed (minfac*dxmax0 <= dxmax <= maxfac*dxmax0)

  • reduce (flaot, optional) – factor do decrease dxmax if current increment did not converge. (dxmax= dxmax/reduce)

  • increase (float, optional) – factor do increase dxmax if current increment and the 3 increments before did converge. (dxmax = dxmax * (1 + (nfev-n)/nfev * increase))

  • verbose (int, optional) – Level of information during iterations (default is 0): verbose=0,1 … no information, verbose=2 … print dxmax changes

Returns:

  • dxmax (ndarray) – updated incremental limit of system vector x

  • z (int) – updated number of recycles in current increment

  • b (int) – updated number of converged increments before this increment

  • dx_changed (bool) – flag to indicate if a change in dxmax was performed

trusspy.solvers.tpsolver.f(Vred, V0red, j, Vmax, equilibrium, stiffness, analysis=None, statev_write=False)[source]#

equilibrium function, extended to (nDOF+1)

trusspy.solvers.tpsolver.pathfollow(g, dgdx, x, analysis, dxmax=[0.02, 0.02], j=None, j_fixed=False, j_pre=True, xlimit=None, incs=20, nfev=8, cycl=4, ftol=1e-08, xtol=1e-08, stepcontrol=True, maxfac=10, minfac=1e-06, reduce=8, increase=1, dxtol=1.25, verbose=0)[source]#

Path following algorithm of a curve.

Parameters:
  • f (ndarray) – 1D Vectorized function to minimize which depends on vector x

  • dfdx (array) – 2D Derivative of function w.r.t. x

  • x (ndarray) – 1D Initial solution vector

  • analysis (trusspy.core.analysis) – Analysis object

  • dxmax (array_like, optional) – Maximum incremental step in Dx. Several input methods are possible. A single float value will assign dxmax to all components of Dx. A list of length 2 will control all values with dxmax[0] except for the last one, which is controlled by dxmax[1]. A list of length x assigns each component of dxmax to the corresponding component of x. (default is [0.02, 0.02])

  • j (int, optional) – initial control component. Limit j-th component of Dx during an increment (default is None which will use last component of Dx –> LPF load component)

  • j_fixed (bool, optional) – Lock control component to initial j (default is False). If True, a dedicated control component j has to be specified.

  • j_pre (bool, optional) – Use linearized solution at the beginning of each increment to determine the control component j. The determinant of K control the sign of j. (default is True)

  • x_limit (list, optional) – List of length 2 containing [j,max_value] to limit the loadcase execution. (default is None)

  • incs (int, optional) – Maximum number of increments. (default is 20)

  • nfev (int, optional) – Maximum number of newton iterations (default is 8)

  • cycl (int, optional) – Maximum number of recycles, either due to a switch in control component or non-converged newton step if stepsize-control is active. (default is 4)

  • ftol (float, optional) – Tolerance for residual of function: norm(f) (default is 1e-8)

  • xtol (float, optional) – Tolerance for residual of x: norm(x) (default is 1e-8)

  • stepcontrol (bool, optional) – Automatic adjustment of incremental stepwidth Dx. Parameters macfac, minfac, reduce and increase will control the adjustment. All components of dxmax will be increased or reduced by the same factor. (default is True)

  • maxfac (float, optional) – Maximum factor compared to initial dxmax. (default is 10)

  • minfac (float, optional) – Minimum factor compared to initial dxmax. (default is 1e-6)

  • reduce (float, optional) – Factor to reduce dxmax. Updating dxmax follows dxmax = dxmax/reduce. (default is 8)

  • increase (float, optional) – Factor to increase dxmax. To increase dxmax the total number of newton iterations to achieve convergence will be used. Updating dxmax follows dxmax = dxmax*(1+(nfev-n)/nfev * increase). (default is 1)

  • dxtol (float, optional) – Allowed vvershoot factor of control component if solution has converged. Will help to speed-up solution and avoid unneccessary re- cycles. (default is 1.25)

  • verbose (int, optional) – Level of information during iterations (default is 0): verbose=0 … no information, verbose=1 … print iteration number, norm(f), norm(x)

Returns:

  • res_x (ndarray) – 2D-array containing all valid solutions for all increments. Shape is res_x.shape = (incs, len(x)+1). Result array res_x[1] contains the converged solution vector for the first increment. Result component res_x[0] contains start solution which is typically zeros.

  • res_a (Analysis) – Analysis Class (trusspy.core.analysis.Analysis) with converged solution.