pyoti package#

Submodules#

pyoti.core module#

pyoti.core.compilation_status()#

PURPOSE: Returns true if the library was compiled with openmp support.

class pyoti.core.dHelp#

Bases: object

get_base_exp(indx, order)#

PURPOSE: Get the base - exponent representation of an imaginary direction given by its index and order.

get_compact_fulldir(indx, order)#

PURPOSE: Get the compact representation of an imaginary direction defined by (index,order).

get_deriv_factor(indx, order)#
get_fulldir(indx, order)#

PURPOSE: Get the expanded representation of an imaginary direction as an array.

get_ndir_order(nbases, order)#
PURPOSE: Return the number of imaginary directions of given order for the number of

basis given.

@param[in] nbases: Number of imaginary basis. @param[in] order: Order of imagianry direcitions.

get_ndir_total(nbases, order)#
PURPOSE: Return the total number of imaginary directions for the given number of

basis and truncation order.

@param[in] nbases: Number of imaginary basis @param[in] order: Truncation order

get_str_fulldir(indx, order)#

PURPOSE: Get the expanded string representation of an imaginary direction.

mult_dir(indx1, ord1, indx2, ord2)#

PURPOSE: Multiply two imaginary directions.

@param[in] indx1, ord1: Pair defining imaginary direction 1. @param[in] indx2, ord2: Pair defining imaginary direction 2.

print_capabilities()#

PURPOSE: Print capabilities of the direction helper.

pyoti.core.dhelp_get_matrix_form(nbases, order, export_latex=True, export_strings=False, export_sparse=False)#
pyoti.core.div_imdir(humdir_num, humdir_den)#
pyoti.core.div_imdir_idxord(numidx, numord, denidx, denord)#
pyoti.core.exit_with_error()#
pyoti.core.expand_imdir(hum_dir)#
pyoti.core.get_CR_mdl(dirBasis, maxBasis)#
PURPOSE: Return the matrix positions where a dual number will exist in the current OTI number

of an oti number of “nvar” variables and order “order”.

pyoti.core.get_dHelp()#

PURPOSE: Return the global helper that is a global variable inside the otilib.

pyoti.core.get_deriv_factor(hum_dir)#
PURPOSE: Get the factor to be multiplied to the coprresponding imaginary coefficient to get the

exact value of the derivative.

pyoti.core.get_latex_dir(indx, order, real='_{\\mbox{Re}}', epsilon='\\epsilon')#
PURPOSE: To print the imaginary direction referenced to a position of the

binary indexing.

pyoti.core.get_trunc_order()#

PURPOSE: Get the global truncation order for OTI algebra.

pyoti.core.imdir(hum_dir)#
pyoti.core.ndir_order(nbases, order)#

PURPOSE: Compute the number of directions for a given truncation order.

Parameters:
  • nbases – Number of basis.

  • order – Truncation order.

pyoti.core.ndir_total(nbases, order)#

PURPOSE: Compute the total number of directions.

Parameters:
  • nbases – Number of basis.

  • order – Truncation order.

pyoti.core.print_capabilities()#
pyoti.core.print_global_test_py()#
pyoti.core.print_python_error_py()#
pyoti.core.set_global_test_py(x)#
pyoti.core.set_trunc_order(order)#
PURPOSE: Set the global truncation order for OTI algebra. This allows to compute derivatives up to

the set order using oti numbers.

class pyoti.core.writer(order, nbases, language='fortran', tab='  ', coeff_type='REAL*8')#

Bases: object

set_type_fortran()#

pyoti.dense module#

pyoti.dense.acos(val)#

PURPOSE: Mathematical function of inverse cosine for OTI numbers

pyoti.dense.acosh(val)#

PURPOSE: Mathematical function of inverse hyperbolic cosine for OTI numbers

pyoti.dense.add(lhs, rhs)#

PURPOSE: Add two OTI numbers.

DESCRIPTION: Eliminates the need to type check the input parameters

INPUTS:

lhs: otinum rhs: otinum out: otinum, optional. Result holder

pyoti.dense.addO(lhs, rhs, out=None)#

PURPOSE: Add two OTI numbers.

DESCRIPTION: Eliminates the need to type check the input parameters

INPUTS:

lhs: otinum rhs: otinum out: otinum, optional. Result holder

pyoti.dense.addO_to(lhs, rhs, out)#

PURPOSE: Add two elements.

DESCRIPTION: Eliminates the need to type check the input parameters

INPUTS:

lhs: omat rhs: omat out: omat Result holder

pyoti.dense.add_to(lhs, rhs, out)#

PURPOSE: Add two OTI numbers.

DESCRIPTION: Faster version to add two oti numbers to something already allocated.

INPUTS:

lhs: otinum rhs: otinum out: otinum, optional. Result holder

pyoti.dense.asin(val)#

PURPOSE: Mathematical function of inverse sine for OTI numbers

pyoti.dense.asinh(val)#

PURPOSE: Mathematical function of inverse hyperbolic sine for OTI numbers

pyoti.dense.atan(val)#

PURPOSE: Mathematical function of arctangent for OTI numbers

pyoti.dense.atanh(val)#

PURPOSE: Mathematical function of Inverse hyperbolic tangent for OTI numbers

pyoti.dense.cos(val)#

PURPOSE: Mathematical function of cosine for OTI numbers

pyoti.dense.cosh(val)#

PURPOSE: Mathematical function of hyperbolic cosine for OTI numbers

pyoti.dense.det(A)#
pyoti.dense.dot(A, B)#
pyoti.dense.e(hum_dir, order=0, nbases=0)#
PURPOSE: To create an OTI number with value 1 at the specified

direction, in a human friendly manner.

pyoti.dense.exp(val)#

PURPOSE: Exponential function for OTI numbers.

pyoti.dense.eye(size, nbases=0, order=0)#
pyoti.dense.helper_get_multpl(hum_dir)#
pyoti.dense.invert(A)#
pyoti.dense.log(val)#

PURPOSE: Natural logarithm for OTI numbers.

pyoti.dense.log10(val)#

PURPOSE: Natural logarithm base 10 for OTI numbers.

pyoti.dense.logb(val, base)#

PURPOSE: Logarithm base b for OTI numbers.

pyoti.dense.mul(lhs, rhs)#

PURPOSE: Add two OTI numbers.

DESCRIPTION: Faster version to add two oti numbers to something already allocated.

INPUTS:

lhs: otinum rhs: otinum

pyoti.dense.mul_to(lhs, rhs, res)#

PURPOSE: Multiply two OTI numbers.

DESCRIPTION: Faster version to multiply two oti numbers to something already allocated.

INPUTS:

lhs: otinum rhs: otinum out: otinum. Result holder

pyoti.dense.mulr_to(lhs, rhs, res)#

PURPOSE: Multiply two OTI numbers.

DESCRIPTION: Faster version to multiply two oti numbers to something already allocated.

INPUTS:

lhs: otinum rhs: otinum out: otinum. Result holder

pyoti.dense.multiply_val(a)#
class pyoti.dense.omat#

Bases: object

copy()#

PURPOSE: Copy the elements to new memory spaces.

get_deriv(hum_dir, copy=True)#

PURPOSE: Get the corresponding derivative of the system.

get_im(hum_dir, copy=True)#

PURPOSE: Get the corresponding imaginary direction in the omat object.

get_imdir(idx, order, copy=True)#

PURPOSE: Get the corresponding imaginary direction in the omat object.

nbases#

Return the number of imaginary basis of the sistem.

Type:

PURPOSE

order#

Return the truncation order of array.

Type:

PURPOSE

real#

Get a numpy array with all coefficients in the real direction.

Type:

PURPOSE

set_imdir(arr, idx, order)#

PURPOSE: Get the corresponding imaginary direction in the omat object.

shape#

Return the shape of the stored matrix.

Type:

PURPOSE

size#

Return the size of array.

Type:

PURPOSE

pyoti.dense.ones(nrows, ncols, nbases=0, order=0)#
class pyoti.dense.oti_n2m2#

Bases: object

copy()#
PURPOSE: To create a copy of a spr_otinum object, totally

independent of the original.

DESCRIPTION: The equality operator “=” is intended to create aliases

of multicomplex numbers. You should use copy() when you need a copy instead of an alias.

e1#
e11#
e12#
e2#
e22#
nbases#

Return the number of bases in the otinum.

Type:

PURPOSE

ndir#

Return the number of directions in the otinum.

Type:

PURPOSE

order#

To return the maximum order of the number.

DESCRIPTION: Reads the value in num.

Type:

PURPOSE

re#
short_repr()#
PURPOSE: To print a representation of the otinum object that could be

used to create new otinum objects, in a compact form.

class pyoti.dense.otibase#

Bases: object

Dense OTI scalar number base class.

OTI is short for Order Truncated Imaginary numbers, which will allow you to compute derivatives very precisely on computer machines. The main idea is that you use OTIs as an on-demand tool to compute derivatives of a program that is enabled to use this algebra, by perturbing the variable of interest with an OTI direction.

changeOrder(newOrder)#

PURPOSE: To get the value of an otinum coefficient.

copy()#
dtype#
empty_like()#
extract_deriv(item)#

PURPOSE: Extract the OTI number contained below the given imaginary direction.

extract_im(item)#

PURPOSE: Extract the OTI number contained below the given imaginary direction.

getIm(item)#

PURPOSE: To get the value of an otinum coefficient.

nbases#
ndir#
order#
p_im#
p_ndpo#
re#
setIm(item, value)#

