Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ TL;DR
```bash
conda create --name voxenv python=3.12
conda activate voxenv
pip install evoxels[torch,jax,dev,notebooks]
pip install "evoxels[torch,jax,dev,notebooks]"
pip install --upgrade "jax[cuda12]"
```

Expand All @@ -59,7 +59,7 @@ Navigate to the evoxels folder, then
```
pip install -e .[torch] # install with torch backend
pip install -e .[jax] # install with jax backend
pip install -e .[dev, notebooks] # install testing and notebooks
pip install -e .[dev,notebooks] # install testing and notebooks
```
Note that the default `[jax]` installation is only CPU compatible. To install the corresponding CUDA libraries check your CUDA version with
```bash
Expand All @@ -71,7 +71,7 @@ pip install -U "jax[cuda12]"
```
To install both backends within one environment it is important to install torch first and then upgrade the `jax` installation e.g.
```bash
pip install evoxels[torch, jax, dev, notebooks]
pip install "evoxels[torch,jax,dev,notebooks]"
pip install --upgrade "jax[cuda12]"
```
To work with the example notebooks install Jupyter and all notebook related dependencies via
Expand Down
12 changes: 6 additions & 6 deletions docs/notebooks/00-using-voxelfields.ipynb

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions docs/notebooks/01-using-solvers.ipynb

Large diffs are not rendered by default.

25 changes: 12 additions & 13 deletions docs/notebooks/02-microstructure-workflow.ipynb

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions docs/notebooks/03-ODE-prototyping.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions evoxels/problem_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def __post_init__(self):
bc_fun = self.vg.bc.pad_zero_flux_periodic
self.pad_boundary = lambda field, bc0, bc1: bc_fun(field)
k_squared = self.vg.fft_k_squared_nonperiodic()
else:
raise ValueError(f"Unsupported BC type: {self.BC_type}")

self._fourier_symbol = -self.D * self.A * k_squared

Expand Down
10 changes: 8 additions & 2 deletions evoxels/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ def mms_convergence_test(
vf = evo.VoxelFields((2**p, 2**p, 2**p), (1, 1, 1), convention=convention)
elif convention == 'staggered_x':
vf = evo.VoxelFields((2**p + 1, 2**p, 2**p), (1, 1, 1), convention=convention)
else:
raise ValueError("Chosen convention must be cell_center or staggered_x.")
vf.precision = dtype
dx[i] = vf.spacing[0]

Expand All @@ -231,6 +233,8 @@ def mms_convergence_test(
ODE = ODE_class(vg, **problem_kwargs)
rhs_orig = ODE.rhs
grid = vg.meshgrid()
if convention == 'staggered_x':
grid = (grid[0][1:-1,:,:], grid[1][1:-1,:,:], grid[2][1:-1,:,:])

# Construct new rhs including forcing term from MMS
if mode == 'temporal':
Expand All @@ -246,7 +250,6 @@ def mms_rhs(t, u):
u_ex_list.append(vg.expand_dim(u_list[j](t_, *grid), 0))
rhs = vg.set(rhs, j, rhs[j] + u_t_list[j](t_, *grid))
u_ex = vg.concatenate(u_ex_list, 0)
u_ex = vg.bc.trim_boundary_nodes(u_ex)
rhs -= rhs_orig(t, u_ex)
return rhs

Expand Down Expand Up @@ -322,7 +325,10 @@ def mms_rhs(t, u):
for j, func in enumerate(test_functions):
exact = vf.fields[f'u{j}_final']
diff = vf.fields[f'u{j}'] - exact
errors[j, k, i] = np.linalg.norm(diff) / np.linalg.norm(exact)
if convention == 'staggered_x':
errors[j, k, i] = np.linalg.norm(diff[1:-1,:,:]) / np.linalg.norm(exact[1:-1,:,:])
else:
errors[j, k, i] = np.linalg.norm(diff) / np.linalg.norm(exact)

# Fit slope after loop
def calc_slope(x, y):
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ dev = [
notebooks = [
"ipywidgets",
"ipympl",
"notebook"
"notebook",
"taufactor"
]

[tool.setuptools.packages.find]
Expand Down