-
Notifications
You must be signed in to change notification settings - Fork 37
Monodomain project #407
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
Merged
pancetta
merged 147 commits into
Parallel-in-Time:master
from
grosilho:monodomain_skinny
Apr 1, 2024
Merged
Monodomain project #407
Changes from all commits
Commits
Show all changes
147 commits
Select commit
Hold shift + click to select a range
7173530
addded some classes from oldexplicit_stabilized branch. Mainly, the p…
grosilho 8326cbe
added implicit,explicit,exponential integrator (in electrophysiology …
grosilho 845ad1f
added exponential imex and mES, added parabolic_system in vec format
grosilho d8ea6d1
added new stabilized integrators using multirate, splitting and expon…
grosilho 9ecc345
before adding exponential_runge_kutta as underlying method, instead o…
grosilho efcdfbf
added first order exponential runge kutta as underlying collocation m…
grosilho 9b5c460
generalized exponential runge kutta to higher order. Added exponentia…
grosilho 0da7d5d
fixed a few things
grosilho acaa70f
optimized a few things
grosilho 3f19732
renamed project ExplicitStabilized to Monodomain
grosilho d4201a1
removed deprecated problems
grosilho c3bb09f
fixed some renaming issues
grosilho b3d253a
did refactoring of code and put in Monodomain_NEW
grosilho e500cff
removed old code and renamed new code
grosilho c29ce46
added finite difference discretization
grosilho 7eb10ba
added many things, cant remember
grosilho 5bbfc71
old convergence_controller
grosilho 4686e59
addded some classes from oldexplicit_stabilized branch. Mainly, the p…
grosilho 3ed021c
added implicit,explicit,exponential integrator (in electrophysiology …
grosilho 71a2296
added exponential imex and mES, added parabolic_system in vec format
grosilho edf3193
added new stabilized integrators using multirate, splitting and expon…
grosilho 7cd6b35
before adding exponential_runge_kutta as underlying method, instead o…
grosilho 3c25e4a
added first order exponential runge kutta as underlying collocation m…
grosilho 776822f
generalized exponential runge kutta to higher order. Added exponentia…
grosilho aed06ac
fixed a few things
grosilho 7ee7278
optimized a few things
grosilho 297b4d0
renamed project ExplicitStabilized to Monodomain
grosilho b8c3469
removed deprecated problems
grosilho 77496ad
fixed some renaming issues
grosilho 129d608
did refactoring of code and put in Monodomain_NEW
grosilho 12d4aff
removed old code and renamed new code
grosilho 1654ae0
added finite difference discretization
grosilho 574289f
added many things, cant remember
grosilho a833924
added smooth TTP model for conv test, added DCT for 2D and 3D problems
grosilho 3bcb16b
added plot stuff and run scripts
grosilho f05f749
fixed controller to original
grosilho c4673ed
removed explicit stabilized files
grosilho f532a90
fixed other files
grosilho 57ae9c1
removed obsolete splittings from ionic models
grosilho a43d5d5
removed old sbatch scripts
grosilho f0a7ea6
removed mass transfer and sweeper
grosilho f879a16
fixed something
grosilho c03974f
removed my base transfer
grosilho ff00ac4
removed hook class pde
grosilho f55a3e2
removed FD files
grosilho 6b0b61c
fixed some calls to FD stuff
grosilho 79532b4
removed FEM FEniCSx files
grosilho ebd2189
renamed FD_Vector to DCT_Vector
grosilho ef30448
added hook for output and visualization script
grosilho 017c78a
removed plot scripts
grosilho ae871de
removed run scripts, except convergence
grosilho abd9d37
removed convergence experiments script
grosilho 2c9daff
fixed TestODE
grosilho 252ba0b
added stability test in run_TestODE
grosilho 8c55168
added stability test in run_TestODE
grosilho cc7465f
added stability test in run_TestODE
grosilho fc489ad
removed obsolete stuff in TestODE
grosilho 4c9345e
removed unneeded stuff from run_MonodomainODE
grosilho 08e3053
cleaned a bit run_MonodomainODE
grosilho 08ee957
removed utils/
grosilho 84820ec
added few comments, cleaned a bit
grosilho bbdfb81
removed schedule from workflow
grosilho 75f9af0
restored tutorial step 7 A which I has modified time ago
grosilho 1524531
run black on monodomain project
grosilho 0607746
fixed a formatting thing
grosilho 82c82e9
reformatted everything with black
grosilho 93effd5
Revert "revert formatted with black"
grosilho 1bfa064
added environment file for monodomain project, started to add stuff i…
grosilho 1f343cd
added first test
grosilho e5a9f9f
added package tqdm to monodomain environment
grosilho e1a3367
added new TestODE using DCT_vectors instead of myfloat, moved phi_eva…
grosilho dab760b
deleted old TestODE and myfloat stuff
grosilho aa5d155
renamed TestODEnew to TestODE
grosilho 605268e
cleaned a bit
grosilho ca90673
added stability, convergence and iterations tests. Changed a bit othe…
grosilho fe7724e
reactivated other tests in workflow
grosilho d3bf297
removed my tests temporarly
grosilho 3484093
added monodomain marker to project pyproject.toml
grosilho ffc68ba
changed files and function names for tests
grosilho 5b911be
fixed convergence test
grosilho d2624de
made one test a bit shorter
grosilho 4705282
added test for SDC on HH and fixed missing feature in SDC imex sweepe…
grosilho c7e95c6
reformatted with correct black options
grosilho 73ff9d3
fixed a lint error
grosilho 7e96f5d
another lint error
grosilho 7c8433f
adding tests with plot
grosilho 7655d9e
modified convergence test
grosilho eb77d6f
added test iterations in parallel
grosilho e4a96c8
removed plot from tests
grosilho 08884e7
added plots without writing to file
grosilho b4f9e5c
added write to file
grosilho 3490af7
simplified plot
grosilho 977c5a8
new plot
grosilho 63b17a1
fixed plot in iterations parallel
grosilho 29bc76f
added back all tests and plots
grosilho c5e2b87
cleaned a bit
grosilho 863ff0b
added README
grosilho fe0e1d8
fixed readme
grosilho 0d0dd23
modified comments in controllers
grosilho d38007f
try to compute phi every step
grosilho 8ce1eba
removed my controllers, check u changed before comuting phis
grosilho c515809
enabled postprocessing in pipeline
grosilho c2c6f99
added comments to data_type classes, removed unnecessary methods
grosilho 98100fb
added comments to hooks
grosilho 5c7b027
added comments to the problem classes
grosilho 2cc84f8
added comments to the run scripts
grosilho a530e3a
added comments to sweepers and transfer classes
grosilho 86e6e27
fixed the readme
grosilho 6f08ceb
decommented if in pipeline
grosilho 358bd19
removed recv_mprobe option
grosilho cfbcf71
changed back some stuff outiside of monodomain project
grosilho f672095
same
grosilho 07a7830
again
grosilho 0367c9c
fixed Thomas hints
grosilho 15b389f
removed old unneeded move coverage folders
grosilho 0efbc90
fixed previously missed Thomas comments
grosilho acf0e06
begin change datatype
grosilho ae3620d
changed run_Monodomain
grosilho 4f52f68
added prints
grosilho 2e90dba
fixed prints
grosilho 2ab15d4
mod print
grosilho 14e9a3f
mod print
grosilho 189eed4
mod print
grosilho 6eec84c
mod print
grosilho d177cfd
rading init val
grosilho 0bf0f31
rading init val
grosilho 0033d24
removed prints
grosilho 495a751
removed prints
grosilho 7a66b86
checking longer time
grosilho d892284
checking longer time
grosilho 81a0c62
fixed call phi eval
grosilho a667cd4
trying 2D
grosilho 34923ab
trying 2D
grosilho 5ce87c0
new_data type passing tests
grosilho b91a10b
removed coverage folders
grosilho 369ba23
merged new_datatype
grosilho 25af922
optmized phi eval lists
grosilho 05cf6d5
before changing phi type
grosilho 6ea1369
changed eval phi lists
grosilho a9037b5
polished a bit
grosilho ec0646c
before switch indeces
grosilho cb8820b
reformatted phi computaiton to its traspose
grosilho de5ba3f
before changing Q
grosilho 73c622a
optimized integral of exp terms
grosilho c4bf545
changed interfate to c++ code
grosilho 8a0fd8e
moved definition of dtype u f
grosilho 6749e3d
tests passed after code refactoring
grosilho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .. include:: /../../pySDC/projects/Monodomain/README.rst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| Exponential SDC for the Monodomain Equation in Cardiac Electrophysiology | ||
| ============================================================================== | ||
| This project implements the exponential spectral deferred correction (ESDC) method for the monodomain equation in cardiac electrophysiology. | ||
| The method proposed here is an adaptation of the `ESDC method proposed by T. Buvoli <https://doi.org/10.1137/19M1256166>`_ to the monodomain equation. | ||
| In particular, the implicit-explicit Rush-Larsen method is used as correction scheme. Moreover, not all model components have exponential terms, therefore the resulting method is an hybrid between ESDC and the standard SDC method. | ||
|
|
||
| Monodomain equation | ||
| ------------------- | ||
| The monodomain equation models the electrical activity in the heart. It is a reaction-diffusion equation coupled with an ordinary differential equation for the ionic model and is given by | ||
|
|
||
| .. math:: | ||
| \begin{align} | ||
| \chi (C_m\frac{\partial V}{\partial t}+I_{ion}(V,z_E,z_e, t)) &= \nabla \cdot (D \nabla V) & \quad \text{in } &\Omega \times (0,T), \\ | ||
| \frac{\partial z_E}{\partial t} &= g_E(V,z_E,z_e) & \quad \text{in } &\Omega \times (0,T), \\ | ||
| \frac{\partial z_e}{\partial t} &= \Lambda_e(V)(z_e-z_{e,\infty}(V)) & \quad \text{in } &\Omega \times (0,T), \\ | ||
| \end{align} | ||
|
|
||
| plus the boundary conditions, where :math:`V(t,x)\in\mathbb{R}` is the transmembrane potential and :math:`z_E(t,x)\in\mathbb{R}^n`, :math:`z_e(t,x)\in\mathbb{R}^m` are the ionic model state variables. | ||
| The ionic model right-hand side :math:`g_E` is a general nonlinear term, while :math:`\Lambda_e` is a diagonal matrix. The typical range for the number of unknowns :math:`N=1+n+m` is :math:`N\in [4,50]` and depends on the ionic model of choice. | ||
|
|
||
| Spatial discretization yields a system of ODEs which can be written in compact form as | ||
|
|
||
| .. math:: | ||
| \mathbf y'=f_I(\mathbf y)+f_E(\mathbf y)+f_e(\mathbf y), | ||
|
|
||
| where :math:`\mathbf y(t)\in\mathbb{R}^{M N}` is the vector of unknowns and :math:`M` the number of mesh nodes. | ||
| Concerning the right-hand sides, :math:`f_I` is a linear term for the discrete diffusion, :math:`f_E` is a nonlinear but non-stiff term for :math:`I_{ion},g_E`, and :math:`f_e` is a severely stiff term for :math:`\Lambda_e(V)(z_e-z_{e,\infty}(V))`. | ||
|
|
||
| The standard (serial) way of integrating the monodomain equation is by using a splitting method, where :math:`f_I` is integrated implicitly, :math:`f_E` explicitly, and :math:`f_e` using the exponential Euler method (which is inexpensive due to the diagonal structure of :math:`\Lambda_e`). We denote this method as IMEXEXP. | ||
|
|
||
| The ESDC method for the monodomain equation | ||
| ------------------------------------------- | ||
| A possible way to parallelize the integration of the monodomain equation is by employing the SDC method in combination with the IMEXEXP approach for the correction scheme (preconditioner). | ||
| However, this approach is unstable due to the severe stiffness of :math:`f_e`. | ||
| Therefore we propose a hybrid method, where we employ SDC for the :math:`f_I,f_E` terms and ESDC for the :math:`f_e` term. For the correcttion scheme we still use the IMEXEXP method. | ||
| The resulting method can be seen as a particular case of ESDC and will be denoted by ESDC in the next figures, for simplicity. | ||
|
|
||
| Running the code | ||
| ---------------- | ||
| Due to their complexity, ionic models are coded in C++ and wrapped to Python. Therefore, before running any example you need to compile the ionic models by running the following command in the root folder: | ||
|
|
||
| .. code-block:: | ||
|
|
||
| export IONIC_MODELS_PATH=pySDC/projects/Monodomain/problem_classes/ionicmodels/cpp | ||
| c++ -O3 -Wall -shared -std=c++11 -fPIC -fvisibility=hidden $(python3 -m pybind11 --includes) ${IONIC_MODELS_PATH}/bindings_definitions.cpp -o ${IONIC_MODELS_PATH}/ionicmodels$(python3-config --extension-suffix) | ||
|
|
||
| Then an example can be run: | ||
|
|
||
| .. code-block:: | ||
|
|
||
| cd pySDC/projects/Monodomain/run_scripts | ||
| mpirun -n 4 python run_MonodomainODE_cli.py --dt 0.05 --end_time 0.2 --num_nodes 6,3 --domain_name cube_1D --refinements 0 --ionic_model_name TTP --truly_time_parallel --n_time_ranks 4 | ||
|
|
||
| Stability | ||
| --------- | ||
| We display here the stability domain of the ESDC and SDC methods, both with IMEXEXP as correction scheme, applied to the test problem | ||
|
|
||
| .. math:: | ||
| y'=\lambda_I y+\lambda_E y+\lambda_e y, | ||
|
|
||
| with :math:`\lambda_I,\lambda_E,\lambda_e` representing :math:`f_I,f_E,f_e`, respectively. | ||
| We fix :math:`\lambda_E=-1` and vary the stiff terms :math:`\lambda_I,\lambda_e` only. We see that the ESDC method is stable for all tested values of :math:`\lambda_I,\lambda_e`, while SDC is not. | ||
|
|
||
| .. image:: ../../../data/stability_domain_IMEXEXP_EXPRK.png | ||
| :scale: 60 % | ||
| .. image:: ../../../data/stability_domain_IMEXEXP.png | ||
| :scale: 60 % | ||
|
|
||
| Convergence | ||
| ----------- | ||
| Here we verify convergence of the ESDC method for the monodomain equation. | ||
| We fix the number of collocation nodes to :math:`m=6` and perform a convergence experiment fixing the number of sweeps to either :math:`k=3` or :math:`k=6`. | ||
| We use the ten Tusscher-Panfilov ionic model, which is employed in practical applications. | ||
| We see that we gain one order of accuracy per sweep, as expected. | ||
|
|
||
| .. image:: ../../../data/convergence_ESDC_fixed_iter.png | ||
| :scale: 100 % | ||
|
|
||
|
|
||
| Iterations | ||
| ---------- | ||
| Here we consider three methods: | ||
|
|
||
| * ESDC: with :math:`m=6` collocation nodes. | ||
| * MLESDC: This is a multilevel version of ESDC with :math:`m=6` collocation nodes on the fine level and :math:`m=3` nodes on the coarse level. | ||
| * PFASST: Combination of the PFASST parallelization method with MLESDC, using 24 processors. | ||
|
|
||
| We display the number of iterations required by each method to reach a given tolerance and the residual at convergence. As ionic model we use again the ten Tusscher-Panfilov model. | ||
| We see that PFASST requires a reasonalbly small number of iterations, comparable to the serial counterparts ESDC and MLESDC. | ||
|
|
||
| .. image:: ../../../data/niter_VS_time.png | ||
| :scale: 100 % | ||
| .. image:: ../../../data/res_VS_time.png | ||
| :scale: 100 % | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from pySDC.implementations.datatype_classes.mesh import MultiComponentMesh | ||
|
|
||
|
|
||
| class imexexp_mesh(MultiComponentMesh): | ||
| components = ['impl', 'expl', 'exp'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: pySDC_monodomain | ||
| channels: | ||
| - conda-forge | ||
| - defaults | ||
| dependencies: | ||
| - python | ||
| - numpy | ||
| - scipy>=0.17.1 | ||
| - matplotlib>=3.0 | ||
| - sympy>=1.0 | ||
| - numba>=0.35 | ||
| - dill>=0.2.6 | ||
| - pytest | ||
| - pytest-benchmark | ||
| - pytest-timeout | ||
| - pytest-order | ||
| - coverage[toml] | ||
| - sphinx | ||
| - numdifftools | ||
| - pybind11 | ||
| - mpi4py | ||
| - mpich | ||
| - tqdm | ||
| - pymp-pypi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| from pySDC.core.Hooks import hooks | ||
|
|
||
|
|
||
| class pde_hook(hooks): | ||
| """ | ||
| Hook class to write the solution to file. | ||
| """ | ||
|
|
||
| def __init__(self): | ||
| super(pde_hook, self).__init__() | ||
|
|
||
| def pre_run(self, step, level_number): | ||
| """ | ||
| Overwrite default routine called before time-loop starts | ||
| It calls the default routine and then writes the initial value to file. | ||
| """ | ||
| super(pde_hook, self).pre_run(step, level_number) | ||
|
|
||
| L = step.levels[level_number] | ||
| P = L.prob | ||
| if level_number == 0 and L.time == P.t0: | ||
| P.write_solution(L.u[0], P.t0) | ||
|
|
||
| def post_step(self, step, level_number): | ||
| """ | ||
| Overwrite default routine called after each step. | ||
| It calls the default routine and then writes the solution to file. | ||
| """ | ||
| super(pde_hook, self).post_step(step, level_number) | ||
|
|
||
| if level_number == 0: | ||
| L = step.levels[level_number] | ||
| P = L.prob | ||
| P.write_solution(L.uend, L.time + L.dt) |
34 changes: 34 additions & 0 deletions
34
pySDC/projects/Monodomain/hooks/HookClass_post_iter_info.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import time | ||
| from pySDC.core.Hooks import hooks | ||
|
|
||
|
|
||
| class post_iter_info_hook(hooks): | ||
| """ | ||
| Hook class to write additional iteration information to the command line. | ||
| It is used to print the final residual, after u[0] has been updated with the new value from the previous step. | ||
| This residual is the one used to check the convergence of the iteration and when running in parallel is different from | ||
| the one printed at IT_FINE. | ||
| """ | ||
|
|
||
| def __init__(self): | ||
| super(post_iter_info_hook, self).__init__() | ||
|
|
||
| def post_iteration(self, step, level_number): | ||
| """ | ||
| Overwrite default routine called after each iteration. | ||
| It calls the default routine and then writes the residual to the command line. | ||
| We call this the residual at IT_END. | ||
| """ | ||
| super().post_iteration(step, level_number) | ||
| self.__t1_iteration = time.perf_counter() | ||
|
|
||
| L = step.levels[level_number] | ||
|
|
||
| self.logger.info( | ||
| "Process %2i on time %8.6f at stage %15s: ----------- Iteration: %2i --------------- " "residual: %12.8e", | ||
| step.status.slot, | ||
| L.time, | ||
| "IT_END", | ||
| step.status.iter, | ||
| L.status.residual, | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.