Loss Function Implementation for 2D Convection-Diffusion Problem
Overview
This module implements the loss function for solving 2D convection-diffusion equations using Physics-Informed Neural Networks (PINNs). It focuses on computing residuals of the Partial Differential Equation (PDE) with known coefficients.
Key Functions
pde_loss_cd2d
: Computes the PDE loss for 2D convection-diffusion equations.
Function: pde_loss_cd2d
Description
Calculates residuals for the 2D convection-diffusion problem using the PINNs methodology.
The loss function includes:
- Diffusion term: -ε∇²(u)
- Convection term: b·∇u
- Reaction term: cu
where ε
, b
, and c
are known coefficients.
Arguments
pred_nn
(tf.Tensor
): Neural network solution at quadrature points.
Shape:(N_points, 1)
pred_grad_x_nn
(tf.Tensor
): x-derivative of the neural network solution at quadrature points.
Shape:(N_points, 1)
pred_grad_y_nn
(tf.Tensor
): y-derivative of the neural network solution at quadrature points.
Shape:(N_points, 1)
pred_grad_xx_nn
(tf.Tensor
): Second-order x-derivative of the neural network solution at quadrature points.
Shape:(N_points, 1)
pred_grad_yy_nn
(tf.Tensor
): Second-order y-derivative of the neural network solution at quadrature points.
Shape:(N_points, 1)
forcing_function
(callable
): Right-hand side forcing term.bilinear_params
(dict
): A dictionary containing:eps
: Diffusion coefficient.b_x
: x-direction convection coefficient.b_y
: y-direction convection coefficient.c
: Reaction coefficient.
Returns
tf.Tensor
: Cell-wise residuals averaged over test functions.
Shape:(1,)
Notes
- The methodology combines the effects of diffusion, convection, and reaction in a unified residual formulation.