Skip to content

Commit 2b3da6e

Browse files
authored
Merge pull request #248 from CEMeNT-PSAAP/dev
version 0.11.0
2 parents eb564c6 + 7e22708 commit 2b3da6e

File tree

176 files changed

+7333
-9596
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+7333
-9596
lines changed

.github/workflows/numba_reg.yml renamed to .github/workflows/regression_test-numba_cpu.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ jobs:
2222
- uses: mpi4py/setup-mpi@v1
2323
- name: Install dependencies
2424
run: |
25-
#sudo apt-get install libopenmpi-dev
26-
#pip install numpy numba h5py matplotlib scipy pytest colorama mpi4py ngsolve distinctipy
27-
pip list
2825
pip install -e .
26+
pip list
2927
- name: Patch Numba
3028
run : |
3129
bash .github/workflows/patch.sh
3230
- name: Regression Test - Numba
3331
run: |
3432
cd test/regression
35-
python run.py --mode=numba
33+
python run.py --mode=numba

.github/workflows/mpi_numba_reg.yml renamed to .github/workflows/regression_test-numba_cpu_mpi.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
os: ["ubuntu-latest"] #, "macos-latest"
11+
os: ["ubuntu-latest"]
1212
steps:
1313
- uses: actions/checkout@v3
1414
- name: Set up python 3.11
@@ -22,10 +22,8 @@ jobs:
2222
- uses: mpi4py/setup-mpi@v1
2323
- name: Install dependencies
2424
run: |
25-
#sudo apt-get install libopenmpi-dev
26-
#pip install numpy numba h5py matplotlib scipy pytest colorama mpi4py ngsolve distinctipy
27-
pip list
2825
pip install -e .
26+
pip list
2927
- name: Patch Numba
3028
run : |
3129
bash .github/workflows/patch.sh

.github/workflows/numba_gpu.yml renamed to .github/workflows/regression_test-numba_gpu.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ jobs:
2424
- uses: mpi4py/setup-mpi@v1
2525
- name: Install dependencies
2626
run: |
27-
#sudo apt-get install libopenmpi-dev
28-
#pip install numpy numba h5py matplotlib scipy pytest colorama mpi4py ngsolve distinctipy
29-
pip list
3027
pip install -e .
28+
pip list
3129
- name: Patch Numba
3230
run : |
3331
bash .github/workflows/patch.sh
3432
- name: Regression Test - Numba
3533
run: |
3634
cd test/regression
37-
python run.py --mode=numba
35+
python run.py --mode=numba --target=gpu

.github/workflows/python_reg.yml renamed to .github/workflows/regression_test-python.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ jobs:
2222
- uses: mpi4py/setup-mpi@v1
2323
- name: Install dependencies
2424
run: |
25-
#sudo apt-get install libopenmpi-dev
26-
#pip install numpy numba h5py matplotlib scipy pytest colorama mpi4py ngsolve distinctipy
27-
pip list
2825
pip install -e .
26+
pip list
2927
- name: Patch Numba
3028
run : |
3129
bash .github/workflows/patch.sh
3230
- name: Regression Test - Python
3331
run: |
3432
cd test/regression
35-
python run.py
33+
python run.py

.github/workflows/mpi_reg.yml renamed to .github/workflows/regression_test-python_mpi.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ jobs:
2222
- uses: mpi4py/setup-mpi@v1
2323
- name: Install dependencies
2424
run: |
25-
#sudo apt-get install libopenmpi-dev
26-
#pip install numpy numba h5py matplotlib scipy pytest colorama mpi4py ngsolve distinctipy
27-
pip list
2825
pip install -e .
26+
pip list
2927
- name: Patch Numba
3028
run : |
3129
bash .github/workflows/patch.sh
File renamed without changes.

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ __pycache__
1515

1616
# GPU cache
1717
__ptxcache__
18+
__harmonize_cache__
1819

1920
# Editor
2021
.spyproject
@@ -55,3 +56,7 @@ docs/build
5556
docs/source/pythonapi/generated/
5657

