You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Standard MLPs are universal function approximator i.e. they're good at approximating functions ( that maps set of numbers to set of numbers).However, MLPs struggle to approximate operator (which maps function to function), partly due to Data structure and computation limitations. To approximate Operators, we use DeepONet, which is a universal operator approximator.
Here, We considered example of 1D diffusion with variable diffusion coefficient $D(x)$. We made a DeepONet network which takes $D(x)$ as input and output $u(x,t)$.
1D Diffusion equation
Fick's second law for variable diffusion coefficient is described as :
Now, in order to have a labelled dataset $D(x) \to u(x,t)$, we need to generate the function $D(x)$, and then solve for $u(x,t)$ for each $D(x)$. This is discussed in upcoming sections.
Defining the problem domain
We consider $x \in [0,1]$ and $t \in [0,1]$. We can think of it as 1D pipe spanning from $x=0$ to $x=1$ where concentration is being monitored.
Generating D(x)
First of all, We will generate many diffusion functions $D_j(x)$, $j = 1,2,...,N$ where $N$ is total number of Dataset samples.
To acheive this, we will generate linear functions in $x \in [0,1]$$s.t.$ its minimum value is $>m$ and its maximum value $< M$, where $m$ and $M$ some positive numbers $(M>m)$. Then, clearly
$$
\begin{equation*}
D(x) = ax + b
\end{equation*}
$$
Here, we generate a random linear fucntion $D(x)$ by generating coefficients $a$ and $b$ as follows:
$$
\begin{align*}
b \sim U[m,M]
\end{align*}
$$
$$
\begin{align*}
a \sim U[m-b,M-b]
\end{align*}
$$
Where $U$ is Uniform Random Distribution.
Boundary and Initial Conditions
For this problem, we define Initial condition as :
Initial Condition : $u(x,0) = sin(\pi x)$
and, there are two types of Boundary conditions
Dirichlet Boundary Conditions
We consider ends of this 1D pipe to be open. As a result, we get $u(x\text{=}0,t)=0$ and $u(x\text{=}1,t)=0$$\forall t$.
Neumann Boundary Conditions
We consider ends of this pipe to be closed. As a result, we get $\frac{\partial u}{\partial x}\vert_{x=0}=0$ and $\frac{\partial u}{\partial x}\vert_{x=1}=0$.
Solving for $u(x,t)$ using Finite Difference Method (FDM)
For each $D_j(x)$, we solve for $u_j(x,t)$ in equation $(2)$ using Finite Difference Method, Specifically FTCS.
Considering $N_x$ spatial grids and $N_t$ time grids, This gives us $u_j(x_p,t_q)$ with
$j=1,2,...,N$
$p=1,2,...,N_x$
$q=1,2,...,N_t$
This concentration Data (which we will consider ground truth for our experiment) can be expressed in matrix as
DeepONet consists of Branch Net and Trunk Net, where Branch Net takes input functions and Trunk Net takes queries (position and time at which we want our output velocity).
Suppose for each function $D_j(x)$, we have $M$ sensors at $x=x_1,x_2,...,x_M$. Then we can write this input function as matrix as :
By training this (& hence minimising $\mathcal{L}$), we learn the parameters $\theta$ to learn operator $G_{\theta}$ such that $G_{\theta} \approx \mathcal{G}$ ,
where $\mathcal{G}$ is such that $\mathcal{G}(D)(u) : \mathcal{A} \to \mathcal{U}$
Here $\mathcal{A}$ is input function space (Vector space of functions containing all possible input $D(x)$ functions) and $\mathcal{U}$ is output function space (vector space of output functions $u$).
Results
We generated data and trained our model for both boundary conditions.
Model was trained on 800 instances of training data, each for Dirichlet and Neumann B.C. and was evaluted at 200 instances of test set data. It performed well with 3.98% relative error for Dirichlet B.C. and 2.56% relative error for Neumann B.C. (error metric being $E = \frac{\Vert U_{true} - U_{predicted}\Vert_2}{\Vert U_{true}\Vert_2}$ ).
Below is result for one of the 200 predictions on test set for each B.C.
About
An illustration of how Deep Operator Network (DeepONet) is implemented, along with the code (in .ipynb file)