esys.escript Package¶
Classes and tools that form the basis of the escript system. Specific solvers and domains are found in their respective packages.
Classes¶
- class esys.escript.ContinuousDomain¶
Class representing continuous domains
- __init__()¶
Raises an exception This class cannot be instantiated from Python
- 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
- 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
- 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 : ¶
- getDataShape((ContinuousDomain)arg1, (object)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
- getNumDataPointsGlobal((ContinuousDomain)arg1) int : ¶
- Returns
the number of data points summed across all MPI processes
- 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
- getTransportTypeId((ContinuousDomain)arg1, (object)solver, (object)preconditioner, (object)package, (object)symmetry) int ¶
- newOperator((ContinuousDomain)arg1, (object)row_blocksize, (FunctionSpace)row_functionspace, (object)column_blocksize, (FunctionSpace)column_functionspace, (object)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
) –
- newTransportProblem((ContinuousDomain)theta, (object)blocksize, (FunctionSpace)functionspace, (object)type) TransportProblem : ¶
creates a TransportProblemAdapter
- Parameters
theta (
float
) –blocksize (
int
) –functionspace (
FunctionSpace
) –type (
int
) –
- print_mesh_info((ContinuousDomain)arg1[, (object)full=False]) None : ¶
- Parameters
full (
bool
) –
- class esys.escript.Data¶
Represents 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
- copy((Data)arg1, (Data)other) None : ¶
Make this object a copy of
other
- note
The two objects will act independently from now on. That is, changing
other
after this call will not change this object and vice versa.
- 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
other
Data
.Datapoints which correspond to positive values inmask
will be copied fromother
- 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
- getNumberOfDataPoints((Data)arg1) int : ¶
- Return type
int
- Returns
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, (object)dpno) int : ¶
Return tag number for the specified datapoint
- Return type
int
- Parameters
dpno (int) – datapoint number
- getTupleForDataPoint((Data)arg1, (object)dataPointNo) object : ¶
- Returns
Value of the specified datapoint
- Return type
tuple
- Parameters
dataPointNo (
int
) – datapoint to access
- getTupleForGlobalDataPoint((Data)arg1, (object)procNo, (object)dataPointNo) object : ¶
Get a specific datapoint from a specific process
- Return type
tuple
- Parameters
procNo (positive
int
) – MPI rank of the processdataPointNo (int) – datapoint to access
- 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.]
- 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, (object)Amin, (object)Astep, (Data)B, (object)Bmin, (object)Bstep[, (object)undef=1e+50[, (object)check_boundaries=False]]) Data : ¶
- Creates a new Data object by interpolating using the source data (which are
looked up in
table
)A
must be the outer dimension on the table- param table
two dimensional collection of values
- param Amin
The base of locations in table
- type Amin
float
- param Astep
size of gap between each item in the table
- type Astep
float
- param undef
upper bound on interpolated values
- type undef
float
- param B
Scalar representing the second coordinate to be mapped into the table
- type B
- param Bmin
The base of locations in table for 2nd dimension
- type Bmin
float
- param Bstep
size of gap between each item in the table for 2nd dimension
- type Bstep
float
- param check_boundaries
if true, then values outside the boundaries will be rejected. If false, then boundary values will be used.
- raise RuntimeError(DataException)
if the coordinates do not map into the table or if the interpolated value is above
undef
- rtype
interpolateTable( (Data)arg1, (object)table, (object)Amin, (object)Astep [, (object)undef=1e+50 [, (object)check_boundaries=False]]) -> Data
- isComplex((Data)arg1) bool : ¶
- Return type
bool
- Returns
True if this
Data
stores complex values.
- isConstant((Data)arg1) bool : ¶
- Return type
bool
- Returns
True if this
Data
is an instance ofDataConstant
- Note
This does not mean the data is immutable.
- isEmpty((Data)arg1) bool : ¶
Is this object an instance of
DataEmpty
- Return type
bool
- Note
This is not the same thing as asking if the object contains datapoints.
- isExpanded((Data)arg1) bool : ¶
- Return type
bool
- Returns
True if this
Data
is expanded.
- isLazy((Data)arg1) bool : ¶
- Return type
bool
- Returns
True if this
Data
is lazy.
- isProtected((Data)arg1) bool : ¶
Can this instance be modified. :rtype:
bool
- isReady((Data)arg1) bool : ¶
- Return type
bool
- Returns
True if this
Data
is not lazy.
- isTagged((Data)arg1) bool : ¶
- Return type
bool
- Returns
True if this
Data
is expanded.
- nonuniformInterpolate((Data)arg1, (object)in, (object)out, (object)check_boundaries) Data : ¶
1D interpolation with non equally spaced points
- nonuniformSlope((Data)arg1, (object)in, (object)out, (object)check_boundaries) Data : ¶
1D interpolation of slope with non equally spaced points
- promote((Data)arg1) None ¶
- 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, (object)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
string
- param value
value to set tagged data to
- type value
object
which acts like an array,tuple
orlist
- 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, (object)dataPointNo, (object)value) None ¶
setValueOfDataPoint( (Data)arg1, (object)arg2, (object)arg3) -> None
setValueOfDataPoint( (Data)arg1, (object)arg2, (object)arg3) -> None :
Modify the value of a single datapoint.
- param dataPointNo
- type dataPointNo
int
- param value
- type value
float
or an object which acts like an array,tuple
orlist
- warning
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[, (object)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.DataManager(formats=[0], work_dir='.', restart_prefix='restart', do_restart=True)¶
Escript data import/export manager.
Example:
dm=DataManager(formats=[DataManager.RESTART,DataManager.VTK]) if dm.hasData(): dom = dm.getDomain() time = dm.getValue("time") dt = dm.getValue("dt") T = dm.getValue("T") u = dm.getValue("u") else: T = ... u = ... dm.addData(time=time,dt=dt,T=T,u=u) # add data and variables dm.setTime(time) # set the simulation timestamp dm.export() # write out data
- __init__(formats=[0], work_dir='.', restart_prefix='restart', do_restart=True)¶
Initialises the data manager. If do_restart is True and a restart directory is found the contained data is loaded (hasData() returns True) otherwise restart directories are removed (hasData() returns False). Values are only written to disk when export() is called.
- Parameters
formats – A list of export file formats to use. Allowed values are RESTART, SILO, VISIT, VTK.
work_dir – top-level directory where files are exported to
restart_prefix – prefix for restart directories. Will be used to load restart files (if do_restart is True) and store new restart files (if RESTART is used)
do_restart – whether to attempt to load restart files
- RESTART = 0¶
- SILO = 1¶
- VISIT = 2¶
- VTK = 3¶
- addData(**data)¶
Adds ‘escript.Data’ objects and other data to be exported to this manager.
- Note
This method does not make copies of Data objects so any modifications will be carried over until export() is called.
- export()¶
Executes the actual data export. Depending on the formats parameter used in the constructor all data added by addData() is written to disk (RESTART,SILO,VTK) or made available through the VisIt simulation interface (VISIT).
- getCycle()¶
Returns the export cycle (=number of times export() has been called)
- getDomain()¶
Returns the domain as recovered from restart files.
- getValue(value_name)¶
Returns an ‘escript.Data’ object or other value that has been loaded from restart files.
- hasData()¶
Returns True if the manager holds data for restart
- setCheckpointFrequency(freq)¶
Sets the number of calls to export() before new restart files are generated.
- setDomain(domain)¶
Sets the domain without adding data.
- setMeshLabels(x, y, z='')¶
Sets labels for the mesh axes. These are currently only used by the Silo exporter.
- setMeshUnits(x, y, z='')¶
Sets units for the mesh axes. These are currently only used by the Silo exporter.
- setMetadataSchemaString(schema, metadata='')¶
Sets metadata namespaces and the corresponding metadata. Only used for the VTK file format at the moment.
- Parameters
schema – A dictionary that maps namespace prefixes to namespace names, e.g. {‘gml’:’http://www.opengis.net/gml’}
metadata – The actual metadata string which will be enclosed in ‘<MetaData>’ tags.
- setTime(time)¶
Sets the simulation timestamp.
- class esys.escript.Domain¶
Base 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
Domain
- Return type
int
- getNormal((Domain)arg1) Data : ¶
- Return type
escript
- Returns
Boundary normals
- getNumpyX((Domain)arg1) numpy.ndarray : ¶
- Return type
numpy ndarray
- Returns
Locations in the`Domain`. FunctionSpace is chosen appropriately
- getSize((Domain)arg1) Data : ¶
- Returns
the local size of samples. The function space is chosen appropriately
- Return type
- 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
name
- Return type
string
- getX((Domain)arg1) Data : ¶
- Return type
- Returns
Locations in the`Domain`. FunctionSpace is chosen appropriately
- isCellOriented((Domain)arg1, (object)functionSpaceCode) bool : ¶
- Returns
true is the data is cell centered.
- Return type
int
- isValidTagName((Domain)arg1, (str)name) bool : ¶
- Returns
True is
name
corresponds to a tag- Return 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, (object)tag) None : ¶
Give a tag number a name.
- Parameters
name (
string
) – Name for the tagtag (
int
) – numeric id
- Note
Tag names must be unique within a domain
- 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.Evaluator(*expressions)¶
- __init__(*expressions)¶
Returns a symbolic evaluator.
- Parameters
expressions – optional expressions to initialise with
- addExpression(expression)¶
Adds an expression to this evaluator.
- Returns
the modified Evaluator object
- evaluate(evalf=False, **args)¶
Evaluates all expressions in this evaluator and returns the result as a tuple.
- Returns
the evaluated expressions in the order they were added to this Evaluator.
- subs(**args)¶
Symbol substitution.
- Returns
the modified Evaluator object
- class esys.escript.FileWriter(fn, append=False, createLocalFiles=False)¶
Interface to write data to a file. In essence this class wrappes the standard
file
object to write data that are global in MPI to a file. In fact, data are writen on the processor with MPI rank 0 only. It is recommended to useFileWriter
rather thanopen
in order to write code that is running with as well as with MPI. It is safe to useopen
onder 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
fn
for writing. If running under MPI only the first processor with rank==0 will open the file and write to it. IfcreateLocalFiles
each 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.
- close()¶
Closes the file
- flush()¶
Flush the internal I/O buffer.
- write(txt)¶
Write string
txt
to file.- Parameters
txt (
str
) – stringtxt
to be written to file
- writelines(txts)¶
Write the list
txt
of strings to the file.- Parameters
txts (any iterable object producing strings) – sequense of strings to be written to file
- Note
Note that newlines are not added. This method is equivalent to call write() for each string.
- class esys.escript.FunctionJob(fn, *args, **kwargs)¶
Takes a python function (with only self and keyword params) to be called as the work method
- __init__(fn, *args, **kwargs)¶
It ignores all of its parameters, except that, it requires the following as keyword arguments
- Variables
domain – Domain to be used as the basis for all
Data
and PDEs in this Job.jobid – sequence number of this job. The first job has id=1
- work()¶
Need to be overloaded for the job to actually do anthing. A return value of True indicates this job thinks it is done. A return value of False indicates work still to be done
- class esys.escript.FunctionSpace¶
A FunctionSpace describes which points from the
Domain
to 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 : ¶
- getListOfTags((FunctionSpace)arg1) list : ¶
- Returns
a list of the tags used in this function space
- Return type
list
- getReferenceIDFromDataPointNo((FunctionSpace)arg1, (object)dataPointNo) int : ¶
- Returns
the reference number associated with
dataPointNo
- Return type
int
- getTagFromDataPointNo((FunctionSpace)arg1, (object)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
- setTags((FunctionSpace)arg1, (object)newtag, (Data)mask) None : ¶
Set tags according to a mask
- param newtag
tag number to set
- type newtag
string, non-zero
int
- param mask
Samples which correspond to positive values in the mask will be set to
newtag
.- type mask
scalar
Data
setTags( (FunctionSpace)arg1, (str)newtag, (Data)mask) -> None
- class esys.escript.Internal_SplitWorld¶
Manages a group of sub worlds. For internal use only.
- __init__((object)arg1, (object)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.Job(*args, **kwargs)¶
Describes a sequence of work to be carried out in a subworld. The instances of this class used in the subworlds will be constructed by the system. To do specific work, this class should be subclassed and the work() (and possibly __init__ methods overloaded). The majority of the work done by the job will be in the overloaded work() method. The work() method should retrieve values from the outside using importValue() and pass values to the rest of the system using exportValue(). The rest of the methods should be considered off limits.
- __init__(*args, **kwargs)¶
It ignores all of its parameters, except that, it requires the following as keyword arguments
- Variables
domain – Domain to be used as the basis for all
Data
and PDEs in this Job.jobid – sequence number of this job. The first job has id=1
- clearExports()¶
Remove exported values from the map
- clearImports()¶
Remove imported values from their map
- declareImport(name)¶
Adds name to the list of imports
- exportValue(name, v)¶
Make value v available to other Jobs under the label name. name must have already been registered with the SplitWorld instance. For use inside the work() method.
- Variables
name – registered label for exported value
v – value to be imported
- importValue(name)¶
For use inside the work() method.
- Variables
name – label for imported value.
- setImportValue(name, v)¶
Use to make a value available to the job (ie called from outside the job)
- Variables
name – label used to identify this import
v – value to be imported
- work()¶
Need to be overloaded for the job to actually do anthing. A return value of True indicates this job thinks it is done. A return value of False indicates work still to be done
- class esys.escript.NonlinearPDE(domain, u, debug=0)¶
This class is used to define a general nonlinear, steady, second order PDE for an unknown function u on a given domain defined through a
Domain
object.For a single PDE having a solution with a single component the nonlinear PDE is defined in the following form:
-div(X) + Y = 0
where X,*Y*=f(u,*grad(u)*). div(F) denotes the divergence of F and grad(F) is the spatial derivative of F.
The coefficients X (rank 1) and Y (scalar) have to be specified through
Symbol
objects.The following natural boundary conditions are considered:
n[j]*X[j] + y = 0
where n is the outer normal field. Notice that the coefficient X is defined in the PDE. The coefficient y is a scalar
Symbol
.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.
For a system of PDEs and a solution with several components, u is rank one, while the PDE coefficient X is rank two and y is rank one.
The PDE is solved by linearising the coefficients and iteratively solving the corresponding linear PDE until the error is smaller than a tolerance or a maximum number of iterations is reached.
Typical usage:
u = Symbol('u', dim=dom.getDim()) p = NonlinearPDE(dom, u) p.setValue(X=grad(u), Y=1+5*u) v = p.getSolution(u=0.)
- __init__(domain, u, debug=0)¶
Initializes a new nonlinear PDE.
- DEBUG0 = 0¶
- DEBUG1 = 1¶
- DEBUG2 = 2¶
- DEBUG3 = 3¶
- DEBUG4 = 4¶
- ORDER = 0¶
- createCoefficient(name)¶
Creates a new coefficient
name
as Symbol- Parameters
name (
string
) – name of the coefficient requested- Returns
the value of the coefficient
- Return type
- Raises
IllegalCoefficient – if
name
is not a coefficient of the PDE
- getCoefficient(name)¶
Returns the value of the coefficient
name
as Symbol- Parameters
name (
string
) – name of the coefficient requested- Returns
the value of the coefficient
- Return type
- Raises
IllegalCoefficient – if
name
is not a coefficient of the PDE
- getLinearPDE()¶
Returns the linear PDE used to calculate the Newton-Raphson update
- Return type
LinearPDE
- getLinearSolverOptions()¶
Returns the options of the linear PDE solver class
- getNumSolutions()¶
Returns the number of the solution components :rtype:
int
- getSensitivity(f, g=None, **subs)¶
Calculates the sensitivity of the solution of an input factor
f
in directiong
.- Parameters
f (
Symbol
) – the input factor to be investigated.f
may be of rank 0 or 1.g (
list
or single offloat
,numpy.array
orData
.) – the direction(s) of change. If not present, it is g=eye(n) wheren
is the number of components off
.subs – Substitutions for all symbols used in the coefficients including unknown u and the input factor
f
to be investigated
- Returns
the sensitivity
- Return type
Data
with shape u.getShape()+(len(g),) if len(g)>1 or u.getShape() if len(g)==1
- getShapeOfCoefficient(name)¶
Returns the shape of the coefficient
name
- Parameters
name (
string
) – name of the coefficient enquired- Returns
the shape of the coefficient
name
- Return type
tuple
ofint
- Raises
IllegalCoefficient – if
name
is not a coefficient of the PDE
- getSolution(**subs)¶
Returns the solution of the PDE.
- Parameters
subs – Substitutions for all symbols used in the coefficients including the initial value for the unknown u.
- Returns
the solution
- Return type
- getUnknownSymbol()¶
Returns the symbol of the PDE unknown
- Returns
the symbol of the PDE unknown
- Return type
- setOptions(**opts)¶
Allows setting options for the nonlinear PDE.
- The supported options are:
tolerance
error tolerance for the Newton method
iteration_steps_max
maximum number of Newton iterations
omega_min
minimum relaxation factor
atol
solution norms less than
atol
are assumed to beatol
. This can be useful if one of your solutions is expected to be zero.quadratic_convergence_limit
if the norm of the Newton-Raphson correction is reduced by less than
quadratic_convergence_limit
between two iteration steps quadratic convergence is assumed.simplified_newton_limit
if the norm of the defect is reduced by less than
simplified_newton_limit
between two iteration steps and quadratic convergence is detected the iteration switches to the simplified Newton-Raphson scheme.
- setValue(**coefficients)¶
Sets new values to one or more coefficients.
- Parameters
coefficients – new values assigned to coefficients
coefficients – new values assigned to coefficients
X (
Symbol
or any type that can be cast to aData
object) – value for coefficientX
Y (
Symbol
or any type that can be cast to aData
object) – value for coefficientY
y (
Symbol
or any type that can be cast to aData
object) – value for coefficienty
y_contact (
Symbol
or any type that can be cast to aData
object) – value for coefficienty_contact
y_dirac (
Symbol
or any type that can be cast to aData
object) – value for coefficienty_dirac
q (any type that can be cast to a
Data
object) – mask for location of constraintr (
Symbol
or any type that can be cast to aData
object) – value of solution prescribed by constraint
- Raises
IllegalCoefficient – if an unknown coefficient keyword is used
IllegalCoefficientValue – if a supplied coefficient value has an invalid shape
- trace1(text)¶
Prints the text message if the debug level is greater than DEBUG0
- Parameters
text (
string
) – message to be printed
- trace3(text)¶
Prints the text message if the debug level is greater than DEBUG3
- Parameters
text (
string
) – message to be printed
- class esys.escript.Operator¶
- __init__((object)arg1) None ¶
- isEmpty((Operator)arg1) bool : ¶
- Return type
bool
- Returns
True if matrix is empty
- nullifyRowsAndCols((Operator)arg1, (Data)arg2, (Data)arg3, (object)arg4) None ¶
- of((Operator)arg1, (Data)right) Data : ¶
matrix*vector multiplication
- resetValues((Operator)arg1, (object)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.Reducer¶
- __init__()¶
Raises an exception This class cannot be instantiated from Python
- class esys.escript.SolverBuddy¶
- __init__((object)arg1) None ¶
- acceptConvergenceFailure((SolverBuddy)arg1) bool : ¶
Returns
True
if 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 thehasConverged
method to check if the last call to the solver was successful.- Returns
True
if a failure to achieve convergence is accepted.- Return type
bool
- adaptInnerTolerance((SolverBuddy)arg1) bool : ¶
Returns
True
if the tolerance of the inner solver is selected automatically. Otherwise the inner tolerance set bysetInnerTolerance
is used.- Returns
True
if 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 (
str
in the list above.) – name of diagnostic information to return- Returns
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, (object)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
True
if 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
True
if the solver is expected to be verbose.- Returns
True if verbosity of switched on.
- Return type
bool
- resetDiagnostics((SolverBuddy)arg1[, (object)all=False]) None : ¶
Resets the diagnostics
- Parameters
all (
bool
) – ifall
isTrue
all diagnostics including accumulative counters are reset.
- setAbsoluteTolerance((SolverBuddy)arg1, (object)atol) None : ¶
Sets the absolute tolerance for the solver
- Parameters
atol (non-negative
float
) – absolute tolerance
- setAcceptanceConvergenceFailure((SolverBuddy)arg1, (object)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, (object)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, (object)dim) None : ¶
Sets the dimension of the problem.
- Parameters
dim – Either 2 or 3.
- Return type
int
- setDropStorage((SolverBuddy)arg1, (object)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, (object)drop_tol) None : ¶
Sets the relative drop tolerance in ILUT
- Parameters
drop_tol (positive
float
) – drop tolerance
- setHermitian((SolverBuddy)arg1, (object)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, (object)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, (object)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, (object)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, (object)iter_max) None : ¶
Sets the maximum number of iteration steps
- Parameters
iter_max (
int
) – maximum number of iteration steps
- setLocalPreconditioner((SolverBuddy)arg1, (object)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, (object)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, (object)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, (object)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, (object)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, (object)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, (object)relaxation) None : ¶
Sets the relaxation factor used to add dropped elements in RILU to the main diagonal.
- Parameters
factor (
float
) – relaxation factor- Note
RILU with a relaxation factor 0 is identical to ILU0
- setReordering((SolverBuddy)arg1, (object)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, (object)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, (object)method) None : ¶
Sets the solver method to be used. Use
method``=``DIRECT
to indicate that a direct rather than an iterative solver should be used and usemethod``=``ITERATIVE
to 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, (object)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, (object)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, (object)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, (object)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
True
if 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
True
if local preconditioning is applied- Return type
bool
- class esys.escript.SolverOptions¶
- __init__()¶
- 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¶
- 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}¶
- 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.SplitWorld(count)¶
Wrapper for the C++ class exposed as __SplitWorld. This is a namespace consideration, it allows us to make boost::python::raw_functions into members of a class.
- __init__(count)¶
- Variables
count – How many equally sized subworlds should our compute resources be partitioned into?
- addJob(jobctr, *vec, **kwargs)¶
Submit a job to be run later on an available subworld.
- Variables
jobctr – class or function to be called to create a job
The remaining parameters are for the arguments of the function.
- addJobPerWorld(jobctr, *vec, **kwargs)¶
Submit one job per subworld to run later.
- Variables
jobctr – class or function to be called to create a job
The remaining parameters are for the arguments of the function.
- addVariable(vname, vartype, *vec, **kwargs)¶
Create a variable on all subworlds.
- Variables
vartype – the type of variable to be created
The remaining parameters are for optional arguments depending on the variable type.
- buildDomains(fn, *vec, **kwargs)¶
Instruct subworlds how to build the domain.
- Variables
fn – The function/class to call to create a domain.
The remaining parameters are for the arguments of the function.
- clearVariable(vname)¶
Clears the value of the named variable. The variable itself still exists.
- Variables
vname – variable to clear
- copyVariable(src, dest)¶
copy the contents of one splitworld variable into another
- Variables
src – name of variable to copy from
dest – name of variable to copy to
- getFloatVariable(vname)¶
Return the value of a floating point variable
- getLocalObjectVariable(vname)¶
Return the value of a local object variable - that is, an object (eg tuple) which does not need to be reduced/shared between worlds
- getSubWorldCount()¶
Return the number of subworlds in this splitworld
- getSubWorldID()¶
Return the id of the subworld which _this_ MPI process belongs to.
- getVarInfo()¶
Returns the names of all declared variables and a description of type. The details of the output are not fixed and may change without notice
- getVarList()¶
Returns the names of all declared variables and a boolean for each indicating whether they have values.
- removeVariable(vname)¶
Removes the named variable from all subworlds.
- Variables
vname – What to remove
- runJobs()¶
Executes pending jobs.
- class esys.escript.SubWorld¶
Information about a group of workers.
- __init__()¶
Raises an exception This class cannot be instantiated from Python
- class esys.escript.Symbol(*args, **kwargs)¶
Symbol
objects are placeholders for a single mathematical symbol, such as ‘x’, or for arbitrarily complex mathematical expressions such as ‘c*x**4+alpha*exp(x)-2*sin(beta*x)’, where ‘alpha’, ‘beta’, ‘c’, and ‘x’ are also Symbols (the symbolic ‘atoms’ of the expression).With the help of the ‘Evaluator’ class these symbols and expressions can be resolved by substituting numeric values and/or escript
Data
objects for the atoms. To facilitate the use ofData
objects aSymbol
has a shape (and thus a rank) as well as a dimension (see constructor). Symbols are useful to perform mathematical simplifications, compute derivatives and as coefficients for nonlinear PDEs which can be solved by theNonlinearPDE
class.- __init__(*args, **kwargs)¶
Initialises a new
Symbol
object in one of three ways:u=Symbol('u')
returns a scalar symbol by the name ‘u’.
alpha=Symbol(‘alpha’, (4,3))
returns a rank 2 symbol with the shape (4,3), whose elements are named ‘[alpha]_i_j’ (with i=0..3, j=0..2).
a,b,c=symbols(‘a,b,c’) x=Symbol([[a+b,0,0],[0,b-c,0],[0,0,c-a]])
returns a rank 2 symbol with the shape (3,3) whose elements are explicitly specified by numeric values and other symbols/expressions within a list or numpy array.
The dimensionality of the symbol can be specified through the
dim
keyword. All other keywords are passed to the underlying symbolic library (currently sympy).- Parameters
args – initialisation arguments as described above
dim (
int
) – dimensionality of the new Symbol (default: 2)
- applyfunc(f, on_type=None)¶
Applies the function
f
to all elements (if on_type is None) or to all elements of typeon_type
.
- atoms(*types)¶
Returns the atoms that form the current Symbol.
By default, only objects that are truly atomic and cannot be divided into smaller pieces are returned: symbols, numbers, and number symbols like I and pi. It is possible to request atoms of any type, however.
Note that if this symbol contains components such as [x]_i_j then only their main symbol ‘x’ is returned.
- Parameters
types – types to restrict result to
- Returns
list of atoms of specified type
- Return type
set
- coeff(x, expand=True)¶
Returns the coefficient of the term “x” or 0 if there is no “x”.
If “x” is a scalar symbol then “x” is searched in all components of this symbol. Otherwise the shapes must match and the coefficients are checked component by component.
Example:
x=Symbol('x', (2,2)) y=3*x print y.coeff(x) print y.coeff(x[1,1])
will print:
[[3 3] [3 3]] [[0 0] [0 3]]
- Parameters
x (
Symbol
,numpy.ndarray
,list
) – the term whose coefficients are to be found- Returns
the coefficient(s) of the term
- Return type
Symbol
- diff(*symbols, **assumptions)¶
- evalf()¶
Applies the sympy.evalf operation on all elements in this symbol
- expand()¶
Applies the sympy.expand operation on all elements in this symbol
- getDataSubstitutions()¶
Returns a dictionary of symbol names and the escript
Data
objects they represent within this Symbol.- Returns
the dictionary of substituted
Data
objects- Return type
dict
- getDim()¶
Returns the spatial dimensionality of this symbol.
- Returns
the symbol’s spatial dimensionality, or -1 if undefined
- Return type
int
- getRank()¶
Returns the rank of this symbol.
- Returns
the symbol’s rank which is equal to the length of the shape.
- Return type
int
- getShape()¶
Returns the shape of this symbol.
- Returns
the symbol’s shape
- Return type
tuple
ofint
- grad(where=None)¶
Returns a symbol which represents the gradient of this symbol. :type where:
Symbol
,FunctionSpace
- inverse()¶
- is_Add = False¶
- is_Float = False¶
- item(*args)¶
Returns an element of this symbol. This method behaves like the item() method of numpy.ndarray. If this is a scalar Symbol, no arguments are allowed and the only element in this Symbol is returned. Otherwise, ‘args’ specifies a flat or nd-index and the element at that index is returned.
- Parameters
args – index of item to be returned
- Returns
the requested element
- Return type
sympy.Symbol
,int
, orfloat
- lambdarepr()¶
- simplify()¶
Applies the sympy.simplify operation on all elements in this symbol
- subs(old, new)¶
Substitutes an expression.
- swap_axes(axis0, axis1)¶
- tensorProduct(other, axis_offset)¶
- tensorTransposedProduct(other, axis_offset)¶
- trace(axis_offset)¶
Returns the trace of this Symbol.
- transpose(axis_offset)¶
Returns the transpose of this Symbol.
- transposedTensorProduct(other, axis_offset)¶
- class esys.escript.TestDomain¶
Test 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
- class esys.escript.TransportProblem¶
- __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, (object)arg2) None : ¶
resets the transport operator typically as they have been updated.
- resetValues((TransportProblem)arg1, (object)arg2) None ¶
Functions¶
- esys.escript.Abs(arg)¶
Returns the absolute value of argument
arg
.
- esys.escript.C_GeneralTensorProduct((Data)arg0, (Data)arg1[, (object)axis_offset=0[, (object)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.ComplexData((object)value[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d296f8190>[, (object)expanded=False]]) Data ¶
- esys.escript.ComplexScalar([(object)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697990>[, (object)expanded=False]]]) Data : ¶
Construct a Data object containing scalar data-points.
- Parameters
value (float) – scalar value for all points
what (
FunctionSpace
) – FunctionSpace for Dataexpanded (
bool
) – If True, a value is stored for each point. If False, more efficient representations may be used
- Return type
- esys.escript.ComplexTensor([(object)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697c30>[, (object)expanded=False]]]) Data : ¶
Construct a Data object containing rank2 data-points.
- param value
scalar value for all points
- rtype
- type value
float
- param what
FunctionSpace for Data
- type what
- param expanded
If True, a value is stored for each point. If False, more efficient representations may be used
- type expanded
bool
ComplexTensor( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697d10> [, (object)expanded=False]]) -> Data
- esys.escript.ComplexTensor3([(object)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697df0>[, (object)expanded=False]]]) Data : ¶
Construct a Data object containing rank3 data-points.
- param value
scalar value for all points
- rtype
- type value
float
- param what
FunctionSpace for Data
- type what
- param expanded
If True, a value is stored for each point. If False, more efficient representations may be used
- type expanded
bool
ComplexTensor3( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697f40> [, (object)expanded=False]]) -> Data
- esys.escript.ComplexTensor4([(object)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d296f8040>[, (object)expanded=False]]]) Data : ¶
Construct a Data object containing rank4 data-points.
- param value
scalar value for all points
- rtype
- type value
float
- param what
FunctionSpace for Data
- type what
- param expanded
If True, a value is stored for each point. If False, more efficient representations may be used
- type expanded
bool
ComplexTensor4( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d296f8120> [, (object)expanded=False]]) -> Data
- esys.escript.ComplexVector([(object)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697a70>[, (object)expanded=False]]]) Data : ¶
Construct a Data object containing rank1 data-points.
- param value
scalar value for all points
- rtype
- type value
float
- param what
FunctionSpace for Data
- type what
- param expanded
If True, a value is stored for each point. If False, more efficient representations may be used
- type expanded
bool
ComplexVector( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697b50> [, (object)expanded=False]]) -> Data
- esys.escript.ContinuousFunction((Domain)domain) FunctionSpace : ¶
- Returns
a continuous FunctionSpace (overlapped node values)
- Return type
- esys.escript.DiracDeltaFunctions((Domain)domain) FunctionSpace : ¶
- Return type
- esys.escript.Function((Domain)domain) FunctionSpace : ¶
- Returns
a function
FunctionSpace
- Return type
- esys.escript.FunctionOnBoundary((Domain)domain) FunctionSpace : ¶
- Returns
a function on boundary FunctionSpace
- Return type
- esys.escript.FunctionOnContactOne((Domain)domain) FunctionSpace : ¶
- Returns
Return a FunctionSpace on right side of contact
- Return type
- esys.escript.FunctionOnContactZero((Domain)domain) FunctionSpace : ¶
- Returns
Return a FunctionSpace on left side of contact
- Return type
- esys.escript.L2(arg)¶
Returns the L2 norm of
arg
atwhere
.
- esys.escript.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
) – argument- Returns
maximum value of the absolute value of
arg
over all components and all data points- Return type
float
- Raises
TypeError – if type of
arg
cannot be processed
- esys.escript.MPIBarrierWorld() None : ¶
Wait until all MPI processes have reached this point.
- esys.escript.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.NumpyToData(array, isComplex, functionspace)¶
Uses a numpy ndarray to create a
Data
objectExample usage: NewDataObject = NumpyToData(ndarray, isComplex, FunctionSpace)
- esys.escript.RandomData((tuple)shape, (FunctionSpace)fs[, (object)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.ReducedContinuousFunction((Domain)domain) FunctionSpace : ¶
- Returns
a continuous with reduced order FunctionSpace (overlapped node values on reduced element order)
- Return type
- esys.escript.ReducedFunction((Domain)domain) FunctionSpace : ¶
- Returns
a function FunctionSpace with reduced integration order
- Return type
- esys.escript.ReducedFunctionOnBoundary((Domain)domain) FunctionSpace : ¶
- Returns
a function on boundary FunctionSpace with reduced integration order
- Return type
- esys.escript.ReducedFunctionOnContactOne((Domain)domain) FunctionSpace : ¶
- Returns
Return a FunctionSpace on right side of contact with reduced integration order
- Return type
- esys.escript.ReducedFunctionOnContactZero((Domain)domain) FunctionSpace : ¶
- Returns
a FunctionSpace on left side of contact with reduced integration order
- Return type
- esys.escript.ReducedSolution((Domain)domain) FunctionSpace : ¶
- Return type
- esys.escript.Scalar([(object)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697920>[, (object)expanded=False]]]) Data : ¶
Construct a Data object containing scalar data-points.
- Parameters
value (float) – scalar value for all points
what (
FunctionSpace
) – FunctionSpace for Dataexpanded (
bool
) – If True, a value is stored for each point. If False, more efficient representations may be used
- Return type
- esys.escript.Solution((Domain)domain) FunctionSpace : ¶
- Return type
- esys.escript.Tensor([(object)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697bc0>[, (object)expanded=False]]]) Data : ¶
Construct a Data object containing rank2 data-points.
- param value
scalar value for all points
- rtype
- type value
float
- param what
FunctionSpace for Data
- type what
- param expanded
If True, a value is stored for each point. If False, more efficient representations may be used
- type expanded
bool
Tensor( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697ca0> [, (object)expanded=False]]) -> Data
- esys.escript.Tensor3([(object)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697d80>[, (object)expanded=False]]]) Data : ¶
Construct a Data object containing rank3 data-points.
- param value
scalar value for all points
- rtype
- type value
float
- param what
FunctionSpace for Data
- type what
- param expanded
If True, a value is stored for each point. If False, more efficient representations may be used
- type expanded
bool
Tensor3( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697e60> [, (object)expanded=False]]) -> Data
- esys.escript.Tensor4([(object)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697ed0>[, (object)expanded=False]]]) Data : ¶
Construct a Data object containing rank4 data-points.
- param value
scalar value for all points
- rtype
- type value
float
- param what
FunctionSpace for Data
- type what
- param expanded
If True, a value is stored for each point. If False, more efficient representations may be used
- type expanded
bool
Tensor4( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d296f80b0> [, (object)expanded=False]]) -> Data
- esys.escript.Vector([(object)value=0.0[, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697a00>[, (object)expanded=False]]]) Data : ¶
Construct a Data object containing rank1 data-points.
- param value
scalar value for all points
- rtype
- type value
float
- param what
FunctionSpace for Data
- type what
- param expanded
If True, a value is stored for each point. If False, more efficient representations may be used
- type expanded
bool
Vector( (object)value [, (FunctionSpace)what=<esys.escriptcore.escriptcpp.FunctionSpace object at 0x7f2d29697ae0> [, (object)expanded=False]]) -> Data
- esys.escript.acos(arg)¶
Returns the inverse cosine of argument
arg
.
- esys.escript.acosh(arg)¶
Returns the inverse hyperbolic cosine of argument
arg
.
- esys.escript.antihermitian(arg)¶
Returns the anti-hermitian part of the square matrix
arg
. That is, (arg-adjoint(arg))/2.
- esys.escript.antisymmetric(arg)¶
Returns the anti-symmetric part of the square matrix
arg
. That is, (arg-transpose(arg))/2.
- esys.escript.asin(arg)¶
Returns the inverse sine of argument
arg
.
- esys.escript.asinh(arg)¶
Returns the inverse hyperbolic sine of argument
arg
.
- esys.escript.atan(arg)¶
Returns inverse tangent of argument
arg
.
- esys.escript.atan2(arg0, arg1)¶
Returns inverse tangent of argument
arg0
overarg1
- esys.escript.atanh(arg)¶
Returns the inverse hyperbolic tangent of argument
arg
.
- esys.escript.boundingBox(domain)¶
Returns the bounding box of a domain
- Parameters
domain (
escript.Domain
) – a domain- Returns
bounding box of the domain
- Return type
list
of pairs offloat
- esys.escript.boundingBoxEdgeLengths(domain)¶
Returns the edge lengths of the bounding box of a domain
- Parameters
domain (
escript.Domain
) – a domain- Return type
list
offloat
- esys.escript.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.clip(arg, minval=None, maxval=None)¶
Cuts the values of
arg
betweenminval
andmaxval
.- Parameters
arg (
numpy.ndarray
,escript.Data
,Symbol
,int
orfloat
) – argumentminval (
float
orNone
) – lower range. If None no lower range is appliedmaxval (
float
orNone
) – upper range. If None no upper range is applied
- Returns
an object that contains all values from
arg
betweenminval
andmaxval
- Return type
numpy.ndarray
,escript.Data
,Symbol
,int
orfloat
depending on the input- Raises
ValueError – if
minval>maxval
- esys.escript.combineData(array, shape)¶
- esys.escript.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 dimensionNone
is returned.- Return type
int
orNone
- Raises
ValueError – if the objects with identifiable dimension don’t have the same spatial dimension.
- esys.escript.commonShape(arg0, arg1)¶
Returns a shape to which
arg0
can be extended from the right andarg1
can be extended from the left.
- esys.escript.condEval(f, tval, fval)¶
Wrapper to allow non-data objects to be used.
- esys.escript.convertToNumpy(data)¶
Writes
Data
objects to a numpy array.The keyword args are Data objects to save. If a scalar
Data
object is passed with the namemask
, then only samples which correspond to positive values inmask
will be output.Example usage:
s=Scalar(..) v=Vector(..) t=Tensor(..) f=float() array = getNumpy(a=s, b=v, c=t, d=f)
- esys.escript.cos(arg)¶
Returns cosine of argument
arg
.
- esys.escript.cosh(arg)¶
Returns the hyperbolic cosine of argument
arg
.
- esys.escript.delay(arg)¶
Returns a lazy version of arg
- esys.escript.deviatoric(arg)¶
Returns the deviatoric version of
arg
.
- esys.escript.diameter(domain)¶
Returns the diameter of a domain.
- Parameters
domain (
escript.Domain
) – a domain- Return type
float
- esys.escript.div(arg, where=None)¶
Returns the divergence of
arg
atwhere
.- Parameters
arg (
escript.Data
orSymbol
) – function of which the divergence is to be calculated. Its shape has to be (d,) where d is the spatial dimension.where (
None
orescript.FunctionSpace
) –FunctionSpace
in which the divergence will be calculated. If not present orNone
an appropriate default is used.
- Returns
divergence of
arg
- Return type
escript.Data
orSymbol
- esys.escript.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
,Symbol
depending on the input- Note
for
escript.Data
andSymbol
objects the dimension is restricted to 3.
- esys.escript.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
tuple
ofescript.Data
- Note
The dimension is restricted to 3.
- esys.escript.erf(arg)¶
Returns the error function erf of argument
arg
.
- esys.escript.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.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.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.escript_inverse(arg)¶
arg is a Data object!
- esys.escript.exp(arg)¶
Returns e to the power of argument
arg
.
- esys.escript.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:]
- esys.escript.generalTensorTransposedProduct(arg0, arg1, axis_offset=0)¶
Generalized tensor product of
arg0
and 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:]
The function call
generalTensorTransposedProduct(arg0,arg1,axis_offset)
is equivalent togeneralTensorProduct(arg0,transpose(arg1,arg1.ndim-axis_offset),axis_offset)
.- Parameters
- Returns
the general tensor product of
arg0
andtranspose(arg1)
at each data point- Return type
numpy.ndarray
,escript.Data
,Symbol
depending on the input
- esys.escript.generalTransposedTensorProduct(arg0, arg1, axis_offset=0)¶
Generalized tensor product of transposed of
arg0
andarg1
.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:]
The function call
generalTransposedTensorProduct(arg0,arg1,axis_offset)
is equivalent togeneralTensorProduct(transpose(arg0,arg0.ndim-axis_offset),arg1,axis_offset)
.- Parameters
- Returns
the general tensor product of
transpose(arg0)
andarg1
at each data point- Return type
numpy.ndarray
,escript.Data
,Symbol
depending on the input
- esys.escript.getClosestValue(arg, origin=0)¶
Returns the value in
arg
which is closest to origin.- Parameters
arg (
escript.Data
) – functionorigin (
float
orescript.Data
) – reference value
- Returns
value in
arg
closest to origin- Return type
numpy.ndarray
- esys.escript.getEpsilon()¶
- esys.escript.getEscriptParamInt((str)name[, (object)sentinel=0]) int : ¶
Read the value of an escript tuning parameter
- Parameters
name (
string
) – parameter to lookupsentinel (
int
) – Value to be returned ifname
is not a known parameter
- esys.escript.getMPIRankWorld() int : ¶
Return the rank of this process in the MPI World.
- esys.escript.getMPISizeWorld() int : ¶
Return number of MPI processes in the job.
- esys.escript.getMPIWorldMax((object)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.getMPIWorldSum((object)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.getMachinePrecision() float ¶
- esys.escript.getMaxFloat()¶
- esys.escript.getNumberOfThreads() int : ¶
Return the maximum number of threads available to OpenMP.
- esys.escript.getNumpy(**data)¶
Writes
Data
objects to a numpy array.The keyword args are Data objects to save. If a scalar
Data
object is passed with the namemask
, then only samples which correspond to positive values inmask
will be output.Example usage:
s=Scalar(..) v=Vector(..) t=Tensor(..) f=float() array = getNumpy(a=s, b=v, c=t, d=f)
- esys.escript.getRank(arg)¶
Identifies the rank of the argument.
- Parameters
arg (
numpy.ndarray
,escript.Data
,float
,int
,Symbol
) – an object whose rank is to be returned- Returns
the rank of the argument
- Return type
int
- Raises
TypeError – if type of
arg
cannot be processed
- esys.escript.getShape(arg)¶
Identifies the shape of the argument.
- Parameters
arg (
numpy.ndarray
,escript.Data
,float
,int
,Symbol
) – an object whose shape is to be returned- Returns
the shape of the argument
- Return type
tuple
ofint
- Raises
TypeError – if type of
arg
cannot be processed
- esys.escript.getTagNames(domain)¶
Returns a list of tag names used by the domain.
- Parameters
domain (
escript.Domain
) – a domain object- Returns
a list of tag names used by the domain
- Return type
list
ofstr
- esys.escript.getTestDomainFunctionSpace((object)dpps, (object)samples[, (object)size=1]) FunctionSpace : ¶
For testing only. May be removed without notice.
- esys.escript.getTotalDifferential(f, x, order=0)¶
This function computes:
| Df/Dx = del_f/del_x + del_f/del_grad(x)*del_grad(x)/del_x + ... | \ / \ / | a b
- esys.escript.getVersion() int : ¶
This method will only report accurate version numbers for clean checkouts.
- esys.escript.gmshGeo2Msh(geoFile, mshFile, numDim, order=1, verbosity=0)¶
Runs gmsh to mesh input
geoFile
. Returns 0 on success.
- esys.escript.grad(arg, where=None)¶
Returns the spatial gradient of
arg
atwhere
.If
g
is the returned object, thenif
arg
is rank 0g[s]
is the derivative ofarg
with respect to thes
-th spatial dimensionif
arg
is rank 1g[i,s]
is the derivative ofarg[i]
with respect to thes
-th spatial dimensionif
arg
is rank 2g[i,j,s]
is the derivative ofarg[i,j]
with respect to thes
-th spatial dimensionif
arg
is rank 3g[i,j,k,s]
is the derivative ofarg[i,j,k]
with respect to thes
-th spatial dimension.
- Parameters
arg (
escript.Data
orSymbol
) – function of which the gradient is to be calculated. Its rank has to be less than 3.where (
None
orescript.FunctionSpace
) – FunctionSpace in which the gradient is calculated. If not present orNone
an appropriate default is used.
- Returns
gradient of
arg
- Return type
escript.Data
orSymbol
- esys.escript.grad_n(arg, n, where=None)¶
- esys.escript.hasFeature((str)name) bool : ¶
Check if escript was compiled with a certain feature
- Parameters
name (
string
) – feature to lookup
- esys.escript.hermitian(arg)¶
Returns the hermitian part of the square matrix
arg
. That is, (arg+adjoint(arg))/2.
- esys.escript.identity(shape=())¶
Returns the
shape
xshape
identity tensor.- Parameters
shape (
tuple
ofint
) – input shape for the identity tensor- Returns
array whose shape is shape x shape where u[i,k]=1 for i=k and u[i,k]=0 otherwise for len(shape)=1. If len(shape)=2: u[i,j,k,l]=1 for i=k and j=l and u[i,j,k,l]=0 otherwise.
- Return type
numpy.ndarray
of rank 1, rank 2 or rank 4- Raises
ValueError – if len(shape)>2
- esys.escript.identityTensor(d=3)¶
Returns the
d
xd
identity matrix.- Parameters
d (
int
,escript.Domain
orescript.FunctionSpace
) – dimension or an object that has thegetDim
method defining the dimension- Returns
the object u of rank 2 with u[i,j]=1 for i=j and u[i,j]=0 otherwise
- Return type
numpy.ndarray
orescript.Data
of rank 2
- esys.escript.identityTensor4(d=3)¶
Returns the
d
xd
xd
xd
identity tensor.- Parameters
d (
int
or any object with agetDim
method) – dimension or an object that has thegetDim
method defining the dimension- Returns
the object u of rank 4 with u[i,j,k,l]=1 for i=k and j=l and u[i,j,k,l]=0 otherwise
- Return type
numpy.ndarray
orescript.Data
of rank 4
- esys.escript.inf(arg)¶
Returns the minimum value over all data points.
- Parameters
arg (
float
,int
,escript.Data
,numpy.ndarray
) – argument- Returns
minimum value of
arg
over all components and all data points- Return type
float
- Raises
TypeError – if type of
arg
cannot be processed
- esys.escript.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
.arg0
andarg1
must have the same shape.- Parameters
- Returns
the inner product of
arg0
andarg1
at each data point- Return type
numpy.ndarray
,escript.Data
,Symbol
,float
depending on the input- Raises
ValueError – if the shapes of the arguments are not identical
- esys.escript.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>
- esys.escript.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> (
float
ornumpy.ndarray
) – value to be used for <tag_name>
- Returns
target
- Return type
escript.Data
- esys.escript.integrate(arg, where=None)¶
Returns the integral of the function
arg
over its domain. Ifwhere
is presentarg
is interpolated towhere
before integration.
- esys.escript.internal_addJob()¶
object internal_addJob(tuple args, dict kwds)
- esys.escript.internal_addJobPerWorld()¶
object internal_addJobPerWorld(tuple args, dict kwds)
- esys.escript.internal_addVariable()¶
object internal_addVariable(tuple args, dict kwds)
- esys.escript.internal_buildDomains()¶
object internal_buildDomains(tuple args, dict kwds)
- esys.escript.internal_makeDataReducer((str)op) Reducer : ¶
Create a reducer to work with Data and the specified operation.
- esys.escript.internal_makeLocalOnly() Reducer : ¶
Create a variable which is not connected to copies in other worlds.
- esys.escript.internal_makeScalarReducer((str)op) Reducer : ¶
Create a reducer to work with doubles and the specified operation.
- esys.escript.interpolate(arg, where)¶
Interpolates the function into the
FunctionSpace
where
. If the argumentarg
has the requested function spacewhere
no interpolation is performed andarg
is returned.- Parameters
arg (
escript.Data
orSymbol
) – interpolantwhere (
escript.FunctionSpace
) –FunctionSpace
to be interpolated to
- Returns
interpolated argument
- Return type
escript.Data
orSymbol
- esys.escript.interpolateTable(tab, dat, start, step, undef=1e+50, check_boundaries=False)¶
- esys.escript.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
,Symbol
depending on the input- Note
for
escript.Data
objects the dimension is restricted to 3.
- esys.escript.isSymbol(arg)¶
Returns True if the argument
arg
is an escriptSymbol
orsympy.Basic
object, False otherwise.
- esys.escript.jump(arg, domain=None)¶
Returns the jump of
arg
across the continuity of the domain.
- esys.escript.kronecker(d=3)¶
Returns the kronecker delta-symbol.
- Parameters
d (
int
,escript.Domain
orescript.FunctionSpace
) – dimension or an object that has thegetDim
method defining the dimension- Returns
the object u of rank 2 with u[i,j]=1 for i=j and u[i,j]=0 otherwise
- Return type
numpy.ndarray
orescript.Data
of rank 2
- esys.escript.length(arg)¶
Returns the length (Euclidean norm) of argument
arg
at each data point.
- esys.escript.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.listFeatures() list : ¶
- Returns
A list of strings representing the features escript supports.
- esys.escript.load((str)fileName, (Domain)domain) Data : ¶
reads Data on domain from file in netCDF format
- Parameters
fileName (
string
) –domain (
Domain
) –
- esys.escript.loadIsConfigured() bool : ¶
- Returns
True if the load function is configured.
- esys.escript.log(arg)¶
Returns the natural logarithm of argument
arg
.
- esys.escript.log10(arg)¶
Returns base-10 logarithm of argument
arg
.
- esys.escript.longestEdge(domain)¶
Returns the length of the longest edge of the domain
- Parameters
domain (
escript.Domain
) – a domain- Returns
longest edge of the domain parallel to the Cartesian axis
- Return type
float
- esys.escript.makeTagMap(fs)¶
Produce an expanded Data over the function space where the value is the tag associated with the sample
- esys.escript.matchShape(arg0, arg1)¶
Returns a representation of
arg0
andarg1
which have the same shape.
- esys.escript.matchType(arg0=0.0, arg1=0.0)¶
Converts
arg0
andarg1
both to the same typenumpy.ndarray
orescript.Data
- Parameters
arg0 (
numpy.ndarray
,`escript.Data`,``float``,int
,Symbol
) – first argumentarg1 (
numpy.ndarray
,`escript.Data`,``float``,int
,Symbol
) – second argument
- Returns
a tuple representing
arg0
andarg1
with the same type or with at least one of them being aSymbol
- Return type
tuple
of twonumpy.ndarray
or twoescript.Data
- Raises
TypeError – if type of
arg0
orarg1
cannot be processed
- esys.escript.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
arg0
and the first dimension ofarg1
must match.- Parameters
- Returns
the matrix-matrix or matrix-vector product of
arg0
andarg1
at each data point- Return type
numpy.ndarray
,escript.Data
,Symbol
depending on the input- Raises
ValueError – if the shapes of the arguments are not appropriate
- esys.escript.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
arg0
andarg1
must match.- Parameters
- Returns
the product of
arg0
and the transposed ofarg1
at each data point- Return type
numpy.ndarray
,escript.Data
,Symbol
depending on the input- Raises
ValueError – if the shapes of the arguments are not appropriate
- esys.escript.matrixmult(arg0, arg1)¶
See
matrix_mult
.
- esys.escript.maximum(*args)¶
The maximum over arguments
args
.
- esys.escript.maxval(arg)¶
Returns the maximum value over all components of
arg
at each data point.
- esys.escript.meanValue(arg)¶
return the mean value of the argument over its domain
- Parameters
arg (
escript.Data
) – function- Returns
mean value
- Return type
float
ornumpy.ndarray
- esys.escript.minimum(*args)¶
The minimum over arguments
args
.
- esys.escript.minval(arg)¶
Returns the minimum value over all components of
arg
at each data point.
- esys.escript.mkDir(*pathname)¶
creates a directory of name
pathname
if the directory does not exist.- Parameters
pathname (
str
orsequence of strings
) – valid path name- Note
The method is MPI safe.
- esys.escript.mult(arg0, arg1)¶
Product of
arg0
andarg1
.- Parameters
- Returns
the product of
arg0
andarg1
- Return type
Symbol
,float
,int
,escript.Data
ornumpy.ndarray
- Note
The shape of both arguments is matched according to the rules used in
matchShape
.
- esys.escript.negative(arg)¶
returns the negative part of arg
- esys.escript.nonsymmetric(arg)¶
Deprecated alias for antisymmetric
- esys.escript.normalize(arg, zerolength=0)¶
Returns the normalized version of
arg
(=``arg/length(arg)``).
- esys.escript.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
- esys.escript.phase(arg)¶
return the “phase”/”arg”/”angle” of a number
- esys.escript.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
None
- Return type
int
orNone
- esys.escript.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.positive(arg)¶
returns the positive part of arg
- esys.escript.pprint(expr, use_unicode=None)¶
Prints expr in pretty form.
pprint is just a shortcut for this function
- esys.escript.pretty_print(expr, use_unicode=None)¶
Prints expr in pretty form.
pprint is just a shortcut for this function
- esys.escript.printParallelThreadCounts() None ¶
- esys.escript.releaseUnusedMemory() None ¶
- esys.escript.removeFsFromGrad(sym)¶
Returns
sym
with all occurrences grad_n(a,b,c) replaced by grad_n(a,b). That is, all functionspace parameters are removed.
- esys.escript.reorderComponents(arg, index)¶
Resorts the components of
arg
according to index.
- esys.escript.resolve(arg)¶
Returns the value of arg resolved.
- esys.escript.resolveGroup((object)arg1) None ¶
- esys.escript.runMPIProgram((list)arg1) int : ¶
Spawns an external MPI program using a separate communicator.
- esys.escript.safeDiv(arg0, arg1, rtol=None)¶
returns arg0/arg1 but return 0 where arg1 is (almost) zero
- esys.escript.saveDataCSV(filename, append=False, refid=False, sep=', ', csep='_', **data)¶
Writes
Data
objects 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 beginningrefid (
bool
) – IfTrue
, then a list of reference ids will be printed in the first columnsep (
string
) – separator between fieldscsep – separator for components of rank 2 and above (e.g. ‘_’ -> c0_1)
The keyword args are Data objects to save. If a scalar
Data
object is passed with the namemask
, then only samples which correspond to positive values inmask
will be output. Example:s=Scalar(..) v=Vector(..) t=Tensor(..) f=float() saveDataCSV("f.csv", a=s, b=v, c=t, d=f)
Will result in a file
a, b0, b1, c0_0, c0_1, .., c1_1, d 1.0, 1.5, 2.7, 3.1, 3.4, .., 0.89, 0.0 0.9, 8.7, 1.9, 3.4, 7.8, .., 1.21, 0.0
The first line is a header, the remaining lines give the values.
- esys.escript.saveESD(datasetName, dataDir='.', domain=None, timeStep=0, deltaT=1, dynamicMesh=0, timeStepFormat='%04d', **data)¶
Saves
Data
objects 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 filedataDir (
str
) – optional directory where the data files should be saveddomain (
escript.Domain
) – domain of theData
object(s). If not specified, the domain of the givenData
objects is used.timeStep (
int
) – current timestep or sequence number - first one must be 0deltaT (
int
) – timestep or sequence increment, see example abovedynamicMesh (
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> (
Data
object) – 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.
- esys.escript.setEscriptParamInt((str)name[, (object)value=0]) None : ¶
Modify the value of an escript tuning parameter
- Parameters
name (
string
) –value (
int
) –
- esys.escript.setNumberOfThreads((object)arg1) None : ¶
Use of this method is strongly discouraged.
- esys.escript.showEscriptParams()¶
Displays the parameters escript recognises with an explanation and their current value.
- esys.escript.sign(arg)¶
Returns the sign of argument
arg
.
- esys.escript.sin(arg)¶
Returns sine of argument
arg
.
- esys.escript.sinh(arg)¶
Returns the hyperbolic sine of argument
arg
.
- esys.escript.sqrt(arg)¶
Returns the square root of argument
arg
.
- esys.escript.sup(arg)¶
Returns the maximum value over all data points.
- Parameters
arg (
float
,int
,escript.Data
,numpy.ndarray
) – argument- Returns
maximum value of
arg
over all components and all data points- Return type
float
- Raises
TypeError – if type of
arg
cannot be processed
- esys.escript.swap_axes(arg, axis0=0, axis1=1)¶
Returns the swap of
arg
by swapping the componentsaxis0
andaxis1
.- Parameters
arg (
escript.Data
,Symbol
,numpy.ndarray
) – argumentaxis0 (
int
) – first axis.axis0
must be non-negative and less than the rank ofarg
.axis1 (
int
) – second axis.axis1
must be non-negative and less than the rank ofarg
.
- Returns
arg
with swapped components- Return type
escript.Data
,Symbol
ornumpy.ndarray
depending on the type ofarg
- esys.escript.symbols(*names, **kwargs)¶
Emulates the behaviour of sympy.symbols.
- esys.escript.symmetric(arg)¶
Returns the symmetric part of the square matrix
arg
. That is, (arg+transpose(arg))/2.
- esys.escript.tan(arg)¶
Returns tangent of argument
arg
.
- esys.escript.tanh(arg)¶
Returns the hyperbolic tangent of argument
arg
.
- esys.escript.tensor_mult(arg0, arg1)¶
The tensor product of the two arguments.
For
arg0
of 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
arg0
of 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
arg0
and the last dimension ofarg1
must match and in the second case the two last dimensions ofarg0
must match the two first dimensions ofarg1
.- Parameters
- Returns
the tensor product of
arg0
andarg1
at each data point- Return type
numpy.ndarray
,escript.Data
,Symbol
depending on the input
- esys.escript.tensor_transposed_mult(arg0, arg1)¶
The tensor product of the first and the transpose of the second argument.
For
arg0
of rank 2 this isout[s0,s1]=Sigma_{r0} arg0[s0,r0]*arg1[s1,r0]
and for
arg0
of 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
arg0
andarg1
must match and in the second case the two last dimensions ofarg0
must match the two last dimensions ofarg1
.The function call
tensor_transpose_mult(arg0,arg1)
is equivalent totensor_mult(arg0,transpose(arg1))
.- Parameters
- Returns
the tensor product of the transposed of
arg0
andarg1
at each data point- Return type
numpy.ndarray
,escript.Data
,Symbol
depending on the input
- esys.escript.tensormult(arg0, arg1)¶
See
tensor_mult
.
- esys.escript.testForZero(arg)¶
Tests if the argument is identical to zero.
- Parameters
arg (typically
numpy.ndarray
,escript.Data
,float
,int
) – the object to test for zero- Returns
True if the argument is identical to zero, False otherwise
- Return type
bool
- esys.escript.trace(arg, axis_offset=0)¶
Returns the trace of
arg
which is the sum ofarg[k,k]
over k.- Parameters
arg (
escript.Data
,Symbol
,numpy.ndarray
) – argumentaxis_offset (
int
) –axis_offset
to components to sum over.axis_offset
must be non-negative and less than the rank ofarg
+1. The dimensions of componentaxis_offset
and axis_offset+1 must be equal.
- Returns
trace of arg. The rank of the returned object is rank of
arg
minus 2.- Return type
escript.Data
,Symbol
ornumpy.ndarray
depending on the type ofarg
- esys.escript.transpose(arg, axis_offset=None)¶
Returns the transpose of
arg
by swapping the firstaxis_offset
and the lastrank-axis_offset
components.- Parameters
arg (
escript.Data
,Symbol
,numpy.ndarray
,float
,int
) – argumentaxis_offset (
int
) – the firstaxis_offset
components are swapped with the rest.axis_offset
must be non-negative and less or equal to the rank ofarg
. Ifaxis_offset
is not presentint(r/2)
where r is the rank ofarg
is used.
- Returns
transpose of
arg
- Return type
escript.Data
,Symbol
,numpy.ndarray
,float
,int
depending on the type ofarg
- esys.escript.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
arg0
andarg1
must match.- Parameters
- Returns
the product of the transpose of
arg0
andarg1
at each data point- Return type
numpy.ndarray
,escript.Data
,Symbol
depending on the input- Raises
ValueError – if the shapes of the arguments are not appropriate
- esys.escript.transposed_tensor_mult(arg0, arg1)¶
The tensor product of the transpose of the first and the second argument.
For
arg0
of 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
arg0
of 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
arg0
and the first dimension ofarg1
must match and in the second case the two first dimensions ofarg0
must match the two first dimensions ofarg1
.The function call
transposed_tensor_mult(arg0,arg1)
is equivalent totensor_mult(transpose(arg0),arg1)
.- Parameters
- Returns
the tensor product of transpose of arg0 and arg1 at each data point
- Return type
numpy.ndarray
,escript.Data
,Symbol
depending on the input
- esys.escript.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 elementd (
int
,escript.Domain
orescript.FunctionSpace
) – dimension or an object that has thegetDim
method 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.ndarray
orescript.Data
of rank 1
- esys.escript.vol(arg)¶
Returns the volume or area of the oject
arg
- Parameters
arg (
escript.FunctionSpace
orescript.Domain
) – a geometrical object- Return type
float
- esys.escript.whereNegative(arg)¶
Returns mask of negative values of argument
arg
.
- esys.escript.whereNonNegative(arg)¶
Returns mask of non-negative values of argument
arg
.
- esys.escript.whereNonPositive(arg)¶
Returns mask of non-positive values of argument
arg
.
- esys.escript.whereNonZero(arg, tol=0.0)¶
Returns mask of values different from zero of argument
arg
.- Parameters
arg (
float
,escript.Data
,Symbol
,numpy.ndarray
) – argumenttol (
float
) – absolute tolerance. Values with absolute value less than tol are accepted as zero. Iftol
is not presentrtol``*```Lsup` (arg)
is used.
- Return type
float
,escript.Data
,Symbol
,numpy.ndarray
depending on the type ofarg
- Raises
ValueError – if
rtol
is non-negative.TypeError – if the type of the argument is not expected
- esys.escript.wherePositive(arg)¶
Returns mask of positive values of argument
arg
.
- esys.escript.whereZero(arg, tol=None, rtol=1.4901161193847656e-08)¶
Returns mask of zero entries of argument
arg
.- Parameters
arg (
float
,escript.Data
,Symbol
,numpy.ndarray
) – argumenttol (
float
) – absolute tolerance. Values with absolute value less than tol are accepted as zero. Iftol
is not presentrtol``*```Lsup` (arg)
is used.rtol (non-negative
float
) – relative tolerance used to define the absolute tolerance iftol
is not present.
- Return type
float
,escript.Data
,Symbol
,numpy.ndarray
depending on the type ofarg
- Raises
ValueError – if
rtol
is non-negative.TypeError – if the type of the argument is not expected
- esys.escript.zeros(shape=())¶
Returns the
shape
zero tensor.- Parameters
shape (
tuple
ofint
) – input shape for the identity tensor- Returns
array of shape filled with zeros
- Return type
numpy.ndarray
Others¶
DBLE_MAX
EPSILON
HAVE_SYMBOLS