esys.escript.flows Package

Classes

class esys.escript.flows.DarcyFlow(domain, useReduced=False, solver='POST', verbose=False, w=1.0)

Bases: object

solves the problem

u_i+k_{ij}*p_{,j} = g_i u_{i,i} = f

where p represents the pressure and u the Darcy flux. k represents the permeability,

Variables:
  • EVAL – direct pressure gradient evaluation for flux
  • POST – global postprocessing of flux by solving the PDE K_{ij} u_j + (w * K * l u_{k,k})_{,i}= - p_{,j} + K_{ij} g_j where l is the length scale, K is the inverse of the permeability tensor, and w is a positive weighting factor.
  • SMOOTH – global smoothing by solving the PDE K_{ij} u_j= - p_{,j} + K_{ij} g_j
EVAL = 'EVAL'
POST = 'POST'
SIMPLE = 'EVAL'
SMOOTH = 'SMOOTH'
getFlux(p, u0=None)

returns the flux for a given pressure p where the flux is equal to u0 on locations where location_of_fixed_flux is positive (see setValue). Notice that g is used, see setValue.

Parameters:
  • p (scalar value on the domain (e.g. escript.Data).) – pressure.
  • u0 (vector values on the domain (e.g. escript.Data) or None) – flux on the locations of the domain marked be location_of_fixed_flux.
Returns:

flux

Return type:

escript.Data

getSolverOptionsFlux()

Returns the solver options used to solve the flux problems :return: SolverOptions

getSolverOptionsPressure()

Returns the solver options used to solve the pressure problems :return: SolverOptions

setSolverOptionsFlux(options=None)

Sets the solver options used to solve the flux problems If options is not present, the options are reset to default :param options: SolverOptions

setSolverOptionsPressure(options=None)

Sets the solver options used to solve the pressure problems If options is not present, the options are reset to default

Parameters:optionsSolverOptions
Note :if the adaption of subtolerance is choosen, the tolerance set by options will be overwritten before the solver is called.
setValue(f=None, g=None, location_of_fixed_pressure=None, location_of_fixed_flux=None, permeability=None)

assigns values to model parameters

Parameters:
  • f (scalar value on the domain (e.g. escript.Data)) – volumetic sources/sinks
  • g (vector values on the domain (e.g. escript.Data)) – flux sources/sinks
  • location_of_fixed_pressure (scalar value on the domain (e.g. escript.Data)) – mask for locations where pressure is fixed
  • location_of_fixed_flux (vector values on the domain (e.g. escript.Data)) – mask for locations where flux is fixed.
  • permeability (scalar or symmetric tensor values on the domain (e.g. escript.Data)) – permeability tensor. If scalar s is given the tensor with s on the main diagonal is used.
Note :

the values of parameters which are not set by calling setValue are not altered.

Note :

at any point on the boundary of the domain the pressure (location_of_fixed_pressure >0) or the normal component of the flux (location_of_fixed_flux[i]>0) if direction of the normal is along the x_i axis.

solve(u0, p0)

solves the problem.

Parameters:
  • u0 (vector value on the domain (e.g. escript.Data).) – initial guess for the flux. At locations in the domain marked by location_of_fixed_flux the value of u0 is kept unchanged.
  • p0 (scalar value on the domain (e.g. escript.Data).) – initial guess for the pressure. At locations in the domain marked by location_of_fixed_pressure the value of p0 is kept unchanged.
Returns:

flux and pressure

Return type:

tuple of escript.Data.

class esys.escript.flows.StokesProblemCartesian(domain, **kwargs)

Bases: esys.escript.pdetools.HomogeneousSaddlePointProblem

solves

-(eta*(u_{i,j}+u_{j,i}))_j + p_i = f_i-stress_{ij,j}
u_{i,i}=0

u=0 where fixed_u_mask>0 eta*(u_{i,j}+u_{j,i})*n_j-p*n_i=surface_stress +stress_{ij}n_j

if surface_stress is not given 0 is assumed.

typical usage:

sp=StokesProblemCartesian(domain) sp.setTolerance() sp.initialize(...) v,p=sp.solve(v0,p0) sp.setStokesEquation(...) # new values for some parameters v1,p1=sp.solve(v,p)
Bv(v, tol)

returns inner product of element p and div(v)

Parameters:v – a residual
Returns:inner product of element p and div(v)
Return type:float
getAbsoluteTolerance()

Returns the absolute tolerance.

Returns:absolute tolerance
Return type:float
getDV(p, v, tol)

return the value for v for a given p

Parameters:
  • p – a pressure
  • v – a initial guess for the value v to return.
Returns:

dv given as Adv=(f-Av-B^*p)

getSolverOptionsDiv()

returns the solver options for solving the equation to project the divergence of the velocity onto the function space of presure.

Return type:SolverOptions
getSolverOptionsPressure()

returns the solver options used solve the equation for pressure. :rtype: SolverOptions

getSolverOptionsVelocity()

returns the solver options used solve the equation for velocity.

Return type:SolverOptions
getTolerance()

Returns the relative tolerance.

Returns:relative tolerance
Return type:float
initialize(f=<esys.escript.escriptcpp.Data object at 0x6378c00>, fixed_u_mask=<esys.escript.escriptcpp.Data object at 0x6378c58>, eta=1, surface_stress=<esys.escript.escriptcpp.Data object at 0x6378cb0>, stress=<esys.escript.escriptcpp.Data object at 0x6378d08>, restoration_factor=0)

