deepxde.icbc

deepxde.icbc.boundary_conditions module

Boundary conditions.

class deepxde.icbc.boundary_conditions.BC(geom, on_boundary, component)[source]

Bases: ABC

Boundary condition base class.

Parameters:
  • geom – A deepxde.geometry.Geometry instance.

  • on_boundary – A function: (x, Geometry.on_boundary(x)) -> True/False.

  • component – The output component satisfying this BC.

collocation_points(X)[source]
abstract error(X, inputs, outputs, beg, end, aux_var=None)[source]

Returns the loss.

filter(X)[source]
normal_derivative(X, inputs, outputs, beg, end)[source]
class deepxde.icbc.boundary_conditions.DirichletBC(geom, func, on_boundary, component=0)[source]

Bases: BC

Dirichlet boundary conditions: y(x) = func(x).

error(X, inputs, outputs, beg, end, aux_var=None)[source]

Returns the loss.

class deepxde.icbc.boundary_conditions.Interface2DBC(geom, func, on_boundary1, on_boundary2, direction='normal')[source]

Bases: object

2D interface boundary condition.

This BC applies to the case with the following conditions: (1) the network output has two elements, i.e., output = [y1, y2], (2) the 2D geometry is dde.geometry.Rectangle or dde.geometry.Polygon, which has two edges of the same length, (3) uniform boundary points are used, i.e., in dde.data.PDE or dde.data.TimePDE, train_distribution="uniform". For a pair of points on the two edges, compute <output_1, d1> for the point on the first edge and <output_2, d2> for the point on the second edge in the n/t direction (‘n’ for normal or ‘t’ for tangent). Here, <v1, v2> is the dot product between vectors v1 and v2; and d1 and d2 are the n/t vectors of the first and second edges, respectively. In the normal case, d1 and d2 are the outward normal vectors; and in the tangent case, d1 and d2 are the outward normal vectors rotated 90 degrees clockwise. The points on the two edges are paired as follows: the boundary points on one edge are sampled clockwise, and the points on the other edge are sampled counterclockwise. Then, compare the sum with ‘values’, i.e., the error is calculated as <output_1, d1> + <output_2, d2> - values, where ‘values’ is the argument func evaluated on the first edge.

Parameters:
  • geom – a dde.geometry.Rectangle or dde.geometry.Polygon instance.

  • func – the target discontinuity between edges, evaluated on the first edge, e.g., func=lambda x: 0 means no discontinuity is wanted.

  • on_boundary1 – First edge func. (x, Geometry.on_boundary(x)) -> True/False.

  • on_boundary2 – Second edge func. (x, Geometry.on_boundary(x)) -> True/False.

  • direction (string) – “normal” or “tangent”.

collocation_points(X)[source]
error(X, inputs, outputs, beg, end, aux_var=None)[source]
class deepxde.icbc.boundary_conditions.NeumannBC(geom, func, on_boundary, component=0)[source]

Bases: BC

Neumann boundary conditions: dy/dn(x) = func(x).

error(X, inputs, outputs, beg, end, aux_var=None)[source]

Returns the loss.

class deepxde.icbc.boundary_conditions.OperatorBC(geom, func, on_boundary)[source]

Bases: BC

General operator boundary conditions: func(inputs, outputs, X) = 0.

Parameters:
  • geomGeometry.

  • func – A function takes arguments (inputs, outputs, X) and outputs a tensor of size N x 1, where N is the length of inputs. inputs and outputs are the network input and output tensors, respectively; X are the NumPy array of the inputs.

  • on_boundary – (x, Geometry.on_boundary(x)) -> True/False.

Warning

If you use X in func, then do not set num_test when you define dde.data.PDE or dde.data.TimePDE, otherwise DeepXDE would throw an error. In this case, the training points will be used for testing, and this will not affect the network training and training loss. This is a bug of DeepXDE, which cannot be fixed in an easy way for all backends.

error(X, inputs, outputs, beg, end, aux_var=None)[source]

Returns the loss.

class deepxde.icbc.boundary_conditions.PeriodicBC(geom, component_x, on_boundary, derivative_order=0, component=0)[source]

Bases: BC

Periodic boundary conditions on component_x.

collocation_points(X)[source]
error(X, inputs, outputs, beg, end, aux_var=None)[source]

Returns the loss.

class deepxde.icbc.boundary_conditions.PointSetBC(points, values, component=0, batch_size=None, shuffle=True)[source]

Bases: object

Dirichlet boundary condition for a set of points.

Compare the output (that associates with points) with values (target data). If more than one component is provided via a list, the resulting loss will be the addative loss of the provided componets.

Parameters:
  • points – An array of points where the corresponding target values are known and used for training.

  • values – A scalar or a 2D-array of values that gives the exact solution of the problem.

  • component – Integer or a list of integers. The output components satisfying this BC. List of integers only supported for the backend PyTorch.

  • batch_size – The number of points per minibatch, or None to return all points. This is only supported for the backend PyTorch and PaddlePaddle. Note, If you want to use batch size here, you should also set callback ‘dde.callbacks.PDEPointResampler(bc_points=True)’ in training.

  • shuffle – Randomize the order on each pass through the data when batching.

collocation_points(X)[source]
error(X, inputs, outputs, beg, end, aux_var=None)[source]
class deepxde.icbc.boundary_conditions.PointSetOperatorBC(points, values, func)[source]

Bases: object

General operator boundary conditions for a set of points.

Compare the function output, func, (that associates with points)

with values (target data).

Parameters:
  • points – An array of points where the corresponding target values are known and used for training.

  • values – An array of values which output of function should fulfill.

  • func – A function takes arguments (inputs, outputs, X) and outputs a tensor of size N x 1, where N is the length of inputs. inputs and outputs are the network input and output tensors, respectively; X are the NumPy array of the inputs.

collocation_points(X)[source]
error(X, inputs, outputs, beg, end, aux_var=None)[source]
class deepxde.icbc.boundary_conditions.RobinBC(geom, func, on_boundary, component=0)[source]

Bases: BC

Robin boundary conditions: dy/dn(x) = func(x, y).

error(X, inputs, outputs, beg, end, aux_var=None)[source]

Returns the loss.

deepxde.icbc.initial_conditions module

Initial conditions.

class deepxde.icbc.initial_conditions.IC(geom, func, on_initial, component=0)[source]

Bases: object

Initial conditions: y([x, t0]) = func([x, t0]).

collocation_points(X)[source]
error(X, inputs, outputs, beg, end, aux_var=None)[source]
filter(X)[source]