PURPOSE: To set the value of an otinum coefficient.

class pyoti.dense.otinum#

Bases: object

OTI scalar number class.

OTI is short for Order Truncated Imaginary numbers, which will allow you to compute derivatives very precisely on computer machines. The main idea is that you use OTIs as an on-demand tool to compute derivatives of a program, by perturbing the variable of interest with an OTI direction.

Example:

>>> import pyoti.dense as oti
>>> x = 3.5 + oti.e(1, order=2)
>>> f = oti.sin(x**2)* oti.log(x)  # <-- This is the function we want to differentiate.
>>>                                # At this point f already contains all derivatives,
>>>                                # we just need to extract them
>>> f
out: -0.389759 + 8.24523 * e([1]) + 12.6531 * e([[1,2]])
>>> # This is the oti representation.
>>>
>>> f.get_all_deriv()
out: array([-0.38975881,  8.24523458, 25.30624122])
>>> #       ^ f(3.5)     ^ df/dx(3.5) ^ d^2f/dx^2(3.5)
copy()#
PURPOSE: To create a copy of a spr_otinum object, totally

independent of the original.

DESCRIPTION: The equality operator “=” is intended to create aliases

of multicomplex numbers. You should use copy() when you need a copy instead of an alias.

get_all_deriv(order=-1, get_indices=False)#

PURPOSE: To retreive the derivatives contained in the oti number.

get_deriv(hum_dir)#

PURPOSE: to retrieve the derivative contained in the oti number.

nbases#

Return the number of bases in the otinum.

Type:

PURPOSE

ndir#

Return the number of directions in the otinum.

Type:

PURPOSE

order#

To return the maximum order of the number.

DESCRIPTION: Reads the value in num.

Type:

PURPOSE

short_repr()#
PURPOSE: To print a representation of the otinum object that could be

used to create new otinum objects, in a compact form.

to_matrix(sparse_mat=False)#

This function converts an otinum into its equivalent real-only matrix form (Cauchy-Riemann matrix form).

Parameters:

sparse_mat (bool, optional. Default sparse_mat=False.) – Bool to specify if it returns a sparse matrix.

to_vector()#

PURPOSE: To convert an otinum into its vector form.

pyoti.dense.power(val, exponent)#

PURPOSE: Power function for OTI numbers, for non integer exponents.

pyoti.dense.sin(val)#

PURPOSE: Mathematical function of sine for OTI numbers.

pyoti.dense.sinh(val)#

PURPOSE: Mathematical function of hyperbolic sine for OTI numbers

pyoti.dense.solve(A, b)#

PORPUSE: To solve a dense linear system of equations of OTI algebra.

pyoti.dense.solve_latex(nbases, order, real='re')#

PORPUSE: To solve a dense linear system of equations of OTI algebra.

class pyoti.dense.spr_omat#

Bases: object

change_nbases(new_nbases)#

PORPUSE: Change in memory the nbases for allocation.

change_nbases_order(new_nbases, new_order)#

PURPOSE: Change allocation to new order.

change_order(new_order)#

PORPUSE: Change in memory the order with corresponding allocation changesa

get_base_sprmat_creator()#
PORPUSE: Obtain the sparse matrix creator required to generate the corresponding

sparse matrix elements.

get_deriv(hum_dir)#
PURPOSE: Get the factor to be multiplied to the coprresponding imaginary coefficient to get the

exact value of the derivative.

get_imdir(idx, order)#

PURPOSE: Get the corresponding imaginary direction in the omat object.

nbases#
ncols#
ndir#
nrows#
order#
p_im#
p_ndpo#
re#
recompute_ndir()#

PURPOSE: Convert to CSR sparse format.

set_and_sum_from_otinum(index, in_otinum)#

PURPOSE: Add to an element of the array from a sotinum_t

set_from_otinum(index, in_otinum)#

PORPUSE: Set element by otinum.

size#
spr_type#
to_coo()#

PURPOSE: Convert to COO sparse format.

to_csr()#

PURPOSE: Convert to CSR sparse format.

to_dense()#

PURPOSE: Convert to dense omat representation.

to_lil()#

PURPOSE: Convert to LIL sparse format.

pyoti.dense.spsolve(A, b, solver='LU')#

PORPUSE: To solve a sparse linear system of equations of OTI algebra.

pyoti.dense.sqrt(val)#

PURPOSE: Square root function for OTI numbers, for non integer exponents.

pyoti.dense.sub(lhs, rhs)#

PURPOSE: subtract two OTI numbers.

DESCRIPTION: Eliminates the need to type check the input parameters

INPUTS:

lhs: otinum rhs: otinum out: otinum, optional. Result holder

pyoti.dense.sub_to(lhs, rhs, out)#

PURPOSE: subtract two OTI numbers.

DESCRIPTION: Faster version to operate two oti numbers to something already allocated.

INPUTS:

lhs: otinum rhs: otinum out: otinum. Result holder

pyoti.dense.tan(val)#

PURPOSE: Mathematical function of tangent for OTI numbers

pyoti.dense.tanh(val)#

PURPOSE: Mathematical function of hyperbolic tangent for OTI numbers

pyoti.dense.transpose(A)#
pyoti.dense.zeros(nrows, ncols, nbases=0, order=0)#

pyoti.fem module#

class pyoti.fem.dmesh#

Bases: object

pyoti.fem.dx(func1)#

PURPOSE: Define derivative of a Finite Element operation.

INPUTS:

-> func1: Finite element function that will be derived.

pyoti.fem.dy(func1)#

PURPOSE: Define derivative of a Finite Element operation.

INPUTS:

-> func1: Finite element function that will be derived.

pyoti.fem.dz(func1)#

PURPOSE: Define derivative of a Finite Element operation.

INPUTS:

-> func1: Finite element function that will be derived.

class pyoti.fem.elbase#

Bases: object

J#
Jinv#
N#
Neta#
Nx#
Nxi#
Ny#
Nz#
Nzeta#
allocate(intorder, **kwargs)#

DESCRIPTION: Allocate all items as integrat ion points.

INPUTS:

-> intorder: Integration order of the element (helps define the number of integration points).

OUTPUTS:

None. Things occur internally.

allocate_spatial(ndim_an, compute_Jinv=False)#

DESCRIPTION: Allocate all spatial variables.

INPUTS:

-> ndim_an: Number of dimensions of the analysis. -> compute_Jinv: Bool to compute inverse of jacobian (Default False).

OUTPUTS:

None. Things occur internally.

basis#
boundEls#
compute_jacobian()#

DESCRIPTION: Compute jacobian and derived functions.

compute_jacobian_bruteforce()#

DESCRIPTION: Compute jacobian and derived functions.

copy()#

PURPOSE: Create a copy of the element class.

static createElement(nbasis, order, geomBase, kind, ndim, basis, boundEls, faceIndx)#

Static method to create an elbase object. Use this when adding new element types.

This creates and associates an element that can be called from the Problem class.

Parameters:
  • nbasis – Number of basis - Number of degrees of freedom - Number of nodes.

  • order – Maximum order of the element.

  • geomBase – Geometric element type - elLine, elTriangle, etc …

  • kind – Kind of element: Affine - IsoParametric

  • ndim – Number of dimensions of the element. (0-> 0D, 1 -> 1D, 2 -> 2D, 3 -> 3D)

  • basis – Function that evaluates the interpolation basis (N) of the element at the integration points: [N0,N1,…] = basis( xi, eta, zeta)

  • boundEls – List of the already defined interpolation functions that define the boundary interpolation, in the following order. –> [0D, 1D, 2D]

  • faceIndx – Indices of the face to be used in the element.

Returns:

A new elbase object is created.

# 3 node triangle:
#
# (2)
#  * *
#  *   *
# (0)* *(1)

>>> lineIndx1 = np.array([[ 0, 1 ],     # Define the indices of the 1D (edges)
                          [ 1, 2 ],     # in the triangle.
                          [ 2, 0 ]],dtype=np.uint64)

