Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update develop #194

Merged
merged 9 commits into from
Aug 28, 2024
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ conda activate neuromancer
conda install -c defaults intel-openmp -f
```

##### MacOS (Apple M1)
##### MacOS (Apple Silicon)

``` bash
conda env create -f osxarm64_env.yml
Expand Down Expand Up @@ -352,6 +352,21 @@ From the top level directory of cloned neuromancer
pip install -e . --no-deps
```

### Install Graphviz (optional)
In order to use the Problem graph plots, we recommend installing Graphviz system-wide. Note that this feature is optional.

#### For Windows:
Package must be installed manually: [Graphviz website](https://graphviz.org/download/)

#### For Linux (Debian, Ubuntu)
```bash
sudo apt install graphviz
```
#### For MacOS
```bash
brew install graphviz
```

### Test NeuroMANCER install
Run pytest on the [tests folder](https://github.com/pnnl/neuromancer/tree/master/tests).
It should take about 2 minutes to run the tests on CPU.
Expand Down
179 changes: 99 additions & 80 deletions examples/PDEs/Part_1_PINN_DiffusionEquation.ipynb

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions examples/PDEs/Part_1_PINN_DiffusionEquation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
import numpy as np
import matplotlib.pyplot as plt

# filter some user warnings from torch broadcast
import warnings
warnings.filterwarnings("ignore")


def f_real(x, t):
# exact PDE solution y(x,t)
Expand Down Expand Up @@ -61,7 +65,13 @@ def plot3D(X, T, y):
torch.set_default_dtype(torch.float) # Set default dtype to float32
torch.manual_seed(1234) # PyTorch random number generator
np.random.seed(1234) # numpy Random number generators
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# Device configuration
if torch.backends.mps.is_available():
device = torch.device('mps')
elif torch.cuda.is_available():
device = torch.device('cuda')
else:
device = torch.device('cpu')

"""
## Generate data of the exact solution
Expand Down Expand Up @@ -334,7 +344,7 @@ def plot3D(X, T, y):
)

# show the PINN computational graph
problem.show()
# problem.show()

optimizer = torch.optim.Adam(problem.parameters(), lr=0.001)
epochs = 5000
Expand All @@ -349,6 +359,7 @@ def plot3D(X, T, y):
dev_metric='train_loss',
eval_metric="train_loss",
warmup=epochs,
device=device
)

# Train PINN
Expand All @@ -360,7 +371,7 @@ def plot3D(X, T, y):
Plot the results
"""
# evaluate trained PINN on test data
PINN = problem.nodes[0]
PINN = problem.nodes[0].cpu()
y1 = PINN(test_data.datadict)['y_hat']

# arrange data for plotting
Expand All @@ -372,4 +383,3 @@ def plot3D(X, T, y):
plot3D(X, T, y_real)
# plot residuals PINN - exact PDE
plot3D(X, T, y_pinn-y_real)

189 changes: 103 additions & 86 deletions examples/PDEs/Part_2_PINN_BurgersEquation.ipynb

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions examples/PDEs/Part_2_PINN_BurgersEquation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@
import torch.nn as nn
import numpy as np
import matplotlib.pyplot as plt

# data imports
from scipy.io import loadmat
import os
os.chdir(os.path.dirname(__file__))

# filter some user warnings from torch broadcast
import warnings
warnings.filterwarnings("ignore")


def plot3D(X, T, y):
Expand Down Expand Up @@ -59,7 +66,14 @@ def plot3D(X, T, y):
torch.set_default_dtype(torch.float) # Set default dtype to float32
torch.manual_seed(1234) # PyTorch random number generator
np.random.seed(1234) # numpy Random number generators
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

# Device configuration
if torch.backends.mps.is_available():
device = torch.device('mps')
elif torch.cuda.is_available():
device = torch.device('cuda')
else:
device = torch.device('cpu')

"""
## Generate data of the exact solution
Expand Down Expand Up @@ -317,7 +331,7 @@ def plot3D(X, T, y):
)

# show the PINN computational graph
problem.show()
# problem.show()

optimizer = torch.optim.AdamW(problem.parameters(), lr=0.003)
epochs = 8000
Expand All @@ -333,6 +347,7 @@ def plot3D(X, T, y):
dev_metric='train_loss',
eval_metric="train_loss",
warmup=epochs,
device=device
)

# Train PINN
Expand All @@ -344,7 +359,7 @@ def plot3D(X, T, y):
Plot the results
"""
# evaluate trained PINN on test data
PINN = problem.nodes[0]
PINN = problem.nodes[0].cpu()
y1 = PINN(test_data.datadict)['y_hat']

# arrange data for plotting
Expand Down
248 changes: 131 additions & 117 deletions examples/PDEs/Part_3_PINN_BurgersEquation_inverse.ipynb

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions examples/PDEs/Part_3_PINN_BurgersEquation_inverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@
import torch.nn as nn
import numpy as np
import matplotlib.pyplot as plt

# data imports
from scipy.io import loadmat
import os
os.chdir(os.path.dirname(__file__))

# filter some user warnings from torch broadcast
import warnings
warnings.filterwarnings("ignore")


def plot3D(X, T, y):
Expand Down Expand Up @@ -61,7 +68,14 @@ def plot3D(X, T, y):
torch.set_default_dtype(torch.float) # Set default dtype to float32
torch.manual_seed(1234) # PyTorch random number generator
np.random.seed(1234) # numpy Random number generators
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

# Device configuration
if torch.backends.mps.is_available():
device = torch.device('mps')
elif torch.cuda.is_available():
device = torch.device('cuda')
else:
device = torch.device('cpu')

"""
## Generate data of the exact solution
Expand Down Expand Up @@ -277,7 +291,7 @@ def plot3D(X, T, y):
)

# show the PINN computational graph
problem.show()
# problem.show()

optimizer = torch.optim.AdamW(problem.parameters(), lr=0.001)
epochs = 10000
Expand All @@ -293,6 +307,7 @@ def plot3D(X, T, y):
dev_metric='train_loss',
eval_metric="train_loss",
warmup=epochs,
device=device
)

# Train PINN
Expand All @@ -309,7 +324,7 @@ def plot3D(X, T, y):
Plot the results
"""
# evaluate trained PINN on test data
PINN = problem.nodes[0]
PINN = problem.nodes[0].cpu()
y1 = PINN(test_data.datadict)['y_hat']

# arrange data for plotting
Expand Down
108 changes: 55 additions & 53 deletions examples/PDEs/Part_4_PINN_LaplaceEquationSteadyState.ipynb

Large diffs are not rendered by default.

Loading
Loading