Skip to main content

A fast tensor-driven variational physics-informed neural network library for solving PDEs.

Project description

Unit tests Integration tests Compatability check codecov PyPI

MIT License Code style: black Python Versions status


FastVPINNs logo

Tensor-driven accelerated framework for hp-variational pinns


Link to Documentation 📚

A robust tensor-based deep learning framework for solving partial differential equations using hp-Variational Physics-Informed Neural Networks (hp-VPINNs). The framework is based on the methodology presented in the FastVPINNs Paper.

This library is a highly optimised version of the the initial implementation of hp-VPINNs by Kharazmi et al.. Refer the hp-VPINNs Paper.

Authors 👨‍💻


Thivin Anandh, Divij Ghose, Sashikumaar Ganesan

STARS Lab, Department of Computational and Data Sciences, Indian Institute of Science, Bangalore, India

Installation 🛠️


The build of the code is currently tested on Python versions (3.8, 3.9, 3.10, 3.11), on OS Ubuntu 20.04 and Ubuntu 22.04, MacOS-latest and Windows-latest (refer compatibility build Compatability check).

You can install the package using pip as follows:

pip install fastvpinns

On ubuntu systems with libGL issues caused due to matplotlib or gmsh, please run the following command to install the required dependencies:

sudo apt-get install -y libglu1-mesa 

For more information on the installation process, please refer to our documentation here.

Citing 📜


If you use this code in your research, please consider citing the following paper:

@misc{anandh2024fastvpinns,
      title={FastVPINNs: Tensor-Driven Acceleration
             of VPINNs for Complex Geometries}, 
      author={Thivin Anandh, Divij Ghose, Himanshu Jain
               and Sashikumaar Ganesan},
      year={2024},
      eprint={2404.12063},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}

Usage 🚀


For detailed usage, please refer to our documentation here.

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. We could observe that we can solve a PDE using fastvpinns using 15 lines of code.

#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()

Note : Supporting functions which define the actual solution and boundary conditions have to be passed to the main code.

Contributing 🤝


This code is currently maintained by the authors as mentioned in the section above. We welcome contributions from the community. Please refer to the documentation for guidelines on contributing to the project.

License 📑


This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastvpinns-1.0.2.tar.gz (45.6 kB view details)

Uploaded Source

Built Distribution

fastvpinns-1.0.2-py3-none-any.whl (67.8 kB view details)

Uploaded Python 3

File details

Details for the file fastvpinns-1.0.2.tar.gz.

File metadata

  • Download URL: fastvpinns-1.0.2.tar.gz
  • Upload date:
  • Size: 45.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.10

File hashes

Hashes for fastvpinns-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a3073f18b1d9cdb67a3027e726a7a7bd058a4d10bbfa53d43aa296c4f178914d
MD5 17248a0b574ac04a82951237e61b101a
BLAKE2b-256 654359d8bf28cc6066dbdb3f87e628e072ec32b2740d2e0f38d1efa5812b2195

See more details on using hashes here.

File details

Details for the file fastvpinns-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: fastvpinns-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 67.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.10

File hashes

Hashes for fastvpinns-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 670d0862d88348a8752c6126738fb9817c800ae4316f5e9ab9ce973fa590f3ca
MD5 ccdceccf043c92c1ca2ab2255453b682
BLAKE2b-256 7ff7c47b5b315e62a42e9897e42e7f93963be08f20ec93d0f73495bd240cd822

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page