Skip to content

example_poisson2d

Example script for solving a 2D Poisson equation using FastvPINNs.

Author: Thivin Anandh (https://thivinanandh.github.io/)

Versions
  • 27-Dec-2024 (Version 0.1): Initial Implementation

boundary_data(x, y)

Function to generate the boundary data for the Poisson 2D problem

Source code in examples/sciml/pinns/forward_problems/example_poisson2d.py
def boundary_data(x, y):
    """
    Function to generate the boundary data for the Poisson 2D problem
    """
    val = 0
    return np.ones_like(x) * val

exact_solution(x, y)

Function to generate the exact solution for the Poisson 2D problem

Source code in examples/sciml/pinns/forward_problems/example_poisson2d.py
def exact_solution(x, y):
    """
    Function to generate the exact solution for the Poisson 2D problem
    """
    omegaX = 2.0 * np.pi
    omegaY = 2.0 * np.pi
    val = -1.0 * np.sin(omegaX * x) * np.sin(omegaY * y)

    return val

rhs(x, y)

Function to generate the right hand side of the Poisson 2D problem

Source code in examples/sciml/pinns/forward_problems/example_poisson2d.py
def rhs(x, y):
    """
    Function to generate the right hand side of the Poisson 2D problem
    """
    omegaX = 2.0 * np.pi
    omegaY = 2.0 * np.pi
    f_temp = -2.0 * (omegaX**2) * (np.sin(omegaX * x) * np.sin(omegaY * y))

    return f_temp