deepxde.icbc
deepxde.icbc.boundary_conditions module
Boundary conditions.
- class deepxde.icbc.boundary_conditions.BC(geom, on_boundary, component)[source]
Bases:
ABCBoundary condition base class.
- Parameters:
geom – A
deepxde.geometry.Geometryinstance.on_boundary – A function: (x, Geometry.on_boundary(x)) -> True/False.
component – The output component satisfying this BC.
- class deepxde.icbc.boundary_conditions.DirichletBC(geom, func, on_boundary, component=0)[source]
Bases:
BCDirichlet boundary conditions: y(x) = func(x).
- class deepxde.icbc.boundary_conditions.Interface2DBC(geom, func, on_boundary1, on_boundary2, direction='normal')[source]
Bases:
object2D 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.Rectangleordde.geometry.Polygon, which has two edges of the same length, (3) uniform boundary points are used, i.e., indde.data.PDEordde.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.Rectangleordde.geometry.Polygoninstance.func – the target discontinuity between edges, evaluated on the first edge, e.g.,
func=lambda x: 0means 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”.
- class deepxde.icbc.boundary_conditions.NeumannBC(geom, func, on_boundary, component=0)[source]
Bases:
BCNeumann boundary conditions: dy/dn(x) = func(x).
- class deepxde.icbc.boundary_conditions.OperatorBC(geom, func, on_boundary)[source]
Bases:
BCGeneral operator boundary conditions: func(inputs, outputs, X) = 0.
- Parameters:
geom –
Geometry.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_testwhen you definedde.data.PDEordde.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.
- class deepxde.icbc.boundary_conditions.PeriodicBC(geom, component_x, on_boundary, derivative_order=0, component=0)[source]
Bases:
BCPeriodic boundary conditions on component_x.
- class deepxde.icbc.boundary_conditions.PointSetBC(points, values, component=0, batch_size=None, shuffle=True)[source]
Bases:
objectDirichlet 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.
- class deepxde.icbc.boundary_conditions.PointSetOperatorBC(points, values, func, batch_size=None, shuffle=True)[source]
Bases:
objectGeneral 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.
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.
deepxde.icbc.initial_conditions module
Initial conditions.