tensors module

class apsg.tensors.DefGrad

Bases: numpy.ndarray

DefGrad store deformation gradient tensor derived from numpy.ndarray.

Parameters:a (3x3 array_like) – Input data, that can be converted to 3x3 2D array. This includes lists, tuples and ndarrays.
Returns:DefGrad object

Example

>>> F = DefGrad(np.diag([2, 1, 0.5]))
classmethod from_axis(vector, theta)

Return DefGrad representing rotation around axis.

Parameters:
  • vector – Rotation axis as Vec3 like object
  • theta – Angle of rotation in degrees

Example

>>> F = DefGrad.from_axis(Lin(120, 30), 45)
classmethod from_comp(xx=1, xy=0, xz=0, yx=0, yy=1, yz=0, zx=0, zy=0, zz=1)

Return DefGrad tensor defined by individual components. Default is identity tensor.

Keyword Arguments:
 xy, xz, yx, yy, yz, zx, zy, zz (xx,) – tensor components

Example

>>> F = DefGrad.from_comp(xy=1, zy=-0.5)
>>> F
DefGrad:
[[ 1.   1.   0. ]
 [ 0.   1.   0. ]
 [ 0.  -0.5  1. ]]
classmethod from_pair(p)
classmethod from_ratios(Rxy=1, Ryz=1)

Return isochoric DefGrad tensor with axial stretches defined by strain ratios. Default is identity tensor.

Keyword Arguments:
 Ryz (Rxy,) – strain ratios

Example

>>> F = DefGrad.from_ratios(Rxy=2, Ryz=3)
>>> F
DefGrad:
[[2.28942849 0.         0.        ]
 [0.         1.14471424 0.        ]
 [0.         0.         0.38157141]]
rotate(vector, theta=0)

Rotate tensor around axis by angle theta.

Using rotation matrix it returns F = R * F * R . T.

velgrad(time=1)

Return VelGrad for given time

E1

Max eigenvalue

E2

Middle eigenvalue

E3

Min eigenvalue

I

Returns the inverse tensor.

R

Return rotation part of DefGrad from polar decomposition.

U

Return stretching part of DefGrad from right polar decomposition.

V

Return stretching part of DefGrad from left polar decomposition.

axisangle

Return rotation part of DefGrad axis, angle tuple.

eigenfols

Return `Group` of principal eigenvectors as Fol objects.

eigenlins

Return `Group` of principal eigenvectors as Lin objects.

eigenvals

Return tuple of sorted eigenvalues.

eigenvects

Return `Group` of principal eigenvectors as Vec3 objects.

class apsg.tensors.VelGrad

Bases: numpy.ndarray

VelGrad store velocity gradient tensor derived from numpy.ndarray.

Parameters:a (3x3 array_like) – Input data, that can be converted to 3x3 2D array. This includes lists, tuples and ndarrays.
Returns:VelGrad object

Example

>>> L = VelGrad(np.diag([0.1, 0, -0.1]))
defgrad(time=1)

Return DefGrad tensor accumulated after given time.

When time is iterable, return list of DefGrad tensors for each time

classmethod from_comp(xx=0, xy=0, xz=0, yx=0, yy=0, yz=0, zx=0, zy=0, zz=0)

Return VelGrad tensor. Default is zero tensor.

Keyword Arguments:
 xy, xz, yx, yy, yz, zx, zy, zz (xx,) – tensor components

Example

>>> L = VelGrad.from_comp(xx=0.1, zz=-0.1)
>>> L
VelGrad:
[[ 0.1  0.   0. ]
 [ 0.   0.   0. ]
 [ 0.   0.  -0.1]]
rotate(vector, theta=0)

Rotate tensor around axis by angle theta.

Using rotation matrix it returns F = R * F * R . T.

rate

Return rate of deformation tensor

spin

Return spin tensor

class apsg.tensors.Stress

Bases: numpy.ndarray

Stress store stress tensor derived from numpy.ndarray.

Parameters:a (3x3 array_like) – Input data, that can be converted to 3x3 2D array. This includes lists, tuples and ndarrays.
Returns:Stress object

Example

>>> S = Stress([[-8, 0, 0],[0, -5, 0],[0, 0, -1]])
cauchy(n)

Return stress vector associated with plane given by normal vector.

Parameters:n – normal given as Vec3 or Fol object

Example

>>> S = Stress.from_comp(xx=-5, yy=-2, zz=10, xy=1)
>>> S.cauchy(Fol(160, 30))
V(-2.520, 0.812, 8.660)
fault(n)

Return Fault object derived from given by normal vector.

Parameters:n – normal given as Vec3 or Fol object

Example

>>> S = Stress.from_comp(xx=-5, yy=-2, zz=10, xy=8)
>>> S.fault(Fol(160, 30))
F:160/30-141/29 +
classmethod from_comp(xx=0, xy=0, xz=0, yy=0, yz=0, zz=0)

Return Stress tensor. Default is zero tensor.

Note that stress tensor must be symmetrical.

Keyword Arguments:
 xy, xz, yy, yz, zz (xx,) – tensor components

Example

>>> S = Stress.from_comp(xx=-5, yy=-2, zz=10, xy=1)
>>> S
Stress:
[[-5  1  0]
 [ 1 -2  0]
 [ 0  0 10]]
normal_stress(n)

Return normal stress component on plane given by normal vector.

