Spring - 3D spring element with constant stiffnesses (pyfe3d.spring)#
Defines the two-node element Spring, with six degrees-of-freedom
per node and a constant stiffness for each of them, its probe
SpringProbe and SpringData, which gives the number of
sparse entries per element of each structural matrix.
- class pyfe3d.spring.Spring#
Spring 3D beam element with constant stiffnesses
Note
The default behaviour assumes that the local coordinate system is aligned with the global coordinate system
The constructor stores
pinprobe, setseid,n1,n2,c1andc2to-1, sets theinit_k_*positions, the stiffnesses andvxyi,vxyj,vxykto0, and sets the rotation matrix to the identity.update_KC0()andupdate_probe_finte()read the stiffnesses and the rotation matrix;update_probe_finte()also readsprobe.ue, updated byupdate_probe_ue(). The element has no length, and the nodal coordinates are not used.- Parameters:
- p
SpringProbeobject Probe of the element, stored in
probe. It can be shared with other elements.
- p
- Attributes:
- eid,int
Element identification number.
- kxe, kye, kze: double
Translational stiffnesses in the element coordinate system, force per unit length.
- krxe, krye, krzedouble
Rotational stiffnesses in the element coordinate system, moment per unit rotation.
- r11, r12, r13, r21, r22, r23, r31, r32, r33double
Entries \(T_{ij}\) of the transformation matrix \(\boldsymbol{T}_{3\times 3}\) from element to global coordinates, whose columns are the element axes. By default it assumes that the element is aligned with the global coordinate system. Dimensionless.
- vxyi, vxyj, vxykdouble
Components of a vector on the \(XY\) plane of the element coordinate system, defined using global coordinates. Only the direction of the vector is used.
- c1, c2int
Position of each node in the global stiffness matrix, i.e. of the first of its
6degrees-of-freedom.- n1, n2int
Node identification number.
- init_k_KC0, init_k_KG, init_k_Mint
Position in the arrays storing the sparse data for the structural matrices, where the entries of this element start, see
SpringDatafor their number.probeSpringProbeobjectprobe: pyfe3d.spring.SpringProbe
Methods
update_KC0(self, long[, long[, double[, ...)Update sparse vectors for linear constitutive stiffness matrix KC0
update_fint(self, double[)Update the internal force vector
update_probe_finte(self)Update the internal force vector of the probe
update_probe_ue(self, double[)Update the local displacement vector of the probe of the element
update_rotation_matrix(self, double xi, ...)Update the rotation matrix of the element
Notes
The strain energy of the element is
\[U = \frac{1}{2} \sum_{i=1}^{6} k_i \left( {u_e}_{i+6} - {u_e}_{i} \right)^2\]where \(k_1, ..., k_6\) are
kxe,kye,kze,krxe,kryeandkrze, andueare the displacements in the element coordinate system, in the order ofSpringProbe. Each stiffness connects only the same degree-of-freedom of the two nodes, without coupling between translations and rotations, such that the internal forces arefinte = [K_e] uewith\[\begin{split}\boldsymbol{K}_e = \begin{bmatrix} [k] & -[k] \\ -[k] & [k] \end{bmatrix}, \qquad [k] = \mathrm{diag}(k_1, ..., k_6)\end{split}\]transformed to global coordinates with the transformation matrix of the element, \(\boldsymbol{K} = \boldsymbol{T} \boldsymbol{K}_e \boldsymbol{T}^\top\), where \(\boldsymbol{T}\) is block diagonal with four copies of the matrix \(\boldsymbol{T}_{3\times 3}\) of the entries \(T_{ij}\) stored in
r11, ..., r33, whose columns are the element axes.A rigid translation and equal rotations of the two nodes give no internal forces. Since the nodal coordinates are not used, a rigid rotation \(\boldsymbol{\theta}\) of two nodes at different positions \(\boldsymbol{p}_1\) and \(\boldsymbol{p}_2\) gives the relative translation \(\boldsymbol{\theta} \times (\boldsymbol{p}_2 - \boldsymbol{p}_1)\), normal to the line of the nodes, which loads the translational stiffnesses in that direction: with the element \(x\) axis along the line of the nodes,
kyeandkze. These properties are verified intests/test_spring.py.- c1#
c1: ‘int’
- c2#
c2: ‘int’
- eid#
eid: ‘int’
- init_k_KC0#
init_k_KC0: ‘int’
- init_k_KG#
init_k_KG: ‘int’
- init_k_M#
init_k_M: ‘int’
- krxe#
krxe: ‘double’
- krye#
krye: ‘double’
- krze#
krze: ‘double’
- kxe#
kxe: ‘double’
- kye#
kye: ‘double’
- kze#
kze: ‘double’
- n1#
n1: ‘int’
- n2#
n2: ‘int’
- probe#
probe: pyfe3d.spring.SpringProbe
- r11#
r11: ‘double’
- r12#
r12: ‘double’
- r13#
r13: ‘double’
- r21#
r21: ‘double’
- r22#
r22: ‘double’
- r23#
r23: ‘double’
- r31#
r31: ‘double’
- r32#
r32: ‘double’
- r33#
r33: ‘double’
- update_KC0(self, long[: :1] KC0r, long[: :1] KC0c, double[: :1] KC0v, int update_KC0v_only=0) void#
Update sparse vectors for linear constitutive stiffness matrix KC0
The 72 entries of the matrix of the element, in global coordinates, are written at the positions
init_k_KC0toinit_k_KC0 + 71: the row and column indices, built fromc1andc2, are stored inKC0randKC0c, and the values are added to those already inKC0v. The matrix is computed from the rotation matrix and the stiffnesseskxe,kye,kze,krxe,kryeandkrze. The rotation matrix must be updated before, when the element is not aligned with the global coordinate system, seeupdate_rotation_matrix().- Parameters:
- KC0rnp.array
Array to store row positions of sparse values. 1-D array of integers of the C type
long, of size at leastinit_k_KC0 + 72.- KC0cnp.array
Array to store column positions of sparse values. Same type and size as
KC0r.- KC0vnp.array
Array to store sparse values. 1-D array of floats of size at least
init_k_KC0 + 72.- update_KC0v_onlyint, optional
The default
0means that the row and column indicesKC0randKC0cshould also be updated. Any other value will only update the stiffness matrix valuesKC0v.
- update_fint(self, double[: :1] fint) void#
Update the internal force vector
Calls
update_probe_finte(), transforms the forces and moments ofprobe.finteto global coordinates with the rotation matrix and adds them tofintat the positionsc1toc1 + 5andc2toc2 + 5. The displacementsprobe.uemust be updated before, seeupdate_probe_ue().- Parameters:
- fintnp.array
Array that is updated in place with the internal forces. The internal forces stored in
fintare calculated in global coordinates. Methodupdate_probe_finte()is called to update the parameterfinteof theSpringProbewith the internal forces in local coordinates. 1-D array of size6*M, for \(M\) nodes in the model.
- update_probe_finte(self) void#
Update the internal force vector of the probe
The attribute
finteis updated with theSpringProbethe internal forces in local coordinates. While using this function, mind that the probe can be shared amongst more than one finite element, depending how you defined them, meaning that the probe will always safe the values from the last udpate.Note
The
finteattribute of objectSpringProbeis updated, accessible using.probe.finte.The 12 values of
finteare overwritten. They are computed from the stiffnesseskxe,kye,kze,krxe,kryeandkrzeand from the displacementsprobe.ue, which must be updated before, seeupdate_probe_ue().
- update_probe_ue(self, double[: :1] u) void#
Update the local displacement vector of the probe of the element
Note
The
ueattribute of objectSpringProbeis updated, accessible using.probe.ue.The translations and rotations of the two nodes, read from
uat the positionsc1toc1 + 5andc2toc2 + 5, are transformed to the element coordinate system with the transpose \(\boldsymbol{T}_{3\times 3}^\top\) of the transformation matrix, which must be updated before, seeupdate_rotation_matrix().- Parameters:
- uarray-like
Array with global displacements, for a total of \(M\) nodes in the model, this array will be arranged as: \(u_1, v_1, w_1, {r_x}_1, {r_y}_1, {r_z}_1, u_2, v_2, w_2, {r_x}_2, {r_y}_2, {r_z}_2, ..., u_M, v_M, w_M, {r_x}_M, {r_y}_M, {r_z}_M\). Translations of dimension length and rotations, 1-D array of size
6*M.
- update_rotation_matrix(self, double xi, double xj, double xk, double vxyi, double vxyj, double vxyk) void#
Update the rotation matrix of the element
Attributes
r11,r12,r13,r21,r22,r23,r31,r32,r33are updated, with the entries \(T_{ij}\) of the transformation matrix \(\boldsymbol{T}_{3\times 3}\) from element to global coordinates, whose columns are the element axes.The element coordinate system is determined, identifying the \(ijk\) components of each axis: \({x_e}_i, {x_e}_j, {x_e}_k\); \({y_e}_i, {y_e}_j, {y_e}_k\); \({z_e}_i, {z_e}_j, {z_e}_k\).
The element \(x\) axis is
(xi, xj, xk), the \(z\) axis is normal to the \(x\) axis and to the vector(vxyi, vxyj, vxyk), the \(y\) axis completes the right-handed system, and the three axes are normalized. The element attributesvxyi,vxyjandvxykare also updated.- Parameters:
- xi, xj, xkdouble
Components, in global coordinates, of the element x-axis. Only the direction of the vector is used.
- vxyi, vxyj, vxykdouble
Components, in global coordinates, of a vector on the \(XY\) plane of the element coordinate system. Only the direction of the vector is used. A vector parallel to the element x-axis gives a null \(z\) axis and a rotation matrix with
nanentries.
- vxyi#
vxyi: ‘double’
- vxyj#
vxyj: ‘double’
- vxyk#
vxyk: ‘double’
- class pyfe3d.spring.SpringData#
Used to allocate memory for the sparse matrices.
Each attribute is the number of entries that one
Springelement writes in the arrays of rows, columns and values of a sparse matrix, at the consecutive positions that start at itsinit_k_KC0,init_k_KGorinit_k_M. The constructor takes no argument and sets the values below.- Attributes:
- KC0_SPARSE_SIZE,int
KC0_SPARSE_SIZE = 72, written bySpring.update_KC0().- KG_SPARSE_SIZE,int
KG_SPARSE_SIZE = 0, the element has no geometric stiffness matrix.- M_SPARSE_SIZE,int
M_SPARSE_SIZE = 0, the element has no mass matrix.
- KC0_SPARSE_SIZE#
KC0_SPARSE_SIZE: ‘int’
- KG_SPARSE_SIZE#
KG_SPARSE_SIZE: ‘int’
- M_SPARSE_SIZE#
M_SPARSE_SIZE: ‘int’
- class pyfe3d.spring.SpringProbe#
Probe used for local coordinates, local displacements, local stresses etc
The idea behind using a probe is to avoid allocating larger memory buffers per finite element. The memory buffers are allocated per probe, and one probe can be shared amongst many finite elements, with the information being updated and retrieved on demand.
Note
The probe can be shared amongst more than one finite element, depending on how you defined them. Mind that the probe will always safe the values from the last udpate.
The constructor takes no argument and allocates the arrays below, filled with zeros.
- Attributes:
- xe,array-like
Array of size
NUM_NODES*DOF//2=6containing the nodal coordinates in the element coordinate system, in the following order \({x_e}_1, {y_e}_1, {z_e}_1, {x_e}_2, {y_e}_2, {z_e}_2\). Dimension length. Not updated by the methods ofSpring.- ue,array-like
Array of size
NUM_NODES*DOF=12containing the element displacements in the following order \({u_e}_1, {v_e}_1, {w_e}_1, {{r_x}_e}_1, {{r_y}_e}_1, {{r_z}_e}_1, {u_e}_2, {v_e}_2, {w_e}_2, {{r_x}_e}_2, {{r_y}_e}_2, {{r_z}_e}_2\). Translations of dimension length and rotations. Updated bySpring.update_probe_ue().- finte,array-like
Array of size
NUM_NODES*DOF=12containing the element internal forces corresponding to the degrees-of-freedom described byue, forces and moments. Updated bySpring.update_probe_finte().
- finte#
finte: ‘double[::1]’
- ue#
ue: ‘double[::1]’
- xe#
xe: ‘double[::1]’