## For Elara PDE > **Note:** Elara PDE is still in development and hasn't yet been publicly-released but will be once it's ready. Elara PDE is meant to be a library built on top of Elara Math for solving PDEs. The goals for Elara PDE are: - Symbolic and numerical API - Support for the FEM, FDM, FVM, and BEM methods - PINN support as well that can solve for complicated geometries - Train PINN to be able to solve the EM wave equation for *arbitrary* (well-posed) initial and boundary conditions for fast prediction - Solve PDE by creating a model based on a series solution of Chebyshev polynomials then using neural net (or just regular least-squares optimization) to predict the vector of coefficients $\mathbf{x}$ such that the series solution matches the real solution as best as possible. This may allow a PINN to solve one PDE to solve the PDE with arbitrary boundary conditions. - We will use a formulation that allows solving on point cloud grids to extend to arbitrary geometries, if we have time - And sympy integration - define a PDE using Sympy and solve using PINN - would be even greater, especially if you could do this in a notebook-style environment to preview stuff with latex and make plots direction in the notebook - Neural operators: https://arxiv.org/abs/2101.07206 and see https://mathlab.github.io/PINA/_tutorial.html#neural-operator-learning The core of a library should be the `pdesolve` class for (singular or systems of) partial differential equations. Its API is to be inspired by Mathematica's `ndsolve` - see https://reference.wolfram.com/language/ref/NDSolve.html. The proposed numerical API is based on the **method of lines**, and can be used for both spatial and time-dependent PDEs: ```python h = 0.1 n = 100 c = 1 # Auto-compute sparse matrix # for ∂2u/∂x^2 # with 2nd-order approximation to second-order derivative diff_x = CentralDifference(2, order=2, step_size=h, grid_size=n) # Solve as ODE, etc. etc. # ... ``` The proposed symbolic API: ```python def pde(c=1): return D(D(u, t), t) - c ** 2 * D(D(u, x), x) solver = PDEsolve(pde, bc="Dirichlet") u = solver.compute(grid="disk") plt.title("Wave equation results") plt.imshow(u) plt.show() ``` ## For Elara CLI `elara-cli` is meant to be a generalized Python-based CLI application for accesing all of our software, numerical simulations and documentation, as well as interfaces to Arduino systems for our hardware components. ## For Elara Math ### ODE solver For elara math, we should add back the numerical (ODE) solver. It is automatically adaptive (though this can be turned off); the step size is chosen via an optimization algorithm that runs using autodiff. In addition, it uses an nth-order Taylor series to time-step, which is more flexible and accurate compared with fixed methods like RK23/RK4/RK45 - see https://fse.studenttheses.ub.rug.nl/25354/1/bMATH_2021_LeviN.pdf. It computes this Taylor series using autodiff to get & evaluate the derivatives, to ensure accuracy. Remember: $ f(t + h) = f(t_0) + f'(t_0) (t - t_0) + \dfrac{1}{2!} f''(t_0) (t - t_0)^2 + \dfrac{1}{3!} f'''(t_0) (t - t_0)^3 + \dots $ The order of the Taylor series can optionally be determined automatically, again based on an optimization algorithm that runs using autodiff (it can also be manually set). The point is an ODE solver that is as _stable_, _accurate_, and _reliable_ as possible. ### GPU acceleration Currently in elara math, the base datatype is the `Tensor`, but unlike tensors in other similar libraries, Elara Math tensors are not GPU-accelerated, which is a major missing feature. After all, there are two reasons you'd want to use tensors - either for high-performance computing (since tensors are GPU-accelerated and faster than CPU ndarrays) or for problems that require differentiable programming (since tensors natively support autograd). Elara Math's implementation of tensors should offer both, instead of just the latter. ### PDE solver components While not having a PDE solver itself, Elara Math would benefit from having important building blocks of PDE solvers (finite difference matrix automatic generation from stencils, sparse matrices, Newton root-finding solvers, eigenvalue solvers, etc.) ### New API for autodiff Idea for jax-style `elara_math.grad(func, index)` as thin wrapper over our `backward()` autodiff functionality: take in a closure `x |-> f(x)` and then just basically `eval f(x)` then `f.backward()` and then extract gradient from `x`. ### Autodiff-based rootfinding We also eventually add an implementation of newton's method using elara-math's autodiff. ### Differential coordinate transforms Use the inverse function theorem and numpy for computing inverses to be able to make an auto coordinate transform library. The user can just define their (forwards) coordinate transforms, then the library auto-calculates the backwards transforms by the inverse function theorem: $ (J [f^{- 1}]) = (J [f])^{- 1} $ Note: $J$ is the Jacobian. ### References - https://arxiv.org/abs/physics/9705023 - https://github.com/kochlisGit/Physics-Informed-Neural-Network-PINN-Tensorflow/blob/main/TF_PINN_PDE_System.ipynb - https://georgemilosh.github.io/blog/2022/distill/ - https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4634151 - https://arxiv.org/abs/2310.20360 - https://physicsbaseddeeplearning.org/overview-ns-forw.html?highlight=geometry - https://tum-pbs.github.io/PhiFlow/ - https://pypi.org/project/pyodesys/ - https://github.com/bjodah/pyneqsys