assigns values to the model parameters

Parameters:
  • f (Vector object in FunctionSpace Function or similar) – external force
  • fixed_u_mask (Vector object on FunctionSpace Solution or similar) – mask of locations with fixed velocity.
  • eta (Scalar object on FunctionSpace Function or similar) – viscosity
  • surface_stress (Vector object on FunctionSpace FunctionOnBoundary or similar) – normal surface stress
  • stress (Tensor object on FunctionSpace Function or similar) – initial stress
inner_p(p0, p1)

Returns inner product of p0 and p1

Parameters:
  • p0 – a pressure
  • p1 – a pressure
Returns:

inner product of p0 and p1

Return type:

float

inner_pBv(p, Bv)

returns inner product of element p and Bv=-div(v)

Parameters:
  • p – a pressure increment
  • Bv – a residual
Returns:

inner product of element p and Bv=-div(v)

Return type:

float

norm_Bv(Bv)

Returns Bv (overwrite).

Return type:equal to the type of p
Note :boundary conditions on p should be zero!
norm_p(p)

calculates the norm of p

Parameters:p – a pressure
Returns:the norm of p using the inner product for pressure
Return type:float
norm_v(v)

returns the norm of v

Parameters:v – a velovity
Returns:norm of v
Return type:non-negative float
resetControlParameters(K_p=1.0, K_v=1.0, rtol_max=0.01, rtol_min=1e-07, chi_max=0.5, reduction_factor=0.3, theta=0.1)

sets a control parameter

Parameters:
  • K_p (float) – initial value for constant to adjust pressure tolerance
  • K_v (float) – initial value for constant to adjust velocity tolerance
  • rtol_max (float) – maximuim relative tolerance used to calculate presssure and velocity increment.
  • chi_max (float) – maximum tolerable converegence rate.
  • reduction_factor (float) – reduction factor for adjustment factors.
setAbsoluteTolerance(tolerance=0.0)

Sets the absolute tolerance.

Parameters:tolerance (non-negative float) – tolerance to be used
setControlParameter(K_p=None, K_v=None, rtol_max=None, rtol_min=None, chi_max=None, reduction_factor=None, theta=None)

sets a control parameter

Parameters:
  • K_p (float) – initial value for constant to adjust pressure tolerance
  • K_v (float) – initial value for constant to adjust velocity tolerance
  • rtol_max (float) – maximuim relative tolerance used to calculate presssure and velocity increment.
  • chi_max (float) – maximum tolerable converegence rate.
setSolverOptionsDiv(options=None)

set the solver options for solving the equation to project the divergence of the velocity onto the function space of presure.

Parameters:options (SolverOptions) – new solver options
setSolverOptionsPressure(options=None)

set the solver options for solving the equation for pressure. :param options: new solver options :type options: SolverOptions

setSolverOptionsVelocity(options=None)

set the solver options for solving the equation for velocity.

Parameters:options (SolverOptions) – new solver options
setStokesEquation(f=None, fixed_u_mask=None, eta=None, surface_stress=None, stress=None, restoration_factor=None)

assigns new values to the model parameters.

Parameters:
  • f (Vector object in FunctionSpace Function or similar) – external force
  • fixed_u_mask (Vector object on FunctionSpace Solution or similar) – mask of locations with fixed velocity.
  • eta (Scalar object on FunctionSpace Function or similar) – viscosity
  • surface_stress (Vector object on FunctionSpace FunctionOnBoundary or similar) – normal surface stress
  • stress (Tensor object on FunctionSpace Function or similar) – initial stress
setTolerance(tolerance=0.0001)

Sets the relative tolerance for (v,p).

Parameters:tolerance (non-negative float) – tolerance to be used
solve(v, p, max_iter=20, verbose=False, usePCG=True, iter_restart=20, max_correction_steps=10)

Solves the saddle point problem using initial guesses v and p.

Parameters:
  • v (Data) – initial guess for velocity
  • p (Data) – initial guess for pressure
  • usePCG (bool) – indicates the usage of the PCG rather than GMRES scheme.
  • max_iter (int) – maximum number of iteration steps per correction attempt
  • verbose (bool) – if True, shows information on the progress of the saddlepoint problem solver.
  • iter_restart (int) – restart the iteration after iter_restart steps (only used if useUzaw=False)
Return type:

tuple of Data objects

Note :

typically this method is overwritten by a subclass. It provides a wrapper for the _solve method.

solve_AinvBt(p, tol)

Solves Av=B^*p with accuracy tol

Parameters:p – a pressure increment
Returns:the solution of Av=B^*p
Note :boundary conditions on v should be zero!
solve_prec(Bv, tol)

applies preconditioner for for BA^{-1}B^* to Bv with accuracy self.getSubProblemTolerance()

Parameters:Bv – velocity increment
Returns:p=P(Bv) where P^{-1} is an approximation of BA^{-1}B^ * )
Note :boundary conditions on p are zero.
updateStokesEquation(v, p)

updates the Stokes equation to consider dependencies from v and p :note: This method can be overwritten by a subclass. Use setStokesEquation to set new values to model parameters.

Functions

Others

  • __author__
  • __builtins__
  • __copyright__
  • __doc__
  • __file__
  • __license__
  • __name__
  • __package__
  • __url__