>>> tri3 = elbase.createElement(3,              # Number of basis
                                1,              # Characteristic order of the polynomials
                                elTriangle,     # Geometric type
                                elkindIso,      # Kind of element
                                2,              # Number of dimensions
                                tri3_iso,       # Basis functions.
                                [point1, line2],# Face interpolation functions.
                                np.array([[0,1],
                                 [1,2],         # Face indices
                                 [2,0]],dtype=
                                )
dV#
detJ#
elem_indices#
elh#
elorder#
end()#

Finalize element memory allocation.

eta#
faceIndx#
geomBase#

Get element geometric base.

Type:

PURPOSE

get_boundary_elem(dim, idx)#
DESCRIPTION: Get the boundary of dimension dim and index idx. For this function to work properly,

requires the parent element to be fully allocated (with spatial allocation too) and spatial coordinates have to had been already computed.

INPUTS:

-> dim: Dimension of the boundary to be extracted. -> idx: Index of the boundary element to be extracted.

OUTPUTS:

Returns the elem object of the boundary element already setup for

get_local(arr, out=None)#
DESCRIPTION: get the local items from an array. To call this function, elem_indices must

have been defined.

INPUTS:

-> arr: Global array.

integrate(val, out=None)#

DESCRIPTION: Domain integral over the element.

INPUTS:

-> val: Function that will be integrated. -> out(optional): Preallocated array to receive the result.

OUTPUTS:

If out is None, then an ouput is returned with the correct result.

isInit#

Get if Element is initialized

Type:

PURPOSE

is_allocated()#

Return boolean if the element is allocated.

is_initialized()#

Return boolean if the element is initialized.

kind#

Get element kind.

Type:

PURPOSE

nbasis#

Get number of basis functions of the element.

Type:

PURPOSE

nder#

Get element number of derivatives.

Type:

PURPOSE

ndim#

Get element number of dimensions

  • 0 for point,

  • 1 for line,

  • 2 for triangle/quad,

  • 3 for tetrahedra and brick element.

Type:

PURPOSE

nip#

Get element number of integration points.

Type:

PURPOSE

order#

Get Element integration order

Type:

PURPOSE

reset()#

Reset the values of all spatial variables.

set_coordinates(x, y, z, elem_indices=None)#
DESCRIPTION: Set the coordinates of an OTI number from the global vertices coordinates and the given

elemental indices

INPUTS:

-> x, y, z: Global vertices coordinates. -> elem_indices: (optional) Resets the element nodal index array with the given one.

OUTPUTS:

None. Things occur internally.

set_indices(elem_indices)#
DESCRIPTION: Set the coordinates of an OTI number from the global vertices coordinates and the given

elemental indices

INPUTS:

-> elem_indices: Array with the indices of the corresponding elements in the .

OUTPUTS:

None. Things occur internally.

w#
x#
xi#
y#
z#
zeta#
class pyoti.fem.elemental_operation#

Bases: object

baseSpace#
data#
intorder#
nature#
op_graph#
op_id#
short_repr()#

PURPOSE: Return a short representation of the elemental_operations.

tostr()#

PURPOSE: Return a human readable version of the elemental_operations.

var_id#
pyoti.fem.end_elements()#

This function deallocates all elements if already allocated.

pyoti.fem.enum2string_2(enumId)#

PURPOSE: Returns a string with the name of the corresponding enum value given.

class pyoti.fem.gauss_array#

Bases: object

class pyoti.fem.gauss_matrix#

Bases: object

pyoti.fem.get_elements_from_gmsh(mesh, dim=-1, tag=-1)#

This function allows to get the elements from a gmsh mesh and reshape the nodal indices accordingly.

pyoti.fem.get_enum2str()#

PURPOSE: Returns a dictionary with names of every enum from the FEM module.

pyoti.fem.get_global_algebra()#

PORPUSE: Define the algebra used for the FEM analysis.

pyoti.fem.hex1_iso(xi, eta, zeta)#

Definition of basis functions for the 1 node triangle 2D element (0th order).

NODE NUMBERING:

>     zeta ^          4 y
>          |         / eta
>          |        /
>          |       /
>          |      /
>          |     /
>      *  *|* * *  *
>     * |  |      **
>    *     x     * *
>   *   |       *  *
>  * * * * * * *   *      xi
>  *    | (0)  * x-------->
>  *    |- - - * - *
>  *   /       *  *
>  *  /        * *
>  * /         **
>  * * * * * * *
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.hex20_iso(xi, eta, zeta)#

Definition of basis functions for the 20-node brick 3D element (2nd order). Basis functions taken from Smith, I. “Programming the Finite Element Method” 5th ed. Wiley.

NODE NUMBERING: Node numbering corresponds to GMSH 4 numbering scheme.

>                                         4
>                                         /
>                       ^ zeta           /  eta
>                       |               /
>                       |              /
>                       |             /
>                       |            /
>                       |           /
>             (7)* * * *|* (19)* * * * * *(6)
>             *         |                 **
>            * |        |        /       * *
>           *           |               *  *
>          *   |        |      /       *   *
>        (17)           x           (18)   *
>        *     |             /       *     *
>       *     (15)          x       *     (14)
>      *       |                   *       *
>     *                           *        *
>    *         |                 *         *
>  (4)* * * * * (16)* * * * * *(5)         *
>   *          |                *      x -------------> xi
>   *                           *          *
>   *          |                *          *
>   *         (3)----------(13)-*---------(2)
>   *         /                 *        *
>   *        /                  *       *
>  (10)     /                  (12)    *
>   *      /                    *     *
>   *    (9)                    *   (11)
>   *    /                      *   *
>   *   /                       *  *
>   *  /                        * *
>   * /                         **
>  (0)* * * * * *(8)* * * * * *(1)
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: Evaluated basis functions.

pyoti.fem.hex8_iso(xi, eta, zeta)#

Definition of basis functions for the 8-node brick 3D element (1st order). Basis functions taken from Smith, I. “Programming the Finite Element Method” 5th ed. Wiley.

NODE NUMBERING:

>     zeta ^          4
>          |         / eta
>          |        /
>          |       /
>          |      /
>          |     /
>      (7)*|* * * (6)
>     * |  |      **
>    *     x     * *
>   *   |       *  *
> (4)* * * * *(5)  *      xi
>  *    |      * x-------->
>  *   (3) - - * -(2)
>  *   /       *  *
>  *  /        * *
>  * /         **
> (0)* * * * *(1)
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: Evaluated basis functions.

pyoti.fem.line(a, b, he=1.0, ndivs=None, element_order=1, save=False, real=False)#

PURPOSE: Define a 1D line mesh in the domain [a,b] with an element size he. The order of the element can be specified.

The output contains the physical groups named as follows:

[left]                                  [right]
  |               [domain]                 |
  |                  v                     |
  [----------------------------------------]
Parameters:
  • a (float) – Starting point.

  • b (float) – Ending point.

  • he (float) – <float> Element size. (default he = 1.0)

  • ndivs (int, optional. Devault ndivs=None.) – Number of subdivisions of the line.

  • element_order (int, optional, default element_order=1.) – Order of polynomial basis functions of the elements in the mesh

  • save (Bool, default save=False) – Bool to save mesh into file.

  • real (Bool, default real=False) – Bool to create a mesh with intrinsic double arrays, otherwise use oti arrays.

pyoti.fem.line1_iso(xi, eta, zeta)#

Definition of basis functions for the 1 node line 1D element (0th order).

NODE NUMBERING:

> ------(0)------
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.line2_iso(xi, eta, zeta)#

Definition of basis functions for the 2 node line 1D element (1st order).

NODE NUMBERING:

> (0)---------(1)
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: Evaluated basis functions at the given coordinates.

Derivatives are returned in the following manner:

# Real value. N -> real direction -> [0] .

# First order derivatives dN/dxi -> e1 direction -> [1]. dN/deta -> e2 direction -> [2]. dN/dzeta -> e3 direction -> [3].

# Second order derivatives: d2N/dxi dxi -> e11 direction -> [[1,2]]. d2N/dxi deta -> e12 direction -> [ 1,2 ]. d2N/deta deta -> e22 direction -> [[2,2]]. d2N/dxi dzeta -> e13 direction -> [ 1,3 ]. d2N/deta dzeta -> e23 direction -> [ 2,3 ]. d2N/dzeta dzeta -> e33 direction -> [[3,2]].

# etc…

pyoti.fem.line3_iso(xi, eta, zeta)#

Definition of basis functions for the 3 node Line 1D element (2nd order).

NODE NUMBERING:

> (0)---(2)---(1)
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.map_indices(idxSrc, idxMap)#

PURPOSE:

class pyoti.fem.mesh#

Bases: object

elements#
export(filename, binary=True, dims=None, pd=None, pd_names=None)#

This function loads a file in current format.

INPUTS:

  • filename: Name of the file to save.

  • binary(True):

  • dims(None): Dimensions to export.

  • pd(None): Point Data (can be given in numpy array formats).

  • pd_names(None): Point data names to export.

OUTPUTS:

  • saved file.

static from_gmsh(gmsh)#

PORPUSE: Load from a gmsh object.

get_all_elements(dims=None)#

PORPUSE: Get all the elements in a numpy array.

get_all_elements_pd()#

PORPUSE: Export object as a pandas dataframe.

get_number_elements(dims=None)#

PORPUSE: Get the total number of elements for a given dimension.

group_ids#
group_names#
groups#
static load(filename, generate=True, generate_level=3)#

This function loads a file with format given by its extension. This function uses gmsh to as a backend to open the data.

Currently supported filenames are

  • .msh (GMSH format)

  • .geo (GMSH format)

Parameters:
  • filename (str.) – String with the filename including extension.

  • generate (bool, optional. Default generate=True) – Perform mesh generation from gmsh.

  • generate_level (int, optional. Default generate_level=3.) – Mesh generation option for the number of dimensions to be generated.

ndim#
nnodes#

Get Number of nodes.

Type:

PORPUSE

nodes#

Get nodes as numpy array.

Type:

PORPUSE

to_pv(dims=None, pd=None, pd_names=None)#

PORPUSE: Export mesh as PyVista object. Requires PyVista.

INPUTS:

  • dims(None): Dimensions to export.

  • pd(None): Point Data (can be given in numpy array formats).

  • pd_names(None): Point data names to export.

OUTPUTS:

  • grid: PyVista UnstructuredGrid object.

to_vtk(dims=None, pd=None, pd_names=None, linearize=False)#

PORPUSE: Export mesh as vtk object. (Requires VTK).

INPUTS:

  • dims(None): Dimensions to export.

  • pd(None): Point Data (can be given in numpy array formats).

  • pd_names(None): Point data names to export.

  • linearize(None): Export as linear (order 1) elements.

OUTPUTS:

  • grid: VTK UnstructuredGrid object.

x#
y#
z#
pyoti.fem.op_int2d(Th, f, intorder=None, region=None)#

PURPOSE: Integrate over 2D elements.

pyoti.fem.point1_iso(xi, eta, zeta)#

Definition of basis functions for the 1 node point 0D element. (0th order)

NODE NUMBERING:

>  (0)
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.quad1_iso(xi, eta, zeta)#

Definition of basis functions for the 1 node triangle 2D element (0th order).

NODE NUMBERING:

>       ^ eta
>       |
>       |
> * * * * * * *
> *           *
> *           *        xi
> *    (0)    * ------->
> *           *
> *           *
> * * * * * * *
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.quad4_iso(xi, eta, zeta)#

Definition of basis functions for the 4-node quad 2D element (1st order).This element works for both the first order quad and first order serendipity quad element.

NODE NUMBERING:

>        ^ eta
>        |
>        |
> (3)* * * * *(2)
>  *           *
>  *           *        xi
>  *           * ------->
>  *           *
>  *           *
> (0)* * * * *(1)
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.quad8_iso(xi, eta, zeta)#

Definition of basis functions for the serendipity quad (8-node) 2D element.

NODE NUMBERING:

>  (3)* *(6)* *(2)
>   *           *
>   *           *
>  (7)         (5)
>   *           *
>   *           *
>  (0)* *(4)* *(1)
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.quad9_iso(xi, eta, zeta)#

Definition of basis functions for the 9-node quad 2D element (2nd order).

NODE NUMBERING:

> (3)* *(6)* *(2)
>  *           *
>  *           *
> (7)   (8)   (5)
>  *           *
>  *           *
> (0)* *(4)* *(1)
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.set_global_algebra(algebra)#

PORPUSE: Define the algebra used for the FEM analysis.

class pyoti.fem.somesh#

Bases: object

class pyoti.fem.space#

Bases: object

order#
red_int#
special#
pyoti.fem.square(width, hight, he=1e+30, ndivs=None, element_order=1, quads=False, quad_incomplete=1, quad_linear=1, structured=False, save=False, real=False)#

Define a square mesh according to the given parameters. This function uses gmsh as the mesh generation backend.

Parameters:
  • width (float.) – Width of the square.

  • hight (float.) – Height of the square.

  • he (float, optional. Default he= 1e30.) – Size of elements in the mesh. Defaults to 1e30.

  • ndivs (list or int, optional. Default ndivsNone.) – Number of element divisions. [ndivx,ndivy]. If integer, sets both.

  • element_order (int, optional. Default element_order = 1.) – Order of element to be implemented. Default 1

  • quads (bool, optional. Default quads = False) – Bool to define if qued elements are to be generated. Defaluts to False.

  • quad_incomplete (int, optional. Default quad_incomplete = 1.) – <int>: Indicates if quads are serendipity or not. Defaults to 1.

  • quad_linear (int, optional. Default quad_linear=1.) – <int>: Defaults to 1.

  • structured (bool, optional. Default structured=False.) – <Bool>: Bool to set structured mesh. Defaults to False.

  • save (bool, optional. Default save=False.) – <Bool>: Bool to save mesh. Defaults False.

  • real (bool, optional. Default real=False.) – <Bool>: Not used. Defaults False.

Returns:

a pyoti.fem.mesh object.

pyoti.fem.tet10_iso(xi, eta, zeta)#

Definition of basis functions for the 4-node tetrahedron 3D element (2nd order).

NODE NUMBERING:

>  ^ eta
>  |                         4
>  |                        / zeta
>  |                       /
>  |                      /
>  |                     /
>  |                    /
>  |                   /
>  |                  /
> (2)******(9)******(3)
>  * *              / *
>  *   *               *
>  *     *        /     *
>  *       *             *
>  *         *  /         *
>  *           *           *
>  *          /  *          *
>  *               *         *
> (6)      (7)      (5)      (8)
>  *                   *       *
>  *      /              *      *
>  *                       *     *
>  *    /                    *    *
>  *                           *   *
>  *  /                          *  *
>  *                               * *
>  */                                **
> (0)* * * * * * *(4)* * * * * * * * *(1)------> xi
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.tet1_iso(xi, eta, zeta)#

Definition of basis functions for the 1 node triangle 2D element (0th order).

NODE NUMBERING:

>  ^ eta
>  |         4
>  |        / zeta
>  |       /
>  |      /
>  * * *  *
>  * *  /  *
>  *   *    *
>  *  /  *   *
>  *   (0) *  *
>  */        * *
>  * * * * * * * ------> xi
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.tet4_iso(xi, eta, zeta)#

Definition of basis functions for the 4-node tetrahedron 3D element (1st order).

NODE NUMBERING:

>  ^ eta
>  |         4
>  |        / zeta
>  |       /
>  |      /
> (2)* * (3)
>  * *  /  *
>  *   *    *
>  *  /  *   *
>  *       *  *
>  */        * *
> (0)* * * * *(1)------> xi
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.tri1_iso(xi, eta, zeta)#

Definition of basis functions for the 1 node triangle 2D element (0th order).

NODE NUMBERING:

>  *             |  *
>  * *           |  * *
>  *   *            *   *
>  *     *     <or> *     *
>  *  (0)  *        *       *
>  *         *   |  *         *
>  * * * * * * * | (0)* * * * * *
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.tri3_iso(xi, eta, zeta)#

Definition of basis functions for the 3-node triangle 2D element (1st order).

NODE NUMBERING:

> (2)
>  * *
>  *   *
>  *     *
>  *       *
>  *         *
> (0)* * * * *(1)
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.tri4_iso(xi, eta, zeta)#

Definition of basis functions for the 4-node triangle 2D element (bubble triangle).

NODE NUMBERING:

> (2)
>  * *
>  *   *
>  *     *
>  *  (3)  *
>  *         *
> (0)* * * * *(1)
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.tri6_iso(xi, eta, zeta)#

Definition of basis functions for the 6-node triangle 2D element (2nd order).

NODE NUMBERING:

> (2)
>  * *
>  *   *
> (5)   (4)
>  *       *
>  *         *
> (0)* *(3)* *(1)
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.wedge15_iso(xi, eta, zeta)#

Definition of basis functions for the 15-node wedge 3D element (2nd order). Basis functions taken from Zienkiewicz, “The Finite Element Method: Its Basis and Fundamentals Seventh Edition” 7th ed. Elsevier.

NODE NUMBERING: Node numbering corresponds to Abaqus numbering scheme.

>                       4 eta
>              (5)     /
>              * *    /
>   ^ zeta    * *  * /
>   |        *  *   *
>   |       *   *  /  *
>   |      *    * /    *
>   |   (11)    */      (10)
>   |   *     (14)        *
>   |  *       /*           *
>   | *       / *             *
>  (3)* * * * * (9) * * * * * *(4)    [zeta +1]
>   *      /    *               *
>   *     /     *               *
>   *    /     (2)              *
>   *   /      * *              *
>   *  /      *    *            *
>   * /      *      *           *
> (12) - - -*- - - - -*- - - -(13) -------------> xi
>   *      *           *        *
>   *    (8)           (7)      *
>   *    *                *     *
>   *   *                  *    *
>   *  *                     *  *
>   * *                       * *
>  (0)* * * * * *(6)* * * * * *(1)    [zeta -1]
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.wedge1_iso(xi, eta, zeta)#

Definition of basis functions for the 1 node triangle 2D element (0th order).

NODE NUMBERING:

>                      4 eta
>              *      /
>             * *    /
>  ^ zeta    * *  * /
>  |        *  *   *
>  |       *   *  /  *
>  |      *    * /    *
>  |    *      */       *
>  |   *       *         *
>  |  *       /*           *
>  | *       / *             *
>  * * * * * * * * * * * * * * *     [zeta +1]
>  *      /    *               *
>  *     /     *               *
>  *    /      *               *
>  *   /      * *              *
>  *  /      *    *            *
>  * /      *      *           *
> (0)- - - * - - - - *- - - - -* -------------> xi
>  *      *           *        *
>  *     *              *      *
>  *    *                *     *
>  *   *                  *    *
>  *  *                     *  *
>  * *                       * *
>  * * * * * * * * * * * * * * *     [zeta -1]
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.fem.wedge6_iso(xi, eta, zeta)#

Definition of basis functions for the 6-node wedge 3D element (1st order). Basis functions taken from Zienkiewicz, “The Finite Element Method: Its Basis and Fundamentals Seventh Edition” 7th ed. Elsevier.

This function allows computing derivatives with OTI perturbations.

NODE NUMBERING: Node numbering corresponds to Abaqus numbering scheme.

>                      4 eta
>             (5)     /
>             * *    /
>  ^ zeta    * *  * /
>  |        *  *   *
>  |       *   *  /  *
>  |      *    * /    *
>  |    *      */       *
>  |   *       *         *
>  |  *       /*           *
>  | *       / *             *
> (3)* * * * * * * * * * * * *(4)    [zeta +1]
>  *      /    *               *
>  *     /     *               *
>  *    /     (2)              *
>  *   /      * *              *
>  *  /      *    *            *
>  * /      *      *           *
>  * - - - * - - - - *- - - - -* -------------> xi
>  *      *           *        *
>  *     *              *      *
>  *    *                *     *
>  *   *                  *    *
>  *  *                     *  *
>  * *                       * *
> (0)* * * * * * * * * * * * *(1)    [zeta -1]
Parameters:
  • xi – Xi coordinate for this element.

  • eta – Eta coordinate for this element.

  • zeta – zeta coordinate for this element.

Returns:

[N0,N1,…]: List of evaluated basis functions.

pyoti.real module#

pyoti.real.acos(val, out=None)#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.acosh(val, out=None)#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.array(arr, nip=0)#

PURPOSE: Create a matrix for OTI algebra, according to the given array values.

Array can be:
  • Scalar

  • 0D array

  • 1D array

  • 2D array or

  • 3D array

They can contain real or OTI values. No complex values are supported yet.

pyoti.real.asin(val, out=None)#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.asinh(val, out=None)#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.atan(val, out=None)#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.atanh(val, out=None)#

PURPOSE: Inverse hyperbolic tangent.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.cbrt(val, out=None)#

PURPOSE: Cubic root function.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

INPUTS:

  • val: Value to evaluate. Must be a supported one of the supported types.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the result.

pyoti.real.cos(val, out=None)#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.cosh(val, out=None)#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.det(arr, out=None)#

PURPOSE: Matrix determinant.

pyoti.real.div(lhs, rhs, out=None)#

PURPOSE: Divition between two objects.

class pyoti.real.dmat#

Bases: object

copy()#

PURPOSE: Copy the elements to new memory spaces.

ncols#

Return the number of columns of the stored matrix.

Type:

PURPOSE

nrows#

Return the number of rows of the stored matrix.

Type:

PURPOSE

order#

Return the OTI imaginary order of the array.

Type:

PURPOSE

real#

Get a numpy array with all coefficients in the real direction.

Type:

PURPOSE

set(val)#

PURPOSE: Set all elements to val.

shape#

Return the shape of the stored matrix.

Type:

PURPOSE

size#

Return the size of array.

Type:

PURPOSE

to_numpy()#

PURPOSE: Interface to numpy representation.

class pyoti.real.dmatfe#

Bases: object

copy()#

PURPOSE: Copy to a new object.

gauss_integrate(w)#

PURPOSE: Get the corresponding derivative of the system.

get_ip(ip)#

PURPOSE: Get an Integration point.

get_item_ij(i, j, out=None)#

PURPOSE: Get an item from dmatfe array.

list_repr()#

PURPOSE: A short representation of the object.

long_repr()#

PURPOSE: A short representation of the object.

nip#

Return the number of integration points.

Type:

PURPOSE

real#

Get a numpy array with all coefficients in the real direction.

Type:

PURPOSE

real_numpy#

Get a numpy array with all coefficients in the real direction.

Type:

PURPOSE

set(rhs)#

PURPOSE: Sets from another value.

set_ijk(rrhs, i, j, k)#

PURPOSE: Sets from another value.

shape#

Return the shape of the stored matrix.

Type:

PURPOSE

short_repr()#

PURPOSE: A short representation of the object.

class pyoti.real.dnumfe#

Bases: object

copy()#

PURPOSE: Copy to a new object.

gauss_integrate(w)#

PURPOSE: Get the corresponding derivative of the system.

list_repr()#

PURPOSE: A short representation of the object.

long_repr()#

PURPOSE: A short representation of the object.

nip#

Return the number of integration points.

Type:

PURPOSE

real#

Get a numpy array with all coefficients in the real direction.

Type:

PURPOSE

set(rhs)#

PURPOSE: Sets from another value.

short_repr()#

PURPOSE: A short representation of the object.

pyoti.real.dot(lhs, rhs, out=None)#

PURPOSE: Matrix inner product (standard matrix multiplication).

pyoti.real.dot_product(lhs, rhs, out=None)#

PURPOSE: Vector dot product (For matrices, sum product).

pyoti.real.e(hum_dir, nbases=0, order=0, nip=0)#
PURPOSE: To create a sotinum with value 1 at the specified imaginary direction

in a human friendly manner

class pyoti.real.elm_help#

Bases: object

J#
Jinv#
N#
Neta#
Nx#
Nxi#
Ny#
Nz#
Nzeta#
allocate(ndim, nbasis, nip)#

DESCRIPTION: Allocate all integration points.

INPUTS:

-> nbasis: Number of basis. -> nip: Number of integration points.

allocate_spatial(ndim_an, compute_Jinv=False)#

DESCRIPTION: Allocate all spatial variables.

INPUTS:

-> ndim_an: Number of dimensions of the analysis. -> compute_Jinv: Bool to compute inverse of jacobian (Default False).

OUTPUTS:

None. Things occur internally.

compute_Jinv#
compute_jacobian()#

DESCRIPTION: Compute jacobian and derived functions.

INPUTS:

-> x, y, z: Global vertices coordinates. -> elem_indices: Array with the indices of the corresponding elements in the .

OUTPUTS:

None. Things occur internally.

compute_jacobian_bruteforce()#

DESCRIPTION: Compute jacobian and derived functions.

INPUTS:

-> x, y, z: Global vertices coordinates. -> elem_indices: Array with the indices of the corresponding elements in the .

OUTPUTS:

None. Things occur internally.

dV#
detJ#
end()#

Finalize element memory allocation.

eta#
get(a, elem_indices, out=None)#
DESCRIPTION: Get the elemental array from a global array. That is, extract the nodal values from

an array containing information for all the nodes in a domain.

INPUTS:

-> a: Global vector. -> elem_indices: Array with the indices of the corresponding degrees of freedom of the element.

OUTPUTS:

-> Vector with the corresponding dimension with elemental values.

is_allocated()#

Return boolean if the element is allocated.

nbasis#
ndim#
ndim_an#
nip#
reset()#

Reset the values of all spatial variables.

set_coordinates(x, y, z, elem_indices)#
DESCRIPTION: Set the coordinates of an OTI number from the global vertices coordinates and the given

elemental indices

INPUTS:

-> x, y, z: Global vertices coordinates. -> elem_indices: Array with the indices of the corresponding elements in the .

special#
w#
x#
xi#
y#
z#
zeta#
pyoti.real.exp(val, out=None)#

PURPOSE: Exponential function.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.eye(size, nip=0)#

PURPOSE: Create identity matrix of shape: (size,size).

pyoti.real.gauss_integrate(val, w, out=None)#

PURPOSE: Integrate using Gauss rule.

INPUTS:

  • val: Value to integrate. Must be a constant

  • w: Integration weights.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the integration result.

pyoti.real.inv(arr, out=None)#

PURPOSE: Matrix inverse. Only supported up to 3x3 matrices.

class pyoti.real.lil_matrix#

Bases: object

copy()#

PURPOSE: Deep copy to a new object.

data#

Return the data list of lists of the stored matrix.

Type:

PURPOSE

ncols#
nnz#

Return the number of non-zero elements in the stored matrix.

Type:

PURPOSE

nrows#
real#

Get a numpy array with all coefficients in the real direction.

Type:

PURPOSE

rows#

Return the rows list of lists of the stored matrix.

Type:

PURPOSE

shape#

Return the shape of the stored matrix.

Type:

PURPOSE

size#
tocsr()#

PURPOSE: Get a numpy array with all coefficients in the real direction.

zeros_like()#

PURPOSE: Create new object with OTI zeros in positions.

pyoti.real.log(val, out=None)#

PURPOSE: Natural logarithm function.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

INPUTS:

  • val: Value to evaluate. Must be a supported one of the supported types.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the result.

pyoti.real.log10(val, out=None)#

PURPOSE: Logarithm base 10 function.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

INPUTS:

  • val: Value to evaluate. Must be a supported one of the supported types.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the result.

pyoti.real.logb(val, b, out=None)#

PURPOSE: Logarithm of base b

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

INPUTS:

  • val: Value to evaluate. Must be a supported one of the supported types.

  • b: Base.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the result.

pyoti.real.mul(lhs, rhs, out=None)#

PURPOSE: Multiplication between two objects.

pyoti.real.neg(val, out=None)#

PURPOSE: Algebraic negation.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.norm(arr, p=2.0, out=None)#

PURPOSE: Matrix norm

pyoti.real.number(num, nip=0)#

PURPOSE: To create a real with value num

pyoti.real.one(nip=0)#

PURPOSE: To create a real scalar with real value 1.

pyoti.real.ones(shape_in, nip=0)#

PURPOSE: Create matrix filled with ones of shape: (nrows,ncols).

pyoti.real.pow(val, e, out=None)#

PURPOSE: Power function.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

INPUTS:

  • val: Value to evaluate. Must be a supported one of the supported types.

  • e: exponent.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the result.

pyoti.real.sin(val, out=None)#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.sinh(val, out=None)#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.solve(K_in, b_in, out=None, solver='SuperLU', solver_args={})#

PURPOSE: Solve OTI linear system of equations.

pyoti.real.solve_sparse_tests(K_in, b_in, out=None)#

PURPOSE: Solve real linear system of equations for a sparse K.

pyoti.real.sqrt(val, out=None)#

PURPOSE: Square root function.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

INPUTS:

  • val: Value to evaluate. Must be a supported one of the supported types.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the result.

pyoti.real.sub(lhs, rhs, out=None)#

PURPOSE: Subtraction between two objects.

pyoti.real.sum(lhs, rhs, out=None)#

PURPOSE: Addition between two objects.

pyoti.real.tan(val, out=None)#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.tanh(val, out=None)#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • dmatfe

  • darr

  • sotinum

  • dnumfe

  • real

pyoti.real.transpose(arr, out=None)#

PURPOSE: Matrix transpose

pyoti.real.zero(nip=0)#

PURPOSE: To create a real scalar with real value 1.

pyoti.real.zeros(shape_in, nip=0)#

PURPOSE: Create matrix filled with zeroes of shape: (nrows,ncols).

pyoti.sparse module#

pyoti.sparse.acos()#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.acosh()#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.array(object arr, bases_t nbases = 0, ord_t order = 0, uint64_t nip = 0)#

Create a matrix for OTI numbers, according to the given array parameters.

Parameters:

arr

Iterable that represents a 0D, 1D, 2D or 3D array. Can be given as a list of values, numpy.ndarray (of dtype float or int), or a scalar value. According to the shape, it will be created as a matso or matsofe array.

Note

If arr is defined from a list of values, arr can contain float, int or OTI values. Complex values are currently not supported.

:type : sotinum, list or numpy.ndarray

Parameters:
  • nbases (int, optional. Default nbases=0.) – Define the number of bases to allocate memory in the object.

  • order (int, optional. Default order=0.) – Define the truncation order used to allocate memory in the object.

  • nip (int, optional. Default nip=0.) – Number of integration points for creating a gauss scalar type.

pyoti.sparse.asin()#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.asinh()#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.atan()#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.atanh()#

PURPOSE: Inverse hyperbolic tangent.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.cbrt()#

PURPOSE: Cubic root function.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

INPUTS:

  • val: Value to evaluate. Must be a supported one of the supported types.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the result.

pyoti.sparse.cos()#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.cosh()#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

class pyoti.sparse.csr_matrix#

Bases: object

copy()#

PURPOSE: Deep copy to a new object.

data#

Return the data array of the stored matrix.

Type:

PURPOSE

extract_deriv()#

PURPOSE: Get the corresponding derivative in the object, as OTI number.

extract_im()#

PURPOSE: Get the corresponding imaginary direction in the object.

get_active_bases()#

PORPUSE: Get the bases with non-zero coefficients in the OTI number.

get_deriv()#

PURPOSE: Get the corresponding derivative of the system.

get_im()#

PURPOSE: Get the corresponding derivative of the system.

get_order_im()#

PURPOSE: Get the corresponding derivative in the object, as OTI number.

indices#

Return the indices array the stored matrix.

Type:

PURPOSE

indptr#

Return the indptr array the stored matrix.

Type:

PURPOSE

ncols#
nnz#

Return the number of non-zero elements in the stored matrix.

Type:

PURPOSE

nrows#
order#

Return the shape of the stored matrix.

Type:

PURPOSE

real#

Get a numpy array with all coefficients in the real direction.

Type:

PURPOSE

shape#

Return the shape of the stored matrix.

Type:

PURPOSE

size#
toarray()#

PURPOSE: Create a dense array out of the sparse representation.

todense()#

PURPOSE: Create a dense array out of the sparse representation.

truncate()#

PURPOSE: to set a specific imaginary direction as given.

zeros_like()#

PURPOSE: Create new object with OTI zeros in positions.

pyoti.sparse.det()#

PURPOSE: Matrix determinant.

pyoti.sparse.div()#

PURPOSE: Divition between two objects.

pyoti.sparse.dot()#

PURPOSE: Matrix inner product (standard matrix multiplication).

pyoti.sparse.dot_product()#

PURPOSE: Vector dot product (For matrices, sum product).

pyoti.sparse.e(object hum_dir, bases_t nbases = 0, ord_t order = 0, uint64_t nip = 0)#

This function creates a sotinum with value 1 along the specified imaginary direction in a human friendly manner.

Parameters:
  • hum_dir (list or int.) – Object that defines the imaginary direction in a human-friendly manner.

  • nbases (int, optional. Default nbases=0.) – Defines the number of imaignary bases of the number. If not set, it will only allocate memory for a single imaginary direction at the specified order.

  • order (int, optional. Default order=0.) – Optional. Defines the truncation order of the number. The truncation order is defined as the maximum between the order of the given imaginary direction and the order given in this parameter.

  • nip (int, optional. Default nip=0.) – Defines the number of integration points to create this number. This is useful when using this with the Gauss-types for numerical integration parameters. If nip is 0, then standard types will be used. If nip > 0, then a scalar gauss type will be created.

class pyoti.sparse.elm_help#

Bases: object

J#
Jinv#
N#
Neta#
Nx#
Nxi#
Ny#
Nz#
Nzeta#
allocate()#

DESCRIPTION: Allocate all integration points.

INPUTS:

-> nbasis: Number of basis. -> nip: Number of integration points. -> nbases (Optional): Number of OTI imaginary bases to allocate. -> order (Optional): Truncation order of the OTI members of the number.

allocate_spatial()#

DESCRIPTION: Allocate all spatial variables.

INPUTS:

-> ndim_an: Number of dimensions of the analysis. -> compute_Jinv: Bool to compute inverse of jacobian (Default False).

OUTPUTS:

None. Things occur internally.

compute_Jinv#
compute_jacobian()#

DESCRIPTION: Compute jacobian and derived functions.

INPUTS:

-> x, y, z: Global vertices coordinates. -> elem_indices: Array with the indices of the corresponding elements in the .

OUTPUTS:

None. Things occur internally.

compute_jacobian_bruteforce()#

DESCRIPTION: Compute jacobian and derived functions.

INPUTS:

-> x, y, z: Global vertices coordinates. -> elem_indices: Array with the indices of the corresponding elements in the .

OUTPUTS:

None. Things occur internally.

dV#
detJ#
end()#

Finalize element memory allocation.

eta#
get()#
DESCRIPTION: Get the elemental array from a global array. That is, extract the nodal values from

an array containing information for all the nodes in a domain.

INPUTS:

-> a: Global vector. -> elem_indices: Array with the indices of the corresponding degrees of freedom of the element.

OUTPUTS:

-> Vector with the corresponding dimension with elemental values.

get_local()#

DESCRIPTION: get the local items from an array.

INPUTS:

-> arr: Global array. -> elem_indices: Array with the element nodal indices.

integrate()#

DESCRIPTION: Domain integral over the element.

INPUTS:

-> val: Function that will be integrated. -> out(optional): Preallocated array to receive the result.

OUTPUTS:

If out is None, then an ouput is returned with the correct result.

is_allocated()#

Return boolean if the element is allocated.

nbasis#
ndim#
ndim_an#
nip#
otinbases#
otiorder#
reset()#

Reset the values of all spatial variables.

set_array()#

DESCRIPTION: Set the elements of an array from global to local indices.

INPUTS:

-> arr: Array in global numbering. -> elem_indices: Array with the indices of the corresponding elements in the mesh.

set_coordinates()#
DESCRIPTION: Set the coordinates of an OTI number from the global vertices coordinates and the given

elemental indices

INPUTS:

-> x, y, z: Global vertices coordinates. -> elem_indices: Array with the indices of the corresponding elements in the .

special#
w#
x#
xi#
y#
z#
zeta#
pyoti.sparse.erf()#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.exp()#

PURPOSE: Exponential function.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.extract_deriv()#

PURPOSE: Extract imaginary direction of the given type.

Supported types:

  • matso

  • matsofe

  • sotinum

  • sotife

pyoti.sparse.extract_im()#

PURPOSE: Extract imaginary direction of the given type.

Supported types:

  • matso

  • matsofe

  • sotinum

  • sotife

pyoti.sparse.eye(uint64_t size, bases_t nbases = 0, ord_t order = 0, uint64_t nip = 0)#

This function creates an identity matrix of shape: (size,size).

Parameters:
  • size – dimension of the identity matrix to be created.

  • nbases (int, optional. Default nbases=0.) – Define the number of bases to allocate memory in the object.

  • order (int, optional. Default order=0.) – Define the truncation order used to allocate memory in the object.

  • nip (int, optional. Default nip=0.) – Number of integration points for creating a gauss scalar type.

pyoti.sparse.fezeros()#

PURPOSE: create a matsofe matrix with the given shape and number of integration points

pyoti.sparse.gauss_integrate()#

PURPOSE: Integrate using Gauss rule.

INPUTS:

  • val: Value to integrate. Must be a constant

  • w: Integration weights.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the integration result.

pyoti.sparse.get_active_bases()#
pyoti.sparse.get_deriv()#

PURPOSE: Extract imaginary direction of the given type.

Supported types:

  • matso

  • matsofe

  • sotinum

  • sotife

pyoti.sparse.get_im()#

PURPOSE: Extract imaginary direction of the given type.

Supported types:

  • matso

  • matsofe

  • sotinum

  • sotife

pyoti.sparse.get_order_im()#

PURPOSE: Extract imaginary direction of the given type.

Supported types:

  • matso

  • matsofe

  • sotinum

  • sotife

pyoti.sparse.get_order_im_array()#

PURPOSE: Get a specific order array from a matso array.

INPUTS:
  • ordi: Order to set the array.

  • tmp: matso array that receives the imaginary directions.

OUTPUTS:

Exports a numpy array of real coefficients that contains the coefficients of order ordi from tmp.

pyoti.sparse.interp1d()#

PURPOSE: Linear 1D interpolation.

INPUTS:
  • x

  • xvals: Values of x for interpolation. THis array must come in ascending order with no

    repetitions. Must be matso array

  • yvals: Values of y for the interpolation. Must be matso array.

  • out (optional, default=None): Output object to hold the interpolation result.

pyoti.sparse.inv()#

PURPOSE: Matrix inverse. Only supported up to 3x3 matrices.

pyoti.sparse.inv_block()#

PURPOSE: Matrix inverse using block solver.

class pyoti.sparse.lil_matrix#

Bases: object

copy()#

PURPOSE: Deep copy to a new object.

data#

Return the data list of lists of the stored matrix.

Type:

PURPOSE

extract_deriv()#

PURPOSE: Get the corresponding derivative in the matso object, as OTI number.

extract_im()#

PURPOSE: Get the corresponding imaginary direction in the matso object.

get_active_bases()#
get_deriv()#

PURPOSE: Get the corresponding derivative of the system.

get_im()#

PURPOSE: Get the corresponding derivative of the system.

get_order_im()#

PURPOSE: Get the corresponding derivative in the matso object, as OTI number.

ncols#
nnz#

Return the number of non-zero elements in the stored matrix.

Type:

PURPOSE

nrows#
order#

Return the shape of the stored matrix.

Type:

PURPOSE

real#

Get a numpy array with all coefficients in the real direction.

Type:

PURPOSE

rows#

Return the rows list of lists of the stored matrix.

Type:

PURPOSE

shape#

Return the shape of the stored matrix.

Type:

PURPOSE

size#
tocsr()#

PORPUSE: Convert the matrix to CSR format.

truncate()#

PURPOSE: to set a specific imaginary direction as given.

zeros_like()#

PURPOSE: Create new object with OTI zeros in positions.

pyoti.sparse.log()#

PURPOSE: Natural logarithm function.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

INPUTS:

  • val: Value to evaluate. Must be a supported one of the supported types.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the result.

pyoti.sparse.log10()#

PURPOSE: Logarithm base 10 function.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

INPUTS:

  • val: Value to evaluate. Must be a supported one of the supported types.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the result.

pyoti.sparse.logb()#

PURPOSE: Logarithm of base b

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

INPUTS:

  • val: Value to evaluate. Must be a supported one of the supported types.

  • b: Base.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the result.

class pyoti.sparse.matso#

Bases: object

T#

Return the transpose of the stored matrix.

Type:

PURPOSE

static add()#

PURPOSE: Matrix elementwise addition.

copy()#

PURPOSE: Copy to a new object.

static dot()#

PURPOSE: Matrix multiplication.

extract_deriv()#

PURPOSE: Get the corresponding derivative in the matso object, as OTI number.

extract_im()#

PURPOSE: Get the corresponding imaginary direction in the matso object.

get_active_bases()#
get_deriv()#

PURPOSE: Get the corresponding derivative of the system.

get_im()#

PURPOSE: Get the corresponding imaginary direction in the matso object.

get_order_im()#

PURPOSE: Get the corresponding derivative in the matso object, as OTI number.

static inv()#

PURPOSE: Matrix invertion.

list_repr()#

PURPOSE: A short representation of the object.

long_repr()#

PURPOSE: A short representation of the object.

ncols#

Return the number of columns of the stored matrix.

Type:

PURPOSE

nrows#

Return the number of rows of the stored matrix.

Type:

PURPOSE

order#

Return the shape of the stored matrix.

Type:

PURPOSE

real#

Get a numpy array with all coefficients in the real direction.

Type:

PURPOSE

rom_eval()#

PURPOSE: Perform a Taylor series integration.

set()#

PURPOSE: Sets from another value.

shape#

Return the shape of the stored matrix.

Type:

PURPOSE

short_repr()#

PURPOSE: A short representation of the object.

size#

Return the size of array.

Type:

PURPOSE

static transpose()#

PURPOSE: Matrix transpose.

truncate()#

PURPOSE: to set a specific imaginary direction as given.

truncate_order()#

PURPOSE: to set a specific imaginary direction as given.

class pyoti.sparse.matsofe#

Bases: object

T#

Return the transpose of the matrix.

Type:

PURPOSE

copy()#

PURPOSE: Copy to a new object.

extract_deriv()#

PURPOSE: to set a specific imaginary direction as given.

extract_im()#

PURPOSE: to set a specific imaginary direction as given.

gauss_integrate()#

PURPOSE: Get the corresponding derivative of the system.

get_active_bases()#
get_deriv()#

PURPOSE: to set a specific imaginary direction as given.

get_im()#

PURPOSE: to set a specific imaginary direction as given.

get_ip()#

PURPOSE: Get an Integration point.

get_item_ij()#

PURPOSE: Get an item from matsofe array.

get_order_im()#

PURPOSE: Get the corresponding derivative in the matso object, as OTI number.

list_repr()#

PURPOSE: A short representation of the object.

long_repr()#

PURPOSE: A short representation of the object.

nip#

Return the number of integration points.

Type:

PURPOSE

order#

Return the shape of the stored matrix.

Type:

PURPOSE

real#

Get a real Gauss array with all coefficients in the real direction.

Type:

PURPOSE

real_numpy#

Get a numpy array with all coefficients in the real direction.

Type:

PURPOSE

set()#

PURPOSE: Sets from another value.

set_ijk()#

PURPOSE: Sets from another value.

shape#

Return the shape of the stored matrix.

Type:

PURPOSE

short_repr()#

PURPOSE: A short representation of the object.

truncate()#

PURPOSE: to set a specific imaginary direction as given.

truncate_order()#

PURPOSE: to set a specific imaginary direction as given.

pyoti.sparse.moving_average()#

PURPOSE: Perform a moving average filter in a 1-D vector by a given window size.

INPUTS:
  • data: (matso array). Filter is performed in the flattened version of the array.

  • size: Integer that defines the window size.

pyoti.sparse.mul()#

PURPOSE: Multiplication between two objects.

pyoti.sparse.neg()#

PURPOSE: Algebraic negation.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.norm()#

PURPOSE: Matrix norm

pyoti.sparse.number(coeff_t num, bases_t nbases = 0, ord_t order = 0, uint64_t nip = 0)#

This function creates a scalar OTI with real value num and every imaginary coefficient as zero.

Parameters:
  • num (float or int.) – Define the number of bases to allocate memory in the resulting number.

  • nbases (int, optional. Default nbases=0.) – Define the number of bases to allocate memory in the resulting number.

  • order (int, optional. Default order=0.) – Define the truncation order used to allocate memory and control operations with the. number.

  • nip (int, optional. Default nip=0.) – Number of integration points for creating a gauss scalar type.

pyoti.sparse.one(bases_t nbases = 0, ord_t order = 0, uint64_t nip = 0)#

This function creates a scalar OTI with real value 1 and every imaginary coefficient as zero.

Parameters:
  • nbases (int, optional. Default nbases=0.) – Define the number of bases to allocate memory in the resulting number.

  • order (int, optional. Default order=0.) – Define the truncation order used to allocate memory and control operations with the. number.

  • nip (int, optional. Default nip=0.) – Number of integration points for creating a gauss scalar type.

pyoti.sparse.ones()#

PURPOSE: Create matrix filled with ones of shape: (nrows,ncols).

pyoti.sparse.pow()#

PURPOSE: Power function.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

INPUTS:

  • val: Value to evaluate. Must be a supported one of the supported types.

  • e: exponent.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the result.

pyoti.sparse.read()#

PURPOSE: Load array from a binary format (See documentation of binary format).

USAGE: >>> load( filename )

INPUTS:

  • filename: String object with the name of file to be used.

OUTPUTS: - arr: matso array loaded from memory.

pyoti.sparse.save()#

PURPOSE: Export array into a binary proprietary format.

USAGE: >>> save( arr, filename )

INPUTS: - arr: matso array to be saved. - filename: String object with the name of file to be used.

pyoti.sparse.set_order_im_from_array()#

PURPOSE: Set a specific order from an array.

INPUTS:
  • ordi: Order to set the array.

  • arr: Array to be set.

  • tmp: matso array that receives the imaginary directions.

pyoti.sparse.set_printoptions()#

PURPOSE: Set the print options for OTI numbers.

INPUTS:
  • float_format: (Default “g”) Define the print format for t

  • terms_print: (Default 4) Number of terms to print.

In order to reset the values to defaults, just call set_printoptions() with no arguments.

pyoti.sparse.sin()#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.sinh()#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.solve()#

PURPOSE: Solve OTI linear system of equations.

class pyoti.sparse.sotife#

Bases: object

copy()#

PURPOSE: Copy to a new object.

extract_deriv()#

PURPOSE: to set a specific imaginary direction as given.

extract_im()#

PURPOSE: to set a specific imaginary direction as given.

gauss_integrate()#

PURPOSE: Get the corresponding derivative of the system.

get_active_bases()#
get_deriv()#

PURPOSE: to set a specific imaginary direction as given.

get_im()#

PURPOSE: to set a specific imaginary direction as given.

get_order_im()#

PURPOSE: to set a specific imaginary direction as given.

list_repr()#

PURPOSE: A short representation of the object.

long_repr()#

PURPOSE: A short representation of the object.

nip#

Return the number of integration points.

Type:

PURPOSE

order#

Return the shape of the stored matrix.

Type:

PURPOSE

real#

Get a real Gauss scalar with all coefficients in the real direction.

Type:

PURPOSE

real_numpy#

Get a numpy array with all coefficients in the real direction.

Type:

PURPOSE

set()#

PURPOSE: Sets from another value.

short_repr()#

PURPOSE: A short representation of the object.

truncate()#

PURPOSE: to set a specific imaginary direction as given.

truncate_order()#

PURPOSE: Truncate all imaginary directions with order greater than the specified value.

class pyoti.sparse.sotinum#

Bases: object

This is the base class that supports sparse OTI numbers (scalars). This class provides operator overloads to must arithmetic operations and elementary functions to seamlessly support OTI-algebra within python functions.

The constructor of the sotinum class contains the following elements:

Parameters:
  • re_coeff (float) – Real coefficient of the imaginary number.

  • nbases (int, optional) – Number of bases to allocate memory.

  • order (int, optional) – Truncation order of the number.

  • FLAGS (int, optional) – Integer with flags associated to this object. The first bit active (FLAGS & 1) indicates that the memory is owned by this instance of the object.

  • nnz (list, optional) – Integer list with number of non-zeroes per order to allocate memory.

The attributes of a sotinum object are the following:

Attr real:

Real coefficient of the sotinum object (float)

Variables:
  • order – Truncation order of the number (int).

  • actual_order – Actual order of the number (int). Typically actual_order <= order

  • nnz – Number of non zero coefficients in the number.

  • FLAGS – Flags of the object (int).

This class provides overloads to the following operators (a and b are sotinum objects):

Overloaded operations#

Operator

Symbol

Notes

Negation

-x

Addition

x+y

Subtraction

x-y

Multiplication

x*y

Division

x/y

Power

x**y

Sine

sin(x)

Cosine

cos(x)

Tangent

tan(x)

Hyperbolic Sine

sinh(x)

Hyperbolic Cosine

cosh(x)

Example:

 1import pyoti.sparse as oti
 2
 3x = oti.sotinum(1.5,nbases=3,order=1)
 4print(x)
 5
 6# Set the first order imaginary directions to 1.
 7x[[0,1]] = 1
 8x[[1,1]] = 2
 9x[[2,1]] = 3
10
11print(x)
>>> 1.5 + 1 * e([1]) + 2 * e([2]) + 3 * e([3])
actual_order#

returns the actual order of the number (may not coincide with the truncation order).

DESCRIPTION: Reads the value in num.

Type:

PURPOSE

copy()#

Create a copy of the object.

extract_deriv()#

Similar to extract_im, this function retrieves the OTI number formed by all coefficients multiple of the given imagianry direction. However, this function also sets up the resulting OTI number such that the resulting OTI number contains the correct derivatives

Parameters:

humdir – Imaginary direction given by the basis and exponents. Example [1,2,2]

extract_im()#

Retrieves the OTI number formed by all coefficients multiple of the given imagianry direction. It extracts the coefficients by dividing each direction by the given direction and determining if it is possible to extract the corresponding coefficients.

Parameters:

humdir – Imaginary direction given by the basis and exponents. Example [1,2,2]

get_active_bases()#

Get all the active bases.

get_deriv()#

Retrieves the derivative contained in the oti number.

Parameters:

humdir – Imaginary direction given by the basis and exponents. Example [1,2,2]

get_im()#

Retrieves the coefficient along the indicated imaginary direction direction.

Parameters:

humdir – Imaginary direction given by the basis and exponents. Example [1,2,2]

get_nnz_full()#

PURPOSE: Get the number of non zeros (nnz) in the number, with the following format:

[ total_nnz, # actual nnz active in the number.

max_nnz_storable, # related with reserved memory. [nnz_1,nnz_2,…],# array with the nnz for each order of derivative. [size_1,size_2,…],# array with the size for each order of derivative. ]

get_order_im()#

Extract an OTI number with only the imagianry directions of the given order.

Parameters:

order – Order of imaginary directions to get.

long_repr()#

PURPOSE: To print a representation of the sotinum object in a full detail form.

nnz#

returns the number of non-zero elements in the number. Only accounts for the

DESCRIPTION: Reads the value in num.

Type:

PURPOSE

order#

returns the maximum truncation order of the number.

DESCRIPTION: Reads the value in num.

Type:

PURPOSE

real#

returns the real coefficient of the OTI number.

DESCRIPTION: Reads the value in num.

Type:

PURPOSE

rom_eval()#

Evaluate the Taylor series from the coefficients with in the OTI number.

Parameters:
  • bases – Python list of Imaginary bases to evaluate the ROM

  • deltas – Python list float coefficients to evaluate the ROM (can be a 1D numpy array).

rom_eval_array()#

Evaluate the Taylor series from the coefficients with in the OTI number.

Parameters:
  • bases – Python list of Imagiary bases to evaluate the ROM

  • deltas – Python list with arrays of coefficients of the deltas to evaluate the ROM. Arrays must be numpy arrays, and be of the same shape.

rom_eval_object()#

PURPOSE: Evaluate the Taylor series from the coefficients with in the OTI number.

INPUTS:
  • bases: Python list of Imagiary bases to evaluate the ROM

  • deltas: Python list object coefficients with multiple deltas to evaluate the ROM.

Example

>>>
set()#

Set the sotinum’s object coefficients from the given value. This can be useful to avoid unnecessary memory allocations.

Parameters:

val (float, int or sotinum.) – Value to be set.

set_deriv()#

Sets an imaginary coefficient grom the given derivative.

Parameters:
  • val (int or list.) – Derivative value to be set.

  • humdir – Imaginary direction given by the basis and exponents. Example [1,2,2]

set_im()#

Set a specific imaginary direction with the given coefficient.

Parameters:
  • val (int or list.) – Value to be set.

  • humdir – Imaginary direction given by the basis and exponents. Example [1,2,2]

short_repr()#

PURPOSE: To print a representation of the sotinum object in a compact form.

truncate()#

Removes (sets zero) all coefficients along imaginary directions multiple to the given imaginary direction.

Parameters:

humdir – Imaginary direction given by the basis and exponents. Example [1,2,2]

truncate_order()#

Truncates all imaginary directions with order equal or larger than the one specified.

Parameters:

order – Order to be truncated.

pyoti.sparse.sotinum_arccos()#

PURPOSE: Mathematical function of inverse cosine for OTI numbers

pyoti.sparse.sotinum_arccosh()#

PURPOSE: Mathematical function of inverse hyperbolic cosine for OTI numbers

pyoti.sparse.sotinum_arcsin()#

PURPOSE: Mathematical function of inverse sine for OTI numbers

pyoti.sparse.sotinum_arcsinh()#

PURPOSE: Mathematical function of inverse hyperbolic sine for OTI numbers

pyoti.sparse.sotinum_arctan()#

PURPOSE: Mathematical function of arctangent for OTI numbers

pyoti.sparse.sotinum_arctanh()#

PURPOSE: Mathematical function of Inverse hyperbolic tangent for OTI numbers

pyoti.sparse.sotinum_cbrt()#

PURPOSE: Square root function for OTI numbers, for non integer exponents.

pyoti.sparse.sotinum_cos()#

PURPOSE: Mathematical function of cosine for OTI numbers

pyoti.sparse.sotinum_cosh()#

PURPOSE: Mathematical function of hyperbolic cosine for OTI numbers

pyoti.sparse.sotinum_erf()#

PURPOSE: Error function for OTI numbers

pyoti.sparse.sotinum_exp()#

PURPOSE: Exponential function for OTI numbers.

pyoti.sparse.sotinum_log()#

PURPOSE: Natural logarithm for OTI numbers.

pyoti.sparse.sotinum_log10()#

PURPOSE: Natural logarithm base 10 for OTI numbers.

pyoti.sparse.sotinum_logb()#

PURPOSE: Logarithm base b for OTI numbers.

pyoti.sparse.sotinum_power()#

PURPOSE: Power function for OTI numbers, for non integer exponents.

pyoti.sparse.sotinum_sin()#

PURPOSE: Mathematical function of sine for OTI numbers.

pyoti.sparse.sotinum_sinh()#

PURPOSE: Mathematical function of hyperbolic sine for OTI numbers

pyoti.sparse.sotinum_sqrt()#

PURPOSE: Square root function for OTI numbers, for non integer exponents.

pyoti.sparse.sotinum_tan()#

PURPOSE: Mathematical function of tangent for OTI numbers

pyoti.sparse.sotinum_tanh()#

PURPOSE: Mathematical function of hyperbolic tangent for OTI numbers

pyoti.sparse.sqrt()#

PURPOSE: Square root function.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

INPUTS:

  • val: Value to evaluate. Must be a supported one of the supported types.

  • out: (optional) Holder of result, in order to avoid memory allocation.

OUTPUTS:

If out is not defined, then the result is a newlly allocated member containing the result.

pyoti.sparse.sub()#

PURPOSE: Subtraction between two objects.

pyoti.sparse.sum()#

PURPOSE: Addition between two objects.

pyoti.sparse.tan()#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.tanh()#

PURPOSE: Matrix determinant.

Supported types:

  • matso

  • matsofe

  • darr

  • sotinum

  • sotife

  • real

pyoti.sparse.transpose()#

PURPOSE: Matrix transpose

pyoti.sparse.trunc_dot()#

PURPOSE: Matrix inner product (standard matrix multiplication).

pyoti.sparse.trunc_sub()#

PURPOSE: Subtraction between two objects.

pyoti.sparse.truncate()#

PURPOSE: Truncate the imaginary direction of an OTI member.

Supported types:

  • matso

  • matsofe

  • sotinum

  • sotife

pyoti.sparse.zero(bases_t nbases = 0, ord_t order = 0, uint64_t nip = 0)#

This function creates a scalar OTI with real value 0 and every imaginary coefficient zero.

Parameters:
  • nbases (int, optional. Default nbases=0.) – Define the number of bases to allocate memory in the resulting number.

  • order (int, optional. Default order=0.) – Define the truncation order used to allocate memory and control operations with the. number.

  • nip (int, optional. Default nip=0.) – Number of integration points for creating a gauss scalar type.

pyoti.sparse.zeros()#

PURPOSE: Create matrix filled with zeroes of shape: (nrows,ncols).

pyoti.whereotilib module#

pyoti.whereotilib.getpath()[source]#

PURPOSE: Provides the path of the directory where the otilib is located.

EXAMPLE: if the library is located in /dir/path/, the result is a string with ‘/dir/path/’

Module contents#