5758
*.csv
59+
60+
# Regression tests
61+
dummy_nuclide.h5
62+
source_particles.h5

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
repos:
2+
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
3+
- repo: https://github.com/psf/black-pre-commit-mirror
4+
rev: 24.8.0
5+
hooks:
6+
- id: black
7+
# It is recommended to specify the latest version of Python
8+
# supported by your project here, or alternatively use
9+
# pre-commit's default_language_version, see
10+
# https://pre-commit.com/#top_level-default_language_version
11+
language_version: python3.11

README.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,28 @@ Our documentation on installation, contribution, and a brief user guide is on [R
1717

1818
## Installation
1919

20-
We recommend using [`conda`](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) or some other environment manager to manage the MC/DC installation.
20+
We recommend using [Python virtual environments (venv)](https://docs.python.org/3/library/venv.html) or some other environment manager (e.g. conda) to manage the MC/DC installation.
2121
This avoids the need for admin access when installing MC/DC's dependencies and allows greater configurability for developers.
22-
For most users working on a single machine of which they are administrators, MC/DC can be installed via pip:
22+
For most users working in a venv, MC/DC can be installed via pip:
2323
```bash
2424
pip install mcdc
2525
```
26-
For developers or users on HPC machines, we recommend that you *not* use the pip distribution and instead install MC/DC and its dependencies via the included [install script](https://mcdc.readthedocs.io/en/latest/install.html), which builds `mpi4py` from source and uses conda to manage your environment. *This is the most reliable way to install and configure MC/DC*. It also takes care of the [Numba patch]() and can configure the [continuous energy data library](), if you have access.
26+
For developers or users on HPC machines, mpi4py is often distributed as part of an HPC machines given venv.
2727

2828
### Common issues with `mpi4py`
2929

3030
The `pip mpi4py` distribution commonly has errors when building due to incompatible local MPI dependencies it builds off of. While pip does have some remedy for this, we recommend the following:
3131
* **Mac users:** we recommend `openmpi` is [installed via homebrew](https://formulae.brew.sh/formula/open-mpi) (note that more reliable mpi4py distribution can also be [found on homebrew](https://formulae.brew.sh/formula/mpi4py)), alternatively you can use `conda` if you don't have admin privileges;
3232
* **Linux users:** we recommend `openmpi` is installed via a root package manager if possible (e.g. `sudo apt install openmpi`) or a conda distribution (e.g. `conda install openmpi`)
33-
* **HPC users and developers on any system:** On HPC systems in particular, `mpi4py` must be built using the system's existing `mpi` installation. Installing MC/DC using the [install script](https://mcdc.readthedocs.io/en/latest/install.html) we've included will handle that for you by installing dependencies using conda rather than pip. It also takes care of the [Numba patch]() and can configure the [continuous energy data library](), if you have access.
33+
* **HPC users and developers on any system:** On HPC systems that do not supply a suitable venv, `mpi4py` may need to be built using the system's existing `mpi` installation. Installing MC/DC using the [install script](https://mcdc.readthedocs.io/en/latest/install.html) we've included will handle that for you by installing dependencies using conda rather than pip. It also takes care of the [Numba patch](https://github.com/CEMeNT-PSAAP/MCDC/blob/main/patch_numba.sh) and can configure the [continuous energy data library](https://github.com/CEMeNT-PSAAP/MCDC/blob/main/config_cont_energy.sh), if you have access.
3434

3535
### Numba Config
3636

3737
Running MC/DC performantly in [Numba mode](#numba-mode) requires a patch to a single Numba file. If you installed MC/DC with the [install script](https://mcdc.readthedocs.io/en/latest/install.html), this patch has already been taken care of. If you installed via pip, we have a patch script will make the necessary changes for you:
38-
1. Download the `patch.sh` file [here]() (If you've cloned MC/DC's GitHub repository, you already have this file in your MCDC/ directory).
38+
1. Download the `patch.sh` file [here](https://github.com/CEMeNT-PSAAP/MCDC/blob/main/patch_numba.sh) (If you've cloned MC/DC's GitHub repository, you already have this file in your MCDC/ directory).
3939
2. In your active conda environment, run `bash patch_numba.sh`.
4040
*If you manage your environment with conda, you will not need admin privileges*.
4141

42-
### `visualizer` Config
43-
44-
MC/DC has a visualizer built from the [netgen package](https://ngsolve.org/). This is not included in the base install of MC/DC due to the size of the dependencies (~300MB). To install these dependencies use
45-
```bash
46-
pip install mcdc['viz']
47-
```
48-
4942
## Running
5043

5144
MC/DC can be executed in different modes: via pure python or via a `jit` compiled version (Numba mode).

examples/eigenvalue/2d_c5g7_iqmc/input.py renamed to examples/c5g7/2d/k-eigenvalue-iqmc/input.py

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# =============================================================================
99

1010
# Load material data
11-
lib = h5py.File("2d_c5g7_xs.h5", "r")
11+
lib = h5py.File("../../MGXS-C5G7.h5", "r")
1212

1313

1414
# Materials
@@ -41,23 +41,23 @@ def set_mat(mat):
4141
cy = mcdc.surface("cylinder-z", center=[0.0, 0.0], radius=radius)
4242

4343
# Cells
44-
uo2 = mcdc.cell([-cy], mat_uo2)
45-
mox4 = mcdc.cell([-cy], mat_mox43)
46-
mox7 = mcdc.cell([-cy], mat_mox7)
47-
mox8 = mcdc.cell([-cy], mat_mox87)
48-
gt = mcdc.cell([-cy], mat_gt)
49-
fc = mcdc.cell([-cy], mat_fc)
50-
mod = mcdc.cell([+cy], mat_mod)
51-
modi = mcdc.cell([-cy], mat_mod) # For all-water lattice
44+
uo2 = mcdc.cell(-cy, mat_uo2)
45+
mox4 = mcdc.cell(-cy, mat_mox43)
46+
mox7 = mcdc.cell(-cy, mat_mox7)
47+
mox8 = mcdc.cell(-cy, mat_mox87)
48+
gt = mcdc.cell(-cy, mat_gt)
49+
fc = mcdc.cell(-cy, mat_fc)
50+
mod = mcdc.cell(+cy, mat_mod)
51+
modi = mcdc.cell(-cy, mat_mod) # For all-water lattice
5252

5353
# Universes
54-
u = mcdc.universe([uo2, mod])["ID"]
55-
l = mcdc.universe([mox4, mod])["ID"]
56-
m = mcdc.universe([mox7, mod])["ID"]
57-
n = mcdc.universe([mox8, mod])["ID"]
58-
g = mcdc.universe([gt, mod])["ID"]
59-
f = mcdc.universe([fc, mod])["ID"]
60-
w = mcdc.universe([modi, mod])["ID"]
54+
u = mcdc.universe([uo2, mod])
55+
l = mcdc.universe([mox4, mod])
56+
m = mcdc.universe([mox7, mod])
57+
n = mcdc.universe([mox8, mod])
58+
g = mcdc.universe([gt, mod])
59+
f = mcdc.universe([fc, mod])
60+
w = mcdc.universe([modi, mod])
6161

6262
# =============================================================================
6363
# Assemblies
@@ -125,14 +125,14 @@ def set_mat(mat):
125125
y0 = mcdc.surface("plane-y", y=-pitch * 17 / 2)
126126
y1 = mcdc.surface("plane-y", y=pitch * 17 / 2)
127127
# Cells
128-
assembly_uo2 = mcdc.cell([+x0, -x1, +y0, -y1], lattice_uo2)
129-
assembly_mox = mcdc.cell([+x0, -x1, +y0, -y1], lattice_mox)
130-
assembly_mod = mcdc.cell([+x0, -x1, +y0, -y1], lattice_mod)
128+
assembly_uo2 = mcdc.cell(+x0 & -x1 & +y0 & -y1, lattice_uo2)
129+
assembly_mox = mcdc.cell(+x0 & -x1 & +y0 & -y1, lattice_mox)
130+
assembly_mod = mcdc.cell(+x0 & -x1 & +y0 & -y1, lattice_mod)
131131

132132
# Set assemblies in their respective universes
133-
u_ = mcdc.universe([assembly_uo2])["ID"]
134-
m_ = mcdc.universe([assembly_mox])["ID"]
135-
w_ = mcdc.universe([assembly_mod])["ID"]
133+
u_ = mcdc.universe([assembly_uo2])
134+
m_ = mcdc.universe([assembly_mox])
135+
w_ = mcdc.universe([assembly_mod])
136136

137137
# =============================================================================
138138
# Root universe: core
@@ -153,9 +153,9 @@ def set_mat(mat):
153153
y1_ = mcdc.surface("plane-y", y=0.0, bc="reflective")
154154
# Cell
155155
core = mcdc.cell(
156-
[+x0_, -x1_, +y0_, -y1_],
156+
+x0_ & -x1_ & +y0_ & -y1_,
157157
lattice_core,
158-
lattice_center=[pitch * 17 * 3 / 2, -pitch * 17 * 3 / 2, 0.0],
158+
translation=[pitch * 17 * 3 / 2, -pitch * 17 * 3 / 2, 0.0],
159159
)
160160

161161
# Root universe
@@ -165,27 +165,21 @@ def set_mat(mat):
165165
# iQMC Parameters
166166
# =============================================================================
167167
N = 1e4
168-
maxit = 10
169-
tol = 1e-3
170168
Nx = 17 * 3 * 2
171169
Ny = 17 * 3 * 2
172170
G = 7
173171
x_grid = np.linspace(0.0, pitch * 17 * 3, Nx + 1)
174172
y_grid = np.linspace(-pitch * 17 * 3, 0.0, Ny + 1)
175-
solver = "power_iteration"
176173

177174
phi0 = np.ones((G, Nx, Ny))
178-
fixed_source = np.zeros_like(phi0)
179175

180176
mcdc.iQMC(
181177
x=x_grid,
182178
y=y_grid,
183179
g=np.ones(G),
184180
phi0=phi0,
185-
fixed_source=fixed_source,
186-
eigenmode_solver=solver,
187-
maxit=maxit,
188-
tol=tol,
181+
mode="batched",
182+
scores=["source-x", "source-y"],
189183
)
190184

191185
# =============================================================================
@@ -194,7 +188,7 @@ def set_mat(mat):
194188

195189
# Setting
196190
mcdc.setting(N_particle=N)
197-
mcdc.eigenmode()
191+
mcdc.eigenmode(N_inactive=40, N_active=10)
198192

199193
# Run
200194
mcdc.run()

examples/eigenvalue/2d_c5g7/input.py renamed to examples/c5g7/2d/k-eigenvalue/input.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# =============================================================================
99

1010
# Load material data
11-
lib = h5py.File("2d_c5g7_xs.h5", "r")
11+
lib = h5py.File("../../MGXS-C5G7.h5", "r")
1212

1313

1414
# Materials
@@ -41,23 +41,23 @@ def set_mat(mat):
4141
cy = mcdc.surface("cylinder-z", center=[0.0, 0.0], radius=radius)
4242

4343
# Cells
44-
uo2 = mcdc.cell([-cy], mat_uo2)
45-
mox4 = mcdc.cell([-cy], mat_mox43)
46-
mox7 = mcdc.cell([-cy], mat_mox7)
47-
mox8 = mcdc.cell([-cy], mat_mox87)
48-
gt = mcdc.cell([-cy], mat_gt)
49-
fc = mcdc.cell([-cy], mat_fc)
50-
mod = mcdc.cell([+cy], mat_mod)
51-
modi = mcdc.cell([-cy], mat_mod) # For all-water lattice
44+
uo2 = mcdc.cell(-cy, mat_uo2)
45+
mox4 = mcdc.cell(-cy, mat_mox43)
46+
mox7 = mcdc.cell(-cy, mat_mox7)
47+
mox8 = mcdc.cell(-cy, mat_mox87)
48+
gt = mcdc.cell(-cy, mat_gt)
49+
fc = mcdc.cell(-cy, mat_fc)
50+
mod = mcdc.cell(+cy, mat_mod)
51+
modi = mcdc.cell(-cy, mat_mod) # For all-water lattice
5252

5353
# Universes
54-
u = mcdc.universe([uo2, mod])["ID"]
55-
l = mcdc.universe([mox4, mod])["ID"]
56-
m = mcdc.universe([mox7, mod])["ID"]
57-
n = mcdc.universe([mox8, mod])["ID"]
58-
g = mcdc.universe([gt, mod])["ID"]
59-
f = mcdc.universe([fc, mod])["ID"]
60-
w = mcdc.universe([modi, mod])["ID"]
54+
u = mcdc.universe([uo2, mod])
55+
l = mcdc.universe([mox4, mod])
56+
m = mcdc.universe([mox7, mod])
57+
n = mcdc.universe([mox8, mod])
58+
g = mcdc.universe([gt, mod])
59+
f = mcdc.universe([fc, mod])
60+
w = mcdc.universe([modi, mod])
6161

6262
# =============================================================================
6363
# Assemblies
@@ -125,14 +125,14 @@ def set_mat(mat):
125125
y0 = mcdc.surface("plane-y", y=-pitch * 17 / 2)
126126
y1 = mcdc.surface("plane-y", y=pitch * 17 / 2)
127127
# Cells
128-
assembly_uo2 = mcdc.cell([+x0, -x1, +y0, -y1], lattice_uo2)
129-
assembly_mox = mcdc.cell([+x0, -x1, +y0, -y1], lattice_mox)
130-
assembly_mod = mcdc.cell([+x0, -x1, +y0, -y1], lattice_mod)
128+
assembly_uo2 = mcdc.cell(+x0 & -x1 & +y0 & -y1, lattice_uo2)
129+
assembly_mox = mcdc.cell(+x0 & -x1 & +y0 & -y1, lattice_mox)
130+
assembly_mod = mcdc.cell(+x0 & -x1 & +y0 & -y1, lattice_mod)
131131

132132
# Set assemblies in their respective universes
133-
u_ = mcdc.universe([assembly_uo2])["ID"]
134-
m_ = mcdc.universe([assembly_mox])["ID"]
135-
w_ = mcdc.universe([assembly_mod])["ID"]
133+
u_ = mcdc.universe([assembly_uo2])
134+
m_ = mcdc.universe([assembly_mox])
135+
w_ = mcdc.universe([assembly_mod])
136136

137137
# =============================================================================
138138
# Root universe: core
@@ -153,9 +153,9 @@ def set_mat(mat):
153153
y1_ = mcdc.surface("plane-y", y=0.0, bc="reflective")
154154
# Cell
155155
core = mcdc.cell(
156-
[+x0_, -x1_, +y0_, -y1_],
156+
+x0_ & -x1_ & +y0_ & -y1_,
157157
lattice_core,
158-
lattice_center=[pitch * 17 * 3 / 2, -pitch * 17 * 3 / 2, 0.0],
158+
translation=[pitch * 17 * 3 / 2, -pitch * 17 * 3 / 2, 0.0],
159159
)
160160

161161
# Root universe
@@ -177,7 +177,7 @@ def set_mat(mat):
177177
# Tally
178178
x_grid = np.linspace(0.0, pitch * 17 * 3, 17 * 3 + 1)
179179
y_grid = np.linspace(-pitch * 17 * 3, 0.0, 17 * 3 + 1)
180-
mcdc.tally(scores=["flux"], x=x_grid, y=y_grid, g="all")
180+
mcdc.tally.mesh_tally(scores=["flux"], x=x_grid, y=y_grid, g="all")
181181

182182
# Setting
183183
mcdc.setting(N_particle=1e3)

examples/eigenvalue/2d_c5g7/process.py renamed to examples/c5g7/2d/k-eigenvalue/process.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
# Results
1111
with h5py.File("output.h5", "r") as f:
12-
phi_avg = f["tally/flux/mean"][:]
13-
phi_sd = f["tally/flux/sdev"][:]
12+
phi_avg = f["tallies/mesh_tally_0/flux/mean"][:]
13+
phi_sd = f["tallies/mesh_tally_0/flux/sdev"][:]
1414
k = f["k_cycle"][:]
1515
k_avg = f["k_mean"][()]
1616
k_sd = f["k_sdev"][()]
1717
rg = f["gyration_radius"][:]
18-
x = f["tally/grid/x"][:]
19-
y = f["tally/grid/y"][:]
18+
x = f["tallies/mesh_tally_0/grid/x"][:]
19+
y = f["tallies/mesh_tally_0/grid/y"][:]
2020

2121
dx = x[1] - x[0]
2222
x_mid = 0.5 * (x[1:] + x[:-1])

0 commit comments

Comments
 (0)