esys.escript.linearPDEs Package¶
Classes¶
ContinuousDomainDataDomainFileWriterFunctionSpaceHelmholtzIllegalCoefficientIllegalCoefficientFunctionSpaceIllegalCoefficientValueInternal_SplitWorldLameEquationLinearPDELinearProblemOperatorPDECoefPoissonReducerSolverBuddySolverOptionsSubWorldTestDomainTransportPDETransportProblemUndefinedPDEErrorWavePDE
-
class
esys.escript.linearPDEs.ContinuousDomain¶ Bases:
esys.escriptcore.escriptcpp.DomainClass representing continuous domains
-
__init__()¶ Raises an exception This class cannot be instantiated from Python
-
MPIBarrier((Domain)arg1) → None :¶ Wait until all processes have reached this point
-
addPDEToRHS((ContinuousDomain)arg1, (Data)rhs, (Data)X, (Data)Y, (Data)y, (Data)y_contact, (Data)y_dirac) → None :¶ adds a PDE onto the stiffness matrix mat and a rhs
Parameters:
-
addPDEToSystem((ContinuousDomain)arg1, (Operator)mat, (Data)rhs, (Data)A, (Data)B, (Data)C, (Data)D, (Data)X, (Data)Y, (Data)d, (Data)y, (Data)d_contact, (Data)y_contact, (Data)d_dirac, (Data)y_dirac) → None :¶ adds a PDE onto the stiffness matrix mat and a rhs
Parameters:
-
addPDEToTransportProblem((ContinuousDomain)arg1, (TransportProblem)tp, (Data)source, (Data)M, (Data)A, (Data)B, (Data)C, (Data)D, (Data)X, (Data)Y, (Data)d, (Data)y, (Data)d_contact, (Data)y_contact, (Data)d_dirac, (Data)y_dirac) → None :¶ Parameters:
-
dump((Domain)arg1, (str)filename) → None :¶ Dumps the domain to a file
Parameters: filename (string) –
-
getDataShape((ContinuousDomain)arg1, (int)functionSpaceCode) → object :¶ Returns: a pair (dps, ns) where dps=the number of data points per sample, and ns=the number of samples Return type: tuple
-
getDescription((ContinuousDomain)arg1) → str :¶ Returns: a description for this domain Return type: string
-
getMPIRank((Domain)arg1) → int :¶ Returns: the rank of this process Return type: int
-
getMPISize((Domain)arg1) → int :¶ Returns: the number of processes used for this DomainReturn type: int
-
getNormal((Domain)arg1) → Data :¶ Return type: escriptReturns: Boundary normals
-
getNumDataPointsGlobal((ContinuousDomain)arg1) → int :¶ Returns: the number of data points summed across all MPI processes Return type: int
-
getSize((Domain)arg1) → Data :¶ Returns: the local size of samples. The function space is chosen appropriately Return type: Data
-
getStatus((Domain)arg1) → int :¶ The status of a domain changes whenever the domain is modified
Return type: int
-
getSystemMatrixTypeId((ContinuousDomain)arg1, (object)options) → int :¶ Returns: the identifier of the matrix type to be used for the global stiffness matrix when particular solver options are used. Return type: int
-
getTag((Domain)arg1, (str)name) → int :¶ Returns: tag id for nameReturn type: string
-
getTransportTypeId((ContinuousDomain)arg1, (int)solver, (int)preconditioner, (int)package, (bool)symmetry) → int¶
-
getX((Domain)arg1) → Data :¶ Return type: DataReturns: Locations in the`Domain`. FunctionSpace is chosen appropriately
-
isValidTagName((Domain)arg1, (str)name) → bool :¶ Returns: True is namecorresponds to a tagReturn type: bool
-
newOperator((ContinuousDomain)arg1, (int)row_blocksize, (FunctionSpace)row_functionspace, (int)column_blocksize, (FunctionSpace)column_functionspace, (int)type) → Operator :¶ creates a SystemMatrixAdapter stiffness matrix and initializes it with zeros
Parameters: - row_blocksize (
int) – - row_functionspace (
FunctionSpace) – - column_blocksize (
int) – - column_functionspace (
FunctionSpace) – - type (
int) –
- row_blocksize (
-
newTransportProblem((ContinuousDomain)theta, (int)blocksize, (FunctionSpace)functionspace, (int)type) → TransportProblem :¶ creates a TransportProblemAdapter
Parameters: - theta (
float) – - blocksize (
int) – - functionspace (
FunctionSpace) – - type (
int) –
- theta (
-
onMasterProcessor((Domain)arg1) → bool :¶ Returns: True if this code is executing on the master process Return type: bool
-
print_mesh_info((ContinuousDomain)arg1[, (bool)full=False]) → None :¶ Parameters: full ( bool) –
-
setTagMap((Domain)arg1, (str)name, (int)tag) → None :¶ Give a tag number a name.
Parameters: - name (
string) – Name for the tag - tag (
int) – numeric id
Note: Tag names must be unique within a domain
- name (
-
setX((ContinuousDomain)arg1, (Data)arg) → None :¶ assigns new location to the domain
Parameters: arg ( Data) –
-
showTagNames((Domain)arg1) → str :¶ Returns: A space separated list of tag names Return type: string
-
supportsContactElements((Domain)arg1) → bool :¶ Does this domain support contact elements.
-
-
class
esys.escript.linearPDEs.Data¶ Bases:
Boost.Python.instanceRepresents a collection of datapoints. It is used to store the values of a function. For more details please consult the c++ class documentation.
-
__init__((object)arg1) → None¶ __init__( (object)arg1, (object)value [, (object)p2 [, (object)p3 [, (object)p4]]]) -> None
-
conjugate((Data)arg1) → Data¶
-
copy((Data)arg1, (Data)other) → None :¶ Make this object a copy of
othernote: The two objects will act independently from now on. That is, changing otherafter this call will not change this object and vice versa.- copy( (Data)arg1) -> Data :
note: In the no argument form, a new object will be returned which is an independent copy of this object.
-
copyWithMask((Data)arg1, (Data)other, (Data)mask) → None :¶ Selectively copy values from
otherData.Datapoints which correspond to positive values inmaskwill be copied fromotherParameters:
-
delay((Data)arg1) → Data :¶ Convert this object into lazy representation
-
dump((Data)arg1, (str)fileName) → None :¶ Save the data as a netCDF file
Parameters: fileName ( string) –
-
expand((Data)arg1) → None :¶ Convert the data to expanded representation if it is not expanded already.
-
getFunctionSpace((Data)arg1) → FunctionSpace :¶ Return type: FunctionSpace
-
getNumberOfDataPoints((Data)arg1) → int :¶ Return type: intReturns: Number of datapoints in the object
-
getRank((Data)arg1) → int :¶ Returns: the number of indices required to address a component of a datapoint Return type: positive int
-
getShape((Data)arg1) → tuple :¶ Returns the shape of the datapoints in this object as a python tuple. Scalar data has the shape
()Return type: tuple
-
getTagNumber((Data)arg1, (int)dpno) → int :¶ Return tag number for the specified datapoint
Return type: int Parameters: dpno (int) – datapoint number
-
getTupleForDataPoint((Data)arg1, (int)dataPointNo) → object :¶ Returns: Value of the specified datapoint Return type: tupleParameters: dataPointNo ( int) – datapoint to access
-
getTupleForGlobalDataPoint((Data)arg1, (int)procNo, (int)dataPointNo) → object :¶ Get a specific datapoint from a specific process
Return type: tupleParameters: - procNo (positive
int) – MPI rank of the process - dataPointNo (int) – datapoint to access
- procNo (positive
-
hasInf((Data)arg1) → bool :¶ Returns return true if data contains +-Inf. [Note that for complex values, hasNaN and hasInf are not mutually exclusive.]
-
hasNaN((Data)arg1) → bool :¶ Returns return true if data contains NaN. [Note that for complex values, hasNaN and hasInf are not mutually exclusive.]
-
imag((Data)arg1) → Data¶
-
internal_maxGlobalDataPoint((Data)arg1) → tuple :¶ Please consider using getSupLocator() from pdetools instead.
-
internal_minGlobalDataPoint((Data)arg1) → tuple :¶ Please consider using getInfLocator() from pdetools instead.
-
interpolate((Data)arg1, (FunctionSpace)functionspace) → Data :¶ Interpolate this object’s values into a new functionspace.
-
interpolateTable((Data)arg1, (object)table, (float)Amin, (float)Astep, (Data)B, (float)Bmin, (float)Bstep[, (float)undef=1e+50[, (bool)check_boundaries=False]]) → Data :¶ - Creates a new Data object by interpolating using the source data (which are
looked up in
table)Amust be the outer dimension on the tableparam 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: Dataparam 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 undefrtype: Data
interpolateTable( (Data)arg1, (object)table, (float)Amin, (float)Astep [, (float)undef=1e+50 [, (bool)check_boundaries=False]]) -> Data
-
isComplex((Data)arg1) → bool :¶ Return type: boolReturns: True if this Datastores complex values.
-
isConstant((Data)arg1) → bool :¶ Return type: boolReturns: True if this Datais an instance ofDataConstantNote: This does not mean the data is immutable.
-
isEmpty((Data)arg1) → bool :¶ Is this object an instance of
DataEmptyReturn type: boolNote: This is not the same thing as asking if the object contains datapoints.
-
isExpanded((Data)arg1) → bool :¶ Return type: boolReturns: True if this Datais expanded.
-
isLazy((Data)arg1) → bool :¶ Return type: boolReturns: True if this Datais lazy.
-
isProtected((Data)arg1) → bool :¶ Can this instance be modified. :rtype:
bool
-
isReady((Data)arg1) → bool :¶ Return type: boolReturns: True if this Datais not lazy.
-
isTagged((Data)arg1) → bool :¶ Return type: boolReturns: True if this Datais expanded.
-
nonuniformInterpolate((Data)arg1, (object)in, (object)out, (bool)check_boundaries) → Data :¶ 1D interpolation with non equally spaced points
-
nonuniformSlope((Data)arg1, (object)in, (object)out, (bool)check_boundaries) → Data :¶ 1D interpolation of slope with non equally spaced points
-
phase((Data)arg1) → Data¶
-
promote((Data)arg1) → None¶
-
real((Data)arg1) → Data¶
-
replaceInf((Data)arg1, (object)value) → None :¶ Replaces +-Inf values with value. [Note, for complex Data, both real and imaginary components are replaced even if only one part is Inf].
-
replaceNaN((Data)arg1, (object)value) → None :¶ Replaces NaN values with value. [Note, for complex Data, both real and imaginary components are replaced even if only one part is NaN].
-
resolve((Data)arg1) → None :¶ Convert the data to non-lazy representation.
-
setProtection((Data)arg1) → None :¶ Disallow modifications to this data object
Note: This method does not allow you to undo protection.
-
setTaggedValue((Data)arg1, (int)tagKey, (object)value) → None :¶ Set the value of tagged Data.
param tagKey: tag to update type tagKey: int- setTaggedValue( (Data)arg1, (str)name, (object)value) -> None :
param name: tag to update type name: stringparam value: value to set tagged data to type value: objectwhich acts like an array,tupleorlist
-
setToZero((Data)arg1) → None :¶ After this call the object will store values of the same shape as before but all components will be zero.
-
setValueOfDataPoint((Data)arg1, (int)dataPointNo, (object)value) → None¶ 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: floator an object which acts like an array,tupleorlistwarning: Use of this operation is discouraged. It prevents some optimisations from operating.
-
tag((Data)arg1) → None :¶ Convert data to tagged representation if it is not already tagged or expanded
-
toListOfTuples((Data)arg1[, (bool)scalarastuple=False]) → object :¶ 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]
-
-
class
esys.escript.linearPDEs.Domain¶ Bases:
Boost.Python.instanceBase class for all domains.
-
__init__()¶ Raises an exception This class cannot be instantiated from Python
-
MPIBarrier((Domain)arg1) → None :¶ Wait until all processes have reached this point
-
dump((Domain)arg1, (str)filename) → None :¶ Dumps the domain to a file
Parameters: filename (string) –
-
getMPIRank((Domain)arg1) → int :¶ Returns: the rank of this process Return type: int
-
getMPISize((Domain)arg1) → int :¶ Returns: the number of processes used for this DomainReturn type: int
-
getNormal((Domain)arg1) → Data :¶ Return type: escriptReturns: Boundary normals
-
getSize((Domain)arg1) → Data :¶ Returns: the local size of samples. The function space is chosen appropriately Return type: Data
-
getStatus((Domain)arg1) → int :¶ The status of a domain changes whenever the domain is modified
Return type: int
-
getTag((Domain)arg1, (str)name) → int :¶ Returns: tag id for nameReturn type: string
-
getX((Domain)arg1) → Data :¶ Return type: DataReturns: Locations in the`Domain`. FunctionSpace is chosen appropriately
-
isValidTagName((Domain)arg1, (str)name) → bool :¶ Returns: True is namecorresponds to a tagReturn type: bool
-
onMasterProcessor((Domain)arg1) → bool :¶ Returns: True if this code is executing on the master process Return type: bool
-
setTagMap((Domain)arg1, (str)name, (int)tag) → None :¶ Give a tag number a name.
Parameters: - name (
string) – Name for the tag - tag (
int) – numeric id
Note: Tag names must be unique within a domain
- name (
-
showTagNames((Domain)arg1) → str :¶ Returns: A space separated list of tag names Return type: string
-
supportsContactElements((Domain)arg1) → bool :¶ Does this domain support contact elements.
-
-
class
esys.escript.linearPDEs.FileWriter(fn, append=False, createLocalFiles=False)¶ Bases:
objectInterface to write data to a file. In essence this class wrappes the standard
fileobject 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 useFileWriterrather thanopenin order to write code that is running with as well as with MPI. It is safe to useopenonder MPI to read data which are global under MPI.Variables: - name – name of file
- mode – access mode (=’w’ or =’a’)
- closed – True to indicate closed file
- newlines – line seperator
-
__init__(fn, append=False, createLocalFiles=False)¶ Opens a file of name
fnfor writing. If running under MPI only the first processor with rank==0 will open the file and write to it. IfcreateLocalFileseach individual processor will create a file where for any processor with rank>0 the file name is extended by its rank. This option is normally only used for debug purposes.Parameters: - fn (
str) – filename. - append (
bool) – switches on the creation of local files. - createLocalFiles (
bool) – switches on the creation of local files.
- fn (
-
close()¶ Closes the file
-
flush()¶ Flush the internal I/O buffer.
-
write(txt)¶ Write string
txtto file.Parameters: txt ( str) – stringtxtto be written to file
-
writelines(txts)¶ Write the list
txtof 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.
-
class
esys.escript.linearPDEs.FunctionSpace¶ Bases:
Boost.Python.instanceA FunctionSpace describes which points from the
Domainto use to represent functions.-
__init__((object)arg1) → None¶
-
getApproximationOrder((FunctionSpace)arg1) → int :¶ 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
-
getDim((FunctionSpace)arg1) → int :¶ Returns: the spatial dimension of the underlying domain. Return type: int
-
getDomain((FunctionSpace)arg1) → Domain :¶ Returns: the underlying Domainfor this FunctionSpace.Return type: Domain
-
getListOfTags((FunctionSpace)arg1) → list :¶ Returns: a list of the tags used in this function space Return type: list
-
getReferenceIDFromDataPointNo((FunctionSpace)arg1, (int)dataPointNo) → int :¶ Returns: the reference number associated with dataPointNoReturn type: int
-
getTagFromDataPointNo((FunctionSpace)arg1, (int)arg2) → int :¶ Returns: the tag associated with the given sample number. Return type: int
-
getTypeCode((FunctionSpace)arg1) → int :¶ Return type: int
-
getX((FunctionSpace)arg1) → Data :¶ Returns: a function whose values are its input coordinates. ie an identity function. Return type: Data
-
setTags((FunctionSpace)arg1, (int)newtag, (Data)mask) → None :¶ Set tags according to a mask
param newtag: tag number to set type newtag: string, non-zero intparam mask: Samples which correspond to positive values in the mask will be set to newtag.type mask: scalar DatasetTags( (FunctionSpace)arg1, (str)newtag, (Data)mask) -> None
-
-
class
esys.escript.linearPDEs.Helmholtz(domain, debug=False)¶ Bases:
esys.escriptcore.linearPDEs.LinearPDEClass to define a Helmholtz equation problem. This is generally a
LinearPDEof the formomega*u - grad(k*grad(u)[j])[j] = f
with natural boundary conditions
k*n[j]*grad(u)[j] = g- alphau
and constraints:
u=r where q>0
-
__init__(domain, debug=False)¶ Initializes a new Helmholtz equation.
Parameters: - domain (
Domain) – domain of the PDE - debug – if True debug information is printed
- domain (
-
addPDEToLumpedSystem(operator, a, b, c, hrz_lumping)¶ adds a PDE to the lumped system, results depend on domain
Parameters:
-
addPDEToRHS(righthandside, X, Y, y, y_contact, y_dirac)¶ adds a PDE to the right hand side, results depend on domain
Parameters:
-
addPDEToSystem(operator, righthandside, A, B, C, D, X, Y, d, y, d_contact, y_contact, d_dirac, y_dirac)¶ adds a PDE to the system, results depend on domain
Parameters:
-
addToRHS(rhs, data)¶ adds a PDE to the right hand side, results depend on domain
Parameters: - mat (
OperatorAdapter) – - righthandside (
Data) – - data (
list) –
- mat (
-
addToSystem(op, rhs, data)¶ adds a PDE to the system, results depend on domain
Parameters: - mat (
OperatorAdapter) – - rhs (
Data) – - data (
list) –
- mat (
-
alteredCoefficient(name)¶ Announces that coefficient
namehas been changed.Parameters: name ( string) – name of the coefficient affectedRaises: IllegalCoefficient – if nameis not a coefficient of the PDENote: if nameis q or r, the method will not trigger a rebuild of the system as constraints are applied to the solved system.
-
checkReciprocalSymmetry(name0, name1, verbose=True)¶ Tests two coefficients for reciprocal symmetry.
Parameters: - name0 (
str) – name of the first coefficient - name1 (
str) – name of the second coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed
Returns: True if coefficients
name0andname1are reciprocally symmetric.Return type: bool- name0 (
-
checkSymmetricTensor(name, verbose=True)¶ Tests a coefficient for symmetry.
Parameters: - name (
str) – name of the coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed.
Returns: True if coefficient
nameis symmetricReturn type: bool- name (
-
checkSymmetry(verbose=True)¶ 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: boolNote: This is a very expensive operation. It should be used for degugging only! The symmetry flag is not altered.
-
createCoefficient(name)¶ Creates a
Dataobject corresponding to coefficientname.Returns: the coefficient nameinitialized to 0Return type: DataRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
createOperator()¶ Returns an instance of a new operator.
-
createRightHandSide()¶ Returns an instance of a new right hand side.
-
createSolution()¶ Returns an instance of a new solution.
-
getCoefficient(name)¶ Returns the value of the coefficient
nameof the general PDE.Parameters: name ( string) – name of the coefficient requestedReturns: the value of the coefficient nameReturn type: DataRaises: IllegalCoefficient – invalid name
-
getCurrentOperator()¶ Returns the operator in its current state.
-
getCurrentRightHandSide()¶ Returns the right hand side in its current state.
-
getCurrentSolution()¶ Returns the solution in its current state.
-
getDim()¶ Returns the spatial dimension of the PDE.
Returns: the spatial dimension of the PDE domain Return type: int
-
getDomainStatus()¶ Return the status indicator of the domain
-
getFlux(u=None)¶ 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 ( Dataor None) – argument in the flux. If u is not present or equalsNonethe current solution is used.Returns: flux Return type: Data
-
getFunctionSpaceForCoefficient(name)¶ Returns the
FunctionSpaceto be used for coefficientname.Parameters: name ( string) – name of the coefficient enquiredReturns: the function space to be used for coefficient nameReturn type: FunctionSpaceRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getFunctionSpaceForEquation()¶ Returns the
FunctionSpaceused to discretize the equation.Returns: representation space of equation Return type: FunctionSpace
-
getFunctionSpaceForSolution()¶ Returns the
FunctionSpaceused to represent the solution.Returns: representation space of solution Return type: FunctionSpace
-
getNumEquations()¶ Returns the number of equations.
Returns: the number of equations Return type: intRaises: UndefinedPDEError – if the number of equations is not specified yet
-
getNumSolutions()¶ Returns the number of unknowns.
Returns: the number of unknowns Return type: intRaises: UndefinedPDEError – if the number of unknowns is not specified yet
-
getOperator()¶ Returns the operator of the linear problem.
Returns: the operator of the problem
-
getOperatorType()¶ Returns the current system type.
-
getRequiredOperatorType()¶ Returns the system type which needs to be used by the current set up.
-
getResidual(u=None)¶ Returns the residual of u or the current solution if u is not present.
Parameters: u ( Dataor None) – argument in the residual calculation. It must be representable inself.getFunctionSpaceForSolution(). If u is not present or equalsNonethe current solution is used.Returns: residual of u Return type: Data
-
getRightHandSide()¶ Returns the right hand side of the linear problem.
Returns: the right hand side of the problem Return type: Data
-
getShapeOfCoefficient(name)¶ Returns the shape of the coefficient
name.Parameters: name ( string) – name of the coefficient enquiredReturns: the shape of the coefficient nameReturn type: tupleofintRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getSolverOptions()¶ Returns the solver options
Return type: SolverOptions
-
getSystem()¶ Returns the operator and right hand side of the PDE.
Returns: the discrete version of the PDE Return type: tupleofOperatorandData
-
getSystemStatus()¶ Return the domain status used to build the current system
-
hasCoefficient(name)¶ Returns True if
nameis the name of a coefficient.Parameters: name ( string) – name of the coefficient enquiredReturns: True if nameis the name of a coefficient of the general PDE, False otherwiseReturn type: bool
-
initializeSystem()¶ Resets the system clearing the operator, right hand side and solution.
-
insertConstraint(rhs_only=False)¶ 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
-
introduceCoefficients(**coeff)¶ Introduces new coefficients into the problem.
Use:
p.introduceCoefficients(A=PDECoef(…), B=PDECoef(…))
to introduce the coefficients A and B.
-
invalidateOperator()¶ Indicates the operator has to be rebuilt next time it is used.
-
invalidateRightHandSide()¶ Indicates the right hand side has to be rebuilt next time it is used.
-
invalidateSolution()¶ Indicates the PDE has to be resolved if the solution is requested.
-
invalidateSystem()¶ Announces that everything has to be rebuilt.
-
isComplex()¶ Returns true if this is a complex-valued LinearProblem, false if real-valued.
Return type: bool
-
isHermitian()¶ Checks if the pde is indicated to be Hermitian.
Returns: True if a Hermitian PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isHermitian()
-
isOperatorValid()¶ Returns True if the operator is still valid.
-
isRightHandSideValid()¶ Returns True if the operator is still valid.
-
isSolutionValid()¶ Returns True if the solution is still valid.
-
isSymmetric()¶ Checks if symmetry is indicated.
Returns: True if a symmetric PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isSymmetric()
-
isSystemValid()¶ Returns True if the system (including solution) is still vaild.
-
isUsingLumping()¶ Checks if matrix lumping is the current solver method.
Returns: True if the current solver method is lumping Return type: bool
-
preservePreconditioner(preserve=True)¶ Notifies the PDE that the preconditioner should not be reset when making changes to the operator.
Building the preconditioner data can be quite expensive (e.g. for multigrid methods) so if it is known that changes to the operator are going to be minor calling this method can speed up successive PDE solves.
Note: Not all operator types support this. Parameters: preserve ( bool) – if True, preconditioner will be preserved, otherwise it will be reset when making changes to the operator, which is the default behaviour.
-
reduceEquationOrder()¶ 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
-
reduceSolutionOrder()¶ 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
-
resetAllCoefficients()¶ Resets all coefficients to their default values.
-
resetOperator()¶ Makes sure that the operator is instantiated and returns it initialized with zeros.
-
resetRightHandSide()¶ Sets the right hand side to zero.
-
resetRightHandSideCoefficients()¶ Resets all coefficients defining the right hand side
-
resetSolution()¶ Sets the solution to zero.
-
setDebug(flag)¶ Switches debug output on if
flagis True otherwise it is switched off.Parameters: flag ( bool) – desired debug status
-
setDebugOff()¶ Switches debug output off.
-
setDebugOn()¶ Switches debug output on.
-
setHermitian(flag=False)¶ Sets the Hermitian flag to
flag.Parameters: flag ( bool) – If True, the Hermitian flag is set otherwise reset.Note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOff()¶ Clears the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOn()¶ Sets the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setReducedOrderForEquationOff()¶ Switches reduced order off for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationOn()¶ Switches reduced order on for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionOff()¶ Switches reduced order off for solution representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set.
-
setReducedOrderForSolutionOn()¶ Switches reduced order on for solution representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOff()¶ Switches reduced order off for solution and equation representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOn()¶ Switches reduced order on for solution and equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setSolution(u, validate=True)¶ Sets the solution assuming that makes the system valid with the tolrance defined by the solver options
-
setSolverOptions(options=None)¶ Sets the solver options.
Parameters: options ( SolverOptionsorNone) – the new solver options. If equalNone, the solver options are set to the default.Note: The symmetry flag of options is overwritten by the symmetry flag of the LinearProblem.
-
setSymmetry(flag=False)¶ 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
-
setSymmetryOff()¶ Clears the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSymmetryOn()¶ Sets the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSystemStatus(status=None)¶ Sets the system status to
statusifstatusis not present the current status of the domain is used.
-
setValue(**coefficients)¶ Sets new values to coefficients.
Parameters: - coefficients – new values assigned to coefficients
- omega (any type that can be cast to a
Scalarobject onFunction) – value for coefficient omega - k (any type that can be cast to a
Scalarobject onFunction) – value for coefficient k - f (any type that can be cast to a
Scalarobject onFunction) – value for right hand side f - alpha (any type that can be cast to a
Scalarobject onFunctionOnBoundary) – value for right hand side alpha - g (any type that can be cast to a
Scalarobject onFunctionOnBoundary) – value for right hand side g - r (any type that can be cast to a
Scalarobject onSolutionorReducedSolutiondepending on whether reduced order is used for the representation of the equation) – prescribed values r for the solution in constraints - q (any type that can be cast to a
Scalarobject onSolutionorReducedSolutiondepending on whether reduced order is used for the representation of the equation) – mask for the location of constraints
Raises: IllegalCoefficient – if an unknown coefficient keyword is used
-
shouldPreservePreconditioner()¶ Returns true if the preconditioner / factorisation should be kept even when resetting the operator.
Return type: bool
-
trace(text)¶ Prints the text message if debug mode is switched on.
Parameters: text ( string) – message to be printed
-
validOperator()¶ Marks the operator as valid.
-
validRightHandSide()¶ Marks the right hand side as valid.
-
validSolution()¶ Marks the solution as valid.
-
-
class
esys.escript.linearPDEs.IllegalCoefficient¶ Bases:
ValueErrorException that is raised if an illegal coefficient of the general or particular PDE is requested.
-
__init__()¶ Initialize self. See help(type(self)) for accurate signature.
-
args¶
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
class
esys.escript.linearPDEs.IllegalCoefficientFunctionSpace¶ Bases:
ValueErrorException that is raised if an incorrect function space for a coefficient is used.
-
__init__()¶ Initialize self. See help(type(self)) for accurate signature.
-
args¶
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
class
esys.escript.linearPDEs.IllegalCoefficientValue¶ Bases:
ValueErrorException that is raised if an incorrect value for a coefficient is used.
-
__init__()¶ Initialize self. See help(type(self)) for accurate signature.
-
args¶
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
class
esys.escript.linearPDEs.Internal_SplitWorld¶ Bases:
Boost.Python.instanceManages a group of sub worlds. For internal use only.
-
__init__((object)arg1, (int)num_worlds) → None¶
-
clearVariable((Internal_SplitWorld)arg1, (str)name) → None :¶ Remove the value from the named variable
-
copyVariable((Internal_SplitWorld)arg1, (str)source, (str)destination) → None :¶ Copy the contents of one variable to another
-
getDoubleVariable((Internal_SplitWorld)arg1, (str)arg2) → float :¶ Return the value of floating point variable
-
getLocalObjectVariable((Internal_SplitWorld)arg1, (str)arg2) → object :¶ Returns python object for a variable which is not shared between worlds
-
getSubWorldCount((Internal_SplitWorld)arg1) → int¶
-
getSubWorldID((Internal_SplitWorld)arg1) → int¶
-
getVarInfo((Internal_SplitWorld)arg1) → object :¶ Lists variable descriptions known to the system
-
getVarList((Internal_SplitWorld)arg1) → object :¶ Lists variables known to the system
-
removeVariable((Internal_SplitWorld)arg1, (str)name) → None :¶ Remove the named variable from the SplitWorld
-
runJobs((Internal_SplitWorld)arg1) → None :¶ Execute pending jobs.
-
-
class
esys.escript.linearPDEs.LameEquation(domain, debug=False, useFast=True)¶ Bases:
esys.escriptcore.linearPDEs.LinearPDEClass to define a Lame equation problem. This problem is defined as:
-grad(mu*(grad(u[i])[j]+grad(u[j])[i]))[j] - grad(lambda*grad(u[k])[k])[j] = F_i -grad(sigma[ij])[j]
with natural boundary conditions:
n[j]*(mu*(grad(u[i])[j]+grad(u[j])[i]) + lambda*grad(u[k])[k]) = f_i +n[j]*sigma[ij]
and constraints:
u[i]=r[i] where q[i]>0
-
__init__(domain, debug=False, useFast=True)¶ Initializes a new Lame equation.
Parameters: - domain (
Domain) – domain of the PDE - debug – if True debug information is printed
- domain (
-
addPDEToLumpedSystem(operator, a, b, c, hrz_lumping)¶ adds a PDE to the lumped system, results depend on domain
Parameters:
-
addPDEToRHS(righthandside, X, Y, y, y_contact, y_dirac)¶ adds a PDE to the right hand side, results depend on domain
Parameters:
-
addPDEToSystem(operator, righthandside, A, B, C, D, X, Y, d, y, d_contact, y_contact, d_dirac, y_dirac)¶ adds a PDE to the system, results depend on domain
Parameters:
-
addToRHS(rhs, data)¶ adds a PDE to the right hand side, results depend on domain
Parameters: - mat (
OperatorAdapter) – - righthandside (
Data) – - data (
list) –
- mat (
-
addToSystem(op, rhs, data)¶ adds a PDE to the system, results depend on domain
Parameters: - mat (
OperatorAdapter) – - rhs (
Data) – - data (
list) –
- mat (
-
alteredCoefficient(name)¶ Announces that coefficient
namehas been changed.Parameters: name ( string) – name of the coefficient affectedRaises: IllegalCoefficient – if nameis not a coefficient of the PDENote: if nameis q or r, the method will not trigger a rebuild of the system as constraints are applied to the solved system.
-
checkReciprocalSymmetry(name0, name1, verbose=True)¶ Tests two coefficients for reciprocal symmetry.
Parameters: - name0 (
str) – name of the first coefficient - name1 (
str) – name of the second coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed
Returns: True if coefficients
name0andname1are reciprocally symmetric.Return type: bool- name0 (
-
checkSymmetricTensor(name, verbose=True)¶ Tests a coefficient for symmetry.
Parameters: - name (
str) – name of the coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed.
Returns: True if coefficient
nameis symmetricReturn type: bool- name (
-
checkSymmetry(verbose=True)¶ 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: boolNote: This is a very expensive operation. It should be used for degugging only! The symmetry flag is not altered.
-
createCoefficient(name)¶ Creates a
Dataobject corresponding to coefficientname.Returns: the coefficient nameinitialized to 0Return type: DataRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
createOperator()¶ Returns an instance of a new operator.
-
createRightHandSide()¶ Returns an instance of a new right hand side.
-
createSolution()¶ Returns an instance of a new solution.
-
getCoefficient(name)¶ Returns the value of the coefficient
nameof the general PDE.Parameters: name ( string) – name of the coefficient requestedReturns: the value of the coefficient nameReturn type: DataRaises: IllegalCoefficient – invalid coefficient name
-
getCurrentOperator()¶ Returns the operator in its current state.
-
getCurrentRightHandSide()¶ Returns the right hand side in its current state.
-
getCurrentSolution()¶ Returns the solution in its current state.
-
getDim()¶ Returns the spatial dimension of the PDE.
Returns: the spatial dimension of the PDE domain Return type: int
-
getDomainStatus()¶ Return the status indicator of the domain
-
getFlux(u=None)¶ 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 ( Dataor None) – argument in the flux. If u is not present or equalsNonethe current solution is used.Returns: flux Return type: Data
-
getFunctionSpaceForCoefficient(name)¶ Returns the
FunctionSpaceto be used for coefficientname.Parameters: name ( string) – name of the coefficient enquiredReturns: the function space to be used for coefficient nameReturn type: FunctionSpaceRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getFunctionSpaceForEquation()¶ Returns the
FunctionSpaceused to discretize the equation.Returns: representation space of equation Return type: FunctionSpace
-
getFunctionSpaceForSolution()¶ Returns the
FunctionSpaceused to represent the solution.Returns: representation space of solution Return type: FunctionSpace
-
getNumEquations()¶ Returns the number of equations.
Returns: the number of equations Return type: intRaises: UndefinedPDEError – if the number of equations is not specified yet
-
getNumSolutions()¶ Returns the number of unknowns.
Returns: the number of unknowns Return type: intRaises: UndefinedPDEError – if the number of unknowns is not specified yet
-
getOperator()¶ Returns the operator of the linear problem.
Returns: the operator of the problem
-
getOperatorType()¶ Returns the current system type.
-
getRequiredOperatorType()¶ Returns the system type which needs to be used by the current set up.
-
getResidual(u=None)¶ Returns the residual of u or the current solution if u is not present.
Parameters: u ( Dataor None) – argument in the residual calculation. It must be representable inself.getFunctionSpaceForSolution(). If u is not present or equalsNonethe current solution is used.Returns: residual of u Return type: Data
-
getRightHandSide()¶ Returns the right hand side of the linear problem.
Returns: the right hand side of the problem Return type: Data
-
getShapeOfCoefficient(name)¶ Returns the shape of the coefficient
name.Parameters: name ( string) – name of the coefficient enquiredReturns: the shape of the coefficient nameReturn type: tupleofintRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getSolverOptions()¶ Returns the solver options
Return type: SolverOptions
-
getSystem()¶ Returns the operator and right hand side of the PDE.
Returns: the discrete version of the PDE Return type: tupleofOperatorandData
-
getSystemStatus()¶ Return the domain status used to build the current system
-
hasCoefficient(name)¶ Returns True if
nameis the name of a coefficient.Parameters: name ( string) – name of the coefficient enquiredReturns: True if nameis the name of a coefficient of the general PDE, False otherwiseReturn type: bool
-
initializeSystem()¶ Resets the system clearing the operator, right hand side and solution.
-
insertConstraint(rhs_only=False)¶ 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
-
introduceCoefficients(**coeff)¶ Introduces new coefficients into the problem.
Use:
p.introduceCoefficients(A=PDECoef(…), B=PDECoef(…))
to introduce the coefficients A and B.
-
invalidateOperator()¶ Indicates the operator has to be rebuilt next time it is used.
-
invalidateRightHandSide()¶ Indicates the right hand side has to be rebuilt next time it is used.
-
invalidateSolution()¶ Indicates the PDE has to be resolved if the solution is requested.
-
invalidateSystem()¶ Announces that everything has to be rebuilt.
-
isComplex()¶ Returns true if this is a complex-valued LinearProblem, false if real-valued.
Return type: bool
-
isHermitian()¶ Checks if the pde is indicated to be Hermitian.
Returns: True if a Hermitian PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isHermitian()
-
isOperatorValid()¶ Returns True if the operator is still valid.
-
isRightHandSideValid()¶ Returns True if the operator is still valid.
-
isSolutionValid()¶ Returns True if the solution is still valid.
-
isSymmetric()¶ Checks if symmetry is indicated.
Returns: True if a symmetric PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isSymmetric()
-
isSystemValid()¶ Returns True if the system (including solution) is still vaild.
-
isUsingLumping()¶ Checks if matrix lumping is the current solver method.
Returns: True if the current solver method is lumping Return type: bool
-
preservePreconditioner(preserve=True)¶ Notifies the PDE that the preconditioner should not be reset when making changes to the operator.
Building the preconditioner data can be quite expensive (e.g. for multigrid methods) so if it is known that changes to the operator are going to be minor calling this method can speed up successive PDE solves.
Note: Not all operator types support this. Parameters: preserve ( bool) – if True, preconditioner will be preserved, otherwise it will be reset when making changes to the operator, which is the default behaviour.
-
reduceEquationOrder()¶ 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
-
reduceSolutionOrder()¶ 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
-
resetAllCoefficients()¶ Resets all coefficients to their default values.
-
resetOperator()¶ Makes sure that the operator is instantiated and returns it initialized with zeros.
-
resetRightHandSide()¶ Sets the right hand side to zero.
-
resetRightHandSideCoefficients()¶ Resets all coefficients defining the right hand side
-
resetSolution()¶ Sets the solution to zero.
-
setDebug(flag)¶ Switches debug output on if
flagis True otherwise it is switched off.Parameters: flag ( bool) – desired debug status
-
setDebugOff()¶ Switches debug output off.
-
setDebugOn()¶ Switches debug output on.
-
setHermitian(flag=False)¶ Sets the Hermitian flag to
flag.Parameters: flag ( bool) – If True, the Hermitian flag is set otherwise reset.Note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOff()¶ Clears the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOn()¶ Sets the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setReducedOrderForEquationOff()¶ Switches reduced order off for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationOn()¶ Switches reduced order on for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionOff()¶ Switches reduced order off for solution representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set.
-
setReducedOrderForSolutionOn()¶ Switches reduced order on for solution representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOff()¶ Switches reduced order off for solution and equation representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOn()¶ Switches reduced order on for solution and equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setSolution(u, validate=True)¶ Sets the solution assuming that makes the system valid with the tolrance defined by the solver options
-
setSolverOptions(options=None)¶ Sets the solver options.
Parameters: options ( SolverOptionsorNone) – the new solver options. If equalNone, the solver options are set to the default.Note: The symmetry flag of options is overwritten by the symmetry flag of the LinearProblem.
-
setSymmetry(flag=False)¶ 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
-
setSymmetryOff()¶ Clears the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSymmetryOn()¶ Sets the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSystemStatus(status=None)¶ Sets the system status to
statusifstatusis not present the current status of the domain is used.
-
setValue(**coefficients)¶ Sets new values to coefficients.
Parameters: - coefficients – new values assigned to coefficients
- A (any type that can be cast to a
Dataobject onFunction) – value for coefficientA - A_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientA_reduced - B (any type that can be cast to a
Dataobject onFunction) – value for coefficientB - B_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientB_reduced - C (any type that can be cast to a
Dataobject onFunction) – value for coefficientC - C_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientC_reduced - D (any type that can be cast to a
Dataobject onFunction) – value for coefficientD - D_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientD_reduced - X (any type that can be cast to a
Dataobject onFunction) – value for coefficientX - X_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientX_reduced - Y (any type that can be cast to a
Dataobject onFunction) – value for coefficientY - Y_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientY_reduced - d (any type that can be cast to a
Dataobject onFunctionOnBoundary) – value for coefficientd - d_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnBoundary) – value for coefficientd_reduced - y (any type that can be cast to a
Dataobject onFunctionOnBoundary) – value for coefficienty - d_contact (any type that can be cast to a
Dataobject onFunctionOnContactOneorFunctionOnContactZero) – value for coefficientd_contact - d_contact_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnContactOneorReducedFunctionOnContactZero) – value for coefficientd_contact_reduced - y_contact (any type that can be cast to a
Dataobject onFunctionOnContactOneorFunctionOnContactZero) – value for coefficienty_contact - y_contact_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnContactOneorReducedFunctionOnContactZero) – value for coefficienty_contact_reduced - d_dirac (any type that can be cast to a
Dataobject onDiracDeltaFunctions) – value for coefficientd_dirac - y_dirac (any type that can be cast to a
Dataobject onDiracDeltaFunctions) – value for coefficienty_dirac - r (any type that can be cast to a
Dataobject onSolutionorReducedSolutiondepending on whether reduced order is used for the solution) – values prescribed to the solution at the locations of constraints - q (any type that can be cast to a
Dataobject onSolutionorReducedSolutiondepending on whether reduced order is used for the representation of the equation) – mask for location of constraints
Raises: IllegalCoefficient – if an unknown coefficient keyword is used
-
setValues(**coefficients)¶ Sets new values to coefficients.
Parameters: - coefficients – new values assigned to coefficients
- lame_mu (any type that can be cast to a
Scalarobject onFunction) – value for coefficient mu - lame_lambda (any type that can be cast to a
Scalarobject onFunction) – value for coefficient lambda - F (any type that can be cast to a
Vectorobject onFunction) – value for internal force F - sigma (any type that can be cast to a
Tensorobject onFunction) – value for initial stress sigma - f (any type that can be cast to a
Vectorobject onFunctionOnBoundary) – value for external force f - r (any type that can be cast to a
Vectorobject onSolutionorReducedSolutiondepending on whether reduced order is used for the representation of the equation) – prescribed values r for the solution in constraints - q (any type that can be cast to a
Vectorobject onSolutionorReducedSolutiondepending on whether reduced order is used for the representation of the equation) – mask for the location of constraints
Raises: IllegalCoefficient – if an unknown coefficient keyword is used
-
shouldPreservePreconditioner()¶ Returns true if the preconditioner / factorisation should be kept even when resetting the operator.
Return type: bool
-
trace(text)¶ Prints the text message if debug mode is switched on.
Parameters: text ( string) – message to be printed
-
validOperator()¶ Marks the operator as valid.
-
validRightHandSide()¶ Marks the right hand side as valid.
-
validSolution()¶ Marks the solution as valid.
-
-
class
esys.escript.linearPDEs.LinearPDE(domain, numEquations=None, numSolutions=None, isComplex=False, debug=False)¶ Bases:
esys.escriptcore.linearPDEs.LinearProblemThis class is used to define a general linear, steady, second order PDE for an unknown function u on a given domain defined through a
Domainobject.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
Dataobjects inFunctionand the coefficients A_reduced, B_reduced, C_reduced, D_reduced, X_reduced and Y_reduced have to be specified throughDataobjects inReducedFunction. It is also allowed to use objects that can be converted into suchDataobjects. 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
FunctionOnBoundaryand the coefficients d_reduced and y_reduced are each a scalar inReducedFunctionOnBoundary.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 inReducedFunctionOnBoundary.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]
LinearPDEalso 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 asJ[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.getNormalofFunctionOnContactZero. For a system of PDEs the contact condition takes the formn[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 inFunctionOnContactZeroorFunctionOnContactOne. The coefficient d_contact_reduced is of rank two and y_contact_reduced is of rank one both inReducedFunctionOnContactZeroorReducedFunctionOnContactOne. In case of a single PDE and a single component solution the contact condition takes the formn[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
FunctionOnContactZeroorFunctionOnContactOneand the coefficient d_contact_reduced and y_contact_reduced are each scalar both inReducedFunctionOnContactZeroorReducedFunctionOnContactOne.Typical usage:
p = LinearPDE(dom) p.setValue(A=kronecker(dom), D=1, Y=0.5) u = p.getSolution()
-
__init__(domain, numEquations=None, numSolutions=None, isComplex=False, debug=False)¶ Initializes a new linear PDE.
Parameters: - domain (
Domain) – domain of the PDE - numEquations – number of equations. If
Nonethe number of equations is extracted from the PDE coefficients. - numSolutions – number of solution components. If
Nonethe number of solution components is extracted from the PDE coefficients. - debug – if True debug information is printed
- domain (
-
addPDEToLumpedSystem(operator, a, b, c, hrz_lumping)¶ adds a PDE to the lumped system, results depend on domain
Parameters:
-
addPDEToRHS(righthandside, X, Y, y, y_contact, y_dirac)¶ adds a PDE to the right hand side, results depend on domain
Parameters:
-
addPDEToSystem(operator, righthandside, A, B, C, D, X, Y, d, y, d_contact, y_contact, d_dirac, y_dirac)¶ adds a PDE to the system, results depend on domain
Parameters:
-
addToRHS(rhs, data)¶ adds a PDE to the right hand side, results depend on domain
Parameters: - mat (
OperatorAdapter) – - righthandside (
Data) – - data (
list) –
- mat (
-
addToSystem(op, rhs, data)¶ adds a PDE to the system, results depend on domain
Parameters: - mat (
OperatorAdapter) – - rhs (
Data) – - data (
list) –
- mat (
-
alteredCoefficient(name)¶ Announces that coefficient
namehas been changed.Parameters: name ( string) – name of the coefficient affectedRaises: IllegalCoefficient – if nameis not a coefficient of the PDENote: if nameis q or r, the method will not trigger a rebuild of the system as constraints are applied to the solved system.
-
checkReciprocalSymmetry(name0, name1, verbose=True)¶ Tests two coefficients for reciprocal symmetry.
Parameters: - name0 (
str) – name of the first coefficient - name1 (
str) – name of the second coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed
Returns: True if coefficients
name0andname1are reciprocally symmetric.Return type: bool- name0 (
-
checkSymmetricTensor(name, verbose=True)¶ Tests a coefficient for symmetry.
Parameters: - name (
str) – name of the coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed.
Returns: True if coefficient
nameis symmetricReturn type: bool- name (
-
checkSymmetry(verbose=True)¶ 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: boolNote: This is a very expensive operation. It should be used for degugging only! The symmetry flag is not altered.
-
createCoefficient(name)¶ Creates a
Dataobject corresponding to coefficientname.Returns: the coefficient nameinitialized to 0Return type: DataRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
createOperator()¶ Returns an instance of a new operator.
-
createRightHandSide()¶ Returns an instance of a new right hand side.
-
createSolution()¶ Returns an instance of a new solution.
-
getCoefficient(name)¶ Returns the value of the coefficient
name.Parameters: name ( string) – name of the coefficient requestedReturns: the value of the coefficient Return type: DataRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getCurrentOperator()¶ Returns the operator in its current state.
-
getCurrentRightHandSide()¶ Returns the right hand side in its current state.
-
getCurrentSolution()¶ Returns the solution in its current state.
-
getDim()¶ Returns the spatial dimension of the PDE.
Returns: the spatial dimension of the PDE domain Return type: int
-
getDomainStatus()¶ Return the status indicator of the domain
-
getFlux(u=None)¶ 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 ( Dataor None) – argument in the flux. If u is not present or equalsNonethe current solution is used.Returns: flux Return type: Data
-
getFunctionSpaceForCoefficient(name)¶ Returns the
FunctionSpaceto be used for coefficientname.Parameters: name ( string) – name of the coefficient enquiredReturns: the function space to be used for coefficient nameReturn type: FunctionSpaceRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getFunctionSpaceForEquation()¶ Returns the
FunctionSpaceused to discretize the equation.Returns: representation space of equation Return type: FunctionSpace
-
getFunctionSpaceForSolution()¶ Returns the
FunctionSpaceused to represent the solution.Returns: representation space of solution Return type: FunctionSpace
-
getNumEquations()¶ Returns the number of equations.
Returns: the number of equations Return type: intRaises: UndefinedPDEError – if the number of equations is not specified yet
-
getNumSolutions()¶ Returns the number of unknowns.
Returns: the number of unknowns Return type: intRaises: UndefinedPDEError – if the number of unknowns is not specified yet
-
getOperator()¶ Returns the operator of the linear problem.
Returns: the operator of the problem
-
getOperatorType()¶ Returns the current system type.
-
getRequiredOperatorType()¶ Returns the system type which needs to be used by the current set up.
-
getResidual(u=None)¶ Returns the residual of u or the current solution if u is not present.
Parameters: u ( Dataor None) – argument in the residual calculation. It must be representable inself.getFunctionSpaceForSolution(). If u is not present or equalsNonethe current solution is used.Returns: residual of u Return type: Data
-
getRightHandSide()¶ Returns the right hand side of the linear problem.
Returns: the right hand side of the problem Return type: Data
-
getShapeOfCoefficient(name)¶ Returns the shape of the coefficient
name.Parameters: name ( string) – name of the coefficient enquiredReturns: the shape of the coefficient nameReturn type: tupleofintRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getSolverOptions()¶ Returns the solver options
Return type: SolverOptions
-
getSystem()¶ Returns the operator and right hand side of the PDE.
Returns: the discrete version of the PDE Return type: tupleofOperatorandData
-
getSystemStatus()¶ Return the domain status used to build the current system
-
hasCoefficient(name)¶ Returns True if
nameis the name of a coefficient.Parameters: name ( string) – name of the coefficient enquiredReturns: True if nameis the name of a coefficient of the general PDE, False otherwiseReturn type: bool
-
initializeSystem()¶ Resets the system clearing the operator, right hand side and solution.
-
insertConstraint(rhs_only=False)¶ 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
-
introduceCoefficients(**coeff)¶ Introduces new coefficients into the problem.
Use:
p.introduceCoefficients(A=PDECoef(…), B=PDECoef(…))
to introduce the coefficients A and B.
-
invalidateOperator()¶ Indicates the operator has to be rebuilt next time it is used.
-
invalidateRightHandSide()¶ Indicates the right hand side has to be rebuilt next time it is used.
-
invalidateSolution()¶ Indicates the PDE has to be resolved if the solution is requested.
-
invalidateSystem()¶ Announces that everything has to be rebuilt.
-
isComplex()¶ Returns true if this is a complex-valued LinearProblem, false if real-valued.
Return type: bool
-
isHermitian()¶ Checks if the pde is indicated to be Hermitian.
Returns: True if a Hermitian PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isHermitian()
-
isOperatorValid()¶ Returns True if the operator is still valid.
-
isRightHandSideValid()¶ Returns True if the operator is still valid.
-
isSolutionValid()¶ Returns True if the solution is still valid.
-
isSymmetric()¶ Checks if symmetry is indicated.
Returns: True if a symmetric PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isSymmetric()
-
isSystemValid()¶ Returns True if the system (including solution) is still vaild.
-
isUsingLumping()¶ Checks if matrix lumping is the current solver method.
Returns: True if the current solver method is lumping Return type: bool
-
preservePreconditioner(preserve=True)¶ Notifies the PDE that the preconditioner should not be reset when making changes to the operator.
Building the preconditioner data can be quite expensive (e.g. for multigrid methods) so if it is known that changes to the operator are going to be minor calling this method can speed up successive PDE solves.
Note: Not all operator types support this. Parameters: preserve ( bool) – if True, preconditioner will be preserved, otherwise it will be reset when making changes to the operator, which is the default behaviour.
-
reduceEquationOrder()¶ 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
-
reduceSolutionOrder()¶ 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
-
resetAllCoefficients()¶ Resets all coefficients to their default values.
-
resetOperator()¶ Makes sure that the operator is instantiated and returns it initialized with zeros.
-
resetRightHandSide()¶ Sets the right hand side to zero.
-
resetRightHandSideCoefficients()¶ Resets all coefficients defining the right hand side
-
resetSolution()¶ Sets the solution to zero.
-
setDebug(flag)¶ Switches debug output on if
flagis True otherwise it is switched off.Parameters: flag ( bool) – desired debug status
-
setDebugOff()¶ Switches debug output off.
-
setDebugOn()¶ Switches debug output on.
-
setHermitian(flag=False)¶ Sets the Hermitian flag to
flag.Parameters: flag ( bool) – If True, the Hermitian flag is set otherwise reset.Note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOff()¶ Clears the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOn()¶ Sets the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setReducedOrderForEquationOff()¶ Switches reduced order off for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationOn()¶ Switches reduced order on for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionOff()¶ Switches reduced order off for solution representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set.
-
setReducedOrderForSolutionOn()¶ Switches reduced order on for solution representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOff()¶ Switches reduced order off for solution and equation representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOn()¶ Switches reduced order on for solution and equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setSolution(u, validate=True)¶ Sets the solution assuming that makes the system valid with the tolrance defined by the solver options
-
setSolverOptions(options=None)¶ Sets the solver options.
Parameters: options ( SolverOptionsorNone) – the new solver options. If equalNone, the solver options are set to the default.Note: The symmetry flag of options is overwritten by the symmetry flag of the LinearProblem.
-
setSymmetry(flag=False)¶ 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
-
setSymmetryOff()¶ Clears the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSymmetryOn()¶ Sets the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSystemStatus(status=None)¶ Sets the system status to
statusifstatusis not present the current status of the domain is used.
-
setValue(**coefficients)¶ Sets new values to coefficients.
Parameters: - coefficients – new values assigned to coefficients
- A (any type that can be cast to a
Dataobject onFunction) – value for coefficientA - A_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientA_reduced - B (any type that can be cast to a
Dataobject onFunction) – value for coefficientB - B_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientB_reduced - C (any type that can be cast to a
Dataobject onFunction) – value for coefficientC - C_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientC_reduced - D (any type that can be cast to a
Dataobject onFunction) – value for coefficientD - D_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientD_reduced - X (any type that can be cast to a
Dataobject onFunction) – value for coefficientX - X_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientX_reduced - Y (any type that can be cast to a
Dataobject onFunction) – value for coefficientY - Y_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientY_reduced - d (any type that can be cast to a
Dataobject onFunctionOnBoundary) – value for coefficientd - d_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnBoundary) – value for coefficientd_reduced - y (any type that can be cast to a
Dataobject onFunctionOnBoundary) – value for coefficienty - d_contact (any type that can be cast to a
Dataobject onFunctionOnContactOneorFunctionOnContactZero) – value for coefficientd_contact - d_contact_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnContactOneorReducedFunctionOnContactZero) – value for coefficientd_contact_reduced - y_contact (any type that can be cast to a
Dataobject onFunctionOnContactOneorFunctionOnContactZero) – value for coefficienty_contact - y_contact_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnContactOneorReducedFunctionOnContactZero) – value for coefficienty_contact_reduced - d_dirac (any type that can be cast to a
Dataobject onDiracDeltaFunctions) – value for coefficientd_dirac - y_dirac (any type that can be cast to a
Dataobject onDiracDeltaFunctions) – value for coefficienty_dirac - r (any type that can be cast to a
Dataobject onSolutionorReducedSolutiondepending on whether reduced order is used for the solution) – values prescribed to the solution at the locations of constraints - q (any type that can be cast to a
Dataobject onSolutionorReducedSolutiondepending on whether reduced order is used for the representation of the equation) – mask for location of constraints
Raises: IllegalCoefficient – if an unknown coefficient keyword is used
-
shouldPreservePreconditioner()¶ Returns true if the preconditioner / factorisation should be kept even when resetting the operator.
Return type: bool
-
trace(text)¶ Prints the text message if debug mode is switched on.
Parameters: text ( string) – message to be printed
-
validOperator()¶ Marks the operator as valid.
-
validRightHandSide()¶ Marks the right hand side as valid.
-
validSolution()¶ Marks the solution as valid.
-
class
esys.escript.linearPDEs.LinearProblem(domain, numEquations=None, numSolutions=None, isComplex=False, debug=False)¶ Bases:
objectThis is the base class to define a general linear PDE-type problem for for an unknown function u on a given domain defined through a
Domainobject. The problem can be given as a single equation or as a system of equations.The class assumes that some sort of assembling process is required to form a problem of the form
L u=f
where L is an operator and f is the right hand side. This operator problem will be solved to get the unknown u.
-
__init__(domain, numEquations=None, numSolutions=None, isComplex=False, debug=False)¶ Initializes a linear problem.
Parameters: - domain (
Domain) – domain of the PDE - numEquations – number of equations. If
Nonethe number of equations is extracted from the coefficients. - numSolutions – number of solution components. If
Nonethe number of solution components is extracted from the coefficients. - isComplex – if True this problem will have complex coefficients and a complex-valued result.
- debug – if True debug information is printed
- domain (
-
addPDEToLumpedSystem(operator, a, b, c, hrz_lumping)¶ adds a PDE to the lumped system, results depend on domain
Parameters:
-
addPDEToRHS(righthandside, X, Y, y, y_contact, y_dirac)¶ adds a PDE to the right hand side, results depend on domain
Parameters:
-
addPDEToSystem(operator, righthandside, A, B, C, D, X, Y, d, y, d_contact, y_contact, d_dirac, y_dirac)¶ adds a PDE to the system, results depend on domain
Parameters:
-
addToRHS(rhs, data)¶ adds a PDE to the right hand side, results depend on domain
Parameters: - mat (
OperatorAdapter) – - righthandside (
Data) – - data (
list) –
- mat (
-
addToSystem(op, rhs, data)¶ adds a PDE to the system, results depend on domain
Parameters: - mat (
OperatorAdapter) – - rhs (
Data) – - data (
list) –
- mat (
-
alteredCoefficient(name)¶ Announces that coefficient
namehas been changed.Parameters: name ( string) – name of the coefficient affectedRaises: IllegalCoefficient – if nameis not a coefficient of the PDENote: if nameis q or r, the method will not trigger a rebuild of the system as constraints are applied to the solved system.
-
checkReciprocalSymmetry(name0, name1, verbose=True)¶ Tests two coefficients for reciprocal symmetry.
Parameters: - name0 (
str) – name of the first coefficient - name1 (
str) – name of the second coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed
Returns: True if coefficients
name0andname1are reciprocally symmetric.Return type: bool- name0 (
-
checkSymmetricTensor(name, verbose=True)¶ Tests a coefficient for symmetry.
Parameters: - name (
str) – name of the coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed.
Returns: True if coefficient
nameis symmetricReturn type: bool- name (
-
checkSymmetry(verbose=True)¶ Tests the PDE for symmetry.
Parameters: verbose ( bool) – if set to True or not present a report on coefficients which break the symmetry is printedReturns: True if the problem is symmetric Return type: boolNote: Typically this method is overwritten when implementing a particular linear problem.
-
createCoefficient(name)¶ Creates a
Dataobject corresponding to coefficientname.Returns: the coefficient nameinitialized to 0Return type: DataRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
createOperator()¶ Returns an instance of a new operator.
Note: This method is overwritten when implementing a particular linear problem.
-
createRightHandSide()¶ Returns an instance of a new right hand side.
-
createSolution()¶ Returns an instance of a new solution.
-
getCoefficient(name)¶ Returns the value of the coefficient
name.Parameters: name ( string) – name of the coefficient requestedReturns: the value of the coefficient Return type: DataRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getCurrentOperator()¶ Returns the operator in its current state.
-
getCurrentRightHandSide()¶ Returns the right hand side in its current state.
-
getCurrentSolution()¶ Returns the solution in its current state.
-
getDim()¶ Returns the spatial dimension of the PDE.
Returns: the spatial dimension of the PDE domain Return type: int
-
getDomainStatus()¶ Return the status indicator of the domain
-
getFunctionSpaceForCoefficient(name)¶ Returns the
FunctionSpaceto be used for coefficientname.Parameters: name ( string) – name of the coefficient enquiredReturns: the function space to be used for coefficient nameReturn type: FunctionSpaceRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getFunctionSpaceForEquation()¶ Returns the
FunctionSpaceused to discretize the equation.Returns: representation space of equation Return type: FunctionSpace
-
getFunctionSpaceForSolution()¶ Returns the
FunctionSpaceused to represent the solution.Returns: representation space of solution Return type: FunctionSpace
-
getNumEquations()¶ Returns the number of equations.
Returns: the number of equations Return type: intRaises: UndefinedPDEError – if the number of equations is not specified yet
-
getNumSolutions()¶ Returns the number of unknowns.
Returns: the number of unknowns Return type: intRaises: UndefinedPDEError – if the number of unknowns is not specified yet
-
getOperator()¶ Returns the operator of the linear problem.
Returns: the operator of the problem
-
getOperatorType()¶ Returns the current system type.
-
getRequiredOperatorType()¶ Returns the system type which needs to be used by the current set up.
Note: Typically this method is overwritten when implementing a particular linear problem.
-
getRightHandSide()¶ Returns the right hand side of the linear problem.
Returns: the right hand side of the problem Return type: Data
-
getShapeOfCoefficient(name)¶ Returns the shape of the coefficient
name.Parameters: name ( string) – name of the coefficient enquiredReturns: the shape of the coefficient nameReturn type: tupleofintRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getSolution(**options)¶ Returns the solution of the problem.
Returns: the solution Return type: DataNote: This method is overwritten when implementing a particular linear problem.
-
getSolverOptions()¶ Returns the solver options
Return type: SolverOptions
-
getSystem()¶ Returns the operator and right hand side of the PDE.
Returns: the discrete version of the PDE Return type: tupleofOperatorandData.Note: This method is overwritten when implementing a particular linear problem.
-
getSystemStatus()¶ Return the domain status used to build the current system
-
hasCoefficient(name)¶ Returns True if
nameis the name of a coefficient.Parameters: name ( string) – name of the coefficient enquiredReturns: True if nameis the name of a coefficient of the general PDE, False otherwiseReturn type: bool
-
initializeSystem()¶ Resets the system clearing the operator, right hand side and solution.
-
introduceCoefficients(**coeff)¶ Introduces new coefficients into the problem.
Use:
p.introduceCoefficients(A=PDECoef(…), B=PDECoef(…))
to introduce the coefficients A and B.
-
invalidateOperator()¶ Indicates the operator has to be rebuilt next time it is used.
-
invalidateRightHandSide()¶ Indicates the right hand side has to be rebuilt next time it is used.
-
invalidateSolution()¶ Indicates the PDE has to be resolved if the solution is requested.
-
invalidateSystem()¶ Announces that everything has to be rebuilt.
-
isComplex()¶ Returns true if this is a complex-valued LinearProblem, false if real-valued.
Return type: bool
-
isHermitian()¶ Checks if the pde is indicated to be Hermitian.
Returns: True if a Hermitian PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isHermitian()
-
isOperatorValid()¶ Returns True if the operator is still valid.
-
isRightHandSideValid()¶ Returns True if the operator is still valid.
-
isSolutionValid()¶ Returns True if the solution is still valid.
-
isSymmetric()¶ Checks if symmetry is indicated.
Returns: True if a symmetric PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isSymmetric()
-
isSystemValid()¶ Returns True if the system (including solution) is still vaild.
-
isUsingLumping()¶ Checks if matrix lumping is the current solver method.
Returns: True if the current solver method is lumping Return type: bool
-
preservePreconditioner(preserve=True)¶ Notifies the PDE that the preconditioner should not be reset when making changes to the operator.
Building the preconditioner data can be quite expensive (e.g. for multigrid methods) so if it is known that changes to the operator are going to be minor calling this method can speed up successive PDE solves.
Note: Not all operator types support this. Parameters: preserve ( bool) – if True, preconditioner will be preserved, otherwise it will be reset when making changes to the operator, which is the default behaviour.
-
reduceEquationOrder()¶ 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
-
reduceSolutionOrder()¶ 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
-
resetAllCoefficients()¶ Resets all coefficients to their default values.
-
resetOperator()¶ Makes sure that the operator is instantiated and returns it initialized with zeros.
-
resetRightHandSide()¶ Sets the right hand side to zero.
-
resetRightHandSideCoefficients()¶ Resets all coefficients defining the right hand side
-
resetSolution()¶ Sets the solution to zero.
-
setDebug(flag)¶ Switches debug output on if
flagis True otherwise it is switched off.Parameters: flag ( bool) – desired debug status
-
setDebugOff()¶ Switches debug output off.
-
setDebugOn()¶ Switches debug output on.
-
setHermitian(flag=False)¶ Sets the Hermitian flag to
flag.Parameters: flag ( bool) – If True, the Hermitian flag is set otherwise reset.Note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOff()¶ Clears the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOn()¶ Sets the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setReducedOrderForEquationOff()¶ Switches reduced order off for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationOn()¶ Switches reduced order on for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionOff()¶ Switches reduced order off for solution representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set.
-
setReducedOrderForSolutionOn()¶ Switches reduced order on for solution representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOff()¶ Switches reduced order off for solution and equation representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOn()¶ Switches reduced order on for solution and equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setSolution(u, validate=True)¶ Sets the solution assuming that makes the system valid with the tolrance defined by the solver options
-
setSolverOptions(options=None)¶ Sets the solver options.
Parameters: options ( SolverOptionsorNone) – the new solver options. If equalNone, the solver options are set to the default.Note: The symmetry flag of options is overwritten by the symmetry flag of the LinearProblem.
-
setSymmetry(flag=False)¶ 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
-
setSymmetryOff()¶ Clears the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSymmetryOn()¶ Sets the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSystemStatus(status=None)¶ Sets the system status to
statusifstatusis not present the current status of the domain is used.
-
setValue(**coefficients)¶ Sets new values to coefficients.
Raises: IllegalCoefficient – if an unknown coefficient keyword is used
-
shouldPreservePreconditioner()¶ Returns true if the preconditioner / factorisation should be kept even when resetting the operator.
Return type: bool
-
trace(text)¶ Prints the text message if debug mode is switched on.
Parameters: text ( string) – message to be printed
-
validOperator()¶ Marks the operator as valid.
-
validRightHandSide()¶ Marks the right hand side as valid.
-
validSolution()¶ Marks the solution as valid.
-
-
class
esys.escript.linearPDEs.Operator¶ Bases:
Boost.Python.instance-
__init__((object)arg1) → None¶
-
isEmpty((Operator)arg1) → bool :¶ Return type: boolReturns: True if matrix is empty
-
nullifyRowsAndCols((Operator)arg1, (Data)arg2, (Data)arg3, (float)arg4) → None¶
-
of((Operator)arg1, (Data)right) → Data :¶ matrix*vector multiplication
-
resetValues((Operator)arg1, (bool)arg2) → None :¶ resets the matrix entries
-
saveHB((Operator)arg1, (str)filename) → None :¶ writes the matrix to a file using the Harwell-Boeing file format
-
saveMM((Operator)arg1, (str)fileName) → None :¶ writes the matrix to a file using the Matrix Market file format
-
-
class
esys.escript.linearPDEs.PDECoef(where, pattern, altering, isComplex=False)¶ Bases:
objectA class for describing a PDE coefficient.
Variables: - INTERIOR – indicator that coefficient is defined on the interior of the PDE domain
- BOUNDARY – indicator that coefficient is defined on the boundary of the PDE domain
- CONTACT – indicator that coefficient is defined on the contact region within the PDE domain
- INTERIOR_REDUCED – indicator that coefficient is defined on the interior of the PDE domain using a reduced integration order
- BOUNDARY_REDUCED – indicator that coefficient is defined on the boundary of the PDE domain using a reduced integration order
- CONTACT_REDUCED – indicator that coefficient is defined on the contact region within the PDE domain using a reduced integration order
- SOLUTION – indicator that coefficient is defined through a solution of the PDE
- REDUCED – indicator that coefficient is defined through a reduced solution of the PDE
- DIRACDELTA – indicator that coefficient is defined as Dirac delta functions
- BY_EQUATION – indicator that the dimension of the coefficient shape is defined by the number of PDE equations
- BY_SOLUTION – indicator that the dimension of the coefficient shape is defined by the number of PDE solutions
- BY_DIM – indicator that the dimension of the coefficient shape is defined by the spatial dimension
- OPERATOR – indicator that the coefficient alters the operator of the PDE
- RIGHTHANDSIDE – indicator that the coefficient alters the right hand side of the PDE
- BOTH – indicator that the coefficient alters the operator as well as the right hand side of the PDE
-
__init__(where, pattern, altering, isComplex=False)¶ Initialises a PDE coefficient type.
Parameters: - where (one of
INTERIOR,BOUNDARY,CONTACT,SOLUTION,REDUCED,INTERIOR_REDUCED,BOUNDARY_REDUCED,CONTACT_REDUCED, ‘DIRACDELTA’) – describes where the coefficient lives - pattern (
tupleofBY_EQUATION,BY_SOLUTION,BY_DIM) – describes the shape of the coefficient and how the shape is built for a given spatial dimension and numbers of equations and solutions in then PDE. For instance, (BY_EQUATION,`BY_SOLUTION`,`BY_DIM`) describes a rank 3 coefficient which is instantiated as shape (3,2,2) in case of three equations and two solution components on a 2-dimensional domain. In the case of single equation and a single solution component the shape components marked byBY_EQUATIONorBY_SOLUTIONare dropped. In this case the example would be read as (2,). - altering (one of
OPERATOR,RIGHTHANDSIDE,BOTH) – indicates what part of the PDE is altered if the coefficient is altered - isComplex (
boolean) – if true, this coefficient is part of a complex-valued PDE and values will be converted to complex.
- where (one of
-
BOTH= 12¶
-
BOUNDARY= 1¶
-
BOUNDARY_REDUCED= 14¶
-
BY_DIM= 7¶
-
BY_EQUATION= 5¶
-
BY_SOLUTION= 6¶
-
CONTACT= 2¶
-
CONTACT_REDUCED= 15¶
-
DIRACDELTA= 16¶
-
INTERIOR= 0¶
-
INTERIOR_REDUCED= 13¶
-
OPERATOR= 10¶
-
REDUCED= 4¶
-
RIGHTHANDSIDE= 11¶
-
SOLUTION= 3¶
-
definesNumEquation()¶ Checks if the coefficient allows to estimate the number of equations.
Returns: True if the coefficient allows an estimate of the number of equations, False otherwise Return type: bool
-
definesNumSolutions()¶ Checks if the coefficient allows to estimate the number of solution components.
Returns: True if the coefficient allows an estimate of the number of solution components, False otherwise Return type: bool
-
estimateNumEquationsAndNumSolutions(domain, shape=())¶ Tries to estimate the number of equations and number of solutions if the coefficient has the given shape.
Parameters: - domain (
Domain) – domain on which the PDE uses the coefficient - shape (
tupleofintvalues) – suggested shape of the coefficient
Returns: the number of equations and number of solutions of the PDE if the coefficient has given shape. If no appropriate numbers could be identified,
Noneis returnedReturn type: tupleof twointvalues orNone- domain (
-
getFunctionSpace(domain, reducedEquationOrder=False, reducedSolutionOrder=False)¶ Returns the
FunctionSpaceof the coefficient.Parameters: - domain (
Domain) – domain on which the PDE uses the coefficient - reducedEquationOrder (
bool) – True to indicate that reduced order is used to represent the equation - reducedSolutionOrder (
bool) – True to indicate that reduced order is used to represent the solution
Returns: FunctionSpaceof the coefficientReturn type: - domain (
-
getShape(domain, numEquations=1, numSolutions=1)¶ Builds the required shape of the coefficient.
Parameters: - domain (
Domain) – domain on which the PDE uses the coefficient - numEquations (
int) – number of equations of the PDE - numSolutions (
int) – number of components of the PDE solution
Returns: shape of the coefficient
Return type: tupleofintvalues- domain (
-
isAlteringOperator()¶ Checks if the coefficient alters the operator of the PDE.
Returns: True if the operator of the PDE is changed when the coefficient is changed Return type: bool
-
isAlteringRightHandSide()¶ Checks if the coefficient alters the right hand side of the PDE.
Return type: boolReturns: True if the right hand side of the PDE is changed when the coefficient is changed, Noneotherwise.
-
isComplex()¶ Checks if the coefficient is complex-valued.
Return type: boolReturns: True if the coefficient is complex-valued, False otherwise.
-
resetValue()¶ Resets the coefficient value to the default.
-
setValue(domain, numEquations=1, numSolutions=1, reducedEquationOrder=False, reducedSolutionOrder=False, newValue=None)¶ Sets the value of the coefficient to a new value.
Parameters: - domain (
Domain) – domain on which the PDE uses the coefficient - numEquations (
int) – number of equations of the PDE - numSolutions (
int) – number of components of the PDE solution - reducedEquationOrder (
bool) – True to indicate that reduced order is used to represent the equation - reducedSolutionOrder (
bool) – True to indicate that reduced order is used to represent the solution - newValue (any object that can be converted into a
Dataobject with the appropriate shape andFunctionSpace) – new value of coefficient
Raises: - IllegalCoefficientValue – if the shape of the assigned value does not match the shape of the coefficient
- IllegalCoefficientFunctionSpace – if unable to interpolate value to appropriate function space
- domain (
-
class
esys.escript.linearPDEs.Poisson(domain, debug=False)¶ Bases:
esys.escriptcore.linearPDEs.LinearPDEClass to define a Poisson equation problem. This is generally a
LinearPDEof the form-grad(grad(u)[j])[j] = f
with natural boundary conditions
n[j]*grad(u)[j] = 0
and constraints:
u=0 where q>0
-
__init__(domain, debug=False)¶ Initializes a new Poisson equation.
Parameters: - domain (
Domain) – domain of the PDE - debug – if True debug information is printed
- domain (
-
addPDEToLumpedSystem(operator, a, b, c, hrz_lumping)¶ adds a PDE to the lumped system, results depend on domain
Parameters:
-
addPDEToRHS(righthandside, X, Y, y, y_contact, y_dirac)¶ adds a PDE to the right hand side, results depend on domain
Parameters:
-
addPDEToSystem(operator, righthandside, A, B, C, D, X, Y, d, y, d_contact, y_contact, d_dirac, y_dirac)¶ adds a PDE to the system, results depend on domain
Parameters:
-
addToRHS(rhs, data)¶ adds a PDE to the right hand side, results depend on domain
Parameters: - mat (
OperatorAdapter) – - righthandside (
Data) – - data (
list) –
- mat (
-
addToSystem(op, rhs, data)¶ adds a PDE to the system, results depend on domain
Parameters: - mat (
OperatorAdapter) – - rhs (
Data) – - data (
list) –
- mat (
-
alteredCoefficient(name)¶ Announces that coefficient
namehas been changed.Parameters: name ( string) – name of the coefficient affectedRaises: IllegalCoefficient – if nameis not a coefficient of the PDENote: if nameis q or r, the method will not trigger a rebuild of the system as constraints are applied to the solved system.
-
checkReciprocalSymmetry(name0, name1, verbose=True)¶ Tests two coefficients for reciprocal symmetry.
Parameters: - name0 (
str) – name of the first coefficient - name1 (
str) – name of the second coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed
Returns: True if coefficients
name0andname1are reciprocally symmetric.Return type: bool- name0 (
-
checkSymmetricTensor(name, verbose=True)¶ Tests a coefficient for symmetry.
Parameters: - name (
str) – name of the coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed.
Returns: True if coefficient
nameis symmetricReturn type: bool- name (
-
checkSymmetry(verbose=True)¶ 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: boolNote: This is a very expensive operation. It should be used for degugging only! The symmetry flag is not altered.
-
createCoefficient(name)¶ Creates a
Dataobject corresponding to coefficientname.Returns: the coefficient nameinitialized to 0Return type: DataRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
createOperator()¶ Returns an instance of a new operator.
-
createRightHandSide()¶ Returns an instance of a new right hand side.
-
createSolution()¶ Returns an instance of a new solution.
-
getCoefficient(name)¶ Returns the value of the coefficient
nameof the general PDE.Parameters: name ( string) – name of the coefficient requestedReturns: the value of the coefficient nameReturn type: DataRaises: IllegalCoefficient – invalid coefficient name Note: This method is called by the assembling routine to map the Poisson equation onto the general PDE.
-
getCurrentOperator()¶ Returns the operator in its current state.
-
getCurrentRightHandSide()¶ Returns the right hand side in its current state.
-
getCurrentSolution()¶ Returns the solution in its current state.
-
getDim()¶ Returns the spatial dimension of the PDE.
Returns: the spatial dimension of the PDE domain Return type: int
-
getDomainStatus()¶ Return the status indicator of the domain
-
getFlux(u=None)¶ 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 ( Dataor None) – argument in the flux. If u is not present or equalsNonethe current solution is used.Returns: flux Return type: Data
-
getFunctionSpaceForCoefficient(name)¶ Returns the
FunctionSpaceto be used for coefficientname.Parameters: name ( string) – name of the coefficient enquiredReturns: the function space to be used for coefficient nameReturn type: FunctionSpaceRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getFunctionSpaceForEquation()¶ Returns the
FunctionSpaceused to discretize the equation.Returns: representation space of equation Return type: FunctionSpace
-
getFunctionSpaceForSolution()¶ Returns the
FunctionSpaceused to represent the solution.Returns: representation space of solution Return type: FunctionSpace
-
getNumEquations()¶ Returns the number of equations.
Returns: the number of equations Return type: intRaises: UndefinedPDEError – if the number of equations is not specified yet
-
getNumSolutions()¶ Returns the number of unknowns.
Returns: the number of unknowns Return type: intRaises: UndefinedPDEError – if the number of unknowns is not specified yet
-
getOperator()¶ Returns the operator of the linear problem.
Returns: the operator of the problem
-
getOperatorType()¶ Returns the current system type.
-
getRequiredOperatorType()¶ Returns the system type which needs to be used by the current set up.
-
getResidual(u=None)¶ Returns the residual of u or the current solution if u is not present.
Parameters: u ( Dataor None) – argument in the residual calculation. It must be representable inself.getFunctionSpaceForSolution(). If u is not present or equalsNonethe current solution is used.Returns: residual of u Return type: Data
-
getRightHandSide()¶ Returns the right hand side of the linear problem.
Returns: the right hand side of the problem Return type: Data
-
getShapeOfCoefficient(name)¶ Returns the shape of the coefficient
name.Parameters: name ( string) – name of the coefficient enquiredReturns: the shape of the coefficient nameReturn type: tupleofintRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getSolverOptions()¶ Returns the solver options
Return type: SolverOptions
-
getSystem()¶ Returns the operator and right hand side of the PDE.
Returns: the discrete version of the PDE Return type: tupleofOperatorandData
-
getSystemStatus()¶ Return the domain status used to build the current system
-
hasCoefficient(name)¶ Returns True if
nameis the name of a coefficient.Parameters: name ( string) – name of the coefficient enquiredReturns: True if nameis the name of a coefficient of the general PDE, False otherwiseReturn type: bool
-
initializeSystem()¶ Resets the system clearing the operator, right hand side and solution.
-
insertConstraint(rhs_only=False)¶ 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
-
introduceCoefficients(**coeff)¶ Introduces new coefficients into the problem.
Use:
p.introduceCoefficients(A=PDECoef(…), B=PDECoef(…))
to introduce the coefficients A and B.
-
invalidateOperator()¶ Indicates the operator has to be rebuilt next time it is used.
-
invalidateRightHandSide()¶ Indicates the right hand side has to be rebuilt next time it is used.
-
invalidateSolution()¶ Indicates the PDE has to be resolved if the solution is requested.
-
invalidateSystem()¶ Announces that everything has to be rebuilt.
-
isComplex()¶ Returns true if this is a complex-valued LinearProblem, false if real-valued.
Return type: bool
-
isHermitian()¶ Checks if the pde is indicated to be Hermitian.
Returns: True if a Hermitian PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isHermitian()
-
isOperatorValid()¶ Returns True if the operator is still valid.
-
isRightHandSideValid()¶ Returns True if the operator is still valid.
-
isSolutionValid()¶ Returns True if the solution is still valid.
-
isSymmetric()¶ Checks if symmetry is indicated.
Returns: True if a symmetric PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isSymmetric()
-
isSystemValid()¶ Returns True if the system (including solution) is still vaild.
-
isUsingLumping()¶ Checks if matrix lumping is the current solver method.
Returns: True if the current solver method is lumping Return type: bool
-
preservePreconditioner(preserve=True)¶ Notifies the PDE that the preconditioner should not be reset when making changes to the operator.
Building the preconditioner data can be quite expensive (e.g. for multigrid methods) so if it is known that changes to the operator are going to be minor calling this method can speed up successive PDE solves.
Note: Not all operator types support this. Parameters: preserve ( bool) – if True, preconditioner will be preserved, otherwise it will be reset when making changes to the operator, which is the default behaviour.
-
reduceEquationOrder()¶ 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
-
reduceSolutionOrder()¶ 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
-
resetAllCoefficients()¶ Resets all coefficients to their default values.
-
resetOperator()¶ Makes sure that the operator is instantiated and returns it initialized with zeros.
-
resetRightHandSide()¶ Sets the right hand side to zero.
-
resetRightHandSideCoefficients()¶ Resets all coefficients defining the right hand side
-
resetSolution()¶ Sets the solution to zero.
-
setDebug(flag)¶ Switches debug output on if
flagis True otherwise it is switched off.Parameters: flag ( bool) – desired debug status
-
setDebugOff()¶ Switches debug output off.
-
setDebugOn()¶ Switches debug output on.
-
setHermitian(flag=False)¶ Sets the Hermitian flag to
flag.Parameters: flag ( bool) – If True, the Hermitian flag is set otherwise reset.Note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOff()¶ Clears the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOn()¶ Sets the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setReducedOrderForEquationOff()¶ Switches reduced order off for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationOn()¶ Switches reduced order on for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionOff()¶ Switches reduced order off for solution representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set.
-
setReducedOrderForSolutionOn()¶ Switches reduced order on for solution representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOff()¶ Switches reduced order off for solution and equation representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOn()¶ Switches reduced order on for solution and equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setSolution(u, validate=True)¶ Sets the solution assuming that makes the system valid with the tolrance defined by the solver options
-
setSolverOptions(options=None)¶ Sets the solver options.
Parameters: options ( SolverOptionsorNone) – the new solver options. If equalNone, the solver options are set to the default.Note: The symmetry flag of options is overwritten by the symmetry flag of the LinearProblem.
-
setSymmetry(flag=False)¶ 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
-
setSymmetryOff()¶ Clears the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSymmetryOn()¶ Sets the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSystemStatus(status=None)¶ Sets the system status to
statusifstatusis not present the current status of the domain is used.
-
setValue(**coefficients)¶ Sets new values to coefficients.
Parameters: - coefficients – new values assigned to coefficients
- f (any type that can be cast to a
Scalarobject onFunction) – value for right hand side f - q (any type that can be cast to a rank zero
Dataobject onSolutionorReducedSolutiondepending on whether reduced order is used for the representation of the equation) – mask for location of constraints
Raises: IllegalCoefficient – if an unknown coefficient keyword is used
-
shouldPreservePreconditioner()¶ Returns true if the preconditioner / factorisation should be kept even when resetting the operator.
Return type: bool
-
trace(text)¶ Prints the text message if debug mode is switched on.
Parameters: text ( string) – message to be printed
-
validOperator()¶ Marks the operator as valid.
-
validRightHandSide()¶ Marks the right hand side as valid.
-
validSolution()¶ Marks the solution as valid.
-
-
class
esys.escript.linearPDEs.Reducer¶ Bases:
Boost.Python.instance-
__init__()¶ Raises an exception This class cannot be instantiated from Python
-
-
class
esys.escript.linearPDEs.SolverBuddy¶ Bases:
Boost.Python.instance-
__init__((object)arg1) → None¶
-
acceptConvergenceFailure((SolverBuddy)arg1) → bool :¶ Returns
Trueif a failure to meet the stopping criteria within the given number of iteration steps is not raising in exception. This is useful if a solver is used in a non-linear context where the non-linear solver can continue even if the returned the solution does not necessarily meet the stopping criteria. One can use thehasConvergedmethod to check if the last call to the solver was successful.Returns: Trueif a failure to achieve convergence is accepted.Return type: bool
-
adaptInnerTolerance((SolverBuddy)arg1) → bool :¶ Returns
Trueif the tolerance of the inner solver is selected automatically. Otherwise the inner tolerance set bysetInnerToleranceis used.Returns: Trueif inner tolerance adaption is chosen.Return type: bool
-
getAbsoluteTolerance((SolverBuddy)arg1) → float :¶ Returns the absolute tolerance for the solver
Return type: float
-
getDiagnostics((SolverBuddy)arg1, (str)name) → float :¶ Returns the diagnostic information
name. Possible values are:- ‘num_iter’: the number of iteration steps
- ‘cum_num_iter’: the cumulative number of iteration steps
- ‘num_level’: the number of level in multi level solver
- ‘num_inner_iter’: the number of inner iteration steps
- ‘cum_num_inner_iter’: the cumulative number of inner iteration steps
- ‘time’: execution time
- ‘cum_time’: cumulative execution time
- ‘set_up_time’: time to set up of the solver, typically this includes factorization and reordering
- ‘cum_set_up_time’: cumulative time to set up of the solver
- ‘net_time’: net execution time, excluding setup time for the solver and execution time for preconditioner
- ‘cum_net_time’: cumulative net execution time
- ‘preconditioner_size’: size of preconditioner [Bytes]
- ‘converged’: return True if solution has converged.
- ‘time_step_backtracking_used’: returns True if time step back tracking has been used.
- ‘coarse_level_sparsity’: returns the sparsity of the matrix on the coarsest level
- ‘num_coarse_unknowns’: returns the number of unknowns on the coarsest level
Parameters: name ( strin the list above.) – name of diagnostic information to returnReturns: requested value. 0 is returned if the value is yet to be defined. Note: If the solver has thrown an exception diagnostic values have an undefined status.
-
getDim((SolverBuddy)arg1) → int :¶ Returns the dimension of the problem.
Return type: int
-
getDropStorage((SolverBuddy)arg1) → float :¶ Returns the maximum allowed increase in storage for ILUT
Return type: float
-
getDropTolerance((SolverBuddy)arg1) → float :¶ Returns the relative drop tolerance in ILUT
Return type: float
-
getInnerIterMax((SolverBuddy)arg1) → int :¶ Returns maximum number of inner iteration steps
Return type: int
-
getInnerTolerance((SolverBuddy)arg1) → float :¶ Returns the relative tolerance for an inner iteration scheme
Return type: float
-
getIterMax((SolverBuddy)arg1) → int :¶ Returns maximum number of iteration steps
Return type: int
-
getName((SolverBuddy)arg1, (int)key) → str :¶ Returns the name of a given key
Parameters: key – a valid key
-
getNumRefinements((SolverBuddy)arg1) → int :¶ Returns the number of refinement steps to refine the solution when a direct solver is applied.
Return type: non-negative int
-
getNumSweeps((SolverBuddy)arg1) → int :¶ Returns the number of sweeps in a Jacobi or Gauss-Seidel/SOR preconditioner.
Return type: int
-
getODESolver((SolverBuddy)arg1) → SolverOptions :¶ Returns key of the solver method for ODEs.
Parameters: method (in CRANK_NICOLSON,BACKWARD_EULER,LINEAR_CRANK_NICOLSON) – key of the ODE solver method to be used.
-
getPackage((SolverBuddy)arg1) → SolverOptions :¶ Returns the solver package key
Return type: in the list DEFAULT,PASO,CUSP,MKL,UMFPACK,MUMPS,TRILINOS
-
getPreconditioner((SolverBuddy)arg1) → SolverOptions :¶ Returns the key of the preconditioner to be used.
Return type: in the list ILU0,ILUT,JACOBI,AMG,REC_ILU,GAUSS_SEIDEL,RILU,NO_PRECONDITIONER
-
getRelaxationFactor((SolverBuddy)arg1) → float :¶ Returns the relaxation factor used to add dropped elements in RILU to the main diagonal.
Return type: float
-
getReordering((SolverBuddy)arg1) → SolverOptions :¶ Returns the key of the reordering method to be applied if supported by the solver.
Return type: in NO_REORDERING,MINIMUM_FILL_IN,NESTED_DISSECTION,DEFAULT_REORDERING
-
getRestart((SolverBuddy)arg1) → int :¶ Returns the number of iterations steps after which GMRES performs a restart. If 0 is returned no restart is performed.
Return type: int
-
getSolverMethod((SolverBuddy)arg1) → SolverOptions :¶ Returns key of the solver method to be used.
Return type: in the list DEFAULT,DIRECT,CHOLEVSKY,PCG,CR,CGS,BICGSTAB,GMRES,PRES20,ROWSUM_LUMPING,HRZ_LUMPING,MINRES,ITERATIVE,NONLINEAR_GMRES,TFQMR
-
getSummary((SolverBuddy)arg1) → str :¶ Returns a string reporting the current settings
-
getTolerance((SolverBuddy)arg1) → float :¶ Returns the relative tolerance for the solver
Return type: float
-
getTrilinosParameters((SolverBuddy)arg1) → dict :¶ Returns a dictionary of set Trilinos parameters.
:note This method returns an empty dictionary in a non-Trilinos build.
-
getTruncation((SolverBuddy)arg1) → int :¶ Returns the number of residuals in GMRES to be stored for orthogonalization
Return type: int
-
hasConverged((SolverBuddy)arg1) → bool :¶ Returns
Trueif the last solver call has been finalized successfully.Note: if an exception has been thrown by the solver the status of thisflag is undefined.
-
isComplex((SolverBuddy)arg1) → bool :¶ Checks if the coefficient matrix is set to be complex-valued.
Returns: True if a complex-valued PDE is indicated, False otherwise Return type: bool
-
isHermitian((SolverBuddy)arg1) → bool :¶ Checks if the coefficient matrix is indicated to be Hermitian.
Returns: True if a hermitian PDE is indicated, False otherwise Return type: bool
-
isSymmetric((SolverBuddy)arg1) → bool :¶ Checks if symmetry of the coefficient matrix is indicated.
Returns: True if a symmetric PDE is indicated, False otherwise Return type: bool
-
isVerbose((SolverBuddy)arg1) → bool :¶ Returns
Trueif the solver is expected to be verbose.Returns: True if verbosity of switched on. Return type: bool
-
resetDiagnostics((SolverBuddy)arg1[, (bool)all=False]) → None :¶ Resets the diagnostics
Parameters: all ( bool) – ifallisTrueall diagnostics including accumulative counters are reset.
-
setAbsoluteTolerance((SolverBuddy)arg1, (float)atol) → None :¶ Sets the absolute tolerance for the solver
Parameters: atol (non-negative float) – absolute tolerance
-
setAcceptanceConvergenceFailure((SolverBuddy)arg1, (bool)accept) → None :¶ Sets the flag to indicate the acceptance of a failure of convergence.
Parameters: accept ( bool) – IfTrue, any failure to achieve convergence is accepted.
-
setAcceptanceConvergenceFailureOff((SolverBuddy)arg1) → None :¶ Switches the acceptance of a failure of convergence off.
-
setAcceptanceConvergenceFailureOn((SolverBuddy)arg1) → None :¶ Switches the acceptance of a failure of convergence on
-
setComplex((SolverBuddy)arg1, (bool)complex) → None :¶ Sets the complex flag for the coefficient matrix to
flag.Parameters: flag ( bool) – If True, the complex flag is set otherwise reset.
-
setDim((SolverBuddy)arg1, (int)dim) → None :¶ Sets the dimension of the problem.
Parameters: dim – Either 2 or 3. Return type: int
-
setDropStorage((SolverBuddy)arg1, (float)drop) → None :¶ Sets the maximum allowed increase in storage for ILUT.
storage=2 would mean that a doubling of the storage needed for the coefficient matrix is allowed in the ILUT factorization.Parameters: storage ( float) – allowed storage increase
-
setDropTolerance((SolverBuddy)arg1, (float)drop_tol) → None :¶ Sets the relative drop tolerance in ILUT
Parameters: drop_tol (positive float) – drop tolerance
-
setHermitian((SolverBuddy)arg1, (bool)hermitian) → None :¶ Sets the hermitian flag for the coefficient matrix to
flag.Parameters: flag ( bool) – If True, the hermitian flag is set otherwise reset.
-
setHermitianOff((SolverBuddy)arg1) → None :¶ Clears the hermitian flag for the coefficient matrix.
-
setHermitianOn((SolverBuddy)arg1) → None :¶ Sets the hermitian flag to indicate that the coefficient matrix is hermitian.
-
setInnerIterMax((SolverBuddy)arg1, (int)iter_max) → None :¶ Sets the maximum number of iteration steps for the inner iteration.
Parameters: iter_max ( int) – maximum number of inner iterations
-
setInnerTolerance((SolverBuddy)arg1, (float)rtol) → None :¶ Sets the relative tolerance for an inner iteration scheme, for instance on the coarsest level in a multi-level scheme.
Parameters: rtol (positive float) – inner relative tolerance
-
setInnerToleranceAdaption((SolverBuddy)arg1, (bool)adapt) → None :¶ Sets the flag to indicate automatic selection of the inner tolerance.
Parameters: adapt ( bool) – IfTrue, the inner tolerance is selected automatically.
-
setInnerToleranceAdaptionOff((SolverBuddy)arg1) → None :¶ Switches the automatic selection of inner tolerance off.
-
setInnerToleranceAdaptionOn((SolverBuddy)arg1) → None :¶ Switches the automatic selection of inner tolerance on
-
setIterMax((SolverBuddy)arg1, (int)iter_max) → None :¶ Sets the maximum number of iteration steps
Parameters: iter_max ( int) – maximum number of iteration steps
-
setLocalPreconditioner((SolverBuddy)arg1, (bool)local) → None :¶ Sets the flag to use local preconditioning
Parameters: use ( bool) – IfTrue, local preconditioning on each MPI rank is applied
-
setLocalPreconditionerOff((SolverBuddy)arg1) → None :¶ Sets the flag to use local preconditioning to off
-
setLocalPreconditionerOn((SolverBuddy)arg1) → None :¶ Sets the flag to use local preconditioning to on
-
setNumRefinements((SolverBuddy)arg1, (int)refinements) → None :¶ Sets the number of refinement steps to refine the solution when a direct solver is applied.
Parameters: refinements (non-negative int) – number of refinements
-
setNumSweeps((SolverBuddy)arg1, (int)sweeps) → None :¶ Sets the number of sweeps in a Jacobi or Gauss-Seidel/SOR preconditioner.
Parameters: sweeps (positive int) – number of sweeps
-
setODESolver((SolverBuddy)arg1, (int)solver) → None :¶ Set the solver method for ODEs.
Parameters: method (in CRANK_NICOLSON,BACKWARD_EULER,LINEAR_CRANK_NICOLSON) – key of the ODE solver method to be used.
-
setPackage((SolverBuddy)arg1, (int)package) → None :¶ Sets the solver package to be used as a solver.
Parameters: package (in DEFAULT,PASO,CUSP,MKL,UMFPACK,MUMPS,TRILINOS) – key of the solver package to be used.Note: Not all packages are support on all implementation. An exception may be thrown on some platforms if a particular package is requested.
-
setPreconditioner((SolverBuddy)arg1, (int)preconditioner) → None :¶ Sets the preconditioner to be used.
Parameters: preconditioner (in ILU0,ILUT,JACOBI,AMG, ,REC_ILU,GAUSS_SEIDEL,RILU,NO_PRECONDITIONER) – key of the preconditioner to be used.Note: Not all packages support all preconditioner. It can be assumed that a package makes a reasonable choice if it encounters an unknownpreconditioner.
-
setRelaxationFactor((SolverBuddy)arg1, (float)relaxation) → None :¶ Sets the relaxation factor used to add dropped elements in RILU to the main diagonal.
Parameters: factor ( float) – relaxation factorNote: RILU with a relaxation factor 0 is identical to ILU0
-
setReordering((SolverBuddy)arg1, (int)ordering) → None :¶ Sets the key of the reordering method to be applied if supported by the solver. Some direct solvers support reordering to optimize compute time and storage use during elimination.
Parameters: ordering (in 'NO_REORDERING', 'MINIMUM_FILL_IN', 'NESTED_DISSECTION', 'DEFAULT_REORDERING') – selects the reordering strategy.
-
setRestart((SolverBuddy)arg1, (int)restart) → None :¶ Sets the number of iterations steps after which GMRES performs a restart.
Parameters: restart ( int) – number of iteration steps after which to perform a restart. If 0 no restart is performed.
-
setSolverMethod((SolverBuddy)arg1, (int)method) → None :¶ Sets the solver method to be used. Use
method``=``DIRECTto indicate that a direct rather than an iterative solver should be used and usemethod``=``ITERATIVEto indicate that an iterative rather than a direct solver should be used.Parameters: method (in DEFAULT,DIRECT,CHOLEVSKY,PCG,CR,CGS,BICGSTAB,GMRES,PRES20,ROWSUM_LUMPING,HRZ_LUMPING,ITERATIVE,NONLINEAR_GMRES,TFQMR,MINRES) – key of the solver method to be used.Note: Not all packages support all solvers. It can be assumed that a package makes a reasonable choice if it encounters an unknown solver method.
-
setSymmetry((SolverBuddy)arg1, (bool)symmetry) → None :¶ Sets the symmetry flag for the coefficient matrix to
flag.Parameters: flag ( bool) – If True, the symmetry flag is set otherwise reset.
-
setSymmetryOff((SolverBuddy)arg1) → None :¶ Clears the symmetry flag for the coefficient matrix.
-
setSymmetryOn((SolverBuddy)arg1) → None :¶ Sets the symmetry flag to indicate that the coefficient matrix is symmetric.
-
setTolerance((SolverBuddy)arg1, (float)rtol) → None :¶ Sets the relative tolerance for the solver
Parameters: rtol (non-negative float) – relative tolerance
-
setTrilinosParameter((SolverBuddy)arg1, (str)arg2, (object)arg3) → None :¶ Sets a Trilinos preconditioner/solver parameter.
:note Escript does not check for validity of the parameter name (e.g. spelling mistakes). Parameters are passed 1:1 to escript’s Trilinos wrapper and from there to the relevant Trilinos package. See the relevant Trilinos documentation for valid parameter strings and values.:note This method does nothing in a non-Trilinos build.
-
setTruncation((SolverBuddy)arg1, (int)truncation) → None :¶ Sets the number of residuals in GMRES to be stored for orthogonalization. The more residuals are stored the faster GMRES converged
Parameters: truncation ( int) – truncation
-
setVerbosity((SolverBuddy)arg1, (bool)verbosity) → None :¶ Sets the verbosity flag for the solver to
flag.Parameters: verbose ( bool) – IfTrue, the verbosity of the solver is switched on.
-
setVerbosityOff((SolverBuddy)arg1) → None :¶ Switches the verbosity of the solver off.
-
setVerbosityOn((SolverBuddy)arg1) → None :¶ Switches the verbosity of the solver on.
-
useLocalPreconditioner((SolverBuddy)arg1) → bool :¶ Returns
Trueif the preconditoner is applied locally on each MPI. This reduces communication costs and speeds up the application of the preconditioner but at the costs of more iteration steps. This can be an advantage on clusters with slower interconnects.Returns: Trueif local preconditioning is appliedReturn type: bool
-
-
class
esys.escript.linearPDEs.SolverOptions¶ Bases:
Boost.Python.enum-
__init__()¶ Initialize self. See help(type(self)) for accurate signature.
-
AMG= esys.escriptcore.escriptcpp.SolverOptions.AMG¶
-
BACKWARD_EULER= esys.escriptcore.escriptcpp.SolverOptions.BACKWARD_EULER¶
-
BICGSTAB= esys.escriptcore.escriptcpp.SolverOptions.BICGSTAB¶
-
CGLS= esys.escriptcore.escriptcpp.SolverOptions.CGLS¶
-
CGS= esys.escriptcore.escriptcpp.SolverOptions.CGS¶
-
CHOLEVSKY= esys.escriptcore.escriptcpp.SolverOptions.CHOLEVSKY¶
-
CLASSIC_INTERPOLATION= esys.escriptcore.escriptcpp.SolverOptions.CLASSIC_INTERPOLATION¶
-
CLASSIC_INTERPOLATION_WITH_FF_COUPLING= esys.escriptcore.escriptcpp.SolverOptions.CLASSIC_INTERPOLATION_WITH_FF_COUPLING¶
-
CR= esys.escriptcore.escriptcpp.SolverOptions.CR¶
-
CRANK_NICOLSON= esys.escriptcore.escriptcpp.SolverOptions.CRANK_NICOLSON¶
-
DEFAULT= esys.escriptcore.escriptcpp.SolverOptions.DEFAULT¶
-
DEFAULT_REORDERING= esys.escriptcore.escriptcpp.SolverOptions.DEFAULT_REORDERING¶
-
DIRECT= esys.escriptcore.escriptcpp.SolverOptions.DIRECT¶
-
DIRECT_INTERPOLATION= esys.escriptcore.escriptcpp.SolverOptions.DIRECT_INTERPOLATION¶
-
DIRECT_MUMPS= esys.escriptcore.escriptcpp.SolverOptions.DIRECT_MUMPS¶
-
DIRECT_PARDISO= esys.escriptcore.escriptcpp.SolverOptions.DIRECT_PARDISO¶
-
DIRECT_SUPERLU= esys.escriptcore.escriptcpp.SolverOptions.DIRECT_SUPERLU¶
-
DIRECT_TRILINOS= esys.escriptcore.escriptcpp.SolverOptions.DIRECT_TRILINOS¶
-
GAUSS_SEIDEL= esys.escriptcore.escriptcpp.SolverOptions.GAUSS_SEIDEL¶
-
GMRES= esys.escriptcore.escriptcpp.SolverOptions.GMRES¶
-
HRZ_LUMPING= esys.escriptcore.escriptcpp.SolverOptions.HRZ_LUMPING¶
-
ILU0= esys.escriptcore.escriptcpp.SolverOptions.ILU0¶
-
ILUT= esys.escriptcore.escriptcpp.SolverOptions.ILUT¶
-
ITERATIVE= esys.escriptcore.escriptcpp.SolverOptions.ITERATIVE¶
-
JACOBI= esys.escriptcore.escriptcpp.SolverOptions.JACOBI¶
-
LINEAR_CRANK_NICOLSON= esys.escriptcore.escriptcpp.SolverOptions.LINEAR_CRANK_NICOLSON¶
-
LSQR= esys.escriptcore.escriptcpp.SolverOptions.LSQR¶
-
LUMPING= esys.escriptcore.escriptcpp.SolverOptions.LUMPING¶
-
MINIMUM_FILL_IN= esys.escriptcore.escriptcpp.SolverOptions.MINIMUM_FILL_IN¶
-
MINRES= esys.escriptcore.escriptcpp.SolverOptions.MINRES¶
-
MKL= esys.escriptcore.escriptcpp.SolverOptions.MKL¶
-
MUMPS= esys.escriptcore.escriptcpp.SolverOptions.MUMPS¶
-
NESTED_DISSECTION= esys.escriptcore.escriptcpp.SolverOptions.NESTED_DISSECTION¶
-
NONLINEAR_GMRES= esys.escriptcore.escriptcpp.SolverOptions.NONLINEAR_GMRES¶
-
NO_PRECONDITIONER= esys.escriptcore.escriptcpp.SolverOptions.NO_PRECONDITIONER¶
-
NO_REORDERING= esys.escriptcore.escriptcpp.SolverOptions.NO_REORDERING¶
-
PASO= esys.escriptcore.escriptcpp.SolverOptions.PASO¶
-
PCG= esys.escriptcore.escriptcpp.SolverOptions.PCG¶
-
PRES20= esys.escriptcore.escriptcpp.SolverOptions.PRES20¶
-
REC_ILU= esys.escriptcore.escriptcpp.SolverOptions.REC_ILU¶
-
RILU= esys.escriptcore.escriptcpp.SolverOptions.RILU¶
-
ROWSUM_LUMPING= esys.escriptcore.escriptcpp.SolverOptions.ROWSUM_LUMPING¶
-
TFQMR= esys.escriptcore.escriptcpp.SolverOptions.TFQMR¶
-
TRILINOS= esys.escriptcore.escriptcpp.SolverOptions.TRILINOS¶
-
UMFPACK= esys.escriptcore.escriptcpp.SolverOptions.UMFPACK¶
-
bit_length()¶ Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
-
conjugate()¶ Returns self, the complex conjugate of any int.
-
denominator¶ the denominator of a rational number in lowest terms
-
from_bytes()¶ Return the integer represented by the given array of bytes.
- bytes
- Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
- byteorder
- The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value.
- signed
- Indicates whether two’s complement is used to represent the integer.
-
imag¶ the imaginary part of a complex number
-
name¶
-
names= {'AMG': esys.escriptcore.escriptcpp.SolverOptions.AMG, 'BACKWARD_EULER': esys.escriptcore.escriptcpp.SolverOptions.BACKWARD_EULER, 'BICGSTAB': esys.escriptcore.escriptcpp.SolverOptions.BICGSTAB, 'CGLS': esys.escriptcore.escriptcpp.SolverOptions.CGLS, 'CGS': esys.escriptcore.escriptcpp.SolverOptions.CGS, 'CHOLEVSKY': esys.escriptcore.escriptcpp.SolverOptions.CHOLEVSKY, 'CLASSIC_INTERPOLATION': esys.escriptcore.escriptcpp.SolverOptions.CLASSIC_INTERPOLATION, 'CLASSIC_INTERPOLATION_WITH_FF_COUPLING': esys.escriptcore.escriptcpp.SolverOptions.CLASSIC_INTERPOLATION_WITH_FF_COUPLING, 'CR': esys.escriptcore.escriptcpp.SolverOptions.CR, 'CRANK_NICOLSON': esys.escriptcore.escriptcpp.SolverOptions.CRANK_NICOLSON, 'DEFAULT': esys.escriptcore.escriptcpp.SolverOptions.DEFAULT, 'DEFAULT_REORDERING': esys.escriptcore.escriptcpp.SolverOptions.DEFAULT_REORDERING, 'DIRECT': esys.escriptcore.escriptcpp.SolverOptions.DIRECT, 'DIRECT_INTERPOLATION': esys.escriptcore.escriptcpp.SolverOptions.DIRECT_INTERPOLATION, 'DIRECT_MUMPS': esys.escriptcore.escriptcpp.SolverOptions.DIRECT_MUMPS, 'DIRECT_PARDISO': esys.escriptcore.escriptcpp.SolverOptions.DIRECT_PARDISO, 'DIRECT_SUPERLU': esys.escriptcore.escriptcpp.SolverOptions.DIRECT_SUPERLU, 'DIRECT_TRILINOS': esys.escriptcore.escriptcpp.SolverOptions.DIRECT_TRILINOS, 'GAUSS_SEIDEL': esys.escriptcore.escriptcpp.SolverOptions.GAUSS_SEIDEL, 'GMRES': esys.escriptcore.escriptcpp.SolverOptions.GMRES, 'HRZ_LUMPING': esys.escriptcore.escriptcpp.SolverOptions.HRZ_LUMPING, 'ILU0': esys.escriptcore.escriptcpp.SolverOptions.ILU0, 'ILUT': esys.escriptcore.escriptcpp.SolverOptions.ILUT, 'ITERATIVE': esys.escriptcore.escriptcpp.SolverOptions.ITERATIVE, 'JACOBI': esys.escriptcore.escriptcpp.SolverOptions.JACOBI, 'LINEAR_CRANK_NICOLSON': esys.escriptcore.escriptcpp.SolverOptions.LINEAR_CRANK_NICOLSON, 'LSQR': esys.escriptcore.escriptcpp.SolverOptions.LSQR, 'LUMPING': esys.escriptcore.escriptcpp.SolverOptions.LUMPING, 'MINIMUM_FILL_IN': esys.escriptcore.escriptcpp.SolverOptions.MINIMUM_FILL_IN, 'MINRES': esys.escriptcore.escriptcpp.SolverOptions.MINRES, 'MKL': esys.escriptcore.escriptcpp.SolverOptions.MKL, 'MUMPS': esys.escriptcore.escriptcpp.SolverOptions.MUMPS, 'NESTED_DISSECTION': esys.escriptcore.escriptcpp.SolverOptions.NESTED_DISSECTION, 'NONLINEAR_GMRES': esys.escriptcore.escriptcpp.SolverOptions.NONLINEAR_GMRES, 'NO_PRECONDITIONER': esys.escriptcore.escriptcpp.SolverOptions.NO_PRECONDITIONER, 'NO_REORDERING': esys.escriptcore.escriptcpp.SolverOptions.NO_REORDERING, 'PASO': esys.escriptcore.escriptcpp.SolverOptions.PASO, 'PCG': esys.escriptcore.escriptcpp.SolverOptions.PCG, 'PRES20': esys.escriptcore.escriptcpp.SolverOptions.PRES20, 'REC_ILU': esys.escriptcore.escriptcpp.SolverOptions.REC_ILU, 'RILU': esys.escriptcore.escriptcpp.SolverOptions.RILU, 'ROWSUM_LUMPING': esys.escriptcore.escriptcpp.SolverOptions.ROWSUM_LUMPING, 'TFQMR': esys.escriptcore.escriptcpp.SolverOptions.TFQMR, 'TRILINOS': esys.escriptcore.escriptcpp.SolverOptions.TRILINOS, 'UMFPACK': esys.escriptcore.escriptcpp.SolverOptions.UMFPACK}¶
-
numerator¶ the numerator of a rational number in lowest terms
-
real¶ the real part of a complex number
-
to_bytes()¶ Return an array of bytes representing an integer.
- length
- Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes.
- byteorder
- The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value.
- signed
- Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
-
values= {0: esys.escriptcore.escriptcpp.SolverOptions.DEFAULT, 3: esys.escriptcore.escriptcpp.SolverOptions.MKL, 4: esys.escriptcore.escriptcpp.SolverOptions.PASO, 5: esys.escriptcore.escriptcpp.SolverOptions.TRILINOS, 6: esys.escriptcore.escriptcpp.SolverOptions.UMFPACK, 7: esys.escriptcore.escriptcpp.SolverOptions.MUMPS, 8: esys.escriptcore.escriptcpp.SolverOptions.BICGSTAB, 9: esys.escriptcore.escriptcpp.SolverOptions.CGLS, 10: esys.escriptcore.escriptcpp.SolverOptions.CGS, 11: esys.escriptcore.escriptcpp.SolverOptions.CHOLEVSKY, 12: esys.escriptcore.escriptcpp.SolverOptions.CR, 13: esys.escriptcore.escriptcpp.SolverOptions.DIRECT, 14: esys.escriptcore.escriptcpp.SolverOptions.DIRECT_MUMPS, 15: esys.escriptcore.escriptcpp.SolverOptions.DIRECT_PARDISO, 16: esys.escriptcore.escriptcpp.SolverOptions.DIRECT_SUPERLU, 17: esys.escriptcore.escriptcpp.SolverOptions.DIRECT_TRILINOS, 18: esys.escriptcore.escriptcpp.SolverOptions.GMRES, 19: esys.escriptcore.escriptcpp.SolverOptions.HRZ_LUMPING, 20: esys.escriptcore.escriptcpp.SolverOptions.ITERATIVE, 21: esys.escriptcore.escriptcpp.SolverOptions.LSQR, 22: esys.escriptcore.escriptcpp.SolverOptions.MINRES, 23: esys.escriptcore.escriptcpp.SolverOptions.NONLINEAR_GMRES, 24: esys.escriptcore.escriptcpp.SolverOptions.PCG, 25: esys.escriptcore.escriptcpp.SolverOptions.PRES20, 26: esys.escriptcore.escriptcpp.SolverOptions.ROWSUM_LUMPING, 27: esys.escriptcore.escriptcpp.SolverOptions.TFQMR, 28: esys.escriptcore.escriptcpp.SolverOptions.AMG, 29: esys.escriptcore.escriptcpp.SolverOptions.GAUSS_SEIDEL, 30: esys.escriptcore.escriptcpp.SolverOptions.ILU0, 31: esys.escriptcore.escriptcpp.SolverOptions.ILUT, 32: esys.escriptcore.escriptcpp.SolverOptions.JACOBI, 33: esys.escriptcore.escriptcpp.SolverOptions.NO_PRECONDITIONER, 34: esys.escriptcore.escriptcpp.SolverOptions.REC_ILU, 35: esys.escriptcore.escriptcpp.SolverOptions.RILU, 36: esys.escriptcore.escriptcpp.SolverOptions.BACKWARD_EULER, 37: esys.escriptcore.escriptcpp.SolverOptions.CRANK_NICOLSON, 38: esys.escriptcore.escriptcpp.SolverOptions.LINEAR_CRANK_NICOLSON, 39: esys.escriptcore.escriptcpp.SolverOptions.CLASSIC_INTERPOLATION, 40: esys.escriptcore.escriptcpp.SolverOptions.CLASSIC_INTERPOLATION_WITH_FF_COUPLING, 41: esys.escriptcore.escriptcpp.SolverOptions.DIRECT_INTERPOLATION, 42: esys.escriptcore.escriptcpp.SolverOptions.DEFAULT_REORDERING, 43: esys.escriptcore.escriptcpp.SolverOptions.MINIMUM_FILL_IN, 44: esys.escriptcore.escriptcpp.SolverOptions.NESTED_DISSECTION, 45: esys.escriptcore.escriptcpp.SolverOptions.NO_REORDERING}¶
-
-
class
esys.escript.linearPDEs.SubWorld¶ Bases:
Boost.Python.instanceInformation about a group of workers.
-
__init__()¶ Raises an exception This class cannot be instantiated from Python
-
-
class
esys.escript.linearPDEs.TestDomain¶ Bases:
esys.escriptcore.escriptcpp.DomainTest Class for domains with no structure. May be removed from future releases without notice.
-
__init__()¶ Raises an exception This class cannot be instantiated from Python
-
MPIBarrier((Domain)arg1) → None :¶ Wait until all processes have reached this point
-
dump((Domain)arg1, (str)filename) → None :¶ Dumps the domain to a file
Parameters: filename (string) –
-
getMPIRank((Domain)arg1) → int :¶ Returns: the rank of this process Return type: int
-
getMPISize((Domain)arg1) → int :¶ Returns: the number of processes used for this DomainReturn type: int
-
getNormal((Domain)arg1) → Data :¶ Return type: escriptReturns: Boundary normals
-
getSize((Domain)arg1) → Data :¶ Returns: the local size of samples. The function space is chosen appropriately Return type: Data
-
getStatus((Domain)arg1) → int :¶ The status of a domain changes whenever the domain is modified
Return type: int
-
getTag((Domain)arg1, (str)name) → int :¶ Returns: tag id for nameReturn type: string
-
getX((Domain)arg1) → Data :¶ Return type: DataReturns: Locations in the`Domain`. FunctionSpace is chosen appropriately
-
isValidTagName((Domain)arg1, (str)name) → bool :¶ Returns: True is namecorresponds to a tagReturn type: bool
-
onMasterProcessor((Domain)arg1) → bool :¶ Returns: True if this code is executing on the master process Return type: bool
-
setTagMap((Domain)arg1, (str)name, (int)tag) → None :¶ Give a tag number a name.
Parameters: - name (
string) – Name for the tag - tag (
int) – numeric id
Note: Tag names must be unique within a domain
- name (
-
showTagNames((Domain)arg1) → str :¶ Returns: A space separated list of tag names Return type: string
-
supportsContactElements((Domain)arg1) → bool :¶ Does this domain support contact elements.
-
-
class
esys.escript.linearPDEs.TransportPDE(domain, numEquations=None, numSolutions=None, useBackwardEuler=None, debug=False)¶ Bases:
esys.escriptcore.linearPDEs.LinearProblemThis class is used to define a transport problem given by a general linear, time dependent, second order PDE for an unknown, non-negative, time-dependent function u on a given domain defined through a
Domainobject.For a single equation with a solution with a single component the transport problem is defined in the following form:
(M+M_reduced)*u_t=-(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 u_t denotes the time derivative of u and 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 M, A, B, C, D, X and Y have to be specified through
Dataobjects inFunctionand the coefficients M_reduced, A_reduced, B_reduced, C_reduced, D_reduced, X_reduced and Y_reduced have to be specified throughDataobjects inReducedFunction. It is also allowed to use objects that can be converted into suchDataobjects. M and M_reduced are scalar, 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+X[j]+X_reduced[j])+(d+d_reduced)*u+y+y_reduced=(m+m_reduced)*u_t
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 transport problem. The coefficients m, d and y are each a scalar in
FunctionOnBoundaryand the coefficients m_reduced, d_reduced and y_reduced are each a scalar inReducedFunctionOnBoundary.Constraints for the solution prescribing the value of the solution at certain locations in the domain have the form
u_t=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 transport problem or the boundary condition.
The transport problem 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 and a solution with several components the transport problem has the form
(M[i,k]+M_reduced[i,k]) * u[k]_t=-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, M, M_reduced, 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]+X[i,j]+X_reduced[i,j])+(d[i,k]+d_reduced[i,k])*u[k]+y[i]+y_reduced[i]= (m[i,k]+m_reduced[i,k])*u[k]_t
The coefficient d and m are of rank two and y is of rank one with all in
FunctionOnBoundary. The coefficients d_reduced and m_reduced are of rank two and y_reduced is of rank one all inReducedFunctionOnBoundary.Constraints take the form
u[i]_t=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 transport problem is symmetrical if
- M[i,k]=M[i,k]
- M_reduced[i,k]=M_reduced[i,k]
- 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]
- m[i,k]=m[k,i]
- m_reduced[i,k]=m_reduced[k,i]
- d[i,k]=d[k,i]
- d_reduced[i,k]=d_reduced[k,i]
- d_dirac[i,k]=d_dirac[k,i]
TransportPDEalso 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 asJ[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.getNormalofFunctionOnContactZero. For a system of transport problems the contact condition takes the formn[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 inFunctionOnContactZeroorFunctionOnContactOne. The coefficient d_contact_reduced is of rank two and y_contact_reduced is of rank one both inReducedFunctionOnContactZeroorReducedFunctionOnContactOne. In case of a single PDE and a single component solution the contact condition takes the formn[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
FunctionOnContactZeroorFunctionOnContactOneand the coefficient d_contact_reduced and y_contact_reduced are each scalar both inReducedFunctionOnContactZeroorReducedFunctionOnContactOne.Typical usage:
p = TransportPDE(dom) p.setValue(M=1., C=[-1.,0.]) p.setInitialSolution(u=exp(-length(dom.getX()-[0.1,0.1])**2) t = 0 dt = 0.1 while (t < 1.): u = p.solve(dt)
-
__init__(domain, numEquations=None, numSolutions=None, useBackwardEuler=None, debug=False)¶ Initializes a transport problem.
Parameters: - domain (
Domain) – domain of the PDE - numEquations – number of equations. If
Nonethe number of equations is extracted from the coefficients. - numSolutions – number of solution components. If
Nonethe number of solution components is extracted from the coefficients. - debug – if True debug information is printed
- domain (
-
addPDEToLumpedSystem(operator, a, b, c, hrz_lumping)¶ adds a PDE to the lumped system, results depend on domain
Parameters:
-
addPDEToRHS(righthandside, X, Y, y, y_contact, y_dirac)¶ adds a PDE to the right hand side, results depend on domain
Parameters:
-
addPDEToSystem(operator, righthandside, A, B, C, D, X, Y, d, y, d_contact, y_contact, d_dirac, y_dirac)¶ adds a PDE to the system, results depend on domain
Parameters:
-
addPDEToTransportProblem(operator, righthandside, M, A, B, C, D, X, Y, d, y, d_contact, y_contact, d_dirac, y_dirac)¶ Adds the PDE in the given form to the system matrix :param tp: :type tp:
TransportProblemAdapter:param source: :type source:Data:param data: :type data:list” :param M: :type M:Data:param A: :type A:Data:param B: :type B:Data:param C: :type C:Data:param D: :type D:Data:param X: :type X:Data:param Y: :type Y:Data:param d: :type d:Data:param y: :type y:Data:param d_contact: :type d_contact:Data:param y_contact: :type y_contact:Data:param d_contact: :type d_contact:Data:param y_contact: :type y_contact:Data
-
addToRHS(rhs, data)¶ adds a PDE to the right hand side, results depend on domain
Parameters: - mat (
OperatorAdapter) – - righthandside (
Data) – - data (
list) –
- mat (
-
addToSystem(op, rhs, data)¶ adds a PDE to the system, results depend on domain
Parameters: - mat (
OperatorAdapter) – - rhs (
Data) – - data (
list) –
- mat (
-
alteredCoefficient(name)¶ Announces that coefficient
namehas been changed.Parameters: name ( string) – name of the coefficient affectedRaises: IllegalCoefficient – if nameis not a coefficient of the PDENote: if nameis q or r, the method will not trigger a rebuild of the system as constraints are applied to the solved system.
-
checkReciprocalSymmetry(name0, name1, verbose=True)¶ Tests two coefficients for reciprocal symmetry.
Parameters: - name0 (
str) – name of the first coefficient - name1 (
str) – name of the second coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed
Returns: True if coefficients
name0andname1are reciprocally symmetric.Return type: bool- name0 (
-
checkSymmetricTensor(name, verbose=True)¶ Tests a coefficient for symmetry.
Parameters: - name (
str) – name of the coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed.
Returns: True if coefficient
nameis symmetricReturn type: bool- name (
-
checkSymmetry(verbose=True)¶ Tests the transport problem 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: boolNote: This is a very expensive operation. It should be used for degugging only! The symmetry flag is not altered.
-
createCoefficient(name)¶ Creates a
Dataobject corresponding to coefficientname.Returns: the coefficient nameinitialized to 0Return type: DataRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
createOperator()¶ Returns an instance of a new transport operator.
-
createRightHandSide()¶ Returns an instance of a new right hand side.
-
createSolution()¶ Returns an instance of a new solution.
-
getCoefficient(name)¶ Returns the value of the coefficient
name.Parameters: name ( string) – name of the coefficient requestedReturns: the value of the coefficient Return type: DataRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getCurrentOperator()¶ Returns the operator in its current state.
-
getCurrentRightHandSide()¶ Returns the right hand side in its current state.
-
getCurrentSolution()¶ Returns the solution in its current state.
-
getDim()¶ Returns the spatial dimension of the PDE.
Returns: the spatial dimension of the PDE domain Return type: int
-
getDomainStatus()¶ Return the status indicator of the domain
-
getFunctionSpaceForCoefficient(name)¶ Returns the
FunctionSpaceto be used for coefficientname.Parameters: name ( string) – name of the coefficient enquiredReturns: the function space to be used for coefficient nameReturn type: FunctionSpaceRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getFunctionSpaceForEquation()¶ Returns the
FunctionSpaceused to discretize the equation.Returns: representation space of equation Return type: FunctionSpace
-
getFunctionSpaceForSolution()¶ Returns the
FunctionSpaceused to represent the solution.Returns: representation space of solution Return type: FunctionSpace
-
getNumEquations()¶ Returns the number of equations.
Returns: the number of equations Return type: intRaises: UndefinedPDEError – if the number of equations is not specified yet
-
getNumSolutions()¶ Returns the number of unknowns.
Returns: the number of unknowns Return type: intRaises: UndefinedPDEError – if the number of unknowns is not specified yet
-
getOperator()¶ Returns the operator of the linear problem.
Returns: the operator of the problem
-
getOperatorType()¶ Returns the current system type.
-
getRequiredOperatorType()¶ Returns the system type which needs to be used by the current set up.
Returns: a code to indicate the type of transport problem scheme used Return type: float
-
getRightHandSide()¶ Returns the right hand side of the linear problem.
Returns: the right hand side of the problem Return type: Data
-
getSafeTimeStepSize()¶ Returns a safe time step size to do the next time step.
Returns: safe time step size Return type: floatNote: If not getSafeTimeStepSize()<getUnlimitedTimeStepSize()any time step size can be used.
-
getShapeOfCoefficient(name)¶ Returns the shape of the coefficient
name.Parameters: name ( string) – name of the coefficient enquiredReturns: the shape of the coefficient nameReturn type: tupleofintRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getSolution(dt=None, u0=None)¶ Returns the solution by marching forward by time step dt. If ‘’u0’’ is present, ‘’u0’’ is used as the initial value otherwise the solution from the last call is used.
Parameters: - dt (positive
floatorNone) – time step size. IfNonethe last solution is returned. - u0 (any object that can be interpolated to a
Dataobject onSolutionorReducedSolution) – new initial solution orNone
Returns: the solution
Return type: - dt (positive
-
getSolverOptions()¶ Returns the solver options
Return type: SolverOptions
-
getSystem()¶ Returns the operator and right hand side of the PDE.
Returns: the discrete version of the PDE Return type: tupleofOperatorandData
-
getSystemStatus()¶ Return the domain status used to build the current system
-
getUnlimitedTimeStepSize()¶ Returns the value returned by the
getSafeTimeStepSizemethod to indicate no limit on the safe time step size.return: the value used to indicate that no limit is set to the time step size rtype: floatnote: Typically the biggest positive float is returned
-
hasCoefficient(name)¶ Returns True if
nameis the name of a coefficient.Parameters: name ( string) – name of the coefficient enquiredReturns: True if nameis the name of a coefficient of the general PDE, False otherwiseReturn type: bool
-
initializeSystem()¶ Resets the system clearing the operator, right hand side and solution.
-
introduceCoefficients(**coeff)¶ Introduces new coefficients into the problem.
Use:
p.introduceCoefficients(A=PDECoef(…), B=PDECoef(…))
to introduce the coefficients A and B.
-
invalidateOperator()¶ Indicates the operator has to be rebuilt next time it is used.
-
invalidateRightHandSide()¶ Indicates the right hand side has to be rebuilt next time it is used.
-
invalidateSolution()¶ Indicates the PDE has to be resolved if the solution is requested.
-
invalidateSystem()¶ Announces that everything has to be rebuilt.
-
isComplex()¶ Returns true if this is a complex-valued LinearProblem, false if real-valued.
Return type: bool
-
isHermitian()¶ Checks if the pde is indicated to be Hermitian.
Returns: True if a Hermitian PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isHermitian()
-
isOperatorValid()¶ Returns True if the operator is still valid.
-
isRightHandSideValid()¶ Returns True if the operator is still valid.
-
isSolutionValid()¶ Returns True if the solution is still valid.
-
isSymmetric()¶ Checks if symmetry is indicated.
Returns: True if a symmetric PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isSymmetric()
-
isSystemValid()¶ Returns True if the system (including solution) is still vaild.
-
isUsingLumping()¶ Checks if matrix lumping is the current solver method.
Returns: True if the current solver method is lumping Return type: bool
-
preservePreconditioner(preserve=True)¶ Notifies the PDE that the preconditioner should not be reset when making changes to the operator.
Building the preconditioner data can be quite expensive (e.g. for multigrid methods) so if it is known that changes to the operator are going to be minor calling this method can speed up successive PDE solves.
Note: Not all operator types support this. Parameters: preserve ( bool) – if True, preconditioner will be preserved, otherwise it will be reset when making changes to the operator, which is the default behaviour.
-
reduceEquationOrder()¶ 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
-
reduceSolutionOrder()¶ 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
-
resetAllCoefficients()¶ Resets all coefficients to their default values.
-
resetOperator()¶ Makes sure that the operator is instantiated and returns it initialized with zeros.
-
resetRightHandSide()¶ Sets the right hand side to zero.
-
resetRightHandSideCoefficients()¶ Resets all coefficients defining the right hand side
-
resetSolution()¶ Sets the solution to zero.
-
setDebug(flag)¶ Switches debug output on if
flagis True, otherwise it is switched off.Parameters: flag ( bool) – desired debug status
-
setDebugOff()¶ Switches debug output off.
-
setDebugOn()¶ Switches debug output on.
-
setHermitian(flag=False)¶ Sets the Hermitian flag to
flag.Parameters: flag ( bool) – If True, the Hermitian flag is set otherwise reset.Note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOff()¶ Clears the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOn()¶ Sets the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setInitialSolution(u)¶ Sets the initial solution.
Parameters: u (any object that can be interpolated to a Dataobject onSolutionorReducedSolution) – initial solution
-
setReducedOrderForEquationOff()¶ Switches reduced order off for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationOn()¶ Switches reduced order on for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionOff()¶ Switches reduced order off for solution representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set.
-
setReducedOrderForSolutionOn()¶ Switches reduced order on for solution representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOff()¶ Switches reduced order off for solution and equation representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOn()¶ Switches reduced order on for solution and equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setSolution(u, validate=True)¶ Sets the solution assuming that makes the system valid with the tolrance defined by the solver options
-
setSolverOptions(options=None)¶ Sets the solver options.
Parameters: options ( SolverOptionsorNone) – the new solver options. If equalNone, the solver options are set to the default.Note: The symmetry flag of options is overwritten by the symmetry flag of the LinearProblem.
-
setSymmetry(flag=False)¶ 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
-
setSymmetryOff()¶ Clears the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSymmetryOn()¶ Sets the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSystemStatus(status=None)¶ Sets the system status to
statusifstatusis not present the current status of the domain is used.
-
setValue(**coefficients)¶ Sets new values to coefficients.
Parameters: - coefficients – new values assigned to coefficients
- M (any type that can be cast to a
Dataobject onFunction) – value for coefficientM - M_reduced (any type that can be cast to a
Dataobject onFunction) – value for coefficientM_reduced - A (any type that can be cast to a
Dataobject onFunction) – value for coefficientA - A_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientA_reduced - B (any type that can be cast to a
Dataobject onFunction) – value for coefficientB - B_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientB_reduced - C (any type that can be cast to a
Dataobject onFunction) – value for coefficientC - C_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientC_reduced - D (any type that can be cast to a
Dataobject onFunction) – value for coefficientD - D_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientD_reduced - X (any type that can be cast to a
Dataobject onFunction) – value for coefficientX - X_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientX_reduced - Y (any type that can be cast to a
Dataobject onFunction) – value for coefficientY - Y_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientY_reduced - m (any type that can be cast to a
Dataobject onFunctionOnBoundary) – value for coefficientm - m_reduced (any type that can be cast to a
Dataobject onFunctionOnBoundary) – value for coefficientm_reduced - d (any type that can be cast to a
Dataobject onFunctionOnBoundary) – value for coefficientd - d_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnBoundary) – value for coefficientd_reduced - y (any type that can be cast to a
Dataobject onFunctionOnBoundary) – value for coefficienty - d_contact (any type that can be cast to a
Dataobject onFunctionOnContactOneorFunctionOnContactZero) – value for coefficientd_contact - d_contact_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnContactOneorReducedFunctionOnContactZero) – value for coefficientd_contact_reduced - y_contact (any type that can be cast to a
Dataobject onFunctionOnContactOneorFunctionOnContactZero) – value for coefficienty_contact - y_contact_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnContactOneorReducedFunctionOnContactZero) – value for coefficienty_contact_reduced - d_dirac (any type that can be cast to a
Dataobject onDiracDeltaFunctions) – value for coefficientd_dirac - y_dirac (any type that can be cast to a
Dataobject onDiracDeltaFunctions) – value for coefficienty_dirac - r (any type that can be cast to a
Dataobject onSolutionorReducedSolutiondepending on whether reduced order is used for the solution) – values prescribed to the solution at the locations of constraints - q (any type that can be cast to a
Dataobject onSolutionorReducedSolutiondepending on whether reduced order is used for the representation of the equation) – mask for the location of constraints
Raises: IllegalCoefficient – if an unknown coefficient keyword is used
-
shouldPreservePreconditioner()¶ Returns true if the preconditioner / factorisation should be kept even when resetting the operator.
Return type: bool
-
trace(text)¶ Prints the text message if debug mode is switched on.
Parameters: text ( string) – message to be printed
-
validOperator()¶ Marks the operator as valid.
-
validRightHandSide()¶ Marks the right hand side as valid.
-
validSolution()¶ Marks the solution as valid.
-
class
esys.escript.linearPDEs.TransportProblem¶ Bases:
Boost.Python.instance-
__init__((object)arg1) → None¶
-
getSafeTimeStepSize((TransportProblem)arg1) → float¶
-
getUnlimitedTimeStepSize((TransportProblem)arg1) → float¶
-
insertConstraint((TransportProblem)source, (Data)q, (Data)r, (Data)factor) → None :¶ inserts constraint u_{,t}=r where q>0 into the problem using a weighting factor
-
isEmpty((TransportProblem)arg1) → int :¶ Return type: int
-
reset((TransportProblem)arg1, (bool)arg2) → None :¶ resets the transport operator typically as they have been updated.
-
resetValues((TransportProblem)arg1, (bool)arg2) → None¶
-
-
class
esys.escript.linearPDEs.UndefinedPDEError¶ Bases:
ValueErrorException that is raised if a PDE is not fully defined yet.
-
__init__()¶ Initialize self. See help(type(self)) for accurate signature.
-
args¶
-
with_traceback()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
class
esys.escript.linearPDEs.WavePDE(domain, c, numEquations=None, numSolutions=None, debug=False)¶ Bases:
esys.escriptcore.linearPDEs.LinearPDEA class specifically for waves, passes along values to native implementation to save computational time.
-
__init__(domain, c, numEquations=None, numSolutions=None, debug=False)¶ Initializes a new linear PDE.
Parameters: - domain (
Domain) – domain of the PDE - numEquations – number of equations. If
Nonethe number of equations is extracted from the PDE coefficients. - numSolutions – number of solution components. If
Nonethe number of solution components is extracted from the PDE coefficients. - debug – if True debug information is printed
- domain (
-
addPDEToLumpedSystem(operator, a, b, c, hrz_lumping)¶ adds a PDE to the lumped system, results depend on domain
Parameters:
-
addPDEToRHS(righthandside, X, Y, y, y_contact, y_dirac)¶ adds a PDE to the right hand side, results depend on domain
Parameters:
-
addPDEToSystem(operator, righthandside, A, B, C, D, X, Y, d, y, d_contact, y_contact, d_dirac, y_dirac)¶ adds a PDE to the system, results depend on domain
Parameters:
-
addToRHS(rhs, data)¶ adds a PDE to the right hand side, results depend on domain
Parameters: - mat (
OperatorAdapter) – - righthandside (
Data) – - data (
list) –
- mat (
-
addToSystem(op, rhs, data)¶ adds a PDE to the system, results depend on domain
Parameters: - mat (
OperatorAdapter) – - rhs (
Data) – - data (
list) –
- mat (
-
alteredCoefficient(name)¶ Announces that coefficient
namehas been changed.Parameters: name ( string) – name of the coefficient affectedRaises: IllegalCoefficient – if nameis not a coefficient of the PDENote: if nameis q or r, the method will not trigger a rebuild of the system as constraints are applied to the solved system.
-
checkReciprocalSymmetry(name0, name1, verbose=True)¶ Tests two coefficients for reciprocal symmetry.
Parameters: - name0 (
str) – name of the first coefficient - name1 (
str) – name of the second coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed
Returns: True if coefficients
name0andname1are reciprocally symmetric.Return type: bool- name0 (
-
checkSymmetricTensor(name, verbose=True)¶ Tests a coefficient for symmetry.
Parameters: - name (
str) – name of the coefficient - verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed.
Returns: True if coefficient
nameis symmetricReturn type: bool- name (
-
checkSymmetry(verbose=True)¶ 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: boolNote: This is a very expensive operation. It should be used for degugging only! The symmetry flag is not altered.
-
createCoefficient(name)¶ Creates a
Dataobject corresponding to coefficientname.Returns: the coefficient nameinitialized to 0Return type: DataRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
createOperator()¶ Returns an instance of a new operator.
-
createRightHandSide()¶ Returns an instance of a new right hand side.
-
createSolution()¶ Returns an instance of a new solution.
-
getCoefficient(name)¶ Returns the value of the coefficient
name.Parameters: name ( string) – name of the coefficient requestedReturns: the value of the coefficient Return type: DataRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getCurrentOperator()¶ Returns the operator in its current state.
-
getCurrentRightHandSide()¶ Returns the right hand side in its current state.
-
getCurrentSolution()¶ Returns the solution in its current state.
-
getDim()¶ Returns the spatial dimension of the PDE.
Returns: the spatial dimension of the PDE domain Return type: int
-
getDomainStatus()¶ Return the status indicator of the domain
-
getFlux(u=None)¶ 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 ( Dataor None) – argument in the flux. If u is not present or equalsNonethe current solution is used.Returns: flux Return type: Data
-
getFunctionSpaceForCoefficient(name)¶ Returns the
FunctionSpaceto be used for coefficientname.Parameters: name ( string) – name of the coefficient enquiredReturns: the function space to be used for coefficient nameReturn type: FunctionSpaceRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getFunctionSpaceForEquation()¶ Returns the
FunctionSpaceused to discretize the equation.Returns: representation space of equation Return type: FunctionSpace
-
getFunctionSpaceForSolution()¶ Returns the
FunctionSpaceused to represent the solution.Returns: representation space of solution Return type: FunctionSpace
-
getNumEquations()¶ Returns the number of equations.
Returns: the number of equations Return type: intRaises: UndefinedPDEError – if the number of equations is not specified yet
-
getNumSolutions()¶ Returns the number of unknowns.
Returns: the number of unknowns Return type: intRaises: UndefinedPDEError – if the number of unknowns is not specified yet
-
getOperator()¶ Returns the operator of the linear problem.
Returns: the operator of the problem
-
getOperatorType()¶ Returns the current system type.
-
getRequiredOperatorType()¶ Returns the system type which needs to be used by the current set up.
-
getResidual(u=None)¶ Returns the residual of u or the current solution if u is not present.
Parameters: u ( Dataor None) – argument in the residual calculation. It must be representable inself.getFunctionSpaceForSolution(). If u is not present or equalsNonethe current solution is used.Returns: residual of u Return type: Data
-
getRightHandSide()¶ Returns the right hand side of the linear problem.
Returns: the right hand side of the problem Return type: Data
-
getShapeOfCoefficient(name)¶ Returns the shape of the coefficient
name.Parameters: name ( string) – name of the coefficient enquiredReturns: the shape of the coefficient nameReturn type: tupleofintRaises: IllegalCoefficient – if nameis not a coefficient of the PDE
-
getSolverOptions()¶ Returns the solver options
Return type: SolverOptions
-
getSystem()¶ Returns the operator and right hand side of the PDE.
Returns: the discrete version of the PDE Return type: tupleofOperatorandData
-
getSystemStatus()¶ Return the domain status used to build the current system
-
hasCoefficient(name)¶ Returns True if
nameis the name of a coefficient.Parameters: name ( string) – name of the coefficient enquiredReturns: True if nameis the name of a coefficient of the general PDE, False otherwiseReturn type: bool
-
initializeSystem()¶ Resets the system clearing the operator, right hand side and solution.
-
insertConstraint(rhs_only=False)¶ 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
-
introduceCoefficients(**coeff)¶ Introduces new coefficients into the problem.
Use:
p.introduceCoefficients(A=PDECoef(…), B=PDECoef(…))
to introduce the coefficients A and B.
-
invalidateOperator()¶ Indicates the operator has to be rebuilt next time it is used.
-
invalidateRightHandSide()¶ Indicates the right hand side has to be rebuilt next time it is used.
-
invalidateSolution()¶ Indicates the PDE has to be resolved if the solution is requested.
-
invalidateSystem()¶ Announces that everything has to be rebuilt.
-
isComplex()¶ Returns true if this is a complex-valued LinearProblem, false if real-valued.
Return type: bool
-
isHermitian()¶ Checks if the pde is indicated to be Hermitian.
Returns: True if a Hermitian PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isHermitian()
-
isOperatorValid()¶ Returns True if the operator is still valid.
-
isRightHandSideValid()¶ Returns True if the operator is still valid.
-
isSolutionValid()¶ Returns True if the solution is still valid.
-
isSymmetric()¶ Checks if symmetry is indicated.
Returns: True if a symmetric PDE is indicated, False otherwise Return type: boolNote: the method is equivalent to use getSolverOptions().isSymmetric()
-
isSystemValid()¶ Returns True if the system (including solution) is still vaild.
-
isUsingLumping()¶ Checks if matrix lumping is the current solver method.
Returns: True if the current solver method is lumping Return type: bool
-
preservePreconditioner(preserve=True)¶ Notifies the PDE that the preconditioner should not be reset when making changes to the operator.
Building the preconditioner data can be quite expensive (e.g. for multigrid methods) so if it is known that changes to the operator are going to be minor calling this method can speed up successive PDE solves.
Note: Not all operator types support this. Parameters: preserve ( bool) – if True, preconditioner will be preserved, otherwise it will be reset when making changes to the operator, which is the default behaviour.
-
reduceEquationOrder()¶ 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
-
reduceSolutionOrder()¶ 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
-
resetAllCoefficients()¶ Resets all coefficients to their default values.
-
resetOperator()¶ Makes sure that the operator is instantiated and returns it initialized with zeros.
-
resetRightHandSide()¶ Sets the right hand side to zero.
-
resetRightHandSideCoefficients()¶ Resets all coefficients defining the right hand side
-
resetSolution()¶ Sets the solution to zero.
-
setDebug(flag)¶ Switches debug output on if
flagis True otherwise it is switched off.Parameters: flag ( bool) – desired debug status
-
setDebugOff()¶ Switches debug output off.
-
setDebugOn()¶ Switches debug output on.
-
setHermitian(flag=False)¶ Sets the Hermitian flag to
flag.Parameters: flag ( bool) – If True, the Hermitian flag is set otherwise reset.Note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOff()¶ Clears the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setHermitianOn()¶ Sets the Hermitian flag. :note: The method overwrites the Hermitian flag set by the solver options
-
setReducedOrderForEquationOff()¶ Switches reduced order off for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationOn()¶ Switches reduced order on for equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForEquationTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionOff()¶ Switches reduced order off for solution representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set.
-
setReducedOrderForSolutionOn()¶ Switches reduced order on for solution representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderForSolutionTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOff()¶ Switches reduced order off for solution and equation representation
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderOn()¶ Switches reduced order on for solution and equation representation.
Raises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setReducedOrderTo(flag=False)¶ 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 offRaises: RuntimeError – if order reduction is altered after a coefficient has been set
-
setSolution(u, validate=True)¶ Sets the solution assuming that makes the system valid with the tolrance defined by the solver options
-
setSolverOptions(options=None)¶ Sets the solver options.
Parameters: options ( SolverOptionsorNone) – the new solver options. If equalNone, the solver options are set to the default.Note: The symmetry flag of options is overwritten by the symmetry flag of the LinearProblem.
-
setSymmetry(flag=False)¶ 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
-
setSymmetryOff()¶ Clears the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSymmetryOn()¶ Sets the symmetry flag. :note: The method overwrites the symmetry flag set by the solver options
-
setSystemStatus(status=None)¶ Sets the system status to
statusifstatusis not present the current status of the domain is used.
-
setValue(**coefficients)¶ Sets new values to coefficients.
Parameters: - coefficients – new values assigned to coefficients
- A (any type that can be cast to a
Dataobject onFunction) – value for coefficientA - A_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientA_reduced - B (any type that can be cast to a
Dataobject onFunction) – value for coefficientB - B_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientB_reduced - C (any type that can be cast to a
Dataobject onFunction) – value for coefficientC - C_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientC_reduced - D (any type that can be cast to a
Dataobject onFunction) – value for coefficientD - D_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientD_reduced - X (any type that can be cast to a
Dataobject onFunction) – value for coefficientX - X_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientX_reduced - Y (any type that can be cast to a
Dataobject onFunction) – value for coefficientY - Y_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientY_reduced - d (any type that can be cast to a
Dataobject onFunctionOnBoundary) – value for coefficientd - d_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnBoundary) – value for coefficientd_reduced - y (any type that can be cast to a
Dataobject onFunctionOnBoundary) – value for coefficienty - d_contact (any type that can be cast to a
Dataobject onFunctionOnContactOneorFunctionOnContactZero) – value for coefficientd_contact - d_contact_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnContactOneorReducedFunctionOnContactZero) – value for coefficientd_contact_reduced - y_contact (any type that can be cast to a
Dataobject onFunctionOnContactOneorFunctionOnContactZero) – value for coefficienty_contact - y_contact_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnContactOneorReducedFunctionOnContactZero) – value for coefficienty_contact_reduced - d_dirac (any type that can be cast to a
Dataobject onDiracDeltaFunctions) – value for coefficientd_dirac - y_dirac (any type that can be cast to a
Dataobject onDiracDeltaFunctions) – value for coefficienty_dirac - r (any type that can be cast to a
Dataobject onSolutionorReducedSolutiondepending on whether reduced order is used for the solution) – values prescribed to the solution at the locations of constraints - q (any type that can be cast to a
Dataobject onSolutionorReducedSolutiondepending on whether reduced order is used for the representation of the equation) – mask for location of constraints
Raises: IllegalCoefficient – if an unknown coefficient keyword is used
-
shouldPreservePreconditioner()¶ Returns true if the preconditioner / factorisation should be kept even when resetting the operator.
Return type: bool
-
trace(text)¶ Prints the text message if debug mode is switched on.
Parameters: text ( string) – message to be printed
-
validOperator()¶ Marks the operator as valid.
-
validRightHandSide()¶ Marks the right hand side as valid.
-
validSolution()¶ Marks the solution as valid.
-
Functions¶
-
esys.escript.linearPDEs.Abs(arg)¶ Returns the absolute value of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray.) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.C_GeneralTensorProduct((Data)arg0, (Data)arg1[, (int)axis_offset=0[, (int)transpose=0]]) → Data :¶ Compute a tensor product of two Data objects.
Return type: Parameters: - arg0 –
- arg1 –
- axis_offset (
int) – - transpose (int) – 0: transpose neither, 1: transpose arg0, 2: transpose arg1
-
esys.escript.linearPDEs.ComplexData((object)value[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa053554450>[, (bool)expanded=False]]) → Data¶
-
esys.escript.linearPDEs.ComplexScalar([(object)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa05352adb0>[, (bool)expanded=False]]]) → Data :¶ Construct a Data object containing scalar data-points.
Parameters: - value (float) – scalar value for all points
- what (
FunctionSpace) – FunctionSpace for Data - expanded (
bool) – If True, a value is stored for each point. If False, more efficient representations may be used
Return type:
-
esys.escript.linearPDEs.ComplexTensor([(float)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa053554030>[, (bool)expanded=False]]]) → Data :¶ Construct a Data object containing rank2 data-points.
param value: scalar value for all points rtype: Datatype value: float param what: FunctionSpace for Data type what: FunctionSpaceparam expanded: If True, a value is stored for each point. If False, more efficient representations may be used type expanded: boolComplexTensor( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa0535540f0> [, (bool)expanded=False]]) -> Data
-
esys.escript.linearPDEs.ComplexTensor3([(float)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa0535541b0>[, (bool)expanded=False]]]) → Data :¶ Construct a Data object containing rank3 data-points.
param value: scalar value for all points rtype: Datatype value: float param what: FunctionSpace for Data type what: FunctionSpaceparam expanded: If True, a value is stored for each point. If False, more efficient representations may be used type expanded: boolComplexTensor3( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa0535542d0> [, (bool)expanded=False]]) -> Data
-
esys.escript.linearPDEs.ComplexTensor4([(float)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa053554330>[, (bool)expanded=False]]]) → Data :¶ Construct a Data object containing rank4 data-points.
param value: scalar value for all points rtype: Datatype value: float param what: FunctionSpace for Data type what: FunctionSpaceparam expanded: If True, a value is stored for each point. If False, more efficient representations may be used type expanded: boolComplexTensor4( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa0535543f0> [, (bool)expanded=False]]) -> Data
-
esys.escript.linearPDEs.ComplexVector([(float)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa05352ae70>[, (bool)expanded=False]]]) → Data :¶ Construct a Data object containing rank1 data-points.
param value: scalar value for all points rtype: Datatype value: float param what: FunctionSpace for Data type what: FunctionSpaceparam expanded: If True, a value is stored for each point. If False, more efficient representations may be used type expanded: boolComplexVector( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa05352af30> [, (bool)expanded=False]]) -> Data
-
esys.escript.linearPDEs.ContinuousFunction((Domain)domain) → FunctionSpace :¶ Returns: a continuous FunctionSpace (overlapped node values) Return type: FunctionSpace
-
esys.escript.linearPDEs.DiracDeltaFunctions((Domain)domain) → FunctionSpace :¶ Return type: FunctionSpace
-
esys.escript.linearPDEs.Function((Domain)domain) → FunctionSpace :¶ Returns: a function FunctionSpaceReturn type: FunctionSpace
-
esys.escript.linearPDEs.FunctionOnBoundary((Domain)domain) → FunctionSpace :¶ Returns: a function on boundary FunctionSpace Return type: FunctionSpace
-
esys.escript.linearPDEs.FunctionOnContactOne((Domain)domain) → FunctionSpace :¶ Returns: Return a FunctionSpace on right side of contact Return type: FunctionSpace
-
esys.escript.linearPDEs.FunctionOnContactZero((Domain)domain) → FunctionSpace :¶ Returns: Return a FunctionSpace on left side of contact Return type: FunctionSpace
-
esys.escript.linearPDEs.L2(arg)¶ Returns the L2 norm of
argatwhere.Parameters: arg ( escript.DataorSymbol) – function of which the L2 norm is to be calculatedReturns: L2 norm of argReturn type: floatorSymbolNote: L2(arg) is equivalent to sqrt(integrate(inner(arg,arg)))
-
esys.escript.linearPDEs.LinearPDESystem(domain, isComplex=False, debug=False)¶ Defines a system of linear PDEs.
Parameters: - domain (
Domain) – domain of the PDEs - isComplex (
boolean) – if true, this coefficient is part of a complex-valued PDE and values will be converted to complex. - debug – if True debug information is printed
Return type: - domain (
-
esys.escript.linearPDEs.LinearSinglePDE(domain, isComplex=False, debug=False)¶ Defines a single linear PDE.
Parameters: - domain (
Domain) – domain of the PDE - isComplex (
boolean) – if true, this coefficient is part of a complex-valued PDE and values will be converted to complex. - debug – if True debug information is printed
Return type: - domain (
-
esys.escript.linearPDEs.Lsup(arg)¶ Returns the Lsup-norm of argument
arg. This is the maximum absolute value over all data points. This function is equivalent tosup(abs(arg)).Parameters: arg ( float,int,escript.Data,numpy.ndarray) – argumentReturns: maximum value of the absolute value of argover all components and all data pointsReturn type: floatRaises: TypeError – if type of argcannot be processed
-
esys.escript.linearPDEs.MPIBarrierWorld() → None :¶ Wait until all MPI processes have reached this point.
-
esys.escript.linearPDEs.NcFType((str)filename) → str :¶ Return a character indicating what netcdf format a file uses. c or C indicates netCDF3. 4 indicates netCDF4. u indicates unsupported format (eg netCDF4 file in an escript build which does not support it ? indicates unknown.
-
esys.escript.linearPDEs.NumpyToData(array, isComplex, functionspace)¶ Uses a numpy ndarray to create a
DataobjectExample usage: NewDataObject = NumpyToData(ndarray, isComplex, FunctionSpace)
-
esys.escript.linearPDEs.RandomData((tuple)shape, (FunctionSpace)fs[, (int)seed=0[, (tuple)filter=()]]) → Data :¶ Creates a new expanded Data object containing pseudo-random values. With no filter, values are drawn uniformly at random from [0,1].
Parameters: - shape (tuple) – datapoint shape
- fs (
FunctionSpace) – function space for data object. - seed (long) – seed for random number generator.
-
esys.escript.linearPDEs.ReducedContinuousFunction((Domain)domain) → FunctionSpace :¶ Returns: a continuous with reduced order FunctionSpace (overlapped node values on reduced element order) Return type: FunctionSpace
-
esys.escript.linearPDEs.ReducedFunction((Domain)domain) → FunctionSpace :¶ Returns: a function FunctionSpace with reduced integration order Return type: FunctionSpace
-
esys.escript.linearPDEs.ReducedFunctionOnBoundary((Domain)domain) → FunctionSpace :¶ Returns: a function on boundary FunctionSpace with reduced integration order Return type: FunctionSpace
-
esys.escript.linearPDEs.ReducedFunctionOnContactOne((Domain)domain) → FunctionSpace :¶ Returns: Return a FunctionSpace on right side of contact with reduced integration order Return type: FunctionSpace
-
esys.escript.linearPDEs.ReducedFunctionOnContactZero((Domain)domain) → FunctionSpace :¶ Returns: a FunctionSpace on left side of contact with reduced integration order Return type: FunctionSpace
-
esys.escript.linearPDEs.ReducedSolution((Domain)domain) → FunctionSpace :¶ Return type: FunctionSpace
-
esys.escript.linearPDEs.Scalar([(object)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa05352ad50>[, (bool)expanded=False]]]) → Data :¶ Construct a Data object containing scalar data-points.
Parameters: - value (float) – scalar value for all points
- what (
FunctionSpace) – FunctionSpace for Data - expanded (
bool) – If True, a value is stored for each point. If False, more efficient representations may be used
Return type:
-
esys.escript.linearPDEs.SingleTransportPDE(domain, debug=False)¶ Defines a single transport problem
Parameters: - domain (
Domain) – domain of the PDE - debug – if True debug information is printed
Return type: - domain (
-
esys.escript.linearPDEs.Solution((Domain)domain) → FunctionSpace :¶ Return type: FunctionSpace
-
esys.escript.linearPDEs.Tensor([(float)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa05352af90>[, (bool)expanded=False]]]) → Data :¶ Construct a Data object containing rank2 data-points.
param value: scalar value for all points rtype: Datatype value: float param what: FunctionSpace for Data type what: FunctionSpaceparam expanded: If True, a value is stored for each point. If False, more efficient representations may be used type expanded: boolTensor( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa053554090> [, (bool)expanded=False]]) -> Data
-
esys.escript.linearPDEs.Tensor3([(float)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa053554150>[, (bool)expanded=False]]]) → Data :¶ Construct a Data object containing rank3 data-points.
param value: scalar value for all points rtype: Datatype value: float param what: FunctionSpace for Data type what: FunctionSpaceparam expanded: If True, a value is stored for each point. If False, more efficient representations may be used type expanded: boolTensor3( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa053554210> [, (bool)expanded=False]]) -> Data
-
esys.escript.linearPDEs.Tensor4([(float)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa053554270>[, (bool)expanded=False]]]) → Data :¶ Construct a Data object containing rank4 data-points.
param value: scalar value for all points rtype: Datatype value: float param what: FunctionSpace for Data type what: FunctionSpaceparam expanded: If True, a value is stored for each point. If False, more efficient representations may be used type expanded: boolTensor4( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa053554390> [, (bool)expanded=False]]) -> Data
-
esys.escript.linearPDEs.Vector([(float)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa05352ae10>[, (bool)expanded=False]]]) → Data :¶ Construct a Data object containing rank1 data-points.
param value: scalar value for all points rtype: Datatype value: float param what: FunctionSpace for Data type what: FunctionSpaceparam expanded: If True, a value is stored for each point. If False, more efficient representations may be used type expanded: boolVector( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7fa05352aed0> [, (bool)expanded=False]]) -> Data
-
esys.escript.linearPDEs.acos(arg)¶ Returns the inverse cosine of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.acosh(arg)¶ Returns the inverse hyperbolic cosine of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.antihermitian(arg)¶ Returns the anti-hermitian part of the square matrix
arg. That is, (arg-adjoint(arg))/2.Parameters: arg ( numpy.ndarray,escript.Data,Symbol) – input matrix. Must have rank 2 or 4 and be square.Returns: anti-hermitian part of argReturn type: numpy.ndarray,escript.Data,Symboldepending on the input
-
esys.escript.linearPDEs.antisymmetric(arg)¶ Returns the anti-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: anti-symmetric part of argReturn type: numpy.ndarray,escript.Data,Symboldepending on the input
-
esys.escript.linearPDEs.asin(arg)¶ Returns the inverse sine of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.asinh(arg)¶ Returns the inverse hyperbolic sine of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.atan(arg)¶ Returns inverse tangent of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.atan2(arg0, arg1)¶ Returns inverse tangent of argument
arg0overarg1
-
esys.escript.linearPDEs.atanh(arg)¶ Returns the inverse hyperbolic tangent of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.boundingBox(domain)¶ Returns the bounding box of a domain
Parameters: domain ( escript.Domain) – a domainReturns: bounding box of the domain Return type: listof pairs offloat
-
esys.escript.linearPDEs.boundingBoxEdgeLengths(domain)¶ Returns the edge lengths of the bounding box of a domain
Parameters: domain ( escript.Domain) – a domainReturn type: listoffloat
-
esys.escript.linearPDEs.canInterpolate((FunctionSpace)src, (FunctionSpace)dest) → bool :¶ Parameters: - src – Source FunctionSpace
- dest – Destination FunctionSpace
Returns: True if src can be interpolated to dest
Return type: bool
-
esys.escript.linearPDEs.clip(arg, minval=None, maxval=None)¶ Cuts the values of
argbetweenminvalandmaxval.Parameters: - arg (
numpy.ndarray,escript.Data,Symbol,intorfloat) – argument - minval (
floatorNone) – lower range. If None no lower range is applied - maxval (
floatorNone) – upper range. If None no upper range is applied
Returns: an object that contains all values from
argbetweenminvalandmaxvalReturn type: numpy.ndarray,escript.Data,Symbol,intorfloatdepending on the inputRaises: ValueError – if
minval>maxval- arg (
-
esys.escript.linearPDEs.commonDim(*args)¶ 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 dimensionNoneis returned.Return type: intorNoneRaises: ValueError – if the objects with identifiable dimension don’t have the same spatial dimension.
-
esys.escript.linearPDEs.commonShape(arg0, arg1)¶ Returns a shape to which
arg0can be extended from the right andarg1can be extended from the left.Parameters: Returns: the shape of
arg0orarg1such that the left part equals the shape ofarg0and the right end equals the shape ofarg1Return type: tupleofintRaises: ValueError – if no shape can be found
-
esys.escript.linearPDEs.condEval(f, tval, fval)¶ Wrapper to allow non-data objects to be used.
-
esys.escript.linearPDEs.convertToNumpy(data)¶ Writes
Dataobjects to a numpy array.The keyword args are Data objects to save. If a scalar
Dataobject is passed with the namemask, then only samples which correspond to positive values inmaskwill be output.Example usage:
s=Scalar(..) v=Vector(..) t=Tensor(..) f=float() array = getNumpy(a=s, b=v, c=t, d=f)
-
esys.escript.linearPDEs.cos(arg)¶ Returns cosine of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.cosh(arg)¶ Returns the hyperbolic cosine of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.delay(arg)¶ Returns a lazy version of arg
-
esys.escript.linearPDEs.deviatoric(arg)¶ Returns the deviatoric version of
arg.
-
esys.escript.linearPDEs.diameter(domain)¶ Returns the diameter of a domain.
Parameters: domain ( escript.Domain) – a domainReturn type: float
-
esys.escript.linearPDEs.div(arg, where=None)¶ Returns the divergence of
argatwhere.Parameters: - arg (
escript.DataorSymbol) – function of which the divergence is to be calculated. Its shape has to be (d,) where d is the spatial dimension. - where (
Noneorescript.FunctionSpace) –FunctionSpacein which the divergence will be calculated. If not present orNonean appropriate default is used.
Returns: divergence of
argReturn type: escript.DataorSymbol- arg (
-
esys.escript.linearPDEs.eigenvalues(arg)¶ 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,Symboldepending on the inputNote: for escript.DataandSymbolobjects the dimension is restricted to 3.
-
esys.escript.linearPDEs.eigenvalues_and_eigenvectors(arg)¶ 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: tupleofescript.DataNote: The dimension is restricted to 3.
-
esys.escript.linearPDEs.erf(arg)¶ Returns the error function erf of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray.) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.escript_generalTensorProduct(arg0, arg1, axis_offset, transpose=0)¶ arg0 and arg1 are both Data objects but not necessarily on the same function space. They could be identical!!!
-
esys.escript.linearPDEs.escript_generalTensorTransposedProduct(arg0, arg1, axis_offset)¶ arg0 and arg1 are both Data objects but not necessarily on the same function space. They could be identical!!!
-
esys.escript.linearPDEs.escript_generalTransposedTensorProduct(arg0, arg1, axis_offset)¶ arg0 and arg1 are both Data objects but not necessarily on the same function space. They could be identical!!!
-
esys.escript.linearPDEs.escript_inverse(arg)¶ arg is a Data object!
-
esys.escript.linearPDEs.exp(arg)¶ Returns e to the power of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray.) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type of argRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.generalTensorProduct(arg0, arg1, axis_offset=0)¶ Generalized tensor product.
out[s,t]=Sigma_r arg0[s,r]*arg1[r,t]- where
- s runs through
arg0.Shape[:arg0.ndim-axis_offset] - r runs through
arg1.Shape[:axis_offset] - t runs through
arg1.Shape[axis_offset:]
- s runs through
Parameters: - arg0 (
numpy.ndarray,escript.Data,Symbol,float,int) – first argument - arg1 (
numpy.ndarray,escript.Data,Symbol,float,int) – second argument
Returns: the general tensor product of
arg0andarg1at each data pointReturn type: numpy.ndarray,escript.Data,Symboldepending on the input
-
esys.escript.linearPDEs.generalTensorTransposedProduct(arg0, arg1, axis_offset=0)¶ Generalized tensor product of
arg0and transpose ofarg1.out[s,t]=Sigma_r arg0[s,r]*arg1[t,r]- where
- s runs through
arg0.Shape[:arg0.ndim-axis_offset] - r runs through
arg0.Shape[arg1.ndim-axis_offset:] - t runs through
arg1.Shape[arg1.ndim-axis_offset:]
- s runs through
The function call
generalTensorTransposedProduct(arg0,arg1,axis_offset)is equivalent togeneralTensorProduct(arg0,transpose(arg1,arg1.ndim-axis_offset),axis_offset).Parameters: - arg0 (
numpy.ndarray,escript.Data,Symbol,float,int) – first argument - arg1 (
numpy.ndarray,escript.Data,Symbol,float,int) – second argument
Returns: the general tensor product of
arg0andtranspose(arg1)at each data pointReturn type: numpy.ndarray,escript.Data,Symboldepending on the input
-
esys.escript.linearPDEs.generalTransposedTensorProduct(arg0, arg1, axis_offset=0)¶ Generalized tensor product of transposed of
arg0andarg1.out[s,t]=Sigma_r arg0[r,s]*arg1[r,t]- where
- s runs through
arg0.Shape[axis_offset:] - r runs through
arg0.Shape[:axis_offset] - t runs through
arg1.Shape[axis_offset:]
- s runs through
The function call
generalTransposedTensorProduct(arg0,arg1,axis_offset)is equivalent togeneralTensorProduct(transpose(arg0,arg0.ndim-axis_offset),arg1,axis_offset).Parameters: - arg0 (
numpy.ndarray,escript.Data,Symbol,float,int) – first argument - arg1 (
numpy.ndarray,escript.Data,Symbol,float,int) – second argument
Returns: the general tensor product of
transpose(arg0)andarg1at each data pointReturn type: numpy.ndarray,escript.Data,Symboldepending on the input
-
esys.escript.linearPDEs.getClosestValue(arg, origin=0)¶ Returns the value in
argwhich is closest to origin.Parameters: - arg (
escript.Data) – function - origin (
floatorescript.Data) – reference value
Returns: value in
argclosest to originReturn type: numpy.ndarray- arg (
-
esys.escript.linearPDEs.getEpsilon()¶
-
esys.escript.linearPDEs.getEscriptParamInt((str)name[, (int)sentinel=0]) → int :¶ Read the value of an escript tuning parameter
Parameters: - name (
string) – parameter to lookup - sentinel (
int) – Value to be returned ifnameis not a known parameter
- name (
-
esys.escript.linearPDEs.getMPIRankWorld() → int :¶ Return the rank of this process in the MPI World.
-
esys.escript.linearPDEs.getMPISizeWorld() → int :¶ Return number of MPI processes in the job.
-
esys.escript.linearPDEs.getMPIWorldMax((int)arg1) → int :¶ Each MPI process calls this function with a value for arg1. The maximum value is computed and returned.
Return type: int
-
esys.escript.linearPDEs.getMPIWorldSum((int)arg1) → int :¶ Each MPI process calls this function with a value for arg1. The values are added up and the total value is returned.
Return type: int
-
esys.escript.linearPDEs.getMachinePrecision() → float¶
-
esys.escript.linearPDEs.getMaxFloat()¶
-
esys.escript.linearPDEs.getNumberOfThreads() → int :¶ Return the maximum number of threads available to OpenMP.
-
esys.escript.linearPDEs.getNumpy(**data)¶ Writes
Dataobjects to a numpy array.The keyword args are Data objects to save. If a scalar
Dataobject is passed with the namemask, then only samples which correspond to positive values inmaskwill be output.Example usage:
s=Scalar(..) v=Vector(..) t=Tensor(..) f=float() array = getNumpy(a=s, b=v, c=t, d=f)
-
esys.escript.linearPDEs.getRank(arg)¶ Identifies the rank of the argument.
Parameters: arg ( numpy.ndarray,escript.Data,float,int,Symbol) – an object whose rank is to be returnedReturns: the rank of the argument Return type: intRaises: TypeError – if type of argcannot be processed
-
esys.escript.linearPDEs.getShape(arg)¶ Identifies the shape of the argument.
Parameters: arg ( numpy.ndarray,escript.Data,float,int,Symbol) – an object whose shape is to be returnedReturns: the shape of the argument Return type: tupleofintRaises: TypeError – if type of argcannot be processed
-
esys.escript.linearPDEs.getTagNames(domain)¶ Returns a list of tag names used by the domain.
Parameters: domain ( escript.Domain) – a domain objectReturns: a list of tag names used by the domain Return type: listofstr
-
esys.escript.linearPDEs.getTestDomainFunctionSpace((int)dpps, (int)samples[, (int)size=1]) → FunctionSpace :¶ For testing only. May be removed without notice.
-
esys.escript.linearPDEs.getVersion() → int :¶ This method will only report accurate version numbers for clean checkouts.
-
esys.escript.linearPDEs.gmshGeo2Msh(geoFile, mshFile, numDim, order=1, verbosity=0)¶ Runs gmsh to mesh input
geoFile. Returns 0 on success.
-
esys.escript.linearPDEs.grad(arg, where=None)¶ Returns the spatial gradient of
argatwhere.If
gis the returned object, then- if
argis rank 0g[s]is the derivative ofargwith respect to thes-th spatial dimension - if
argis rank 1g[i,s]is the derivative ofarg[i]with respect to thes-th spatial dimension - if
argis rank 2g[i,j,s]is the derivative ofarg[i,j]with respect to thes-th spatial dimension - if
argis rank 3g[i,j,k,s]is the derivative ofarg[i,j,k]with respect to thes-th spatial dimension.
Parameters: - arg (
escript.DataorSymbol) – function of which the gradient is to be calculated. Its rank has to be less than 3. - where (
Noneorescript.FunctionSpace) – FunctionSpace in which the gradient is calculated. If not present orNonean appropriate default is used.
Returns: gradient of
argReturn type: escript.DataorSymbol- if
-
esys.escript.linearPDEs.grad_n(arg, n, where=None)¶
-
esys.escript.linearPDEs.hasFeature((str)name) → bool :¶ Check if escript was compiled with a certain feature
Parameters: name ( string) – feature to lookup
-
esys.escript.linearPDEs.hermitian(arg)¶ Returns the hermitian part of the square matrix
arg. That is, (arg+adjoint(arg))/2.Parameters: arg ( numpy.ndarray,escript.Data,Symbol) – input matrix. Must have rank 2 or 4 and be square.Returns: hermitian part of argReturn type: numpy.ndarray,escript.Data,Symboldepending on the input
-
esys.escript.linearPDEs.identity(shape=())¶ Returns the
shapexshapeidentity tensor.Parameters: shape ( tupleofint) – input shape for the identity tensorReturns: 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.ndarrayof rank 1, rank 2 or rank 4Raises: ValueError – if len(shape)>2
-
esys.escript.linearPDEs.identityTensor(d=3)¶ Returns the
dxdidentity matrix.Parameters: d ( int,escript.Domainorescript.FunctionSpace) – dimension or an object that has thegetDimmethod defining the dimensionReturns: the object u of rank 2 with u[i,j]=1 for i=j and u[i,j]=0 otherwise Return type: numpy.ndarrayorescript.Dataof rank 2
-
esys.escript.linearPDEs.identityTensor4(d=3)¶ Returns the
dxdxdxdidentity tensor.Parameters: d ( intor any object with agetDimmethod) – dimension or an object that has thegetDimmethod defining the dimensionReturns: 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.ndarrayorescript.Dataof rank 4
-
esys.escript.linearPDEs.inf(arg)¶ Returns the minimum value over all data points.
Parameters: arg ( float,int,escript.Data,numpy.ndarray) – argumentReturns: minimum value of argover all components and all data pointsReturn type: floatRaises: TypeError – if type of argcannot be processed
-
esys.escript.linearPDEs.inner(arg0, arg1)¶ Inner product of the two arguments. The inner product is defined as:
out=Sigma_s arg0[s]*arg1[s]where s runs through
arg0.Shape.arg0andarg1must have the same shape.Parameters: - arg0 (
numpy.ndarray,escript.Data,Symbol,float,int) – first argument - arg1 (
numpy.ndarray,escript.Data,Symbol,float,int) – second argument
Returns: the inner product of
arg0andarg1at each data pointReturn type: numpy.ndarray,escript.Data,Symbol,floatdepending on the inputRaises: ValueError – if the shapes of the arguments are not identical
- arg0 (
-
esys.escript.linearPDEs.insertTagNames(domain, **kwargs)¶ Inserts tag names into the domain.
Parameters: - domain (
escript.Domain) – a domain object - <tag_name> (
int) – tag key assigned to <tag_name>
- domain (
-
esys.escript.linearPDEs.insertTaggedValues(target, **kwargs)¶ Inserts tagged values into the target using tag names.
Parameters: - target (
escript.Data) – data to be filled by tagged values - <tag_name> (
floatornumpy.ndarray) – value to be used for <tag_name>
Returns: targetReturn type: escript.Data- target (
-
esys.escript.linearPDEs.integrate(arg, where=None)¶ Returns the integral of the function
argover its domain. Ifwhereis presentargis interpolated towherebefore integration.Parameters: - arg (
escript.DataorSymbol) – the function which is integrated - where (
Noneorescript.FunctionSpace) – FunctionSpace in which the integral is calculated. If not present orNonean appropriate default is used.
Returns: integral of
argReturn type: float,numpy.ndarrayorSymbol- arg (
-
esys.escript.linearPDEs.internal_addJob()¶ object internal_addJob(tuple args, dict kwds)
-
esys.escript.linearPDEs.internal_addJobPerWorld()¶ object internal_addJobPerWorld(tuple args, dict kwds)
-
esys.escript.linearPDEs.internal_addVariable()¶ object internal_addVariable(tuple args, dict kwds)
-
esys.escript.linearPDEs.internal_buildDomains()¶ object internal_buildDomains(tuple args, dict kwds)
-
esys.escript.linearPDEs.internal_makeDataReducer((str)op) → Reducer :¶ Create a reducer to work with Data and the specified operation.
-
esys.escript.linearPDEs.internal_makeLocalOnly() → Reducer :¶ Create a variable which is not connected to copies in other worlds.
-
esys.escript.linearPDEs.internal_makeScalarReducer((str)op) → Reducer :¶ Create a reducer to work with doubles and the specified operation.
-
esys.escript.linearPDEs.interpolate(arg, where)¶ Interpolates the function into the
FunctionSpacewhere. If the argumentarghas the requested function spacewhereno interpolation is performed andargis returned.Parameters: - arg (
escript.DataorSymbol) – interpolant - where (
escript.FunctionSpace) –FunctionSpaceto be interpolated to
Returns: interpolated argument
Return type: escript.DataorSymbol- arg (
-
esys.escript.linearPDEs.interpolateTable(tab, dat, start, step, undef=1e+50, check_boundaries=False)¶
-
esys.escript.linearPDEs.inverse(arg)¶ 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 tokronecker(arg.getShape()[0])Return type: numpy.ndarray,escript.Data,Symboldepending on the inputNote: for escript.Dataobjects the dimension is restricted to 3.
-
esys.escript.linearPDEs.jump(arg, domain=None)¶ Returns the jump of
argacross the continuity of the domain.Parameters: - arg (
escript.DataorSymbol) – argument - domain (
Noneorescript.Domain) – the domain where the discontinuity is located. If domain is not present or equal toNonethe domain ofargis used.
Returns: jump of
argReturn type: escript.DataorSymbol- arg (
-
esys.escript.linearPDEs.kronecker(d=3)¶ Returns the kronecker delta-symbol.
Parameters: d ( int,escript.Domainorescript.FunctionSpace) – dimension or an object that has thegetDimmethod defining the dimensionReturns: the object u of rank 2 with u[i,j]=1 for i=j and u[i,j]=0 otherwise Return type: numpy.ndarrayorescript.Dataof rank 2
-
esys.escript.linearPDEs.length(arg)¶ Returns the length (Euclidean norm) of argument
argat each data point.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symboldepending on the type ofarg
-
esys.escript.linearPDEs.listEscriptParams() → list :¶ Returns: A list of tuples (p,v,d) where p is the name of a parameter for escript, v is its current value, and d is a description.
-
esys.escript.linearPDEs.listFeatures() → list :¶ Returns: A list of strings representing the features escript supports.
-
esys.escript.linearPDEs.load((str)fileName, (Domain)domain) → Data :¶ reads Data on domain from file in netCDF format
Parameters: - fileName (
string) – - domain (
Domain) –
- fileName (
-
esys.escript.linearPDEs.loadIsConfigured() → bool :¶ Returns: True if the load function is configured.
-
esys.escript.linearPDEs.log(arg)¶ Returns the natural logarithm of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray.) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.log10(arg)¶ Returns base-10 logarithm of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.longestEdge(domain)¶ Returns the length of the longest edge of the domain
Parameters: domain ( escript.Domain) – a domainReturns: longest edge of the domain parallel to the Cartesian axis Return type: float
-
esys.escript.linearPDEs.makeTagMap(fs)¶ Produce an expanded Data over the function space where the value is the tag associated with the sample
-
esys.escript.linearPDEs.matchShape(arg0, arg1)¶ Returns a representation of
arg0andarg1which have the same shape.Parameters: - arg0 (
numpy.ndarray,`escript.Data`,``float``,int,Symbol) – first argument - arg1 (
numpy.ndarray,`escript.Data`,``float``,int,Symbol) – second argument
Returns: arg0andarg1where copies are returned when the shape has to be changedReturn type: tuple- arg0 (
-
esys.escript.linearPDEs.matchType(arg0=0.0, arg1=0.0)¶ Converts
arg0andarg1both to the same typenumpy.ndarrayorescript.DataParameters: - arg0 (
numpy.ndarray,`escript.Data`,``float``,int,Symbol) – first argument - arg1 (
numpy.ndarray,`escript.Data`,``float``,int,Symbol) – second argument
Returns: a tuple representing
arg0andarg1with the same type or with at least one of them being aSymbolReturn type: tupleof twonumpy.ndarrayor twoescript.DataRaises: TypeError – if type of
arg0orarg1cannot be processed- arg0 (
-
esys.escript.linearPDEs.matrix_mult(arg0, arg1)¶ matrix-matrix or matrix-vector product of the two arguments.
out[s0]=Sigma_{r0} arg0[s0,r0]*arg1[r0]or
out[s0,s1]=Sigma_{r0} arg0[s0,r0]*arg1[r0,s1]The second dimension of
arg0and the first dimension ofarg1must match.Parameters: - arg0 (
numpy.ndarray,escript.Data,Symbol) – first argument of rank 2 - arg1 (
numpy.ndarray,escript.Data,Symbol) – second argument of at least rank 1
Returns: the matrix-matrix or matrix-vector product of
arg0andarg1at each data pointReturn type: numpy.ndarray,escript.Data,Symboldepending on the inputRaises: ValueError – if the shapes of the arguments are not appropriate
- arg0 (
-
esys.escript.linearPDEs.matrix_transposed_mult(arg0, arg1)¶ matrix-transposed(matrix) product of the two arguments.
out[s0,s1]=Sigma_{r0} arg0[s0,r0]*arg1[s1,r0]The function call
matrix_transposed_mult(arg0,arg1)is equivalent tomatrix_mult(arg0,transpose(arg1)).The last dimensions of
arg0andarg1must match.Parameters: - arg0 (
numpy.ndarray,escript.Data,Symbol) – first argument of rank 2 - arg1 (
numpy.ndarray,escript.Data,Symbol) – second argument of rank 1 or 2
Returns: the product of
arg0and the transposed ofarg1at each data pointReturn type: numpy.ndarray,escript.Data,Symboldepending on the inputRaises: ValueError – if the shapes of the arguments are not appropriate
- arg0 (
-
esys.escript.linearPDEs.matrixmult(arg0, arg1)¶ See
matrix_mult.
-
esys.escript.linearPDEs.maximum(*args)¶ The maximum over arguments
args.Parameters: args ( numpy.ndarray,escript.Data,Symbol,intorfloat) – argumentsReturns: an object which in each entry gives the maximum of the corresponding values in argsReturn type: numpy.ndarray,escript.Data,Symbol,intorfloatdepending on the input
-
esys.escript.linearPDEs.maxval(arg)¶ Returns the maximum value over all components of
argat each data point.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symboldepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.meanValue(arg)¶ return the mean value of the argument over its domain
Parameters: arg ( escript.Data) – functionReturns: mean value Return type: floatornumpy.ndarray
-
esys.escript.linearPDEs.minimum(*args)¶ The minimum over arguments
args.Parameters: args ( numpy.ndarray,escript.Data,Symbol,intorfloat) – argumentsReturns: an object which gives in each entry the minimum of the corresponding values in argsReturn type: numpy.ndarray,escript.Data,Symbol,intorfloatdepending on the input
-
esys.escript.linearPDEs.minval(arg)¶ Returns the minimum value over all components of
argat each data point.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symboldepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.mkDir(*pathname)¶ creates a directory of name
pathnameif the directory does not exist.Parameters: pathname ( strorsequence of strings) – valid path nameNote: The method is MPI safe.
-
esys.escript.linearPDEs.mult(arg0, arg1)¶ Product of
arg0andarg1.Parameters: - arg0 (
Symbol,float,int,escript.Dataornumpy.ndarray) – first term - arg1 (
Symbol,float,int,escript.Dataornumpy.ndarray) – second term
Returns: the product of
arg0andarg1Return type: Symbol,float,int,escript.Dataornumpy.ndarrayNote: The shape of both arguments is matched according to the rules used in
matchShape.- arg0 (
-
esys.escript.linearPDEs.negative(arg)¶ returns the negative part of arg
-
esys.escript.linearPDEs.nonsymmetric(arg)¶ Deprecated alias for antisymmetric
-
esys.escript.linearPDEs.normalize(arg, zerolength=0)¶ Returns the normalized version of
arg(=``arg/length(arg)``).Parameters: - arg (
escript.DataorSymbol) – function - zerolength (
float) – relative tolerance for arg == 0
Returns: normalized
argwhereargis non-zero, and zero elsewhereReturn type: escript.DataorSymbol- arg (
-
esys.escript.linearPDEs.outer(arg0, arg1)¶ The outer product of the two arguments. The outer product is defined as:
out[t,s]=arg0[t]*arg1[s]- where
- s runs through
arg0.Shape - t runs through
arg1.Shape
- s runs through
Parameters: - arg0 (
numpy.ndarray,escript.Data,Symbol,float,int) – first argument - arg1 (
numpy.ndarray,escript.Data,Symbol,float,int) – second argument
Returns: the outer product of
arg0andarg1at each data pointReturn type: numpy.ndarray,escript.Data,Symboldepending on the input
-
esys.escript.linearPDEs.phase(arg)¶ return the “phase”/”arg”/”angle” of a number
-
esys.escript.linearPDEs.pokeDim(arg)¶ 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 NoneReturn type: intorNone
-
esys.escript.linearPDEs.polarToCart(r, phase)¶ conversion from cartesian to polar coordinates
Parameters: - r (any float type object) – length
- phase (any float type object) – the phase angle in rad
Returns: cartesian representation as complex number
Return type: appropriate complex
-
esys.escript.linearPDEs.positive(arg)¶ returns the positive part of arg
-
esys.escript.linearPDEs.printParallelThreadCounts() → None¶
-
esys.escript.linearPDEs.releaseUnusedMemory() → None¶
-
esys.escript.linearPDEs.reorderComponents(arg, index)¶ Resorts the components of
argaccording to index.
-
esys.escript.linearPDEs.resolve(arg)¶ Returns the value of arg resolved.
-
esys.escript.linearPDEs.resolveGroup((object)arg1) → None¶
-
esys.escript.linearPDEs.runMPIProgram((list)arg1) → int :¶ Spawns an external MPI program using a separate communicator.
-
esys.escript.linearPDEs.safeDiv(arg0, arg1, rtol=None)¶ returns arg0/arg1 but return 0 where arg1 is (almost) zero
-
esys.escript.linearPDEs.saveDataCSV(filename, append=False, refid=False, sep=', ', csep='_', **data)¶ Writes
Dataobjects to a CSV file. These objects must have compatible FunctionSpaces, i.e. it must be possible to interpolate all data to oneFunctionSpace. Note, that with more than one MPI rank this function will fail for some function spaces on some domains.Parameters: - filename (
string) – file to save data to. - append (
bool) – IfTrue, then open file at end rather than beginning - refid (
bool) – IfTrue, then a list of reference ids will be printed in the first column - sep (
string) – separator between fields - csep – separator for components of rank 2 and above (e.g. ‘_’ -> c0_1)
The keyword args are Data objects to save. If a scalar
Dataobject is passed with the namemask, then only samples which correspond to positive values inmaskwill 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.
- filename (
-
esys.escript.linearPDEs.saveESD(datasetName, dataDir='.', domain=None, timeStep=0, deltaT=1, dynamicMesh=0, timeStepFormat='%04d', **data)¶ Saves
Dataobjects to files and creates anescript 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: - datasetName (
str) – name of the dataset, used to name the ESD file - dataDir (
str) – optional directory where the data files should be saved - domain (
escript.Domain) – domain of theDataobject(s). If not specified, the domain of the givenDataobjects is used. - timeStep (
int) – current timestep or sequence number - first one must be 0 - deltaT (
int) – timestep or sequence increment, see example above - dynamicMesh (
int) – by default the mesh is assumed to be static and thus only saved once at timestep 0 to save disk space. Setting this to 1 changes the behaviour and the mesh is saved at each timestep. - timeStepFormat (
str) – timestep format string (defaults to “%04d”) - <name> (
Dataobject) – writes the assigned value to the file using <name> as identifier
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.
- datasetName (
-
esys.escript.linearPDEs.setEscriptParamInt((str)name[, (int)value=0]) → None :¶ Modify the value of an escript tuning parameter
Parameters: - name (
string) – - value (
int) –
- name (
-
esys.escript.linearPDEs.setNumberOfThreads((int)arg1) → None :¶ Use of this method is strongly discouraged.
-
esys.escript.linearPDEs.showEscriptParams()¶ Displays the parameters escript recognises with an explanation and their current value.
-
esys.escript.linearPDEs.sign(arg)¶ Returns the sign of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.sin(arg)¶ Returns sine of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray.) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.sinh(arg)¶ Returns the hyperbolic sine of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.sqrt(arg)¶ Returns the square root of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.sup(arg)¶ Returns the maximum value over all data points.
Parameters: arg ( float,int,escript.Data,numpy.ndarray) – argumentReturns: maximum value of argover all components and all data pointsReturn type: floatRaises: TypeError – if type of argcannot be processed
-
esys.escript.linearPDEs.swap_axes(arg, axis0=0, axis1=1)¶ Returns the swap of
argby swapping the componentsaxis0andaxis1.Parameters: - arg (
escript.Data,Symbol,numpy.ndarray) – argument - axis0 (
int) – first axis.axis0must be non-negative and less than the rank ofarg. - axis1 (
int) – second axis.axis1must be non-negative and less than the rank ofarg.
Returns: argwith swapped componentsReturn type: escript.Data,Symbolornumpy.ndarraydepending on the type ofarg- arg (
-
esys.escript.linearPDEs.symmetric(arg)¶ 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 argReturn type: numpy.ndarray,escript.Data,Symboldepending on the input
-
esys.escript.linearPDEs.tan(arg)¶ Returns tangent of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.tanh(arg)¶ Returns the hyperbolic tangent of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.tensor_mult(arg0, arg1)¶ The tensor product of the two arguments.
For
arg0of rank 2 this isout[s0]=Sigma_{r0} arg0[s0,r0]*arg1[r0]or
out[s0,s1]=Sigma_{r0} arg0[s0,r0]*arg1[r0,s1]and for
arg0of rank 4 this isout[s0,s1,s2,s3]=Sigma_{r0,r1} arg0[s0,s1,r0,r1]*arg1[r0,r1,s2,s3]or
out[s0,s1,s2]=Sigma_{r0,r1} arg0[s0,s1,r0,r1]*arg1[r0,r1,s2]or
out[s0,s1]=Sigma_{r0,r1} arg0[s0,s1,r0,r1]*arg1[r0,r1]In the first case the second dimension of
arg0and the last dimension ofarg1must match and in the second case the two last dimensions ofarg0must match the two first dimensions ofarg1.Parameters: - arg0 (
numpy.ndarray,escript.Data,Symbol) – first argument of rank 2 or 4 - arg1 (
numpy.ndarray,escript.Data,Symbol) – second argument of shape greater than 1 or 2 depending on the rank ofarg0
Returns: the tensor product of
arg0andarg1at each data pointReturn type: numpy.ndarray,escript.Data,Symboldepending on the input- arg0 (
-
esys.escript.linearPDEs.tensor_transposed_mult(arg0, arg1)¶ The tensor product of the first and the transpose of the second argument.
For
arg0of rank 2 this isout[s0,s1]=Sigma_{r0} arg0[s0,r0]*arg1[s1,r0]and for
arg0of rank 4 this isout[s0,s1,s2,s3]=Sigma_{r0,r1} arg0[s0,s1,r0,r1]*arg1[s2,s3,r0,r1]or
out[s0,s1,s2]=Sigma_{r0,r1} arg0[s0,s1,r0,r1]*arg1[s2,r0,r1]In the first case the second dimension of
arg0andarg1must match and in the second case the two last dimensions ofarg0must match the two last dimensions ofarg1.The function call
tensor_transpose_mult(arg0,arg1)is equivalent totensor_mult(arg0,transpose(arg1)).Parameters: - arg0 (
numpy.ndarray,escript.Data,Symbol) – first argument of rank 2 or 4 - arg1 (
numpy.ndarray,escript.Data,Symbol) – second argument of shape greater of 1 or 2 depending on rank ofarg0
Returns: the tensor product of the transposed of
arg0andarg1at each data pointReturn type: numpy.ndarray,escript.Data,Symboldepending on the input- arg0 (
-
esys.escript.linearPDEs.tensormult(arg0, arg1)¶ See
tensor_mult.
-
esys.escript.linearPDEs.testForZero(arg)¶ Tests if the argument is identical to zero.
Parameters: arg (typically numpy.ndarray,escript.Data,float,int) – the object to test for zeroReturns: True if the argument is identical to zero, False otherwise Return type: bool
-
esys.escript.linearPDEs.trace(arg, axis_offset=0)¶ Returns the trace of
argwhich is the sum ofarg[k,k]over k.Parameters: - arg (
escript.Data,Symbol,numpy.ndarray) – argument - axis_offset (
int) –axis_offsetto components to sum over.axis_offsetmust be non-negative and less than the rank ofarg+1. The dimensions of componentaxis_offsetand axis_offset+1 must be equal.
Returns: trace of arg. The rank of the returned object is rank of
argminus 2.Return type: escript.Data,Symbolornumpy.ndarraydepending on the type ofarg- arg (
-
esys.escript.linearPDEs.transpose(arg, axis_offset=None)¶ Returns the transpose of
argby swapping the firstaxis_offsetand the lastrank-axis_offsetcomponents.Parameters: - arg (
escript.Data,Symbol,numpy.ndarray,float,int) – argument - axis_offset (
int) – the firstaxis_offsetcomponents are swapped with the rest.axis_offsetmust be non-negative and less or equal to the rank ofarg. Ifaxis_offsetis not presentint(r/2)where r is the rank ofargis used.
Returns: transpose of
argReturn type: escript.Data,Symbol,numpy.ndarray,float,intdepending on the type ofarg- arg (
-
esys.escript.linearPDEs.transposed_matrix_mult(arg0, arg1)¶ transposed(matrix)-matrix or transposed(matrix)-vector product of the two arguments.
out[s0]=Sigma_{r0} arg0[r0,s0]*arg1[r0]or
out[s0,s1]=Sigma_{r0} arg0[r0,s0]*arg1[r0,s1]The function call
transposed_matrix_mult(arg0,arg1)is equivalent tomatrix_mult(transpose(arg0),arg1).The first dimension of
arg0andarg1must match.Parameters: - arg0 (
numpy.ndarray,escript.Data,Symbol) – first argument of rank 2 - arg1 (
numpy.ndarray,escript.Data,Symbol) – second argument of at least rank 1
Returns: the product of the transpose of
arg0andarg1at each data pointReturn type: numpy.ndarray,escript.Data,Symboldepending on the inputRaises: ValueError – if the shapes of the arguments are not appropriate
- arg0 (
-
esys.escript.linearPDEs.transposed_tensor_mult(arg0, arg1)¶ The tensor product of the transpose of the first and the second argument.
For
arg0of rank 2 this isout[s0]=Sigma_{r0} arg0[r0,s0]*arg1[r0]or
out[s0,s1]=Sigma_{r0} arg0[r0,s0]*arg1[r0,s1]and for
arg0of rank 4 this isout[s0,s1,s2,s3]=Sigma_{r0,r1} arg0[r0,r1,s0,s1]*arg1[r0,r1,s2,s3]or
out[s0,s1,s2]=Sigma_{r0,r1} arg0[r0,r1,s0,s1]*arg1[r0,r1,s2]or
out[s0,s1]=Sigma_{r0,r1} arg0[r0,r1,s0,s1]*arg1[r0,r1]In the first case the first dimension of
arg0and the first dimension ofarg1must match and in the second case the two first dimensions ofarg0must match the two first dimensions ofarg1.The function call
transposed_tensor_mult(arg0,arg1)is equivalent totensor_mult(transpose(arg0),arg1).Parameters: - arg0 (
numpy.ndarray,escript.Data,Symbol) – first argument of rank 2 or 4 - arg1 (
numpy.ndarray,escript.Data,Symbol) – second argument of shape greater of 1 or 2 depending on the rank ofarg0
Returns: the tensor product of transpose of arg0 and arg1 at each data point
Return type: numpy.ndarray,escript.Data,Symboldepending on the input- arg0 (
-
esys.escript.linearPDEs.unitVector(i=0, d=3)¶ Returns a unit vector u of dimension d whose non-zero element is at index i.
Parameters: - i (
int) – index for non-zero element - d (
int,escript.Domainorescript.FunctionSpace) – dimension or an object that has thegetDimmethod defining the dimension
Returns: the object u of rank 1 with u[j]=1 for j=index and u[j]=0 otherwise
Return type: numpy.ndarrayorescript.Dataof rank 1- i (
-
esys.escript.linearPDEs.vol(arg)¶ Returns the volume or area of the oject
argParameters: arg ( escript.FunctionSpaceorescript.Domain) – a geometrical objectReturn type: float
-
esys.escript.linearPDEs.whereNegative(arg)¶ Returns mask of negative values of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.whereNonNegative(arg)¶ Returns mask of non-negative values of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.whereNonPositive(arg)¶ Returns mask of non-positive values of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.whereNonZero(arg, tol=0.0)¶ Returns mask of values different from zero of argument
arg.Parameters: - arg (
float,escript.Data,Symbol,numpy.ndarray) – argument - tol (
float) – absolute tolerance. Values with absolute value less than tol are accepted as zero. Iftolis not presentrtol``*```Lsup` (arg)is used.
Return type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: - ValueError – if
rtolis non-negative. - TypeError – if the type of the argument is not expected
- arg (
-
esys.escript.linearPDEs.wherePositive(arg)¶ Returns mask of positive values of argument
arg.Parameters: arg ( float,escript.Data,Symbol,numpy.ndarray.) – argumentReturn type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: TypeError – if the type of the argument is not expected
-
esys.escript.linearPDEs.whereZero(arg, tol=None, rtol=1.4901161193847656e-08)¶ Returns mask of zero entries of argument
arg.Parameters: - arg (
float,escript.Data,Symbol,numpy.ndarray) – argument - tol (
float) – absolute tolerance. Values with absolute value less than tol are accepted as zero. Iftolis not presentrtol``*```Lsup` (arg)is used. - rtol (non-negative
float) – relative tolerance used to define the absolute tolerance iftolis not present.
Return type: float,escript.Data,Symbol,numpy.ndarraydepending on the type ofargRaises: - ValueError – if
rtolis non-negative. - TypeError – if the type of the argument is not expected
- arg (
-
esys.escript.linearPDEs.zeros(shape=())¶ Returns the
shapezero tensor.Parameters: shape ( tupleofint) – input shape for the identity tensorReturns: array of shape filled with zeros Return type: numpy.ndarray
Others¶
- DBLE_MAX
- EPSILON