Skip to content

Physics-Informed Machine Learning for Solving Partial Differential Equations

License

Notifications You must be signed in to change notification settings

EMSL-Computing/PIML4PDE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PIML4PDE: Physics-Informed Machine Learning for Solving Partial Differential Equations

The PIML4PDE framework is designed to solve Partial Differential Equations (PDEs) using Physics-Informed Machine Learning (PIML). This framework is intended for educational purposes, demonstrating steady-state and transient-state PDE problems. Example applications include water flow through homogeneous and heterogeneous porous media, contaminant tranport and heat conduction.

Applications of PIML4PDE

The PIML codes available here can also be directly applied to the following fields or adapted with modifications:

Multiphase Flow

  • Models the movement of multiple interacting fluid phases (e.g., water, oil, gas) in porous media.
  • Crucial for applications in petroleum engineering, COâ‚‚ sequestration, and groundwater management.

Contaminant Transport

  • Simulates the transport and fate of contaminants in water and soil systems.
  • Essential for environmental engineering, pollution control, and risk assessment.

Heat Conduction

  • Models the steady-state temperature distribution in a medium with uniform thermal conductivity and no internal heat sources.
  • Useful in thermal engineering and material science applications.

Electrostatics

  • Describes the electric potential in regions without charges.
  • Forms the foundation for studying electric fields and potentials, often applied in physics and electronics.

Elasticity Problems

  • Simulates stress distributions in materials under equilibrium conditions.
  • Commonly used in mechanical and structural engineering.

Geophysics

  • Solves electrival resistivity, gravitational or magnetic potential field problems.
  • Aids in subsurface exploration and resource management.

Image Processing

  • Provides a mathematical basis for techniques such as, edge detection, image smoothing, and noise reduction.
  • Useful in computer vision and digital image analysis.

Other Fields

  • Appears in diverse applications such as:
    • Steady-state diffusion processes.
    • Financial modeling for steady-state behaviors.

The PIML4PDE framework provides a versatile platform for solving PDEs across various disciplines, demonstrating the broad applicability of physics-informed machine learning.


Installation

This guide provides a step-by-step approach for cloning the PIML4PDE repository, creating a Conda environment named ml4pde, and installing the required dependencies on both Windows and macOS for seamless use of the PIML4PDE framework.

A. Cloning the PIML4PDE Repository

1. Git Installation: Prerequisites for Windows and Mac: If Git is not installed, do the following steps:

For Windows:
  1. Download Git for Windows from Git's official website.
  2. Run the installer and follow the setup instructions:
    • During installation, choose the default options unless you have specific preferences.
For Mac:
  1. Open the Terminal and check if Git is already installed:
git --version
  1. If not installed, you'll be prompted to install it, or download it from Git's official website.
For Linux:
  1. Open the Terminal and check if Git is already installed:
git --version

If Git is not installed, install it using:

sudo apt update
sudo apt install git
  1. If Git is not installed, you'll be prompted to install it. Follow the on-screen instructions to complete the installation. Alternatively, download Git from Git's official website and install it manually.

2. Cloning the Repository

To clone the PIML4PDE repository, follow these steps:

  1. Open a Terminal (Mac or Linux) or Git-Bash/Command-Prompt/PowerShell (Windows).

  2. Navigate to the directory where you want to clone the repository:

cd /path/to/your/desired/folder
  1. Run the command on Terminal:
git clone https://github.com/EMSL-Computing/PIML4PDE.git
  1. Navigate into the cloned repository:
cd PIML4PDE

B. Setting Up a Python Environment for PIML4PDE framework

Option-1: Using Conda (Preferred)

If Conda is not installed, download and install either Anaconda or Miniconda, depending on your preference.

For Windows:
  • Download the Anaconda installer for Windows from Anaconda's official website.
  • Run the downloaded .exe file to begin the installation.
  • Follow the setup instructions:
    • Choose the default options unless you have specific preferences.
    • Optionally, check "Add Anaconda to my PATH environment variable" during installation.
  • After installation, open Anaconda Prompt and verify the installation:
