Update README.md
Browse files
README.md
CHANGED
|
@@ -1,106 +1,120 @@
|
|
| 1 |
-
#
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
|
| 9 |
-
##
|
| 10 |
|
| 11 |
-
This framework is specifically engineered to solve
|
| 12 |
|
| 13 |
-
1.
|
| 14 |
-
2.
|
| 15 |
-
3.
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
|
|
|
|
| 21 |
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
-
* **2. [cite_start]GeoNet (v26):** An advanced **"Multi-Resolution Hash Grid"** network (inspired by Instant-NGP)[cite: 17, 60]. [cite_start]It is pre-trained to learn the "sharp" geometry SDF and is then frozen (Solution to Challenge 2)[cite: 18, 60].
|
| 27 |
-
* **3. [cite_start]PhysNet (v34):** A 4D (x,y,z,t) PINN that solves the full, non-dimensionalized Maxwell's equations[cite: 19, 61].
|
| 28 |
-
* **4. [cite_start]Novel Training Strategy (v34):** A two-stage **"Pre-training and Annealing"** strategy combined with **"Aggressive Weight Balancing"** ($\lambda_{source}=10000$)[cite: 20, 62]. [cite_start]This forces the model to learn the "Source" first and prevents "Catastrophic Forgetting" (Solution to Challenge 3)[cite: 21].
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
###
|
| 37 |
|
| 38 |
-
If you don't have it, install it from [https://git-lfs.github.com](https://git-lfs.github.com).
|
| 39 |
-
Then, enable it (you only need to do this once per machine):
|
| 40 |
```bash
|
|
|
|
| 41 |
git lfs install
|
| 42 |
-
```
|
| 43 |
|
| 44 |
-
|
|
|
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
| 49 |
```
|
| 50 |
|
| 51 |
-
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
```
|
| 58 |
|
| 59 |
-
|
| 60 |
|
| 61 |
-
You can now run the example script to load the pre-trained models, run the simulation, and visualize the results.
|
| 62 |
```bash
|
| 63 |
python example_usage.py
|
| 64 |
```
|
| 65 |
|
| 66 |
---
|
| 67 |
|
| 68 |
-
## Expected
|
| 69 |
|
| 70 |
-
The
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
* **`source_position`**: `(3,)` array for the (x,y,z) coordinates of the antenna source.
|
| 77 |
-
* **`source_orientation`**: `(3,)` array for the orientation of the source E-field (e.g., `[1,0,0]` for x-polarized).
|
| 78 |
-
* **`source_signal`**: `(T_steps,)` array for the time-varying signal of the source.
|
| 79 |
-
* **`t`**: `(T_steps,)` array of time points corresponding to `source_signal`.
|
| 80 |
|
| 81 |
---
|
| 82 |
|
| 83 |
-
##
|
| 84 |
-
|
| 85 |
-
### Models Included
|
| 86 |
-
|
| 87 |
-
* `HashGridEncoder`: Efficient multi-resolution hash grid encoder for spatial coordinates.
|
| 88 |
-
* [cite_start]`GeoNetHash`: A geometry network that learns Signed Distance Functions (SDFs) of complex objects using `HashGridEncoder`[cite: 68, 119, 120].
|
| 89 |
-
* `PositionalEncoder4D`: A standard positional encoder for 4D (x, y, z, t) inputs.
|
| 90 |
-
* [cite_start]`MaxwellPINN`: The core physics-informed neural network that predicts electromagnetic fields (E, B) based on space and time coordinates[cite: 72].
|
| 91 |
|
| 92 |
-
|
| 93 |
-
*
|
| 94 |
-
* [cite_start]`compute_maxwell_loss`: Implements the physics-based loss derived from the non-dimensionalized Maxwell's equations [cite: 78, 144-150].
|
| 95 |
-
* [cite_start]`compute_data_loss`: Computes the data-driven loss from initial conditions (E0, B0) and source boundary conditions [cite: 75, 204-207].
|
| 96 |
|
| 97 |
-
## Citation
|
| 98 |
|
| 99 |
-
|
| 100 |
|
| 101 |
-
|
| 102 |
-
title = {A Novel, Hybrid, Dual-Network PINN Framework for Solving Maxwell's Equations: Overcoming Numerical Instabilities, Scale Imbalance, and Sharp Geometries},
|
| 103 |
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
This project is licensed under the MIT License.
|
|
|
|
| 1 |
+
# DualMaxwell: Hybrid Dual-Network PINN for Maxwell's Equations
|
| 2 |
|
| 3 |
+
This repository provides the official Python implementation for the paper: **"A Novel, Hybrid, Dual-Network PINN Framework for Solving Maxwell's Equations: Overcoming Numerical Instabilities, Scale Imbalance, and Sharp Geometries"**.
|
| 4 |
|
| 5 |
+
This package implements a framework for simulating electromagnetic (EM) fields by solving the full, 4D, vector Maxwell's equations using Physics-Informed Neural Networks (PINNs).
|
| 6 |
|
| 7 |
+
---
|
| 8 |
|
| 9 |
+
## Key Features & Challenges Addressed
|
| 10 |
|
| 11 |
+
This framework is specifically engineered to solve critical failure modes in standard PINN implementations:
|
| 12 |
|
| 13 |
+
1. **The Scale Challenge:** Overcomes the inherent "Scale Imbalance" (up to $10^9$) between Electric ($E$) and Magnetic ($B$) fields using non-dimensionalization.
|
| 14 |
+
2. **The Geometry Challenge:** Utilizes **GeoNet** (a Multi-Resolution Hash Grid) to learn "sharp" geometry SDFs, avoiding the smoothing bias of standard MLPs.
|
| 15 |
+
3. **The Training Challenge:** Implements a dual-network strategy with aggressive weight balancing to prevent "Catastrophic Forgetting" and trivial solutions.
|
| 16 |
|
| 17 |
+
---
|
| 18 |
|
| 19 |
+
## Installation
|
| 20 |
|
| 21 |
+
You can install and run this framework on a local machine or in cloud environments like Google Colab.
|
| 22 |
|
| 23 |
+
**Note:** This repository contains large model files (`.pth`). If running locally, ensure you have **Git LFS** installed.
|
| 24 |
|
| 25 |
+
### Option 1: Google Colab (Recommended for Testing)
|
| 26 |
|
| 27 |
+
If you are running this on Google Colab, copy and paste the following commands into a code cell:
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
```python
|
| 30 |
+
# 1. Clone the repository from Hugging Face
|
| 31 |
+
!git clone https://huggingface.co/ayda138000/DualMaxwell
|
| 32 |
|
| 33 |
+
# 2. Enter the directory
|
| 34 |
+
%cd DualMaxwell
|
| 35 |
|
| 36 |
+
# 3. Install the package and dependencies
|
| 37 |
+
!pip install .
|
| 38 |
+
!pip install torch numpy matplotlib huggingface_hub
|
| 39 |
+
````
|
| 40 |
|
| 41 |
+
### Option 2: Local Machine (Terminal)
|
| 42 |
|
|
|
|
|
|
|
| 43 |
```bash
|
| 44 |
+
# Install Git LFS if you haven't already
|
| 45 |
git lfs install
|
|
|
|
| 46 |
|
| 47 |
+
# Clone the repository
|
| 48 |
+
git clone https://huggingface.co/ayda138000/DualMaxwell
|
| 49 |
|
| 50 |
+
# Navigate to the folder
|
| 51 |
+
cd DualMaxwell
|
| 52 |
+
|
| 53 |
+
# Install the package
|
| 54 |
+
pip install .
|
| 55 |
```
|
| 56 |
|
| 57 |
+
---
|
| 58 |
|
| 59 |
+
## Running the Simulation
|
| 60 |
+
|
| 61 |
+
The repository includes an `example_usage.py` script that loads the pre-trained models (GeoNet and PhysNet) and visualizes the results.
|
| 62 |
+
|
| 63 |
+
### CRITICAL: Prepare Your Data (`ground_truth.npz`)
|
| 64 |
+
|
| 65 |
+
Before running the example, provide your own data file:
|
| 66 |
+
|
| 67 |
+
* The script expects a file named `ground_truth.npz` in the root `DualMaxwell` directory.
|
| 68 |
+
* **Google Colab:** Upload your `.npz` file into the `DualMaxwell` folder via the "Files" tab on the left sidebar.
|
| 69 |
+
* **Local:** Place the file in the cloned directory.
|
| 70 |
+
|
| 71 |
+
#### Required Data Structure
|
| 72 |
+
|
| 73 |
+
Your `ground_truth.npz` file must contain the following NumPy arrays:
|
| 74 |
+
|
| 75 |
+
* `coords`: Shape `(N, 3)`. Spatial coordinates $(x, y, z)$ used to normalize the geometry inputs.
|
| 76 |
+
* `t`: Shape `(T_steps,)` or `(N, 1)`. Time data, used to determine the maximum simulation time ($T_{max}$).
|
| 77 |
+
|
| 78 |
+
**Note:** If this file is missing or the keys `coords` and `t` do not exist, the script will exit with an error.
|
| 79 |
+
|
| 80 |
+
### Execution
|
| 81 |
+
|
| 82 |
+
Once the file is uploaded/placed, run the script:
|
| 83 |
+
|
| 84 |
+
**In Google Colab:**
|
| 85 |
+
|
| 86 |
+
```python
|
| 87 |
+
!python example_usage.py
|
| 88 |
```
|
| 89 |
|
| 90 |
+
**In Terminal:**
|
| 91 |
|
|
|
|
| 92 |
```bash
|
| 93 |
python example_usage.py
|
| 94 |
```
|
| 95 |
|
| 96 |
---
|
| 97 |
|
| 98 |
+
## Expected Output
|
| 99 |
|
| 100 |
+
The script performs the following actions:
|
| 101 |
|
| 102 |
+
1. Loads GeoNet (`geonet_real_v30.pth`) to handle geometry boundaries.
|
| 103 |
+
2. Loads PhysNet (`physnet_v31_real.pth`) to predict EM fields.
|
| 104 |
+
3. Visualizes the $E_x$ field at time $t = 0.75 \times T_{max}$.
|
| 105 |
+
4. Saves the result as an image: `v35_final_plot_defense.png`.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
---
|
| 108 |
|
| 109 |
+
## Models Included
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
+
* **GeoNetHash:** Pre-trained on the geometry SDF using Multi-Resolution Hash Grids.
|
| 112 |
+
* **MaxwellPINN:** The physics-informed network trained to solve Maxwell's equations.
|
|
|
|
|
|
|
| 113 |
|
|
|
|
| 114 |
|
| 115 |
+
## License
|
| 116 |
|
| 117 |
+
This project is licensed under the MIT License.
|
|
|
|
| 118 |
|
| 119 |
+
```
|
| 120 |
+
```
|
|
|