Bases: Boost.Python.instance
Represents a collection of datapoints. It is used to store the values of a function. For more details please consult the c++ class documentation.
Make this object a copy of other
note: The two objects will act independently from now on. That is, changing other after this call will not change this object and vice versa.
note: | In the no argument form, a new object will be returned which is an independent copy of this object. |
---|
Selectively copy values from other Data.Datapoints which correspond to positive values in mask will be copied from other
Parameters: |
---|
Convert this object into lazy representation
Save the data as a netCDF file
Parameters: | fileName (string) – |
---|
Convert the data to expanded representation if it is not expanded already.
Return type: | Domain |
---|
Return type: | FunctionSpace |
---|
Return type: | int |
---|---|
Returns: | Number of datapoints in the object |
Returns: | the number of indices required to address a component of a datapoint |
---|---|
Return type: | positive int |
Returns the shape of the datapoints in this object as a python tuple. Scalar data has the shape ()
Return type: | tuple |
---|
Return tag number for the specified datapoint
Return type: | int |
---|---|
Parameters: | dpno (int) – datapoint number |
Returns: | Value of the specified datapoint |
---|---|
Return type: | tuple |
Parameters: | dataPointNo (int) – datapoint to access |
Get a specific datapoint from a specific process
Return type: | tuple |
---|---|
Parameters: |
|
Interpolate this object’s values into a new functionspace.
Creates a new Data object by interpolating using the source data (which are looked up in table) A must be the outer dimension on the table
param table: two dimensional collection of values param Amin: The base of locations in table type Amin: float param Astep: size of gap between each item in the table type Astep: float param undef: upper bound on interpolated values type undef: float param B: Scalar representing the second coordinate to be mapped into the table type B: Data param Bmin: The base of locations in table for 2nd dimension type Bmin: float param Bstep: size of gap between each item in the table for 2nd dimension type Bstep: float param check_boundaries: if true, then values outside the boundaries will be rejected. If false, then boundary values will be used. raise RuntimeError(DataException): if the coordinates do not map into the table or if the interpolated value is above undef rtype: Data
interpolateTable( (Data)arg1, (object)table, (float)Amin, (float)Astep [, (float)undef=1e+50 [, (bool)check_boundaries=False]]) -> Data
Return type: | bool |
---|---|
Returns: | True if this Data is an instance of DataConstant |
Note : | This does not mean the data is immutable. |
Is this object an instance of DataEmpty
Return type: | bool |
---|---|
Note : | This is not the same thing as asking if the object contains datapoints. |
Return type: | bool |
---|---|
Returns: | True if this Data is expanded. |
Return type: | bool |
---|---|
Returns: | True if this Data is lazy. |
Can this instance be modified. :rtype: bool
Return type: | bool |
---|---|
Returns: | True if this Data is not lazy. |
Return type: | bool |
---|---|
Returns: | True if this Data is expanded. |
Please consider using getSupLocator() from pdetools instead.
Please consider using getInfLocator() from pdetools instead.
1D interpolation with non equally spaced points
1D interpolation of slope with non equally spaced points
Convert the data to non-lazy representation.
Disallow modifications to this data object
Note : | This method does not allow you to undo protection. |
---|
Set the value of tagged Data.
param tagKey: tag to update type tagKey: int
param name: | tag to update |
---|---|
type name: | string |
param value: | value to set tagged data to |
type value: | object which acts like an array, tuple or list |
After this call the object will store values of the same shape as before but all components will be zero.
setValueOfDataPoint( (Data)arg1, (int)arg2, (object)arg3) -> None
setValueOfDataPoint( (Data)arg1, (int)arg2, (float)arg3) -> None :
Modify the value of a single datapoint.
param dataPointNo: type dataPointNo: int param value: type value: float or an object which acts like an array, tuple or list warning: Use of this operation is discouraged. It prevents some optimisations from operating.
Convert data to tagged representation if it is not already tagged or expanded
Return the datapoints of this object in a list. Each datapoint is stored as a tuple.
Parameters: | scalarastuple – if True, scalar data will be wrapped as a tuple. True => [(0), (1), (2)]; False => [0, 1, 2] |
---|
Bases: exceptions.Exception
Exception thrown if Newton-Raphson did not converge.
Bases: exceptions.Exception
Exception thrown if the ordering of the PDE equations should be revised.
Bases: object
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 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=5*u)
v = p.getSolution(u=0.)
Creates a new coefficient name as Symbol
Parameters: | name (string) – name of the coefficient requested |
---|---|
Returns: | the value of the coefficient |
Return type: | Symbol or Data (for name = “q”) |
Raises IllegalCoefficient: | |
if name is not a coefficient of the PDE |
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: | Symbol |
Raises IllegalCoefficient: | |
if name is not a coefficient of the PDE |
Returns the linear PDE used to calculate the Newton-Raphson update
Return type: | LinearPDE |
---|
Returns the options of the linear PDE solver class
Returns the number of the solution components :rtype: int
Calculates the sensitivity of the solution of an input factor f in direction g.
Parameters: |
|
---|---|
Returns: | the sensitivity |
Return type: | Data with shape u.getShape()+(len(g),) if len(g)>1 or u.getShape() if len(g)==1 |
Returns the shape of the coefficient name
Parameters: | name (string) – name of the coefficient enquired |
---|---|
Returns: | the shape of the coefficient name |
Return type: | tuple of int |
Raises IllegalCoefficient: | |
if name is not a coefficient of the PDE |
Returns the 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: | Data |
Returns the symbol of the PDE unknown
Returns: | the symbol of the PDE unknown |
---|---|
Return type: | Symbol |
Allows setting options for the nonlinear PDE.
Sets new values to one or more coefficients.
Parameters: |
|
---|---|
Raises: |
|
Prints the text message if the debug level is greater than DEBUG0
Parameters: | text (string) – message to be printed |
---|
Prints the text message if the debug level is greater than DEBUG3
Parameters: | text (string) – message to be printed |
---|
Bases: object
This class is used to define a general constraint vartional problem for an unknown function u and (spatially variable) parameter p on a given domain defined through a Domain object. u may be a scalar or a vector. p which may be a scalar or a vector may not be present.
The solution u and the paremeter p are given as the solution of the minimization problem:
min_{u,p} int(H) + int(h)
where int{H} refers to integration over the domain and H*=f(*x,*u*,*grad(u)*,*p*, grad(p)) is a function which may depend on the location x within the domain and is a function of the solution u and the parameter p and their gradients grad(u) and grad(p), respectively. Similarly, int{H} refers to integration over the boundary of the domain and h=f(*x,*u*, p) is a function which may depend on the location x within the domain boundary and is a function of the solution u and the parameter p.
If p is present, u is the solution of a PDE with coefficients depending on the parameter p. The PDE defines a constraint for the variational problem. It is assumed that, if p is present, for any given parameter p a unique solution u of the PDE exists.
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(x,*u*,*grad(u)*, p, grad(p)), 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 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:
s=Symbol(‘s’, dim=dom.getDim()) T = Symbol(‘T’, dim=dom.getDim()) log_k = Symbol(‘log_k’, dim=dom.getDim()) v = VariationalProblem(dom, u=T, p=log_k) v.setValue(X=exp(-log_k)*grad(T), Y=s, h=0.3*(T-0.3)**2) T, log_k, l = v.getSolution(T=0., log_k=1, s=2.45) sT,S_log_k=v.getSensitivity(s, direction=1, T=T, log_k=log_k, s=2.45)
Creates a new coefficient name as Symbol
Parameters: | name (string) – name of the coefficient requested |
---|---|
Returns: | the value of the coefficient |
Return type: | Symbol or Data |
Raises IllegalCoefficient: | |
if name is not a coefficient of the PDE |
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: | Symbol |
Raises IllegalCoefficient: | |
if name is not a coefficient of the PDE |
Returns the NonlinearPDE used to solve the variational problem
Returns: | underlying nonlinear PDE |
---|---|
Return type: | NonlinearPDE |
Returns the number of parameter components. If no parameter is present zero is returned.
Return type: | int |
---|
Returns the number of solution components :rtype: int
Returns the shape of the coefficient name
Parameters: | name (string) – name of the coefficient enquired |
---|---|
Returns: | the shape of the coefficient name |
Return type: | tuple of int |
Raises IllegalCoefficient: | |
if name is not a coefficient of the PDE |
Returns the solution of the variational problem.
Parameters: | subs – Substitutions for all symbols used in the coefficients including the initial value for solution u and for the parameter p (if present) |
---|---|
Returns: | parameter, corresponding solution and lagrangean multiplier |
Return type: | tuple of Data or single Data (if no parameter present) |
Sets new values to one or more coefficients.
Parameters: |
|
---|---|
Raises: |
|
Prints the text message if the debug level is greater than DEBUG0
Parameters: | text (string) – message to be printed |
---|
Prints the text message if the debug level is greater than DEBUG3
Parameters: | text (string) – message to be printed |
---|