GenericTransport

class GenericTransport(*args, **kwargs)[source]

Bases: openpnm.algorithms.GenericAlgorithm.GenericAlgorithm

This class implements steady-state linear transport calculations

Parameters
  • network ((OpenPNM Network object)) – The network object to which this algorithm will apply.

  • name ((string, optional)) – Name of the algorithm

  • project ((OpenPNM Project object, optional)) – Either a Network or a Project must be supplied

Notes

The following table shows the methods that are accessible to the user for setting up the simulation.

Methods

Description

set_value_BC

Applies constant value boundary conditions to the specified pores

set_rate_BC

Applies constant rate boundary conditions to the specified pores

remove_BC

Removes all boundary conditions from the specified pores

rate

Calculates the total rate of transfer through the given pores or throats

setup

A shortcut for applying values in the settings attribute.

results

Returns the results of the calcualtion as a dict with the data stored under the ‘quantity’ specified in the settings

In addition to the above methods there are also the following attributes:

Attribute

Description

A

Retrieves the coefficient matrix

b

Retrieves the RHS matrix

This class contains quite a few hidden methods (preceeded by an underscore) that are called internally. Since these are critical to the functioning of this algorithm they are worth outlining even though the user does not call them directly:

Method or Attribute

Description

_build_A

Builds the A matrix based on the ‘conductance’ specified in settings

_build_b

Builds the b matrix

_apply_BCs

Applies the given BCs by adjust the A and b matrices

_calc_eff_prop

Finds the effective property (e.g. permeability coefficient) based on the given BCs

_solve

Runs the algorithm using the solver specified in the settings

_get_domain_area

Attempts to estimate the area of the inlet pores if not specified by user

_get_domain_length

Attempts to estimate the length between the inlet and outlet faces if not specified by the user

_apply_BCs()[source]

Applies all the boundary conditions that have been specified, by adding values to the A and b matrices.

_build_A()[source]

Builds the coefficient matrix based on conductances between pores. The conductance to use is specified in the algorithm’s settings under conductance. In subclasses (e.g. FickianDiffusion) this is set by default, though it can be overwritten.

_build_b()[source]

Builds the RHS matrix, without applying any boundary conditions or source terms. This method is trivial an basically creates a column vector of 0’s.

_calc_eff_prop(inlets=None, outlets=None, domain_area=None, domain_length=None)[source]

Calculate the effective transport through the network

Parameters
  • inlets (array_like) – The pores where the inlet boundary conditions were applied. If not given an attempt is made to infer them from the algorithm.

  • outlets (array_like) – The pores where the outlet boundary conditions were applied. If not given an attempt is made to infer them from the algorithm.

  • domain_area (scalar) – The area of the inlet and/or outlet face (which shold match)

  • domain_length (scalar) – The length of the domain between the inlet and outlet faces

Returns

Return type

The effective transport property through the network

_solve(A=None, b=None, x0=None)[source]

Sends the A and b matrices to the specified solver, and solves for x given the boundary conditions, and source terms based on the present value of x. This method does NOT iterate to solve for non-linear source terms or march time steps.

Parameters
  • A (sparse matrix) – The coefficient matrix in sparse format. If not specified, then it uses the A matrix attached to the object.

  • b (ND-array) – The RHS matrix in any format. If not specified, then it uses the b matrix attached to the object.

  • x0 (ND-array) – The initial guess for the solution of Ax = b

Notes

The solver used here is specified in the settings attribute of the algorithm.

rate(pores=[], throats=[], mode='group')[source]

Calculates the net rate of material moving into a given set of pores or throats

Parameters
  • pores (array_like) – The pores for which the rate should be calculated

  • throats (array_like) – The throats through which the rate should be calculated

  • mode (string, optional) – Controls how to return the rate. Options are: - ‘group’: (default) Returns the cumulative rate of material moving into the given set of pores - ‘single’ : Calculates the rate for each pore individually

Returns

  • If pores are specified, then the returned values indicate the

  • net rate of material exiting the pore or pores. Thus a positive

  • rate indicates material is leaving the pores, and negative values

  • mean material is entering.

  • If throats are specified the rate is calculated in the direction of

  • the gradient, thus is always positive.

  • If mode is ‘single’ then the cumulative rate through the given

  • pores (or throats) are returned as a vector, if mode is ‘group’

  • then the individual rates are summed and returned as a scalar.

results()[source]

Fetches the calculated quantity from the algorithm and returns it as an array.

set_rate_BC(pores, rates=None, total_rate=None, mode='merge', **kwargs)[source]

Apply constant rate boundary conditons to the specified locations.

Parameters
  • pores (array_like) – The pore indices where the condition should be applied

  • rates (scalar or array_like, optional) – The rates to apply in each pore. If a scalar is supplied that rate is assigned to all locations, and if a vector is supplied it must be the same size as the indices given in pores.

  • total_rate (float, optional) – The total rate supplied to all pores. The rate supplied by this argument is divided evenly among all pores. A scalar must be supplied! Total_rate cannot be specified if rate is specified.

  • mode (str, optional) –

    Controls how the boundary conditions are applied. Options are:

    ’merge’ - (Default) Adds supplied boundary conditions to already existing conditions, and also overwrites any existing values. If BCs of the complementary type already exist in the given locations, these values are kept. ‘overwrite’ - Deletes all boundary conditions of the given type then adds the specified new ones (unless locations already have BCs of the other type).

Notes

The definition of quantity is specified in the algorithm’s settings, e.g. alg.settings['quantity'] = 'pore.pressure'.

set_value_BC(pores, values, mode='merge')[source]

Apply constant value boundary conditons to the specified locations.

These are sometimes referred to as Dirichlet conditions.

Parameters
  • pores (array_like) – The pore indices where the condition should be applied

  • values (scalar or array_like) – The value to apply in each pore. If a scalar is supplied it is assigne to all locations, and if a vector is applied is must be the same size as the indices given in pores.

  • mode (string, optional) –

    Controls how the boundary conditions are applied. Options are:

    ’merge’ - (Default) Adds supplied boundary conditions to already existing conditions, and also overwrites any existing values. If BCs of the complementary type already exist in the given locations, those values are kept. ‘overwrite’ - Deletes all boundary conditions of the given type then adds the specified new ones (unless locations already have BCs of the other type).

Notes

The definition of quantity is specified in the algorithm’s settings, e.g. alg.settings['quantity'] = 'pore.pressure'.

setup(phase=None, quantity='', conductance='', **kwargs)[source]

Customize algorithm settings, e.g. assign phase, set quantity to be solved, set conductance dict key, etc.

Parameters
  • phase (str) – The name of the phase on which the algorithm acts

  • quantity (str) – The name of the physical quantity to be calculated

  • conductance (str) – The name of the pore-scale transport conductance values. These are typically calculated by a model attached to a Physics object associated with the given Phase.