Non-Local Calculus

Description

Graph-based representation methods have shown great success in reduced-order modeling for a range of physical phenomena, that often lend themselves to a PDE form. Non-local calculus on graphs provide a mathematical framework for defining and evaluating these PDE models. This library allows the user to estimate partial derivatives in unstrutured data by systematically constructing graphs with controlled accuracy. The analysis of these methods are provided in [1]. Following section discusses the implementation of examples provided in [2].

Examples

Two examples are introduced in this section. In the first example, synthetic data is generated for a smooth function, \(u:\mathbb{R}^3 \rightarrow \mathbb{R}^3\) and estimate the derivatives, \(\nabla u\). In the second example, a reduced order model for a Reaction-diffusion system is developed using the operators identified using the Non-local calculus module.

Example 1: Derivative Calculation

This example shows the basic I/O format for the datapoints and the resulting derivatives.

Data preparation

The dataset is generated in this step, where each data point can be represented as \((x^1, x^2, x^3, u^1, u^2)\) where the input states \((x^1, x^2, x^3)\) are sampled from uniform distribution on a unit cube, \(U([0,1]^3)\), and the output states are evaluated as \(u^1 = \sum_i (x^i)^2\) and \(u^2 = ((x^1)^2 + (x^2)^2)\times\sin{(10x^1)}\). Synthetic data can be generated using the following commands

cd mechanoChemML/examples/non_local_calculus/Example1_Derivative_Calculation
python generate_data.py

The generated data is saved as a comma-separated values (CSV) file in the data/ folder.

Estimation of derivatives using Non-Local Calculus

The derivatives, \(\nabla_x u\), are generated in this step using the file estimate_derivatives.py. First, another output state, \(u^3\), is generated using following setting:

'algebraic_operations': [[{'func':lambda df: df['x_1'] + df['x_2'] + df['x_3'], 'labels':'u_3'} ]],

All the partial derivatives are requested from the code using the following setting:

'differential_operations':[[
*[{'function':'u_%i'%i,
'variable': ['x_%i'%j],
'weight':['stencil'],
'adjacency':['nearest'],
'manifold':[['x_1', 'x_2', 'x_3']],
'accuracy': [2],
'dimension':[j-1],      #Index of dimension taking partial derivative about
'order':1,
'operation':['partial'],
} for i in range(1,4) for j in range(1,4)]]]

The following commands will estimate the derivatives

cd mechanoChemML/examples/non_local_calculus/Example1_Derivative_Calculation
python estimate_derivatives.py

The result is saved in the result/ folder.

Example 2: Reduced order modeling for Allen Cahn dynamics

In this example a reduced order model is trained for 1D Reaction-Diffusion system. The basis for operators is generated using the “Non-Local Calculus” module. The regression in carried out using the “SystemID” workflow.

Data preparation

The data is generated by first solving the field \(\phi= \phi(x, t) : \Omega \times [0, T ] \rightarrow \mathbb{R}\), governed by first order dynamics driven by gradient flow:

\[\begin{split}\frac{ \partial \phi }{\partial t} &= -M_\phi \frac{\delta \psi}{\delta \phi}, \quad & \textrm{ in } \Omega \times [0,T] \\ \nabla \phi. n &= 0, \quad & \textrm{ on } \partial\Omega \\ \phi(x,0) &= \phi_0 (x) &\end{split}\]

where \(\psi = f(\phi)+ \frac{1}{2}\lambda |\nabla \phi |^2\), with \(\lambda>0\) and the first term, \(f(\phi) = (\phi^2 - 1)^2\) representing the Landau energy density with wells at \(\phi = \pm 1\). Finite Element Method is used for numerically solving the PDE using the Fenics library. Global observables are constructed by computing phase average quantities of different functions \(g(\phi)\) in the two subdomains where it is positive and negative, respectively:

\[\varphi_{g(\phi)_\pm} = \frac{1}{|\Omega|} \int\limits_{\Omega} g( \phi) I(\pm\phi) \mathrm{d}\Omega\]

where \(I\) is the indicator function and \(g(\phi) \in \{\phi, \phi^2, \phi^3, \phi^4, \phi^5, f(\phi), f'(\phi), \Delta \phi, |\nabla \phi|^2, \psi(\phi)\}\). The global observables are evaluated and saved in this step. Following commands are used for generating the data.

cd mechanoChemML/examples/non_local_calculus/Example2_Allen_Cahn/dns
python dns.py settings.prm

This generates 100 samples corresponding to different initial conditions and save the individual trajectories in the dns/data/Sample<i>/ folder.

Reduced-order modeling

Following derivatives are estimated using the Non-local calculus module where \(\Psi\) and \(\Psi_+\) represents the total energy and the energy in the positive phase, respectively.

\[\{ \frac{d\varphi_{\phi_+}}{d t}, \frac{\delta \Psi}{\delta \varphi_{g(\phi)_\pm }}, \frac{\delta \Psi_+}{\delta \varphi_{g(\phi)_\pm }} \}\]

The derivative terms are generated using the following code:

cd mechanoChemML/examples/non_local_calculus/Example2_Allen_Cahn/
python estimate_derivatives.py

Th generated basis is saved in the dns/data/Sample<i>/ProcessDump/ folder for each trajectory. These basis terms from all the trajectories are then combined and regression is carried out using the SystemID workflow. Following commands are used to estimate the reduced order model:

cd mechanoChemML/examples/non_local_calculus/Example2_Allen_Cahn/
python train_model.py config_allen_cahn

References

[1]. Duschenes, M. and Garikipati, K., 2021. Reduced order models from computed states of physical systems using non-local calculus on finite weighted graphs. arXiv preprint arXiv:2105.01740.

[2]. Zhang, X., Teichert, G.H., Wang, Z., Duschenes, M., Srivastava, S., Sunderarajan, A., Livingston, E. and Garikipati, K., 2021. mechanoChemML: A software library for machine learning in computational materials physics. arXiv preprint arXiv:2112.04960.