rotate(vector, theta=0)

Rotate tensor around axis by angle theta.

Using rotation matrix it returns S = R * S * R . T

shear_stress(n)

Return magnitude of shear stress component on plane given by normal vector.

stress_comp(n)

Return normal and shear stress Vec3 components on plane given by normal vector.

E1

Max eigenvalue

E2

Middle eigenvalue

E3

Min eigenvalue

I1

First invariant

I2

Second invariant

I3

Third invariant

deviatoric

A stress deviator tensor component

diagonalized

Returns Stress tensor in a coordinate system with axes oriented to the principal directions and orthogonal matrix R, which brings actual coordinate system to principal one.

eigenfols

Returns Group of three eigenvectors represented as Fol

eigenlins

Returns Group of three eigenvectors represented as Lin

eigenvects

Returns Group of three eigenvectors represented as Vec3

hydrostatic

Mean hydrostatic stress tensor component

mean_stress

Mean stress

class apsg.tensors.Ortensor(matrix, **kwargs)

Bases: apsg.tensors.Tensor

Represents an orientation tensor, which characterize data distribution using eigenvalue method. See (Watson 1966, Scheidegger 1965).

See following methods and properties for additional operations.

Parameters:

matrix (3x3 array_like) – Input data, that can be converted to 3x3 2D matrix. This includes lists, tuples and ndarrays. Array could be also Group (for backward compatibility)

Keyword Arguments:
 
  • name (str) – name od tensor
  • scaled (bool) – When True eigenvectors are scaled by eigenvalues. Otherwise unit length. Default False
Returns:

Ortensor object

Example

>>> ot = Ortensor([[8, 0, 0], [0, 2, 0], [0, 0, 1]])
>>> ot
Ortensor:  Kind: LLS
(E1:8,E2:2,E3:1)
[[8 0 0]
 [0 2 0]
 [0 0 1]]
classmethod from_comp(xx=0, xy=0, xz=0, yy=0, yz=0, zz=0, **kwargs)

Return Ortensor tensor. Default is identity tensor.

Note that Ortensor tensor must be symmetrical.

Example

>>> ot = Ortensor.from_comp(xx=5, yy=2, zz=10, xy=1)
>>> ot
Ortensor:  Kind: SSL
(E1:10,E2:5.303,E3:1.697)
[[ 5  1  0]
 [ 1  2  0]
 [ 0  0 10]]
classmethod from_group(g, **kwargs)

Return Ortensor of data in Group

Parameters:gGroup of Vec3, Lin or Fol

Example

>>> g = Group.examples('B2')
>>> ot = Ortensor.from_group(g)
>>> ot
Ortensor: B2 Kind: L
(E1:0.9825,E2:0.01039,E3:0.007101)
[[ 0.19780807 -0.13566589 -0.35878837]
 [-0.13566589  0.10492993  0.25970594]
 [-0.35878837  0.25970594  0.697262  ]]
>>> ot.eigenlins.data
[L:144/57, L:360/28, L:261/16]
B

Cylindricity index - Vollmer, 1990

E1

Max eigenvalue

E2

Middle eigenvalue

E3

Min eigenvalue

G

Girdle index - Vollmer, 1990

Intensity

Intensity index - Lisle, 1985

MAD

Return approximate deviation according to shape

MADo

Return approximate deviation from the plane normal to E3

MADp

Return approximate angular deviation from the major axis along E1

P

Point index - Vollmer, 1990

R

Random index - Vollmer, 1990

class apsg.tensors.Ellipsoid(matrix, **kwargs)

Bases: apsg.tensors.Tensor

Ellipsoid class

See following methods and properties for additional operations.

Parameters:matrix (3x3 array_like) – Input data, that can be converted to 3x3 2D matrix. This includes lists, tuples and ndarrays.
Returns:Ellipsoid object

Example

>>> E = Ellipsoid([[8, 0, 0], [0, 2, 0], [0, 0, 1]])
>>> E
Ellipsoid:  Kind: LLS
(E1:2.828,E2:1.414,E3:1)
[[8 0 0]
 [0 2 0]
 [0 0 1]]
classmethod from_axes(x=1, y=1, z=1, **kwargs)

Return Ellipsoid tensor defined by principal axes.

Example

>>> E = Ellipsoid.from_axes(x=4, y=0.5, z=0.5)
>>> E
Ellipsoid:  Kind: L
(E1:4,E2:0.5,E3:0.5)
[[16.    0.    0.  ]
 [ 0.    0.25  0.  ]
 [ 0.    0.    0.25]]
classmethod from_defgrad(F, **kwargs)

Return Finger (Left Cauchy-Green) deformation tensor resulting from deformation F

Parameters:FDefGrad or any 3x3 array_like object

Example

>>> F = DefGrad.from_comp(xx=2, xz=1, zz=0.5)
>>> E = Ellipsoid.from_defgrad(F)
>>> E
Ortensor: D Kind: LS
(E1:0.9825,E2:0.01039,E3:0.007101)
[[ 0.19780807 -0.13566589 -0.35878837]
 [-0.13566589  0.10492993  0.25970594]
 [-0.35878837  0.25970594  0.697262  ]]
transform(F)

Return Ellipsoid representing result of deformation F

E1

Max eigenvalue

E2

Middle eigenvalue

E3

Min eigenvalue