Skip to content

Commit

Permalink
Joss Paper Corrections - 1
Browse files Browse the repository at this point in the history
- Added the minimal API documentation to the main documentation page
- Made corrections as per the [review](openjournals/joss-reviews#6764)
  • Loading branch information
thivinanandh committed Jul 29, 2024
1 parent 056f40a commit 6deae68
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 109 deletions.
33 changes: 32 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ FastVPINNs is a robust tensor-based framework for solving partial differential e

The framework is based on the work by `FastVPINNs Paper <https://arxiv.org/abs/2404.12063>`_. hp-Variational PINNs were originally proposed in the `hp-VPINNs Paper <https://arxiv.org/abs/2003.05385>`_.


Statement of Need
~~~~~~~~~~~~~~~~~
The FastVPINNs Python package addresses two main challenges in existing hp-VPINNs implementations. Current hp-VPINNs implementations suffer from computational inefficiency, with training times scaling linearly as the number of elements within the domain increases. Additionally, the existing implementation cannot handle complex computational domains that consist of skewed quadrilateral elements.
Expand All @@ -49,7 +50,6 @@ FastVPINNs relies on two novel contributions to address these limitations. First

The enhancements provided by FastVPINNs, including faster training times and the ability to handle complex geometries, enable broader application of the hp-VPINNs framework to real-world problems in various scientific fields.


hp-Variational Physics-informed neural network
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -60,6 +60,37 @@ For more details on the theory and implementation of hp-VPINNs, please refer to
.. image:: images/vpinns.png
:alt: VPINNs Image

Usage
~~~~~

The package provides a simple API to train and solve PDE using VPINNs. The following code snippet demonstrates how to train a hp-VPINN model for the 2D Poisson equation for a structured grid using less than 6 API calls to the FastVPINNs library.

.. code-block:: python
#load the geometry
domain = Geometry_2D("quadrilateral", "internal", 100, 100, "./")
cells, boundary_points = domain.generate_quad_mesh_internal(x_limits=[0, 1],y_limits=[0, 1],n_cells_x=4, n_cells_y=4, num_boundary_points=400)
# load the FEspace
fespace = Fespace2D(domain.mesh,cells,boundary_points,domain.mesh_type,fe_order=5,fe_type="jacobi",quad_order=5,quad_type="legendre", fe_transformation_type="bilinear",bound_function_dict=bound_function_dict,bound_condition_dict=bound_condition_dict,
forcing_function=rhs,output_path=i_output_path,generate_mesh_plot=True)
# Instantiate Data handler
datahandler = DataHandler2D(fespace, domain, dtype=tf.float32)
# Instantiate the model with the loss function for the model
model = DenseModel(layer_dims=[2, 30, 30, 30, 1],learning_rate_dict=0.01,params_dict=params_dict,
loss_function=pde_loss_poisson, ## Loss function of poisson2D
input_tensors_list=[in_tensor, dir_in, dir_out],
orig_factor_matrices=[datahandler.shape_val_mat_list,datahandler.grad_x_mat_list, datahandler.grad_y_mat_list],
force_function_list=datahandler.forcing_function_list, tensor_dtype=tf.float32,
use_attention=i_use_attention, ## Archived (not in use)
activation=i_activation,
hessian=False)
# Train the model
for epoch in range(1000):
model.train_step()
.. toctree::
:maxdepth: 3
Expand Down
69 changes: 15 additions & 54 deletions joss/jats/paper.jats
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ a Creative Commons Attribution 4.0 International License (CC BY
We have also shown that with proper hyperparameter selection,
FastVPINNs can outperform PINNs both in terms of accuracy and training
time, especially for problems with high frequency solutions.</p>
<p>Our FastVPINNs framework is built using
TensorFlow-v2.0(<xref alt="Abadi et al., 2015" rid="ref-tensorflow2015-whitepaper" ref-type="bibr">Abadi
<p>Our FastVPINNs framework is built using TensorFlow-v2.0
(<xref alt="Abadi et al., 2015" rid="ref-tensorflow2015-whitepaper" ref-type="bibr">Abadi
et al., 2015</xref>), and provides an elegant API for users to solve
both forward and inverse problems for PDEs like the Poisson, Helmholtz
and Convection-Diffusion equations. With the current level of API
Expand Down Expand Up @@ -426,58 +426,13 @@ a Creative Commons Attribution 4.0 International License (CC BY
<sec id="secU003Aminimal-working-example">
<title>Minimal Working Example</title>
<p>With the higher level of abstraction provided by the FastVPINNs
framework, users can solve a PDE with just six API calls. Shown below
is a minimal working example to solve the Poisson equation using the
FastVPINNs framework.</p>
<code language="python">#load the geometry
domain = Geometry_2D(&quot;quadrilateral&quot;, &quot;internal&quot;,
100, 100, &quot;./&quot;)
cells, boundary_points =
domain.generate_quad_mesh_internal(\
x_limits=[0, 1], y_limits=[0, 1],\
n_cells_x=4, n_cells_y=4,\
num_boundary_points=400)

# Note: Users need to provide the necessary
# boundary values and the forcing function

# load the FEspace
fespace = Fespace2D(domain.mesh,cells,boundary_points,\
domain.mesh_type,fe_order=5,\
fe_type=&quot;jacobi&quot;,quad_order=5,\
quad_type=&quot;legendre&quot;, \
fe_transformation_type=&quot;bilinear&quot;\
bound_function_dict=bound_function_dict,\
bound_condition_dict=bound_condition_dict,\
forcing_function=rhs,\
output_path=i_output_path,\
generate_mesh_plot=True)

# Instantiate Data handler
dh = datahandler2D(fespace, domain, dtype=tf.float32)

# Instantiate the model with the loss function for the model
model = DenseModel(layer_dims=[2, 30, 30, 30, 1],\
learning_rate_dict=0.01,params_dict=params_dict,
## Loss function of poisson2D
loss_function=pde_loss_poisson,
input_tensors_list=\
[in_tensor,
dir_in,
dir_out],
orig_factor_matrices=\
[dh.shape_val_mat_list,
dh.grad_x_mat_list,
dh.grad_y_mat_list],
force_function_list=dh.forcing_function_list,\
tensor_dtype=tf.float32,
use_attention=i_use_attention,
activation=i_activation,
hessian=False)

# Train the model
for epoch in range(1000):
model.train_step()</code>
framework, users can solve a PDE with just six API calls. A Minimal
working example to solve the Poisson equation using the FastVPINNs
framework ca be found
<ext-link ext-link-type="uri" xlink:href="https://cmgcds.github.io/fastvpinns/#usage">here</ext-link>.
The example files with detailed documentation can be found in the
<ext-link ext-link-type="uri" xlink:href="https://cmgcds.github.io/fastvpinns/_rst/_tutorial.html">Tutorials
section</ext-link> of the documentation.</p>
</sec>
<sec id="testing">
<title>Testing</title>
Expand Down Expand Up @@ -529,6 +484,7 @@ for epoch in range(1000):
<publisher-name>Elsevier</publisher-name>
<year iso-8601-date="2019">2019</year>
<volume>378</volume>
<pub-id pub-id-type="doi">10.1016/j.jcp.2018.10.045</pub-id>
<fpage>686</fpage>
<lpage>707</lpage>
</element-citation>
Expand All @@ -554,6 +510,7 @@ for epoch in range(1000):
<article-title>FastVPINNs: Tensor-driven acceleration of VPINNs for complex geometries</article-title>
<year iso-8601-date="2024">2024</year>
<uri>https://arxiv.org/abs/2404.12063</uri>
<pub-id pub-id-type="doi">10.48550/arXiv.2404.12063</pub-id>
</element-citation>
</ref>
<ref id="ref-kharazmi2021hp">
Expand All @@ -568,6 +525,7 @@ for epoch in range(1000):
<publisher-name>Elsevier</publisher-name>
<year iso-8601-date="2021">2021</year>
<volume>374</volume>
<pub-id pub-id-type="doi">10.1016/j.cma.2020.113547</pub-id>
<fpage>113547</fpage>
<lpage></lpage>
</element-citation>
Expand All @@ -582,6 +540,7 @@ for epoch in range(1000):
<article-title>Variational physics-informed neural networks for solving partial differential equations</article-title>
<source>arXiv preprint arXiv:1912.00873</source>
<year iso-8601-date="2019">2019</year>
<pub-id pub-id-type="doi">10.48550/arXiv.1912.00873</pub-id>
</element-citation>
</ref>
<ref id="ref-tensorflow2015-whitepaper">
Expand Down Expand Up @@ -631,6 +590,7 @@ for epoch in range(1000):
<article-title>TensorFlow: Large-scale machine learning on heterogeneous systems</article-title>
<year iso-8601-date="2015">2015</year>
<uri>https://www.tensorflow.org/</uri>
<pub-id pub-id-type="doi">10.48550/arXiv.1603.04467</pub-id>
</element-citation>
</ref>
<ref id="ref-ganesan2017finite">
Expand All @@ -642,6 +602,7 @@ for epoch in range(1000):
<source>Finite elements: Theory and algorithms</source>
<publisher-name>Cambridge University Press</publisher-name>
<year iso-8601-date="2017">2017</year>
<pub-id pub-id-type="doi">10.1017/9781108235013</pub-id>
</element-citation>
</ref>
</ref-list>
Expand Down
56 changes: 2 additions & 54 deletions joss/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Where $K_k$ is the $k^{th}$ element in the domain, $v_k$ is the test function in

The existing implementation of hp-VPINNs framework [@hp_vpinns_github] suffers from two major challenges. One being the inabilty of the framework to handle complex geometries and the other being the increased training time associated with the increase in number of elements within the domain. In the work [@anandh2024fastvpinns], we presented FastVPINNs, which addresses both of these challenges. FastVPINNs handles complex geometries by using bilinear transformation, and it uses a tensor-based loss computation to reduce the dependency of training time on number of elements. The current implementation of FastVPINNs can acheive an speed-up of upto a 100 times when compared with the existing implementation of hp-VPINNs. We have also shown that with proper hyperparameter selection, FastVPINNs can outperform PINNs both in terms of accuracy and training time, especially for problems with high frequency solutions.

Our FastVPINNs framework is built using TensorFlow-v2.0[@tensorflow2015-whitepaper], and provides an elegant API for users to solve both forward and inverse problems for PDEs like the Poisson, Helmholtz and Convection-Diffusion equations. With the current level of API abstraction, users should be able to solve PDEs with less than six API calls as shown in the minimal working example section. The framework is well-documented with examples, which can enable users to get started with the framework with ease.
Our FastVPINNs framework is built using TensorFlow-v2.0 [@tensorflow2015-whitepaper], and provides an elegant API for users to solve both forward and inverse problems for PDEs like the Poisson, Helmholtz and Convection-Diffusion equations. With the current level of API abstraction, users should be able to solve PDEs with less than six API calls as shown in the minimal working example section. The framework is well-documented with examples, which can enable users to get started with the framework with ease.

The ability of the framework to allow users to train a hp-VPINNs to solve a PDE both faster and with minimal code, can result in widespread application of this method on several real-world problems, which often require complex geometries with a large number of elements within the domain.

Expand Down Expand Up @@ -120,59 +120,7 @@ This module contains custom subclasses of the `tensorflow.keras.Model` class, wh

# Minimal Working Example {#sec:minimal-working-example}

With the higher level of abstraction provided by the FastVPINNs framework, users can solve a PDE with just six API calls. Shown below is a minimal working example to solve the Poisson equation using the FastVPINNs framework.

```python
#load the geometry
domain = Geometry_2D("quadrilateral", "internal",
100, 100, "./")
cells, boundary_points =
domain.generate_quad_mesh_internal(\
x_limits=[0, 1], y_limits=[0, 1],\
n_cells_x=4, n_cells_y=4,\
num_boundary_points=400)

# Note: Users need to provide the necessary
# boundary values and the forcing function

# load the FEspace
fespace = Fespace2D(domain.mesh,cells,boundary_points,\
domain.mesh_type,fe_order=5,\
fe_type="jacobi",quad_order=5,\
quad_type="legendre", \
fe_transformation_type="bilinear"\
bound_function_dict=bound_function_dict,\
bound_condition_dict=bound_condition_dict,\
forcing_function=rhs,\
output_path=i_output_path,\
generate_mesh_plot=True)

# Instantiate Data handler
dh = datahandler2D(fespace, domain, dtype=tf.float32)

# Instantiate the model with the loss function for the model
model = DenseModel(layer_dims=[2, 30, 30, 30, 1],\
learning_rate_dict=0.01,params_dict=params_dict,
## Loss function of poisson2D
loss_function=pde_loss_poisson,
input_tensors_list=\
[in_tensor,
dir_in,
dir_out],
orig_factor_matrices=\
[dh.shape_val_mat_list,
dh.grad_x_mat_list,
dh.grad_y_mat_list],
force_function_list=dh.forcing_function_list,\
tensor_dtype=tf.float32,
use_attention=i_use_attention,
activation=i_activation,
hessian=False)

# Train the model
for epoch in range(1000):
model.train_step()
```
With the higher level of abstraction provided by the FastVPINNs framework, users can solve a PDE with just six API calls. A Minimal working example to solve the Poisson equation using the FastVPINNs framework ca be found [here](https://cmgcds.github.io/fastvpinns/#usage). The example files with detailed documentation can be found in the [Tutorials section](https://cmgcds.github.io/fastvpinns/_rst/_tutorial.html) of the documentation.

# Testing

Expand Down
Binary file modified joss/paper.pdf
Binary file not shown.

0 comments on commit 6deae68

Please sign in to comment.