conda --version
For macOS with ARM architecture (M series):
  • Use Miniforge to install a Conda environment compatible with the ARM architecture.

  • Download the Miniforge installer for macOS (ARM64) from the Miniforge GitHub releases page.

  • Open Terminal and run the following commands:

    • Download and install Miniforge:
    curl -L -O https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
    bash Miniforge3-MacOSX-arm64.sh
    
    • Follow the instructions during installation.
    • Restart the terminal or run
    source ~/.zshrc
    
    • Verify the installation:
       conda --version
    
For macOS with Intel x86 architecture:
  • Download the Anaconda installer for macOS (Intel) from Anaconda's official website.
  • Open the downloaded .pkg file and follow the instructions to install Anaconda.
  • Alternatively, for the command-line installer, open Terminal and run:
   bash ~/Downloads/Anaconda3-latest-MacOSX-x86_64.sh
  • After installation, restart the terminal or run:
   source ~/.bash_profile
  • Verify the installation:
   conda --version
For Linux:
  • Open the Terminal and download the Anaconda installer:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
  • Run the installer:
bash Miniconda3-latest-Linux-x86_64.sh
  • Follow the prompts to complete the installation:

    • Accept the license terms and choose the installation location (default is recommended).
  • Restart the terminal or activate Conda:

source ~/.bashrc
  • Verify the installation:
conda --version

2. Create and activate the Conda Environment

Open an Anaconda Promt (Windows) or Terminal (Mac or Linux). Run the following command to create a new environment named ml4pde with Python 3.9:

conda create -n ml4pde python=3.9 -y

Activate the newly created environment:

conda activate ml4pde

3. Install the Required Packages

To install all dependencies from the requirements.txt file:

pip install -r requirements.txt

4. Verify the Installation

Type the on Anaconda Prompt (Windows) or Terminal (Mac or Linux) to lunch Jupyter Notebook:

jupyter notebook

Navigate to the example directory in the browser interface. Open and run the testing script testing_packages_for_pinn.ipynb.

You should see the following printout text after running the script if you installed all the packages successfully.

Testing imports and basic functionality...

NumPy: OK
JAX: OK
Optax: OK
Matplotlib: OK
Scikit-learn: OK

Testing complete!

In case of any errors, follow these steps:

pip uninstall <package-name>

pip install <package-name>

Option-2: Without Conda

1. Install Python

If Python is not already installed on your system, download and install the latest Python version:

  • Windows and macOS:Visit the official Python website and download the appropriate installer for your operating system.

  • Linux: Use your system's package manager to install Python (e.g., sudo apt install python3 on Ubuntu).

During installation on Windows, ensure you check the box "Add Python to PATH".

2. Create and Activate a Virtual Environment

For Windows:
  • Open Command Prompt or PowerShell and navigate to your project directory.
  • Run the following commands to create and activate a virtual environment named ml4pde:
python -m venv ml4pde

.\ml4pde\Scripts\activate
For macOS/Linux:
  • Open Terminal and navigate to your project directory.
  • Run the following commands to create and activate a virtual environment named ml4pde:
python3 -m venv ml4pde
source ml4pde/bin/activate

3. Install Required Packages

After activating the virtual environment, install the required Python packages: Use the requirements.txt file to install all dependencies:

pip install -r requirements.txt

4. Verify the Installation

Run the following command to launch a Jupyter Notebook:

jupyter notebook

Navigate to the example directory in the browser interface, open the testing script testing_packages_for_pinn.ipynb, and run it. You should see:

Testing imports and basic functionality...

NumPy: OK
JAX: OK
Optax: OK
Matplotlib: OK
Scikit-learn: OK

Testing complete!

Authors

Development, contribution, and questions

Contact Md Lal Mamud (lal.mamud@pnnl.gov) and/or Maruti Mudunuru (maruti@pnnl.gov): If you have questions or need help getting started.

Acknowledgements

This work was performed on a project award (Award DOIs: 10.46936/lser.proj.2023.60720/60008914, 10.46936/lser.proj.2023.60723/60008915, 10.46936/intm.proj.2023.60904/60008965) from the Environmental Molecular Sciences Laboratory (EMSL), a DOE Office of Science User Facility spon-sored by the Biological and Environmental Research program under contract no. DE-AC05-76RL01830.

PNNL-SA-206348

Disclaimer

This research work was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor any agency thereof, nor any of their employees, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or any agency thereof. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or any agency thereof.

About

Physics-Informed Machine Learning for Solving Partial Differential Equations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published