← Back to Course Schedule

Homework 4 — FEM vs PINNs (Due 4/1 by 11:59 PM)

In this homework we will compare a solution to the Poisson equation using FEM and a physics-informed neural network. You are welcome to work with friends or to use external resources/tools. If you do, you must attribute them in your submission to comply with the UPenn academic code.

AI use policy: You are encouraged to use LLMs to help you explain code and to debug your own code. In order to succeed as the class gets progressively more difficult, you will however need command over how a code like this is structured. Do not just ask an LLM to complete these assignments or you will lose out on building the muscle memory needed to complete future assignments!

Consider the Poisson equation

$$-\nabla^2 u = f$$

with Dirichlet boundary conditions

$$u\big|_{\partial \Omega} = g.$$

We will discretize this PDE on the unit square with a circle of radius $0.15$ removed from its center ($\Omega = [0,1]^2 \setminus B_{0.15}(0.5,0.5)$).

To assess the convergence of FEM and PINNs, we will use the method of manufactured solutions to generate a smooth solution.

Question 1 — Manufactured Solution

"Manufacture" a choice of $f$ and $g$ such that $u = \sin(2\pi x)\sin(2\pi y)$ solves the PDE.

Question 2 — FEM Convergence

Use the scikit-FEM code provided in class to solve this problem. Solve on a sequence of meshes to analyze convergence. Generate a table illustrating the $L^2$ error as a function of the maximum element size, $h$. Comment on how this compares with the FEM convergence theory we discussed in class.

Question 3 — PINN Solution

Generate a PINN that solves the same equation. It will be challenging to perform an apples-to-apples comparison of performance. Articulate your choices for:

Question 4 — Discussion

Discuss and compare the two methods in terms of speed of solution, accuracy, and any other takeaways from the exercise that you find noteworthy.