From e8daa9edf1ff2b925fa407a3efe00ffd62749930 Mon Sep 17 00:00:00 2001 From: daubners Date: Wed, 17 Sep 2025 12:47:28 +0100 Subject: [PATCH 1/2] sbm test bug --- evoxels/problem_definition.py | 8 ++++---- tests/test_rhs.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/evoxels/problem_definition.py b/evoxels/problem_definition.py index 9960eee..133c170 100644 --- a/evoxels/problem_definition.py +++ b/evoxels/problem_definition.py @@ -186,11 +186,11 @@ def pad_bc(self, u): return self.pad_boundary(u, self.bcs[0], self.bcs[1]) def rhs_analytic(self, mask, u, t): - grad = spv.gradient(u) - norm_grad = sp.sqrt(grad.dot(grad)) + grad_m = spv.gradient(mask) + norm_grad_m = sp.sqrt(grad_m.dot(grad_m)) - divergence = spv.divergence(self.D*(grad - u/mask*spv.gradient(mask))) - du = divergence + norm_grad*self.bc_flux + mask*self._eval_f(u/mask, t, sp) + divergence = spv.divergence(self.D*(spv.gradient(u) - u/mask*grad_m)) + du = divergence + norm_grad_m*self.bc_flux + mask*self._eval_f(u/mask, t, sp) return du def rhs(self, u, t): diff --git a/tests/test_rhs.py b/tests/test_rhs.py index e5e8706..5ecbad0 100644 --- a/tests/test_rhs.py +++ b/tests/test_rhs.py @@ -57,7 +57,7 @@ def test_coupled_reaction_diffusion_rhs(): def test_reaction_diffusion_smoothed_boundary_rhs(): _, _, slope, order = rhs_convergence_test( ODE_class = ReactionDiffusionSBM, - problem_kwargs = {"D": 1.0, "BC_type": 'dirichlet', "bcs": (0,1),}, + problem_kwargs = {"D": 1.0, "BC_type": 'dirichlet', "bcs": (0,1), "bc_flux": 1}, test_function = test_fun_sbm, mask_function = mask_fun, convention = 'staggered_x', From 65c0994a578f4f165561ea3be4ec8e530fe759bf Mon Sep 17 00:00:00 2001 From: daubners Date: Thu, 18 Sep 2025 15:09:38 +0100 Subject: [PATCH 2/2] fixes --- .../10-appendix-convergence-testing.ipynb | 22 +++++++++++-------- evoxels/precompiled_solvers/allen_cahn.py | 2 +- evoxels/precompiled_solvers/cahn_hilliard.py | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/docs/notebooks/10-appendix-convergence-testing.ipynb b/docs/notebooks/10-appendix-convergence-testing.ipynb index 4ac9ef2..ba592d8 100644 --- a/docs/notebooks/10-appendix-convergence-testing.ipynb +++ b/docs/notebooks/10-appendix-convergence-testing.ipynb @@ -5,7 +5,7 @@ "id": "23f1215b", "metadata": {}, "source": [ - "# Appendix: Code testing and verification" + "# Appendix: Code testing and verification with Manufactured Solutions" ] }, { @@ -24,7 +24,15 @@ "\n", "This has been included in this project in two ways:\n", "- For each ODE class a ``rhs_analytic`` function needs to be defined which can be used for probing the right (i.e. expected) order of convergence for the spatial discretization of the numerical right-hand side.\n", - "- The method of manufactured solutions (MMS) can be used to test the order of time integration and compare various discretizations of the same initial-boundary-value problem." + "- The method of manufactured solutions (MMS) can also be used to test the order of time integration and compare various discretizations of the same initial-boundary-value problem." + ] + }, + { + "cell_type": "markdown", + "id": "26409459", + "metadata": {}, + "source": [ + "## Method of Manufactured Solution (MMS)" ] }, { @@ -32,8 +40,6 @@ "id": "a1413cf5", "metadata": {}, "source": [ - "# Method of Manufactured Solution (MMS)\n", - "\n", "The main idea of this approach is to construct test cases where the solution to a problem is known a-priori. This means for example when testing the discretization of a spatial derivative, one considers functions, where the continuous counterpart can be computed analytically. We make this more precise in the following sections.\n", "A detailed introduction to MMS can be found [here](https://www.osti.gov/servlets/purl/759450-wLI4Ux/native/).\n" ] @@ -43,8 +49,6 @@ "id": "eb058f7c", "metadata": {}, "source": [ - "## 1. Testing spatial order of convergence\n", - "\n", "In the following we show some examples which are all part of the CI testing of the codebase. They can be found in the test folder in the files `test_laplace.py` and `test_rhs.py`.\n", "\n", "In a nutshell, it is as simple as this (for the leading example $-\\Delta u = \\text{rhs}$)\n", @@ -66,7 +70,7 @@ "id": "843c121d", "metadata": {}, "source": [ - "### Combining the Laplacian stencil with various BCs" + "## Spatial order of convergence for Laplacian stencils" ] }, { @@ -355,7 +359,7 @@ "id": "f2a3c20e", "metadata": {}, "source": [ - "### Testing ODE right-hand sides\n", + "## Testing ODE right-hand sides\n", "\n", "The ODEs are all given in the form $\\partial_t u = \\text{rhs}(t,u)$, e.g. for Allen-Cahn in the form $\\text{rhs}(t,u) = \\Delta u + g(t,u)$.\n", "\n", @@ -432,7 +436,7 @@ "id": "da5b50fd", "metadata": {}, "source": [ - "## 2. Time-dependent problems" + "## Time-dependent problems" ] }, { diff --git a/evoxels/precompiled_solvers/allen_cahn.py b/evoxels/precompiled_solvers/allen_cahn.py index 93a9397..0188e59 100644 --- a/evoxels/precompiled_solvers/allen_cahn.py +++ b/evoxels/precompiled_solvers/allen_cahn.py @@ -23,7 +23,7 @@ def run_allen_cahn_solver( plot_bounds = None, ): """ - Runs the Cahn-Hilliard solver with a predefined problem and timestepper. + Solves time-dependent Allen-Cahn problem with ForwardEuler timestepper. """ solver = TimeDependentSolver( voxelfields, diff --git a/evoxels/precompiled_solvers/cahn_hilliard.py b/evoxels/precompiled_solvers/cahn_hilliard.py index 4052795..2f60baf 100644 --- a/evoxels/precompiled_solvers/cahn_hilliard.py +++ b/evoxels/precompiled_solvers/cahn_hilliard.py @@ -20,7 +20,7 @@ def run_cahn_hilliard_solver( plot_bounds = None, ): """ - Runs the Cahn-Hilliard solver with a predefined problem and timestepper. + Solves time-dependent Cahn-Hilliard problem with PseudoSpectralIMEX timestepper. """ solver = TimeDependentSolver( voxelfields,