Bases: Boost.Python.instance
Represents a collection of datapoints. It is used to store the values of a function. For more details please consult the c++ class documentation.
Make this object a copy of other
note: The two objects will act independently from now on. That is, changing other after this call will not change this object and vice versa.
note: | In the no argument form, a new object will be returned which is an independent copy of this object. |
---|
Selectively copy values from other Data.Datapoints which correspond to positive values in mask will be copied from other
Parameters: |
---|
Convert this object into lazy representation
Save the data as a netCDF file
Parameters: | fileName (string) – |
---|
Convert the data to expanded representation if it is not expanded already.
Return type: | Domain |
---|
Return type: | FunctionSpace |
---|
Return type: | int |
---|---|
Returns: | Number of datapoints in the object |
Returns: | the number of indices required to address a component of a datapoint |
---|---|
Return type: | positive int |
Returns the shape of the datapoints in this object as a python tuple. Scalar data has the shape ()
Return type: | tuple |
---|
Return tag number for the specified datapoint
Return type: | int |
---|---|
Parameters: | dpno (int) – datapoint number |
Returns: | Value of the specified datapoint |
---|---|
Return type: | tuple |
Parameters: | dataPointNo (int) – datapoint to access |
Get a specific datapoint from a specific process
Return type: | tuple |
---|---|
Parameters: |
|
Interpolate this object’s values into a new functionspace.
Creates a new Data object by interpolating using the source data (which are looked up in table) A must be the outer dimension on the table
param table: two dimensional collection of values param Amin: The base of locations in table type Amin: float param Astep: size of gap between each item in the table type Astep: float param undef: upper bound on interpolated values type undef: float param B: Scalar representing the second coordinate to be mapped into the table type B: Data param Bmin: The base of locations in table for 2nd dimension type Bmin: float param Bstep: size of gap between each item in the table for 2nd dimension type Bstep: float param check_boundaries: if true, then values outside the boundaries will be rejected. If false, then boundary values will be used. raise RuntimeError(DataException): if the coordinates do not map into the table or if the interpolated value is above undef rtype: Data
interpolateTable( (Data)arg1, (object)table, (float)Amin, (float)Astep [, (float)undef=1e+50 [, (bool)check_boundaries=False]]) -> Data
Return type: | bool |
---|---|
Returns: | True if this Data is an instance of DataConstant |
Note : | This does not mean the data is immutable. |
Is this object an instance of DataEmpty
Return type: | bool |
---|---|
Note : | This is not the same thing as asking if the object contains datapoints. |
Return type: | bool |
---|---|
Returns: | True if this Data is expanded. |
Return type: | bool |
---|---|
Returns: | True if this Data is lazy. |
Can this instance be modified. :rtype: bool
Return type: | bool |
---|---|
Returns: | True if this Data is not lazy. |
Return type: | bool |
---|---|
Returns: | True if this Data is expanded. |
Please consider using getSupLocator() from pdetools instead.
Please consider using getInfLocator() from pdetools instead.
1D interpolation with non equally spaced points
1D interpolation of slope with non equally spaced points
Convert the data to non-lazy representation.
Disallow modifications to this data object
Note : | This method does not allow you to undo protection. |
---|
Set the value of tagged Data.
param tagKey: tag to update type tagKey: int
param name: | tag to update |
---|---|
type name: | string |
param value: | value to set tagged data to |
type value: | object which acts like an array, tuple or list |
After this call the object will store values of the same shape as before but all components will be zero.
setValueOfDataPoint( (Data)arg1, (int)arg2, (object)arg3) -> None
setValueOfDataPoint( (Data)arg1, (int)arg2, (float)arg3) -> None :
Modify the value of a single datapoint.
param dataPointNo: type dataPointNo: int param value: type value: float or an object which acts like an array, tuple or list warning: Use of this operation is discouraged. It prevents some optimisations from operating.
Convert data to tagged representation if it is not already tagged or expanded
Return the datapoints of this object in a list. Each datapoint is stored as a tuple.
Parameters: | scalarastuple – if True, scalar data will be wrapped as a tuple. True => [(0), (1), (2)]; False => [0, 1, 2] |
---|
Bases: object
Adds an expression to this evaluator.
Returns: | the modified Evaluator object |
---|
Evaluates all expressions in this evaluator and returns the result as a tuple.
Returns: | the evaluated expressions in the order they were added to this Evaluator. |
---|
Symbol substitution.
Returns: | the modified Evaluator object |
---|
Bases: object
Interface to write data to a file. In essence this class wrappes the standard file object to write data that are global in MPI to a file. In fact, data are writen on the processor with MPI rank 0 only. It is recommended to use FileWriter rather than open in order to write code that is running with as well as with MPI. It is safe to use open onder MPI to read data which are global under MPI. :var name: name of file :var mode: access mode (=’w’ or =’a’) :var closed: True to indicate closed file :var newlines: line seperator
Closes the file
Flush the internal I/O buffer.
Write string txt to file.
Parameters: | txt (str) – string txt to be written to file |
---|
Write the list txt of strings to the file.
Parameters: | txts (any iterable object producing strings) – sequense of strings to be written to file |
---|---|
Note : | Note that newlines are not added. This method is equivalent to call write() for each string. |
Bases: object
An abstract forward model that can be plugged into a cost function. Subclasses need to implement getValue(), getGradient(), and possibly getArguments().
Bases: esys.downunder.forwardmodels.ForwardModel
Base class for a forward model using a potential such as magnetic or gravity. It defines a cost function:
defect = 1/2 sum_s integrate( ( weight_i[s] * ( r_i - data_i[s] ) ) ** 2 )
where s runs over the survey, weight_i are weighting factors, data_i are the data, and r_i are the results produced by the forward model. It is assumed that the forward model is produced through postprocessing of the solution of a potential PDE.
Returns the defect value.
Parameters: | result (Vector) – a result vector |
---|---|
Return type: | float |
Returns the domain of the forward model.
Return type: | Domain |
---|
Returns the pair (data_index, weight_index), where data_i is the data of survey i, weight_i is the weighting factor for survey i. If index is None, all surveys will be returned in a pair of lists.
Returns True if spherical coordinates are used.
Bases: Boost.Python.instance
A FunctionSpace describes which points from the Domain to use to represent functions.
Returns: | the approximation order referring to the maximum degree of a polynomial which can be represented exactly in interpolation and/or integration. |
---|---|
Return type: | int |
Returns: | the spatial dimension of the underlying domain. |
---|---|
Return type: | int |
Returns: | the underlying Domain for this FunctionSpace. |
---|---|
Return type: | Domain |
Returns: | a list of the tags used in this function space |
---|---|
Return type: | list |
Returns: | the reference number associated with dataPointNo |
---|---|
Return type: | int |
Returns: | the tag associated with the given sample number. |
---|---|
Return type: | int |
Returns: | a function whose values are its input coordinates. ie an identity function. |
---|---|
Return type: | Data |
Set tags according to a mask
param newtag: tag number to set type newtag: string, non-zero int param mask: Samples which correspond to positive values in the mask will be set to newtag. type mask: scalar Data
setTags( (FunctionSpace)arg1, (str)newtag, (Data)mask) -> None
Bases: esys.downunder.forwardmodels.ForwardModelWithPotential
Forward Model for gravity inversion as described in the inversion cookbook.
Returns precomputed values shared by getValue() and getGradient().
Parameters: | rho (Scalar) – a suggestion for the density distribution |
---|---|
Returns: | gravity potential and corresponding gravity field. |
Return type: | Scalar, Vector |
Returns the defect value.
Parameters: | result (Vector) – a result vector |
---|---|
Return type: | float |
Returns the domain of the forward model.
Return type: | Domain |
---|
Returns the gradient of the defect with respect to density.
Parameters: |
|
---|---|
Return type: | Scalar |
Calculates the gravity potential for a given density distribution.
Parameters: | rho (Scalar) – a suggestion for the density distribution |
---|---|
Returns: | gravity potential |
Return type: | Scalar |
Returns the pair (data_index, weight_index), where data_i is the data of survey i, weight_i is the weighting factor for survey i. If index is None, all surveys will be returned in a pair of lists.
Returns the value of the defect
Parameters: |
|
---|---|
Return type: | float |
rescales the weights such that
sum_s integrate( ( w_i[s] *g_i[s]) (w_j[s]*1/L_j) * L**2 * 4*pi*G*rho_scale )=scale
Parameters: |
|
---|
Returns True if spherical coordinates are used.
Bases: esys.escript.linearPDEs.LinearProblem
This class is used to define a general linear, steady, second order PDE for an unknown function u on a given domain defined through a Domain object.
For a single PDE having a solution with a single component the linear PDE is defined in the following form:
-(grad(A[j,l]+A_reduced[j,l])*grad(u)[l]+(B[j]+B_reduced[j])u)[j]+(C[l]+C_reduced[l])*grad(u)[l]+(D+D_reduced)=-grad(X+X_reduced)[j,j]+(Y+Y_reduced)
where grad(F) denotes the spatial derivative of F. Einstein’s summation convention, ie. summation over indexes appearing twice in a term of a sum performed, is used. The coefficients A, B, C, D, X and Y have to be specified through Data objects in Function and the coefficients A_reduced, B_reduced, C_reduced, D_reduced, X_reduced and Y_reduced have to be specified through Data objects in ReducedFunction. It is also allowed to use objects that can be converted into such Data objects. A and A_reduced are rank two, B, C, X, B_reduced, C_reduced and X_reduced are rank one and D, D_reduced, Y and Y_reduced are scalar.
The following natural boundary conditions are considered:
n[j]*((A[i,j]+A_reduced[i,j])*grad(u)[l]+(B+B_reduced)[j]*u)+(d+d_reduced)*u=n[j]*(X[j]+X_reduced[j])+y
where n is the outer normal field. Notice that the coefficients A, A_reduced, B, B_reduced, X and X_reduced are defined in the PDE. The coefficients d and y are each a scalar in FunctionOnBoundary and the coefficients d_reduced and y_reduced are each a scalar in ReducedFunctionOnBoundary.
Constraints for the solution prescribe the value of the solution at certain locations in the domain. They have the form
u=r where q>0
r and q are each scalar where q is the characteristic function defining where the constraint is applied. The constraints override any other condition set by the PDE or the boundary condition.
The PDE is symmetrical if
A[i,j]=A[j,i] and B[j]=C[j] and A_reduced[i,j]=A_reduced[j,i] and B_reduced[j]=C_reduced[j]
For a system of PDEs and a solution with several components the PDE has the form
-grad((A[i,j,k,l]+A_reduced[i,j,k,l])*grad(u[k])[l]+(B[i,j,k]+B_reduced[i,j,k])*u[k])[j]+(C[i,k,l]+C_reduced[i,k,l])*grad(u[k])[l]+(D[i,k]+D_reduced[i,k]*u[k] =-grad(X[i,j]+X_reduced[i,j])[j]+Y[i]+Y_reduced[i]
A and A_reduced are of rank four, B, B_reduced, C and C_reduced are each of rank three, D, D_reduced, X_reduced and X are each of rank two and Y and Y_reduced are of rank one. The natural boundary conditions take the form:
n[j]*((A[i,j,k,l]+A_reduced[i,j,k,l])*grad(u[k])[l]+(B[i,j,k]+B_reduced[i,j,k])*u[k])+(d[i,k]+d_reduced[i,k])*u[k]=n[j]*(X[i,j]+X_reduced[i,j])+y[i]+y_reduced[i]
The coefficient d is of rank two and y is of rank one both in FunctionOnBoundary. The coefficients d_reduced is of rank two and y_reduced is of rank one both in ReducedFunctionOnBoundary.
Constraints take the form
u[i]=r[i] where q[i]>0
r and q are each rank one. Notice that at some locations not necessarily all components must have a constraint.
The system of PDEs is symmetrical if
- A[i,j,k,l]=A[k,l,i,j]
- A_reduced[i,j,k,l]=A_reduced[k,l,i,j]
- B[i,j,k]=C[k,i,j]
- B_reduced[i,j,k]=C_reduced[k,i,j]
- D[i,k]=D[i,k]
- D_reduced[i,k]=D_reduced[i,k]
- d[i,k]=d[k,i]
- d_reduced[i,k]=d_reduced[k,i]
LinearPDE also supports solution discontinuities over a contact region in the domain. To specify the conditions across the discontinuity we are using the generalised flux J which, in the case of a system of PDEs and several components of the solution, is defined as
J[i,j]=(A[i,j,k,l]+A_reduced[[i,j,k,l])*grad(u[k])[l]+(B[i,j,k]+B_reduced[i,j,k])*u[k]-X[i,j]-X_reduced[i,j]
For the case of single solution component and single PDE J is defined as
J[j]=(A[i,j]+A_reduced[i,j])*grad(u)[j]+(B[i]+B_reduced[i])*u-X[i]-X_reduced[i]
In the context of discontinuities n denotes the normal on the discontinuity pointing from side 0 towards side 1 calculated from FunctionSpace.getNormal of FunctionOnContactZero. For a system of PDEs the contact condition takes the form
n[j]*J0[i,j]=n[j]*J1[i,j]=(y_contact[i]+y_contact_reduced[i])- (d_contact[i,k]+d_contact_reduced[i,k])*jump(u)[k]
where J0 and J1 are the fluxes on side 0 and side 1 of the discontinuity, respectively. jump(u), which is the difference of the solution at side 1 and at side 0, denotes the jump of u across discontinuity along the normal calculated by jump. The coefficient d_contact is of rank two and y_contact is of rank one both in FunctionOnContactZero or FunctionOnContactOne. The coefficient d_contact_reduced is of rank two and y_contact_reduced is of rank one both in ReducedFunctionOnContactZero or ReducedFunctionOnContactOne. In case of a single PDE and a single component solution the contact condition takes the form
n[j]*J0_{j}=n[j]*J1_{j}=(y_contact+y_contact_reduced)-(d_contact+y_contact_reduced)*jump(u)
In this case the coefficient d_contact and y_contact are each scalar both in FunctionOnContactZero or FunctionOnContactOne and the coefficient d_contact_reduced and y_contact_reduced are each scalar both in ReducedFunctionOnContactZero or ReducedFunctionOnContactOne.
Typical usage:
p = LinearPDE(dom)
p.setValue(A=kronecker(dom), D=1, Y=0.5)
u = p.getSolution()
Announces that coefficient name has been changed.
Parameters: | name (string) – name of the coefficient affected |
---|---|
Raises IllegalCoefficient: | |
if name is not a coefficient of the PDE | |
Note : | if name is q or r, the method will not trigger a rebuild of the system as constraints are applied to the solved system. |
Tests two coefficients for reciprocal symmetry.
Parameters: |
|
---|---|
Returns: | True if coefficients name0 and name1 are reciprocally symmetric. |
Return type: | bool |
Tests a coefficient for symmetry.
Parameters: |
|
---|---|
Returns: | True if coefficient name is symmetric |
Return type: | bool |
Tests the PDE for symmetry.
Parameters: | verbose (bool) – if set to True or not present a report on coefficients which break the symmetry is printed. |
---|---|
Returns: | True if the PDE is symmetric |
Return type: | bool |
Note : | This is a very expensive operation. It should be used for degugging only! The symmetry flag is not altered. |
Creates a Data object corresponding to coefficient name.
Returns: | the coefficient name initialized to 0 |
---|---|
Return type: | Data |
Raises IllegalCoefficient: | |
if name is not a coefficient of the PDE |
Returns an instance of a new operator.
Returns an instance of a new right hand side.
Returns an instance of a new solution.
Returns the value of the coefficient name.
Parameters: | name (string) – name of the coefficient requested |
---|---|
Returns: | the value of the coefficient |
Return type: | Data |
Raises IllegalCoefficient: | |
if name is not a coefficient of the PDE |
Returns the operator in its current state.
Returns the right hand side in its current state.
Returns the solution in its current state.
Returns the spatial dimension of the PDE.
Returns: | the spatial dimension of the PDE domain |
---|---|
Return type: | int |
Returns the domain of the PDE.
Returns: | the domain of the PDE |
---|---|
Return type: | Domain |
Return the status indicator of the domain
Returns the flux J for a given u.
J[i,j]=(A[i,j,k,l]+A_reduced[A[i,j,k,l]]*grad(u[k])[l]+(B[i,j,k]+B_reduced[i,j,k])u[k]-X[i,j]-X_reduced[i,j]
or
J[j]=(A[i,j]+A_reduced[i,j])*grad(u)[l]+(B[j]+B_reduced[j])u-X[j]-X_reduced[j]
Parameters: | u (Data or None) – argument in the flux. If u is not present or equals None the current solution is used. |
---|---|
Returns: | flux |
Return type: | Data |
Returns the FunctionSpace to be used for coefficient name.
Parameters: | name (string) – name of the coefficient enquired |
---|---|
Returns: | the function space to be used for coefficient name |
Return type: | FunctionSpace |
Raises IllegalCoefficient: | |
if name is not a coefficient of the PDE |
Returns the FunctionSpace used to discretize the equation.
Returns: | representation space of equation |
---|---|
Return type: | FunctionSpace |
Returns the FunctionSpace used to represent the solution.
Returns: | representation space of solution |
---|---|
Return type: | FunctionSpace |
Returns the number of equations.
Returns: | the number of equations |
---|---|
Return type: | int |
Raises UndefinedPDEError: | |
if the number of equations is not specified yet |
Returns the number of unknowns.
Returns: | the number of unknowns |
---|---|
Return type: | int |
Raises UndefinedPDEError: | |
if the number of unknowns is not specified yet |
Returns the operator of the linear problem.
Returns: | the operator of the problem |
---|
Returns the current system type.
Returns the system type which needs to be used by the current set up.
Returns the residual of u or the current solution if u is not present.
Parameters: | u (Data or None) – argument in the residual calculation. It must be representable in self.getFunctionSpaceForSolution(). If u is not present or equals None the current solution is used. |
---|---|
Returns: | residual of u |
Return type: | Data |
Returns the right hand side of the linear problem.
Returns: | the right hand side of the problem |
---|---|
Return type: | Data |
Returns the shape of the coefficient name.
Parameters: | name (string) – name of the coefficient enquired |
---|---|
Returns: | the shape of the coefficient name |
Return type: | tuple of int |
Raises IllegalCoefficient: | |
if name is not a coefficient of the PDE |
Returns the solver options
Return type: | SolverOptions |
---|
Returns the operator and right hand side of the PDE.
Returns: | the discrete version of the PDE |
---|---|
Return type: | tuple of Operator and Data |
Return the domain status used to build the current system
Returns True if name is the name of a coefficient.
Parameters: | name (string) – name of the coefficient enquired |
---|---|
Returns: | True if name is the name of a coefficient of the general PDE, False otherwise |
Return type: | bool |
Resets the system clearing the operator, right hand side and solution.
Applies the constraints defined by q and r to the PDE.
Parameters: | rhs_only (bool) – if True only the right hand side is altered by the constraint |
---|
Introduces new coefficients into the problem.
Use:
p.introduceCoefficients(A=PDECoef(...), B=PDECoef(...))
to introduce the coefficients A and B.
Indicates the operator has to be rebuilt next time it is used.
Indicates the right hand side has to be rebuilt next time it is used.
Indicates the PDE has to be resolved if the solution is requested.
Announces that everything has to be rebuilt.
Returns True if the operator is still valid.
Returns True if the operator is still valid.
Returns True if the solution is still valid.
Checks if symmetry is indicated.
Returns: | True if a symmetric PDE is indicated, False otherwise |
---|---|
Return type: | bool |
Note : | the method is equivalent to use getSolverOptions().isSymmetric() |
Returns True if the system (including solution) is still vaild.
Checks if matrix lumping is the current solver method.
Returns: | True if the current solver method is lumping |
---|---|
Return type: | bool |
Returns the status of order reduction for the equation.
Returns: | True if reduced interpolation order is used for the representation of the equation, False otherwise |
---|---|
Return type: | bool |
Returns the status of order reduction for the solution.
Returns: | True if reduced interpolation order is used for the representation of the solution, False otherwise |
---|---|
Return type: | bool |
Resets all coefficients to their default values.
Makes sure that the operator is instantiated and returns it initialized with zeros.
Sets the right hand side to zero.
Resets all coefficients defining the right hand side
Sets the solution to zero.
Switches debug output on if flag is True otherwise it is switched off.
Parameters: | flag (bool) – desired debug status |
---|
Switches debug output off.
Switches debug output on.
Switches reduced order off for equation representation.
Raises RuntimeError: | |
---|---|
if order reduction is altered after a coefficient has been set |
Switches reduced order on for equation representation.
Raises RuntimeError: | |
---|---|
if order reduction is altered after a coefficient has been set |
Sets order reduction state for equation representation according to flag.
Parameters: | flag (bool) – if flag is True, the order reduction is switched on for equation representation, otherwise or if flag is not present order reduction is switched off |
---|---|
Raises RuntimeError: | |
if order reduction is altered after a coefficient has been set |
Switches reduced order off for solution representation
Raises RuntimeError: | |
---|---|
if order reduction is altered after a coefficient has been set. |
Switches reduced order on for solution representation.
Raises RuntimeError: | |
---|---|
if order reduction is altered after a coefficient has been set |
Sets order reduction state for solution representation according to flag.
Parameters: | flag (bool) – if flag is True, the order reduction is switched on for solution representation, otherwise or if flag is not present order reduction is switched off |
---|---|
Raises RuntimeError: | |
if order reduction is altered after a coefficient has been set |
Switches reduced order off for solution and equation representation
Raises RuntimeError: | |
---|---|
if order reduction is altered after a coefficient has been set |
Switches reduced order on for solution and equation representation.
Raises RuntimeError: | |
---|---|
if order reduction is altered after a coefficient has been set |
Sets order reduction state for both solution and equation representation according to flag.
Parameters: | flag (bool) – if True, the order reduction is switched on for both solution and equation representation, otherwise or if flag is not present order reduction is switched off |
---|---|
Raises RuntimeError: | |
if order reduction is altered after a coefficient has been set |
Sets the solution assuming that makes the system valid with the tolrance defined by the solver options
Sets the solver options.
Parameters: | options (SolverOptions or None) – the new solver options. If equal None, the solver options are set to the default. |
---|---|
Note : | The symmetry flag of options is overwritten by the symmetry flag of the LinearProblem. |
Sets the symmetry flag to flag.
Parameters: | flag (bool) – If True, the symmetry flag is set otherwise reset. |
---|---|
Note : | The method overwrites the symmetry flag set by the solver options |
Clears the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
Sets the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
Sets the system status to status if status is not present the current status of the domain is used.
Sets new values to coefficients.
Parameters: |
|
---|---|
Raises IllegalCoefficient: | |
if an unknown coefficient keyword is used |
Prints the text message if debug mode is switched on.
Parameters: | text (string) – message to be printed |
---|
Marks the operator as valid.
Marks the right hand side as valid.
Marks the solution as valid.
Bases: esys.downunder.forwardmodels.ForwardModelWithPotential
Forward Model for magnetic inversion as described in the inversion cookbook.
Returns precomputed values shared by getValue() and getGradient().
Parameters: | k (Scalar) – susceptibility |
---|---|
Returns: | scalar magnetic potential and corresponding magnetic field |
Return type: | Scalar, Vector |
Returns the defect value.
Parameters: | result (Vector) – a result vector |
---|---|
Return type: | float |
Returns the domain of the forward model.
Return type: | Domain |
---|
Returns the gradient of the defect with respect to susceptibility.
Parameters: |
|
---|---|
Return type: | Scalar |
Calculates the magnetic potential for a given susceptibility.
Parameters: | k (Scalar) – susceptibility |
---|---|
Returns: | magnetic potential |
Return type: | Scalar |
Returns the pair (data_index, weight_index), where data_i is the data of survey i, weight_i is the weighting factor for survey i. If index is None, all surveys will be returned in a pair of lists.
Returns the value of the defect.
Parameters: |
|
---|---|
Return type: | float |
rescales the weights such that
sum_s integrate( ( w_i[s] *B_i[s]) (w_j[s]*1/L_j) * L**2 * (background_magnetic_flux_density_j[s]*1/L_j) * k_scale )=scale
Parameters: |
|
---|
Returns True if spherical coordinates are used.
Bases: object
Symbol objects are placeholders for a single mathematical symbol, such as ‘x’, or for arbitrarily complex mathematical expressions such as ‘c*x**4+alpha*exp(x)-2*sin(beta*x)’, where ‘alpha’, ‘beta’, ‘c’, and ‘x’ are also Symbols (the symbolic ‘atoms’ of the expression).
With the help of the ‘Evaluator’ class these symbols and expressions can be resolved by substituting numeric values and/or escript Data objects for the atoms. To facilitate the use of Data objects a Symbol has a shape (and thus a rank) as well as a dimension (see constructor). Symbols are useful to perform mathematical simplifications, compute derivatives and as coefficients for nonlinear PDEs which can be solved by the NonlinearPDE class.
Applies the function f to all elements (if on_type is None) or to all elements of type on_type.
Returns the atoms that form the current Symbol.
By default, only objects that are truly atomic and cannot be divided into smaller pieces are returned: symbols, numbers, and number symbols like I and pi. It is possible to request atoms of any type, however.
Note that if this symbol contains components such as [x]_i_j then only their main symbol ‘x’ is returned.
Parameters: | types – types to restrict result to |
---|---|
Returns: | list of atoms of specified type |
Return type: | set |
Returns the coefficient of the term “x” or 0 if there is no “x”.
If “x” is a scalar symbol then “x” is searched in all components of this symbol. Otherwise the shapes must match and the coefficients are checked component by component.
Example:
x=Symbol('x', (2,2))
y=3*x
print y.coeff(x)
print y.coeff(x[1,1])
will print:
[[3 3]
[3 3]]
[[0 0]
[0 3]]
Parameters: | x (Symbol, numpy.ndarray, list) – the term whose coefficients are to be found |
---|---|
Returns: | the coefficient(s) of the term |
Return type: | Symbol |
Applies the sympy.expand operation on all elements in this symbol
Returns a dictionary of symbol names and the escript Data objects they represent within this Symbol.
Returns: | the dictionary of substituted Data objects |
---|---|
Return type: | dict |
Returns the spatial dimensionality of this symbol.
Returns: | the symbol’s spatial dimensionality, or -1 if undefined |
---|---|
Return type: | int |
Returns the rank of this symbol.
Returns: | the symbol’s rank which is equal to the length of the shape. |
---|---|
Return type: | int |
Returns the shape of this symbol.
Returns: | the symbol’s shape |
---|---|
Return type: | tuple of int |
Returns a symbol which represents the gradient of this symbol. :type where: Symbol, FunctionSpace
Returns an element of this symbol. This method behaves like the item() method of numpy.ndarray. If this is a scalar Symbol, no arguments are allowed and the only element in this Symbol is returned. Otherwise, ‘args’ specifies a flat or nd-index and the element at that index is returned.
Parameters: | args – index of item to be returned |
---|---|
Returns: | the requested element |
Return type: | sympy.Symbol, int, or float |
Applies the sympy.simplify operation on all elements in this symbol
Substitutes an expression.
Returns the trace of this Symbol.
Returns the transpose of this Symbol.
Returns the absolute value of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray.) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Compute a tensor product of two Data objects.
Return type: | |
---|---|
Parameters: |
|
Returns: | a function FunctionSpace |
---|---|
Return type: | FunctionSpace |
Returns the L2 norm of arg at where.
Parameters: | arg (escript.Data or Symbol) – function of which the L2 norm is to be calculated |
---|---|
Returns: | L2 norm of arg |
Return type: | float or Symbol |
Note : | L2(arg) is equivalent to sqrt(integrate(inner(arg,arg))) |
Defines a single linear PDE.
Parameters: |
|
---|---|
Return type: |
Returns the Lsup-norm of argument arg. This is the maximum absolute value over all data points. This function is equivalent to sup(abs(arg)).
Parameters: | arg (float, int, escript.Data, numpy.ndarray) – argument |
---|---|
Returns: | maximum value of the absolute value of arg over all components and all data points |
Return type: | float |
Raises TypeError: | |
if type of arg cannot be processed |
Construct a Data object containing scalar data-points.
Parameters: |
|
---|---|
Return type: |
Construct a Data object containing rank1 data-points.
param value: scalar value for all points rtype: Data type value: float param what: FunctionSpace for Data type what: FunctionSpace param expanded: If True, a value is stored for each point. If False, more efficient representations may be used type expanded: bool
Vector( (object)value [, (FunctionSpace)what=<esys.escript.escriptcpp.FunctionSpace object at 0x413ecd0> [, (bool)expanded=False]]) -> Data
Returns the inverse cosine of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns the inverse hyperbolic cosine of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns the inverse sine of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns the inverse hyperbolic sine of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns inverse tangent of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns the inverse hyperbolic tangent of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns the bounding box of a domain
Parameters: | domain (escript.Domain) – a domain |
---|---|
Returns: | bounding box of the domain |
Return type: | list of pairs of float |
Returns the edge lengths of the bounding box of a domain
Parameters: | domain (escript.Domain) – a domain |
---|---|
Return type: | list of float |
Cuts the values of arg between minval and maxval.
Parameters: |
|
---|---|
Returns: | an object that contains all values from arg between minval and maxval |
Return type: | numpy.ndarray, escript.Data, Symbol, int or float depending on the input |
Raises ValueError: | |
if minval>maxval |
Identifies, if possible, the spatial dimension across a set of objects which may or may not have a spatial dimension.
Parameters: | args – given objects |
---|---|
Returns: | the spatial dimension of the objects with identifiable dimension (see pokeDim). If none of the objects has a spatial dimension None is returned. |
Return type: | int or None |
Raises ValueError: | |
if the objects with identifiable dimension don’t have the same spatial dimension. |
Returns a shape to which arg0 can be extended from the right and arg1 can be extended from the left.
Parameters: | |
---|---|
Returns: | the shape of arg0 or arg1 such that the left part equals the shape of arg0 and the right end equals the shape of arg1 |
Return type: | tuple of int |
Raises ValueError: | |
if no shape can be found |
Wrapper to allow non-data objects to be used.
Returns cosine of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns the hyperbolic cosine of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns a lazy version of arg
Returns the deviatoric version of arg.
Returns the diameter of a domain.
Parameters: | domain (escript.Domain) – a domain |
---|---|
Return type: | float |
Returns the divergence of arg at where.
Parameters: |
|
---|---|
Returns: | divergence of arg |
Return type: | escript.Data or Symbol |
Returns the eigenvalues of the square matrix arg.
Parameters: | arg (numpy.ndarray, escript.Data, Symbol) – square matrix. Must have rank 2 and the first and second dimension must be equal. It must also be symmetric, ie. transpose(arg)==arg (this is not checked). |
---|---|
Returns: | the eigenvalues in increasing order |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
Note : | for escript.Data and Symbol objects the dimension is restricted to 3. |
Returns the eigenvalues and eigenvectors of the square matrix arg.
Parameters: | arg (escript.Data) – square matrix. Must have rank 2 and the first and second dimension must be equal. It must also be symmetric, ie. transpose(arg)==arg (this is not checked). |
---|---|
Returns: | the eigenvalues and eigenvectors. The eigenvalues are ordered by increasing value. The eigenvectors are orthogonal and normalized. If V are the eigenvectors then V[:,i] is the eigenvector corresponding to the i-th eigenvalue. |
Return type: | tuple of escript.Data |
Note : | The dimension is restricted to 3. |
Returns the error function erf of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray.) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
arg0 and arg1 are both Data objects but not necessarily on the same function space. They could be identical!!!
arg0 and arg1 are both Data objects but not necessarily on the same function space. They could be identical!!!
arg0 and arg1 are both Data objects but not necessarily on the same function space. They could be identical!!!
arg is a Data object!
Returns e to the power of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray.) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Generalized tensor product.
C{out[s,t]=Sigma_r arg0[s,r]*arg1[r,t]}
Parameters: | |
---|---|
Returns: | the general tensor product of arg0 and arg1 at each data point |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
Generalized tensor product of arg0 and transpose of arg1.
C{out[s,t]=Sigma_r arg0[s,r]*arg1[t,r]}
The function call generalTensorTransposedProduct(arg0,arg1,axis_offset) is equivalent to generalTensorProduct(arg0,transpose(arg1,arg1.ndim-axis_offset),axis_offset).
Parameters: | |
---|---|
Returns: | the general tensor product of arg0 and transpose(arg1) at each data point |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
Generalized tensor product of transposed of arg0 and arg1.
C{out[s,t]=Sigma_r arg0[r,s]*arg1[r,t]}
The function call generalTransposedTensorProduct(arg0,arg1,axis_offset) is equivalent to generalTensorProduct(transpose(arg0,arg0.ndim-axis_offset),arg1,axis_offset).
Parameters: | |
---|---|
Returns: | the general tensor product of transpose(arg0) and arg1 at each data point |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
Returns the value in arg which is closest to origin.
Parameters: |
|
---|---|
Returns: | value in arg closest to origin |
Return type: | numpy.ndarray |
Return the rank of this process in the MPI World.
Each MPI process calls this function with a value for arg1. The maximum value is computed and returned.
Return type: | int |
---|
Identifies the rank of the argument.
Parameters: | arg (numpy.ndarray, escript.Data, float, int, Symbol) – an object whose rank is to be returned |
---|---|
Returns: | the rank of the argument |
Return type: | int |
Raises TypeError: | |
if type of arg cannot be processed |
Identifies the shape of the argument.
Parameters: | arg (numpy.ndarray, escript.Data, float, int, Symbol) – an object whose shape is to be returned |
---|---|
Returns: | the shape of the argument |
Return type: | tuple of int |
Raises TypeError: | |
if type of arg cannot be processed |
Returns a list of tag names used by the domain.
Parameters: | domain (escript.Domain) – a domain object |
---|---|
Returns: | a list of tag names used by the domain |
Return type: | list of str |
This function computes:
| Df/Dx = del_f/del_x + del_f/del_grad(x)*del_grad(x)/del_x + ...
| \ / \ /
| a b
This method will only report accurate version numbers for clean checkouts.
Returns the spatial gradient of arg at where.
If g is the returned object, then
- if arg is rank 0 g[s] is the derivative of arg with respect to the s-th spatial dimension
- if arg is rank 1 g[i,s] is the derivative of arg[i] with respect to the s-th spatial dimension
- if arg is rank 2 g[i,j,s] is the derivative of arg[i,j] with respect to the s-th spatial dimension
- if arg is rank 3 g[i,j,k,s] is the derivative of arg[i,j,k] with respect to the s-th spatial dimension.
Parameters: |
|
---|---|
Returns: | gradient of arg |
Return type: | escript.Data or Symbol |
Returns the shape x shape identity tensor.
Parameters: | shape (tuple of int) – input shape for the identity tensor |
---|---|
Returns: | array whose shape is shape x shape where u[i,k]=1 for i=k and u[i,k]=0 otherwise for len(shape)=1. If len(shape)=2: u[i,j,k,l]=1 for i=k and j=l and u[i,j,k,l]=0 otherwise. |
Return type: | numpy.ndarray of rank 1, rank 2 or rank 4 |
Raises ValueError: | |
if len(shape)>2 |
Returns the d x d identity matrix.
Parameters: | d (int, escript.Domain or escript.FunctionSpace) – dimension or an object that has the getDim method defining the dimension |
---|---|
Returns: | the object u of rank 2 with u[i,j]=1 for i=j and u[i,j]=0 otherwise |
Return type: | numpy.ndarray or escript.Data of rank 2 |
Returns the d x d x d x d identity tensor.
Parameters: | d (int or any object with a getDim method) – dimension or an object that has the getDim method defining the dimension |
---|---|
Returns: | the object u of rank 4 with u[i,j,k,l]=1 for i=k and j=l and u[i,j,k,l]=0 otherwise |
Return type: | numpy.ndarray or escript.Data of rank 4 |
Returns the minimum value over all data points.
Parameters: | arg (float, int, escript.Data, numpy.ndarray) – argument |
---|---|
Returns: | minimum value of arg over all components and all data points |
Return type: | float |
Raises TypeError: | |
if type of arg cannot be processed |
Inner product of the two arguments. The inner product is defined as:
C{out=Sigma_s arg0[s]*arg1[s]}
where s runs through arg0.Shape.
arg0 and arg1 must have the same shape.
Parameters: | |
---|---|
Returns: | the inner product of arg0 and arg1 at each data point |
Return type: | numpy.ndarray, escript.Data, Symbol, float depending on the input |
Raises ValueError: | |
if the shapes of the arguments are not identical |
Inserts tag names into the domain.
Parameters: |
|
---|
Inserts tagged values into the target using tag names.
Parameters: |
|
---|---|
Returns: | target |
Return type: | escript.Data |
Returns the integral of the function arg over its domain. If where is present arg is interpolated to where before integration.
Parameters: |
|
---|---|
Returns: | integral of arg |
Return type: | float, numpy.ndarray or Symbol |
Interpolates the function into the FunctionSpace where. If the argument arg has the requested function space where no interpolation is performed and arg is returned.
Parameters: |
|
---|---|
Returns: | interpolated argument |
Return type: | escript.Data or Symbol |
Returns the inverse of the square matrix arg.
Parameters: | arg (numpy.ndarray, escript.Data, Symbol) – square matrix. Must have rank 2 and the first and second dimension must be equal. |
---|---|
Returns: | inverse of the argument. matrix_mult(inverse(arg),arg) will be almost equal to kronecker(arg.getShape()[0]) |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
Note : | for escript.Data objects the dimension is restricted to 3. |
Returns True if the argument arg is an escript Symbol or sympy.Basic object, False otherwise.
Returns the jump of arg across the continuity of the domain.
Parameters: |
|
---|---|
Returns: | jump of arg |
Return type: | escript.Data or Symbol |
Returns the kronecker delta-symbol.
Parameters: | d (int, escript.Domain or escript.FunctionSpace) – dimension or an object that has the getDim method defining the dimension |
---|---|
Returns: | the object u of rank 2 with u[i,j]=1 for i=j and u[i,j]=0 otherwise |
Return type: | numpy.ndarray or escript.Data of rank 2 |
Returns the length (Euclidean norm) of argument arg at each data point.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol depending on the type of arg |
Returns: | A list of pairs (p,d) where p is the name of a parameter for escript and d is a description. |
---|
Returns the natural logarithm of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray.) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns base-10 logarithm of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns the length of the longest edge of the domain
Parameters: | domain (escript.Domain) – a domain |
---|---|
Returns: | longest edge of the domain parallel to the Cartesian axis |
Return type: | float |
Returns a representation of arg0 and arg1 which have the same shape.
Parameters: | |
---|---|
Returns: | arg0 and arg1 where copies are returned when the shape has to be changed |
Return type: | tuple |
Converts arg0 and arg1 both to the same type numpy.ndarray or escript.Data
Parameters: |
|
---|---|
Returns: | a tuple representing arg0 and arg1 with the same type or with at least one of them being a Symbol |
Return type: | tuple of two numpy.ndarray or two escript.Data |
Raises TypeError: | |
if type of arg0 or arg1 cannot be processed |
matrix-matrix or matrix-vector product of the two arguments.
C{out[s0]=Sigma_{r0} arg0[s0,r0]*arg1[r0]}
or
C{out[s0,s1]=Sigma_{r0} arg0[s0,r0]*arg1[r0,s1]}
The second dimension of arg0 and the first dimension of arg1 must match.
Parameters: | |
---|---|
Returns: | the matrix-matrix or matrix-vector product of arg0 and arg1 at each data point |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
Raises ValueError: | |
if the shapes of the arguments are not appropriate |
matrix-transposed(matrix) product of the two arguments.
C{out[s0,s1]=Sigma_{r0} arg0[s0,r0]*arg1[s1,r0]}
The function call matrix_transposed_mult(arg0,arg1) is equivalent to matrix_mult(arg0,transpose(arg1)).
The last dimensions of arg0 and arg1 must match.
Parameters: | |
---|---|
Returns: | the product of arg0 and the transposed of arg1 at each data point |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
Raises ValueError: | |
if the shapes of the arguments are not appropriate |
See matrix_mult.
The maximum over arguments args.
Parameters: | args (numpy.ndarray, escript.Data, Symbol, int or float) – arguments |
---|---|
Returns: | an object which in each entry gives the maximum of the corresponding values in args |
Return type: | numpy.ndarray, escript.Data, Symbol, int or float depending on the input |
Returns the maximum value over all components of arg at each data point.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
return the mean value of the argument over its domain
Parameters: | arg (escript.Data) – function |
---|---|
Returns: | mean value |
Return type: | float or numpy.ndarray |
The minimum over arguments args.
Parameters: | args (numpy.ndarray, escript.Data, Symbol, int or float) – arguments |
---|---|
Returns: | an object which gives in each entry the minimum of the corresponding values in args |
Return type: | numpy.ndarray, escript.Data, Symbol, int or float depending on the input |
Returns the minimum value over all components of arg at each data point.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
creates a directory of name pathname if the directory does not exist.
Parameters: | pathname (str or sequence of strings) – valid path name |
---|---|
Note : | The method is MPI safe. |
Product of arg0 and arg1.
Parameters: | |
---|---|
Returns: | the product of arg0 and arg1 |
Return type: | Symbol, float, int, escript.Data or numpy.ndarray |
Note : | The shape of both arguments is matched according to the rules used in matchShape. |
returns the negative part of arg
Returns the non-symmetric part of the square matrix arg. That is, (arg-transpose(arg))/2.
Parameters: | arg (numpy.ndarray, escript.Data, Symbol) – input matrix. Must have rank 2 or 4 and be square. |
---|---|
Returns: | non-symmetric part of arg |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
Returns the normalized version of arg (=``arg/length(arg)``).
Parameters: |
|
---|---|
Returns: | normalized arg where arg is non-zero, and zero elsewhere |
Return type: | escript.Data or Symbol |
The outer product of the two arguments. The outer product is defined as:
out[t,s]=arg0[t]*arg1[s]
Parameters: | |
---|---|
Returns: | the outer product of arg0 and arg1 at each data point |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
Identifies the spatial dimension of the argument.
Parameters: | arg (any) – an object whose spatial dimension is to be returned |
---|---|
Returns: | the spatial dimension of the argument, if available, or None |
Return type: | int or None |
returns the positive part of arg
Prints expr in pretty form.
pprint is just a shortcut for this function
Prints expr in pretty form.
pprint is just a shortcut for this function
Returns sym with all occurrences grad_n(a,b,c) replaced by grad_n(a,b). That is, all functionspace parameters are removed.
Resorts the components of arg according to index.
Returns the value of arg resolved.
returns arg0/arg1 but return 0 where arg1 is (almost) zero
Writes Data objects to a CSV file. These objects must have compatible FunctionSpaces, i.e. it must be possible to interpolate all data to one FunctionSpace. Note, that with more than one MPI rank this function will fail for some function spaces on some domains.
Parameters: |
|
---|
The keyword args are Data objects to save. If a scalar Data object is passed with the name mask, then only samples which correspond to positive values in mask will be output. Example:
s=Scalar(..)
v=Vector(..)
t=Tensor(..)
f=float()
saveDataCSV("f.csv", a=s, b=v, c=t, d=f)
Will result in a file
a, b0, b1, c0_0, c0_1, .., c1_1, d 1.0, 1.5, 2.7, 3.1, 3.4, .., 0.89, 0.0 0.9, 8.7, 1.9, 3.4, 7.8, .., 1.21, 0.0
The first line is a header, the remaining lines give the values.
Saves Data objects to files and creates an I{escript dataset} (ESD) file for convenient processing/visualisation.
Single timestep example:
tmp = Scalar(..)
v = Vector(..)
saveESD("solution", "data", temperature=tmp, velocity=v)
Time series example:
while t < t_end:
tmp = Scalar(..)
v = Vector(..)
# save every 10 timesteps
if t % 10 == 0:
saveESD("solution", "data", timeStep=t, deltaT=10, temperature=tmp, velocity=v)
t = t + 1
tmp, v and the domain are saved in native format in the “data” directory and the file “solution.esd” is created that refers to tmp by the name “temperature” and to v by the name “velocity”.
Parameters: |
|
---|---|
Note : | The ESD concept is experimental and the file format likely to change so use this function with caution. |
Note : | The data objects have to be defined on the same domain (but not necessarily on the same FunctionSpace). |
Note : | When saving a time series the first timestep must be 0 and it is assumed that data from all timesteps share the domain. The dataset file is updated in each iteration. |
Displays the parameters escript recognises with an explanation and their current value.
Returns the sign of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns sine of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray.) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns the hyperbolic sine of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns the square root of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns the maximum value over all data points.
Parameters: | arg (float, int, escript.Data, numpy.ndarray) – argument |
---|---|
Returns: | maximum value of arg over all components and all data points |
Return type: | float |
Raises TypeError: | |
if type of arg cannot be processed |
Returns the swap of arg by swapping the components axis0 and axis1.
Parameters: |
|
---|---|
Returns: | arg with swapped components |
Return type: | escript.Data, Symbol or numpy.ndarray depending on the type of arg |
Emulates the behaviour of sympy.symbols.
Returns the symmetric part of the square matrix arg. That is, (arg+transpose(arg))/2.
Parameters: | arg (numpy.ndarray, escript.Data, Symbol) – input matrix. Must have rank 2 or 4 and be square. |
---|---|
Returns: | symmetric part of arg |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
Returns tangent of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns the hyperbolic tangent of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
The tensor product of the two arguments.
For arg0 of rank 2 this is
C{out[s0]=Sigma_{r0} arg0[s0,r0]*arg1[r0]}
or
C{out[s0,s1]=Sigma_{r0} arg0[s0,r0]*arg1[r0,s1]}
and for arg0 of rank 4 this is
C{out[s0,s1,s2,s3]=Sigma_{r0,r1} arg0[s0,s1,r0,r1]*arg1[r0,r1,s2,s3]}
or
C{out[s0,s1,s2]=Sigma_{r0,r1} arg0[s0,s1,r0,r1]*arg1[r0,r1,s2]}
or
C{out[s0,s1]=Sigma_{r0,r1} arg0[s0,s1,r0,r1]*arg1[r0,r1]}
In the first case the second dimension of arg0 and the last dimension of arg1 must match and in the second case the two last dimensions of arg0 must match the two first dimensions of arg1.
Parameters: | |
---|---|
Returns: | the tensor product of arg0 and arg1 at each data point |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
The tensor product of the first and the transpose of the second argument.
For arg0 of rank 2 this is
C{out[s0,s1]=Sigma_{r0} arg0[s0,r0]*arg1[s1,r0]}
and for arg0 of rank 4 this is
C{out[s0,s1,s2,s3]=Sigma_{r0,r1} arg0[s0,s1,r0,r1]*arg1[s2,s3,r0,r1]}
or
C{out[s0,s1,s2]=Sigma_{r0,r1} arg0[s0,s1,r0,r1]*arg1[s2,r0,r1]}
In the first case the second dimension of arg0 and arg1 must match and in the second case the two last dimensions of arg0 must match the two last dimensions of arg1.
The function call tensor_transpose_mult(arg0,arg1) is equivalent to tensor_mult(arg0,transpose(arg1)).
Parameters: | |
---|---|
Returns: | the tensor product of the transposed of arg0 and arg1 at each data point |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
See tensor_mult.
Tests if the argument is identical to zero.
Parameters: | arg (typically numpy.ndarray, escript.Data, float, int) – the object to test for zero |
---|---|
Returns: | True if the argument is identical to zero, False otherwise |
Return type: | bool |
Returns the trace of arg which is the sum of arg[k,k] over k.
Parameters: |
|
---|---|
Returns: | trace of arg. The rank of the returned object is rank of arg minus 2. |
Return type: | escript.Data, Symbol or numpy.ndarray depending on the type of arg |
Returns the transpose of arg by swapping the first axis_offset and the last rank-axis_offset components.
Parameters: |
|
---|---|
Returns: | transpose of arg |
Return type: | escript.Data, Symbol, numpy.ndarray, float, int depending on the type of arg |
transposed(matrix)-matrix or transposed(matrix)-vector product of the two arguments.
C{out[s0]=Sigma_{r0} arg0[r0,s0]*arg1[r0]}
or
C{out[s0,s1]=Sigma_{r0} arg0[r0,s0]*arg1[r0,s1]}
The function call transposed_matrix_mult(arg0,arg1) is equivalent to matrix_mult(transpose(arg0),arg1).
The first dimension of arg0 and arg1 must match.
Parameters: | |
---|---|
Returns: | the product of the transpose of arg0 and arg1 at each data point |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
Raises ValueError: | |
if the shapes of the arguments are not appropriate |
The tensor product of the transpose of the first and the second argument.
For arg0 of rank 2 this is
C{out[s0]=Sigma_{r0} arg0[r0,s0]*arg1[r0]}
or
C{out[s0,s1]=Sigma_{r0} arg0[r0,s0]*arg1[r0,s1]}
and for arg0 of rank 4 this is
C{out[s0,s1,s2,s3]=Sigma_{r0,r1} arg0[r0,r1,s0,s1]*arg1[r0,r1,s2,s3]}
or
C{out[s0,s1,s2]=Sigma_{r0,r1} arg0[r0,r1,s0,s1]*arg1[r0,r1,s2]}
or
C{out[s0,s1]=Sigma_{r0,r1} arg0[r0,r1,s0,s1]*arg1[r0,r1]}
In the first case the first dimension of arg0 and the first dimension of arg1 must match and in the second case the two first dimensions of arg0 must match the two first dimensions of arg1.
The function call transposed_tensor_mult(arg0,arg1) is equivalent to tensor_mult(transpose(arg0),arg1).
Parameters: | |
---|---|
Returns: | the tensor product of transpose of arg0 and arg1 at each data point |
Return type: | numpy.ndarray, escript.Data, Symbol depending on the input |
Returns a unit vector u of dimension d whose non-zero element is at index i.
Parameters: |
|
---|---|
Returns: | the object u of rank 1 with u[j]=1 for j=index and u[j]=0 otherwise |
Return type: | numpy.ndarray or escript.Data of rank 1 |
Returns the volume or area of the oject arg
Parameters: | arg (escript.FunctionSpace or escript.Domain) – a geometrical object |
---|---|
Return type: | float |
Returns mask of negative values of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns mask of non-negative values of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns mask of non-positive values of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns mask of values different from zero of argument arg.
Parameters: |
|
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises: |
|
Returns mask of positive values of argument arg.
Parameters: | arg (float, escript.Data, Symbol, numpy.ndarray.) – argument |
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises TypeError: | |
if the type of the argument is not expected |
Returns mask of zero entries of argument arg.
Parameters: |
|
---|---|
Return type: | float, escript.Data, Symbol, numpy.ndarray depending on the type of arg |
Raises: |
|
Returns the shape zero tensor.
Parameters: | shape (tuple of int) – input shape for the identity tensor |
---|---|
Returns: | array of shape filled with zeros |
Return type: | numpy.ndarray |