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

[WIP] Harmonize solvers #1030

Open
wants to merge 307 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
307 commits
Select commit Hold shift + click to select a range
d048d00
Add convergence normalization methods
guyer Jul 8, 2022
a3f4d27
Add tests of convergence criteria
guyer Jul 8, 2022
7a658c0
Don't check residual when failed
guyer Jul 7, 2022
bbee5db
Add classes to pyamgx namespace
guyer Jul 8, 2022
5dc3d19
Add `convergence=` to pyamgx solvers
guyer Jul 8, 2022
e5b47be
Switch to default solver
guyer Jul 8, 2022
d91c700
Warn at correct level
guyer Jul 8, 2022
39ce157
Plug leaks
guyer Jul 8, 2022
6200c5b
Document supported convergence criteria
guyer Jul 11, 2022
58dc3da
JSON-encode logged dicts
guyer Jul 11, 2022
f08186e
Convert residual from numpy array to float
guyer Jul 11, 2022
7a287fe
Change `AZ_loss` from `Divergence` to `Convergence`
guyer Jul 11, 2022
c2be571
Fix typos
guyer Jul 11, 2022
f54cba5
Remove `callback_type` argument; not supported in SciPy I'm using
guyer Jul 11, 2022
62e55a8
Make `Convergence` log from itself, not `Solver`
guyer Jul 11, 2022
142645f
Remove logging hook for exceptions
guyer Jul 11, 2022
dbf595c
Remove preconditioner if `precon=None`
guyer Jul 11, 2022
5701750
Remove datreant and simplify
guyer Jul 11, 2022
23df906
Correct convergence normalization for PETSc
guyer Jul 12, 2022
f0482a3
Report un-normalized residual from all solvers
guyer Jul 12, 2022
98e08f2
Add preconditioners to PETSc
guyer Jul 12, 2022
b541200
Allow specifying the preconditioner
guyer Jul 12, 2022
aeb888a
Add preconditioners to SciPy
guyer Jul 12, 2022
5c9c060
Add ILU preconditioner to Trilinos
guyer Jul 12, 2022
0749cf3
Add preconditioners to pyamgx (correctly)
guyer Jul 12, 2022
4d5d35e
Fix inheritance for PyAMG preconditioners
guyer Jul 12, 2022
6939871
Remove unecessary `__init__`
guyer Jul 12, 2022
2c2e22b
Change arguments and don't loop over solver suites
guyer Jul 12, 2022
edb6bec
Drop `pyamgx.LinearCGSolver`
guyer Jul 13, 2022
be2dd04
Remove (redundant) `cg` runs
guyer Jul 13, 2022
4cece6f
Fix names
guyer Jul 13, 2022
4f1c9b8
Refactor residual vector and norm calculation
guyer Jul 13, 2022
acb8824
Swap order of looping over solvers and looping over sizes
guyer Jul 13, 2022
bd3c661
Document options and add example invocation
guyer Jul 13, 2022
1b7b114
Add logging configuration files
guyer Jul 13, 2022
982b640
Add gpu logging configuration
guyer Jul 13, 2022
0eb5e83
Rename preconditioner for consistency
guyer Jul 13, 2022
4b7e180
Rename another preconditioner
guyer Jul 13, 2022
e74f38f
Remove directory creation
guyer Jul 13, 2022
90a37c3
Change solver selection to cascade of ifs
guyer Jul 13, 2022
e8ddc09
Change output to TSV of solution
guyer Jul 13, 2022
e51ec00
Fix typo
guyer Jul 13, 2022
582ad18
Add sbatch (slurm) invocation
guyer Jul 13, 2022
7d14264
Change `--log` option to take configuration path and log path
guyer Jul 14, 2022
9fde12a
Remove `--writeFiles` option
guyer Jul 14, 2022
1c39345
Add serial loggging template
guyer Jul 14, 2022
3868b5a
Re-enable actual commands
guyer Jul 14, 2022
57b1be5
Ensure path exists for log file
guyer Jul 14, 2022
274205b
Differentiate by preconditioner
guyer Jul 14, 2022
3c6ed21
Change to class names
guyer Jul 14, 2022
bae9e04
Instrument actual solve operation
guyer Jul 15, 2022
ca84bbc
Add notebook for analysis of solver benchmarking
guyer Jul 16, 2022
2f221d8
Save results in `.npz` instead of `.tsv`
guyer Jul 19, 2022
6366ea0
Log much more information about FiPy environment
guyer Jul 21, 2022
855e194
Attempt to make problem less stiff
guyer Jul 22, 2022
38b307e
Make executable
guyer Jul 22, 2022
bc80964
Add FIPY_LOG_CONFIG only when stipulated
guyer Jul 22, 2022
c5ea3f7
Remove entire temporary directory
guyer Jul 22, 2022
6792b91
Abort if attempting to precondition LU
guyer Jul 22, 2022
c8d6b45
Fix syntax of list comprehension from tuple
guyer Jul 22, 2022
38c63ab
Record location of output file
guyer Jul 22, 2022
82891ff
Add intercomparison between solvers
guyer Jul 22, 2022
2b34d23
Fix typo
guyer Jul 22, 2022
bf01443
Fix reshaping
guyer Jul 22, 2022
94fbece
Constant diffusion
guyer Jul 23, 2022
cb8228d
Arithmetic diffusion
guyer Jul 23, 2022
e511e20
Introduce benchmarker based nucleation phase field
guyer Jul 23, 2022
ed86463
Strip out notebookisms and Viewers
guyer Jul 23, 2022
8e37429
Adapt phase field benchmark 8c for solver benchmarking
guyer Jul 24, 2022
f657e65
Switch to steppyngstounes
guyer Jul 24, 2022
17194d8
Add options for solvers
guyer Jul 24, 2022
8d78002
Add derived nucleation script
guyer Jul 24, 2022
d440e43
Back up on failure and relax stepper tolerance
guyer Jul 24, 2022
317aec2
Switch to FixedStepper
guyer Jul 24, 2022
0c91c5d
Fixed steps always succeed
guyer Jul 24, 2022
f6fe871
Fix typo
guyer Jul 24, 2022
28ae895
Log beginning and end of each solve
guyer Jul 25, 2022
b5071e4
Add slurm timeout
guyer Jul 25, 2022
ca004ce
Make pyamgx preconditioners proper subclasses
guyer Aug 4, 2022
91a988a
Fix typo
guyer Aug 4, 2022
87b752c
Organize utilities and render more results
guyer Aug 5, 2022
6b58e2c
Add confidence bands to scaling plots
guyer Aug 5, 2022
f2fdc2a
Collect properly labeled pyamgx results
guyer Aug 5, 2022
0fe258e
Fix preconditioners
guyer Aug 5, 2022
9447f82
Differentiate display depending on if converged
guyer Aug 5, 2022
e2053a1
Improve legends
guyer Aug 5, 2022
3b1c0bb
Display legend items only when appropriate
guyer Aug 5, 2022
bdae2ce
Simplify assignment of simulation id
guyer Aug 5, 2022
89f8d6c
Update plots of diffusion runs
guyer Aug 5, 2022
0dd92d3
Remove obsolete code
guyer Aug 5, 2022
79b9975
Rewrite `plot_error_matrix()` to use `DataFrame.groupby()`
guyer Aug 8, 2022
ed70d01
Switch axis labels to annotations
guyer Aug 8, 2022
01f3b1d
Refactor perpendicular and parallel labelers
guyer Aug 9, 2022
d76c1b9
Adjust label position based on labels that came before
guyer Aug 9, 2022
87ab92e
Refactor loading from diffing
guyer Aug 10, 2022
a18ba0c
Add comparison functions
guyer Aug 10, 2022
9c0fbce
Reorganize and remove cruft
guyer Aug 10, 2022
896b6e4
Fix nested label alignment
guyer Aug 10, 2022
a775669
Group comparisons with data sets
guyer Aug 10, 2022
26a1210
Refactor functions
guyer Aug 10, 2022
955ea3b
Document functions
guyer Aug 10, 2022
fb1ced5
Cleanup
guyer Aug 11, 2022
938ddc8
Move data to common directory
guyer Aug 11, 2022
c0997e0
Add colorbars and calculate actual solve time
guyer Aug 12, 2022
480182f
Account for reorganized data
guyer Aug 31, 2022
a2ae06e
Operate on a copy of the DataFrame (view)
guyer Aug 31, 2022
66fa290
Remove conversions that shouldn't be repeated
guyer Aug 31, 2022
1c52ffa
Skip missing multiindices
guyer Aug 31, 2022
5be1e8e
Remove unnecessary comparison
guyer Aug 31, 2022
9cb06b9
Loop over preconditioners
guyer Aug 31, 2022
6410176
Add explanatory text
guyer Nov 16, 2022
2d7aa7b
Add facility to store matrix
guyer Dec 22, 2022
646052a
Add ability to store matrix
guyer Dec 22, 2022
7eb96d3
Account for missing FIPY_DISPLAY_MATRIX environment variable
guyer Dec 22, 2022
da743e2
Remove redundant method
guyer Jan 12, 2023
57a3a77
Shift diffusion problem definition to notebook
guyer Jan 25, 2023
54f44ff
Display representative matrices
guyer Jan 25, 2023
b273b15
Revise datapath to results
guyer Jan 25, 2023
243e65a
Clean up cruft
guyer Jan 27, 2023
c4f6dc4
Add solutions used to illustrate matrices
guyer Jan 27, 2023
1b6b660
Tidy log configuration files
guyer Jan 27, 2023
9bc35a6
Downcase notebook name
guyer Jan 28, 2023
1eb8b58
Tidy notebooks and scripts
guyer Jan 28, 2023
b261168
Add README and file descriptions
guyer Feb 3, 2023
c06d518
Migrated solver benchmarking to separate solvers_and_timings repo
guyer Sep 8, 2023
62cbf22
Log overall `Term.solve()` and `Term._prepareLinearSystem()`
guyer Sep 29, 2023
c770717
Clarify convergence criteria
guyer Oct 8, 2023
670da6a
Merge branch 'master' into harmonize_solvers
guyer Oct 8, 2023
c19b95c
Fix merge errors
guyer Oct 8, 2023
39e55ad
Use correct napoleon setting for aliases
guyer Oct 10, 2023
cd98ec6
Document parameter as optional
guyer Oct 10, 2023
65702d1
Update index syntax
guyer Oct 10, 2023
4122fe5
Document Convergence classes
guyer Oct 10, 2023
3923a06
Fix class references
guyer Oct 10, 2023
857e7a0
Fix parameter syntax
guyer Oct 10, 2023
015377f
Document Term class
guyer Oct 10, 2023
19919a2
Make convergence table more explicit
guyer Oct 10, 2023
b427d07
Further clarify convergence criteria
guyer Oct 11, 2023
2098bb2
Factor scale from residual
guyer Oct 11, 2023
fd53ff8
Account for absolute and divergence tolerance
guyer Oct 12, 2023
243fbc2
Change from CSR to CRV
guyer Oct 25, 2023
9414eff
Actually add fix indexing
guyer Oct 27, 2023
d8a569e
Switch to PETSc.IntType
guyer Oct 27, 2023
3aa4f56
Improve explanation of `criterion="default"`
guyer Oct 30, 2023
6e74c3d
Improve explanation of FiPy-implemented criteria
guyer Oct 30, 2023
684bc19
Specify `Convergence` classes
guyer Oct 30, 2023
5e0f3cf
Make wide tables scroll
guyer Oct 31, 2023
e86a34e
Update link
guyer Nov 2, 2023
6dd047e
Rotate wide tables in PDF
guyer Nov 2, 2023
fc7249f
Split convergences and divergences into separate tables
guyer Nov 2, 2023
80544bf
Make wide tables responsive without scrolling
guyer Nov 2, 2023
369b4bb
Make Convergence attributes more consistent and refactor logging
guyer Nov 2, 2023
235e7a9
Make solver-independent Convergence and Divergence classes.
guyer Nov 3, 2023
7849b50
Document Convergence attributes
guyer Nov 3, 2023
75f044f
Ensure number of iterations is an integer
guyer Nov 3, 2023
5356eee
Make convergence text more readable
guyer Nov 3, 2023
49102c7
Add `tolerance_scale` to Convergence
guyer Nov 7, 2023
e227e1a
Remove `max_iterations` from Convergence
guyer Nov 7, 2023
2bcafac
Fix tolerance scaling
guyer Nov 7, 2023
e118552
Provide unified access to matrix, vector, and right-hand-side.
guyer Nov 7, 2023
dada3bc
Use initial value for PETSc solves
guyer Nov 7, 2023
75ccc4e
Document that PETSc residual is approximate
guyer Nov 7, 2023
86cb0e4
Rewrite solver tolerance testing
guyer Nov 7, 2023
5c2a040
Rename "default" Solver criterion to "legacy"
guyer Nov 8, 2023
b271031
Fix error in normalization
guyer Nov 8, 2023
584cbc7
Refactor PySparse base class trees
guyer Nov 8, 2023
62e0c3b
Reintroduce "default" solver criterion and set to "RHS"
guyer Nov 8, 2023
b323e6a
Use super() and explicit arguments
guyer Nov 8, 2023
dc0078c
Unhide solver base classes
guyer Nov 8, 2023
d635abf
Change default solver tolerance to 1e-5
guyer Nov 8, 2023
ba48797
Add environment variable for default solver criterion
guyer Nov 9, 2023
f0a3f12
Add "default" preconditioner for PETSc
guyer Nov 9, 2023
d8d0535
Remove redundant test
guyer Nov 9, 2023
f29295a
Consolidate Solver default parameters
guyer Nov 9, 2023
745ccf6
Clarify that it's pysparse that needs special treatment, not petsc
guyer Nov 10, 2023
637e91a
Avoid clobbering class attribute
guyer Nov 10, 2023
5a5c590
Document Solver class attributes
guyer Nov 10, 2023
da86849
Fix name
guyer Nov 10, 2023
dd914bc
Harmonize preconditioners
guyer Nov 11, 2023
78493e3
Add custom DivergenceWarning
guyer Nov 11, 2023
b873c7e
Account for LU factorization in solve time
guyer Nov 18, 2023
6605bd6
Profile sweeping
guyer Nov 20, 2023
87ed4de
Log preconditioning
guyer Nov 20, 2023
5682d87
Revert "Profile sweeping"
guyer Nov 21, 2023
2f2f8c5
Merge branch 'master' into harmonize_solvers
guyer Dec 4, 2023
38b2b8c
Merge branch 'master' into harmonize_solvers
guyer Dec 14, 2023
51e1f60
Cache row and column IDs
guyer Dec 20, 2023
a315c0e
Remove `in1d()` to make `_getStencil_()` more efficient
guyer Dec 20, 2023
2054173
Remove `in1d()` to make `bodies` more efficient
guyer Dec 20, 2023
56da150
Refactor id1 conversion into two steps
guyer Dec 20, 2023
78f108d
Use __iadd__ for __iadd__
guyer Dec 19, 2023
d2eb7ca
Cache matrix
guyer Dec 18, 2023
97327ff
Remove import
guyer Dec 22, 2023
ecf1f67
Make indices appropriate type for matrix
guyer Dec 19, 2023
36bff38
Add method to zero matrix entries
guyer Dec 24, 2023
e14871a
Improve access to INDEX_TYPE
guyer Dec 27, 2023
ad51b75
Fix typos
guyer Dec 28, 2023
6ef2b87
Stack mask for coupled/vector matrices
guyer Dec 28, 2023
cf06a8b
Assemble before zeroing
guyer Dec 28, 2023
88dcb7f
Fix indexing of offset matrices
guyer Dec 29, 2023
dc1c50e
Zero all entries, even of offset matrices
guyer Dec 29, 2023
d4fe3ff
Ensure b-vector is ndarray
guyer Dec 29, 2023
2385cbd
Ensure bandwidth is integer
guyer Dec 29, 2023
ad921ee
Properly cache offset matrices
guyer Dec 29, 2023
1d794d9
Restore matrix normalization
guyer Dec 29, 2023
a57bd08
Standardize that `Solver._Lxb` returns a FiPy _SparseMatrix
guyer Jan 2, 2024
6607a2e
Document what `._Lxb` does
guyer Jan 2, 2024
58d06a1
Refactor `_solve()` and `_solve_()`
guyer Jan 3, 2024
c487305
Use default preconditioning
guyer Jan 3, 2024
3d2b076
Convert solver diagnostics into tests
guyer Jan 5, 2024
d103551
Ensure norms are floats
guyer Jan 5, 2024
e06f2ea
Bump iteration count by 1
guyer Jan 5, 2024
e96c9aa
Add explanation about solver testing
guyer Jan 5, 2024
8bf6b8d
Use default preconditioning for PETSc
guyer Jan 5, 2024
7a915c3
Use ILU preconditioning for Trilinos
guyer Jan 5, 2024
f30053c
Skip setValuesRCV with empty stencils
guyer Jan 5, 2024
1f18964
Make pass for petsc and explain why
guyer Jan 5, 2024
d0f5304
Make input4thOrder1D use LU for all solver suites
guyer Jan 5, 2024
211cc2d
Tolerate iterations within 1
guyer Jan 5, 2024
ab8e4c4
Prevent PETSc for throwing DTOL divergences
guyer Jan 6, 2024
17df159
Fix import
guyer Jan 6, 2024
2468127
Prevent solver from getting "stuck"
guyer Jan 9, 2024
37886d1
Don't ignore things that don't exist
guyer Jan 9, 2024
5fb28c5
Restore solve conditions
guyer Jan 9, 2024
b590844
Remove pointless if
guyer Jan 9, 2024
9a81ed4
Relax tolerance
guyer Jan 9, 2024
974b180
Turn off divergence tolerance
guyer Jan 10, 2024
5b14a84
Tweak solver for other than pysparse
guyer Jan 10, 2024
df9e2f4
Log solver norms
guyer Jan 10, 2024
9f41d20
Allow pressure corrector to iterate longer to a smaller tolerance
guyer Jan 10, 2024
114685d
Fix typo
guyer Jan 10, 2024
51fa84d
Adjust convergence for when b-vector is zero
guyer Jan 10, 2024
8261cf5
Change preconditioner for PETSc to enable problem to solve
guyer Jan 11, 2024
e34b134
Adjust tolerances to account for relaxed default solver tolerance
guyer Jan 11, 2024
dd41d32
Enable tests to pass with PETSc's default `divergence_tolerance`
guyer Jan 12, 2024
1e78000
Introduce Timer context manager
guyer Jan 18, 2024
eced40c
Document `_solve()`
guyer Jan 19, 2024
6a15c0c
Get rid of name mangling in DiffusionTerm
guyer Apr 21, 2024
6ffe79e
Document _AbstractDiffusionTerm._calcConstraints()
guyer Apr 22, 2024
c8834f3
Turn constraint contributions into dictionary keyed on variable
guyer Apr 22, 2024
1ed01ad
Get rid of more name mangling in DiffusionTerm
guyer Apr 22, 2024
2ff8600
Remove diagnostics
guyer Apr 22, 2024
abe6f2c
Move imports to top
guyer Apr 27, 2024
abc59a0
Reformat
guyer Apr 27, 2024
c3cea2c
Refactor _calcGeomCoeff
guyer Apr 27, 2024
3de8be5
Refactor _calcConstraints
guyer Apr 27, 2024
7333981
Refactor _doBCs
guyer Apr 27, 2024
5bcd48b
Refactor _buildMatrix
guyer Apr 27, 2024
b0d350d
Merge branch 'master' into harmonize_solvers
guyer Jun 26, 2024
2c7ac21
Fix typo
guyer Jun 26, 2024
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
302 changes: 275 additions & 27 deletions docs/source/SOLVERS.rst

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions docs/source/USAGE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,14 @@ package.
print a variety of diagnostic information. All other solvers should use
`Logging`_ and :envvar:`FIPY_LOG_CONFIG`.

.. envvar:: FIPY_DEFAULT_CRITERION

Changes the default solver :ref:`CONVERGENCE` criterion to the specified
value. Valid choices are "``legacy``", "``unscaled``", "``RHS``",
"``matrix``", "``initial``", "``solution``", "``preconditioned``",
"``natural``", "``default``". A value of "``default``" is admittedly
circular, but it works.

.. envvar:: FIPY_VIEWER

Forces the use of the specified viewer. Valid values are any
Expand All @@ -303,7 +311,7 @@ package.
:ref:`PETSC` solvers in order to see what options are possible. Ignored
if solver is not :ref:`PETSC`.

.. _PETSc configuration options: https://docs.petsc.org/en/latest/manual/other/#sec-options
.. _PETSc configuration options: https://petsc.org/main/manual/other/#runtime-options

.. _PARALLEL:

Expand Down Expand Up @@ -1063,13 +1071,13 @@ Thanks to the future_ package and to the contributions of pya_ and
woodscn_, :term:`FiPy` runs under both :term:`Python 3` and :term:`Python`
2.7, without conversion or modification.

Because :term:`Python` itself will `drop support for Python 2.7 on January
1, 2020`_ and many of the prerequisites for :term:`FiPy` have `pledged to
drop support for Python 2.7 no later than 2020`_, we have prioritized adding
Because :term:`Python` itself `dropped support for Python 2.7 on January
1, 2020`_ and many of the prerequisites for :term:`FiPy` `pledged to
drop support for Python 2.7 no later than 2020`_, we prioritized adding
support for better :term:`Python 3` solvers, starting with
:term:`petsc4py`.

Because the faster :term:`PySparse` and :term:`Trilinos` solvers are not
Because the faster :term:`PySparse` solvers are not
available under :term:`Python 3`, we will maintain :term:`Python` 2.x
support as long as practical. Be aware that the conda-forge_ packages that
:term:`FiPy` depends upon are not well-maintained on :term:`Python` 2.x
Expand All @@ -1081,7 +1089,7 @@ become available on conda-forge_.
.. _future: http://python-future.org
.. _pya: https://github.com/pya
.. _woodscn: https://github.com/pya
.. _drop support for Python 2.7 on January 1, 2020: https://www.python.org/dev/peps/pep-0373/#update
.. _dropped support for Python 2.7 on January 1, 2020: https://www.python.org/dev/peps/pep-0373/#update
.. _pledged to drop support for Python 2.7 no later than 2020: https://python3statement.org

------
Expand Down
10 changes: 10 additions & 0 deletions docs/source/_static/residuals.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
criterion,residual,scale,PETSc_ [#KSP_Convergence_Tests]_,pyamgx_ [#AMGX_convergence]_,PySparse_,SciPy_ [#SciPy_Convergence_Test]_,Trilinos_ [#AztecOO_convergence]_
``unscaled``,:math:`\|\mathsf{L}\vec{x} - \vec{b}\|_2`,:math:`1`,[#FiPy_Convergence_Test]_,``ABSOLUTE``,[#FiPy_Convergence_Test]_,[#FiPy_Convergence_Test]_,``AZ_noscaled``
``RHS``,:math:`\|\mathsf{L}\vec{x} - \vec{b}\|_2`,:math:`\|\vec{b}\|_2`,|KSP_NORM_UNPRECONDITIONED|_,[#FiPy_Convergence_Test]_,"`cgs <https://sourceforge.net/p/pysparse/git/ci/master/tree/pysparse/itsolvers/src/cgs.c#l90>`_, `pcg <https://sourceforge.net/p/pysparse/git/ci/master/tree/pysparse/itsolvers/src/pcg.c#l154>`_, `qmres <https://sourceforge.net/p/pysparse/git/ci/master/tree/pysparse/itsolvers/src/qmrs.c#l139>`_, or [#FiPy_Convergence_Test]_",``default``,``AZ_rhs``
``matrix``,:math:`\|\mathsf{L}\vec{x} - \vec{b}\|_2`,:math:`\|\mathsf{L}\|_\infty`,[#FiPy_Convergence_Test]_,[#FiPy_Convergence_Test]_,[#FiPy_Convergence_Test]_,[#FiPy_Convergence_Test]_,``AZ_Anorm``
``initial``,:math:`\|\mathsf{L}\vec{x} - \vec{b}\|_2`,:math:`\|\mathsf{L}\vec{x} - \vec{b}\|_2^{(0)}`,[#FiPy_Convergence_Test]_,``RELATIVE_INI_CORE``,"`bicgstab <https://sourceforge.net/p/pysparse/git/ci/master/tree/pysparse/itsolvers/src/bicgstab.c#l287>`_, `gmres <https://sourceforge.net/p/pysparse/git/ci/master/tree/pysparse/itsolvers/src/gmres.c#l159>`_, `minres <https://sourceforge.net/p/pysparse/git/ci/master/tree/pysparse/itsolvers/src/minres.c#l195>`_, or [#FiPy_Convergence_Test]_",[#FiPy_Convergence_Test]_,``AZ_r0``
``solution``,:math:`\|\mathsf{L}\vec{x} - \vec{b}\|_\infty`,:math:`\|\mathsf{L}\|_\infty * \|\vec{x}\|_1 + \|\vec{b}\|_\infty`,,,,,``AZ_sol``
``preconditioned``,:math:`\left\|\mathsf{P}^{-1}(\mathsf{L}\vec{x} - \vec{b})\right\|_2`,:math:`\left\|\vec{b}\right\|_2`,|KSP_NORM_PRECONDITIONED|_,,,,
``natural``,:math:`\sqrt{(\mathsf{L}\vec{x} - \vec{b})\mathsf{P}^{-1}(\mathsf{L}\vec{x} - \vec{b})}`,:math:`\left\|\vec{b}\right\|_2`,|KSP_NORM_NATURAL|_,,,,
``legacy``,,,|KSP_NORM_DEFAULT|_ (``RHS`` or ``preconditioned``),``initial``,``RHS`` or ``initial``,``RHS``,``initial``
``default``,,,``RHS``,``RHS``,``RHS``,``RHS``,``RHS``
9 changes: 9 additions & 0 deletions docs/source/_static/solver_convergence.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
,,PETSc_,pyamgx_,PySparse_,SciPy_,Trilinos_
:class:`~fipy.solvers.convergence.Convergence`,Convergence criteria met.,,|AMGX_SOLVE_SUCCESS|_,,|SciPy_0|_,|AZ_normal|_
:class:`~fipy.solvers.convergence.IterationConvergence`,Requested iterations complete (and no residual calculated).,|KSP_CONVERGED_ITS|_,,,,
:class:`~fipy.solvers.convergence.AbsoluteToleranceConvergence`,"Converged, residual is as small as seems reasonable on this machine.",|KSP_CONVERGED_ATOL|_,,|PySparse_2|_,,
:class:`~fipy.solvers.convergence.RHSZeroConvergence`,"Converged, :math:`\mathbf{b} = 0`, so the exact solution is :math:`\mathbf{x} = 0`.",,,|PySparse_1|_,,
:class:`~fipy.solvers.convergence.RelativeToleranceConvergence`,"Converged, relative error appears to be less than tolerance.",|KSP_CONVERGED_RTOL|_,,|PySparse_0|_,,
:class:`~fipy.solvers.convergence.HappyBreakdownConvergence`,"""Exact"" solution found and more iterations will just make things worse.",|KSP_CONVERGED_HAPPY_BREAKDOWN|_,,,,
:class:`~fipy.solvers.convergence.LossOfAccuracyConvergence`,The iterative solver has terminated due to a lack of accuracy in the recursive residual (caused by rounding errors).,,,,,|AZ_loss|_
:class:`~fipy.solvers.convergence.IteratingConvergence`,Solve still in progress.,|KSP_CONVERGED_ITERATING|_,,,,
10 changes: 10 additions & 0 deletions docs/source/_static/solver_divergence.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
,,PETSc_,pyamgx_,PySparse_,SciPy_,Trilinos_
:class:`~fipy.solvers.convergence.BreakdownDivergence`,Illegal input or the iterative solver has broken down.,|KSP_DIVERGED_BREAKDOWN|_,|AMGX_SOLVE_FAILED|_,,|SciPy_lt0|_,|AZ_breakdown|_
:class:`~fipy.solvers.convergence.IterationDivergence`,Maximum number of iterations was reached.,|KSP_DIVERGED_ITS|_,|AMGX_SOLVE_DIVERGED|_,|PySparse_neg1|_,|SciPy_gt0|_,|AZ_maxits|_
:class:`~fipy.solvers.convergence.PreconditioningDivergence`,The system involving the preconditioner was ill-conditioned.,|KSP_DIVERGED_PC_FAILED|_,,|PySparse_neg2|_,,
:class:`~fipy.solvers.convergence.IllConditionedPreconditionerDivergence`,"An inner product of the form :math:`\mathbf{x}^T \mathsf{P}^{-1} \mathbf{x}` was not positive, so the preconditioning matrix :math:`\mathsf{P}` does not appear to be positive definite.",|KSP_DIVERGED_INDEFINITE_PC|_,,|PySparse_neg3|_,,
:class:`~fipy.solvers.convergence.IllConditionedDivergence`,The matrix :math:`\mathsf{L}` appears to be ill-conditioned.,|KSP_DIVERGED_INDEFINITE_MAT|_,,|PySparse_neg4|_,,|AZ_ill_cond|_
:class:`~fipy.solvers.convergence.StagnatedDivergence`,The method stagnated.,,,|PySparse_neg5|_,,
:class:`~fipy.solvers.convergence.OutOfRangeDivergence`,A scalar quantity became too small or too large to continue computing.,|KSP_DIVERGED_NANORINF|_,,|PySparse_neg6|_,,
:class:`~fipy.solvers.convergence.NullDivergence`,Breakdown when solving the Hessenberg system within GMRES.,|KSP_DIVERGED_NULL|_,,,,
:class:`~fipy.solvers.convergence.ToleranceDivergence`,The residual norm increased by a factor of ``divtol``.,|KSP_DIVERGED_DTOL|_,,,,
38 changes: 38 additions & 0 deletions docs/source/_static/widetable.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Wide tables are unclickable, apparently because they're under the sidebar.
*
* Adapted from:
* https://groups.google.com/g/sphinx-users/c/ZV8gGObVrQU
* https://blogs.perficient.com/2021/01/18/freezing-row-and-column-in-html-table-using-css/
*/

/*
* Make wide table horizontally scrollable.
* This has significant UI issues.
*/
table.widescroll {
display: block;
overflow: auto;
}

table.widescroll th.stub {
left: 0;
position: sticky;
z-index: 50;
}

table.widescroll caption span.caption-text {
left: 0;
position: sticky;
}

/* Move wide table above whatever is blocking it. */
table.wideshow {
/*
* "The `position: static` property prevents z-index from having an effect."
* but where does `position: static` come from?
*/
position: relative;
z-index: 25;
}

7 changes: 5 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@
# [@MadPhysicist](https://stackoverflow.com/users/2988730/mad-physicist)
# [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)
# https://stackoverflow.com/a/66182779
napoleon_use_param = True
# napoleon_preprocess_types = True
# Corrected for https://github.com/sphinx-doc/sphinx/issues/10963
napoleon_preprocess_types = True
napoleon_type_aliases = {
'array-like': ':term:`array-like <array_like>`',
'array_like': ':term:`array_like`'
Expand Down Expand Up @@ -244,6 +244,8 @@
\definecolor{bluish}{rgb}{0.216,0.188,0.533}

\newcommand{\fipylogo}{\scalebox{10}{\rotatebox{4}{\textcolor{redish}{\( \varphi \)}}\kern-.70em\raisebox{-.15em}{\textcolor{bluish}{\( \pi\)}}}}

\usepackage{pdflscape}
""",
'printindex': r'\footnotesize\raggedright\printindex',
}
Expand Down Expand Up @@ -332,6 +334,7 @@ def autodoc_skip_member(app, what, name, obj, skip, options):

def setup(app):
app.connect('autodoc-skip-member', autodoc_skip_member)
app.add_css_file('widetable.css')

# lifted from astropy/astropy@e68ca1a1

Expand Down
6 changes: 1 addition & 5 deletions examples/cahnHilliard/mesh2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@

>>> dexp = -5
>>> elapsed = 0.
>>> if __name__ == "__main__":
... duration = 1000.
... else:
... duration = 1000.
>>> duration = 1000.

>>> while elapsed < duration:
... dt = min(100, numerix.exp(dexp))
Expand Down Expand Up @@ -118,4 +115,3 @@
exec(fipy.tests.doctestPlus._getScript())

input('finished')

6 changes: 3 additions & 3 deletions examples/cahnHilliard/tanh1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@
single: LinearLUSolver
single: DefaultSolver

>>> import fipy.solvers.solver
>>> if fipy.solvers.solver_suite in ['pysparse', 'pyamgx']:
>>> from fipy.solvers import solver_suite
>>> if solver_suite in ['pysparse']:
... solver = LinearLUSolver(tolerance=1e-15, iterations=100)
... else:
... solver = DefaultSolver()
... solver = DefaultSolver(tolerance=1e-15, iterations=100)

The solution to this 1D problem over an infinite domain is given by,

Expand Down
10 changes: 6 additions & 4 deletions examples/convection/exponential1D/tri2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
>>> eq = (DiffusionTerm(coeff=diffCoeff)
... + ExponentialConvectionTerm(coeff=convCoeff))

>>> eq.solve(var = var,
... solver=DefaultAsymmetricSolver(iterations=10000))
It should be possible to drive this steady-state solution to high accuracy.

>>> solver = DefaultAsymmetricSolver(tolerance=1e-10, iterations=10000)
>>> eq.solve(var=var, solver=solver)

The analytical solution test for this problem is given by:

Expand All @@ -45,8 +47,8 @@
>>> DD = 1. - numerix.exp(-convCoeff[axis] * L / diffCoeff)
>>> analyticalArray = CC / DD

>>> print(var.allclose(analyticalArray, rtol = 1e-6, atol = 1e-6))
1
>>> print(var.allclose(analyticalArray, rtol=1e-6, atol=1e-6))
True

>>> if __name__ == '__main__':
... viewer = Viewer(vars = var)
Expand Down
2 changes: 1 addition & 1 deletion examples/convection/exponential1DSource/tri2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
... - ExponentialConvectionTerm(coeff = convCoeff))

>>> eq.solve(var=var,
... solver=DefaultAsymmetricSolver(tolerance=1.e-15, iterations=10000))
... solver=DefaultAsymmetricSolver(tolerance=1.e-8, iterations=10000))

The analytical solution test for this problem is given by:

Expand Down
9 changes: 6 additions & 3 deletions examples/convection/exponential2D/tri2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
>>> eq = (DiffusionTerm(coeff=diffCoeff)
... + ExponentialConvectionTerm(coeff=convCoeff))

>>> eq.solve(var = var)
It should be possible to drive this steady-state solution to high accuracy.

>>> solver = eq.getDefaultSolver(tolerance=1e-10)
>>> eq.solve(var=var, solver=solver)

The analytical solution test for this problem is given by:

Expand All @@ -36,8 +39,8 @@
>>> CC = 1. - numerix.exp(-convCoeff[axis] * x / diffCoeff)
>>> DD = 1. - numerix.exp(-convCoeff[axis] * L / diffCoeff)
>>> analyticalArray = CC / DD
>>> print(var.allclose(analyticalArray, rtol = 1e-10, atol = 1e-10))
1
>>> print(var.allclose(analyticalArray, rtol=1e-10, atol=1e-10))
True

>>> if __name__ == '__main__':
... viewer = Viewer(vars = var)
Expand Down
10 changes: 8 additions & 2 deletions examples/diffusion/mesh1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@
and see that :math:`\phi` dissipates to the expected average value of 0.2 with
reasonable accuracy.

>>> print(numerix.allclose(phi, 0.2, atol=1e-5))
>>> print(numerix.allclose(phi, 0.2, atol=4e-5))
True

If we reset the initial condition
Expand Down Expand Up @@ -788,7 +788,13 @@
>>> if __name__ == '__main__':
... viewer.plot()

>>> (TransientTerm() == DiffusionTerm(D)).solve(var=phi, dt=1e6*dt)
>>> eq = (TransientTerm() == DiffusionTerm(D))

The initial residual is much larger than the norm of the right-hand-side
vector, so we use `"initial"` tolerance scaling.

>>> solver = eq.getDefaultSolver(criterion="initial")
>>> eq.solve(var=phi, dt=1e6*dt, solver=solver)
>>> if __name__ == '__main__':
... viewer.plot()
>>> from fipy import input
Expand Down
8 changes: 2 additions & 6 deletions examples/diffusion/nthOrder/input4thOrder1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
.. index::
single: Grid1D

>>> from fipy import CellVariable, Grid1D, NthOrderBoundaryCondition, DiffusionTerm, Viewer, GeneralSolver
>>> from fipy import CellVariable, Grid1D, NthOrderBoundaryCondition, DiffusionTerm, Viewer, LinearLUSolver

>>> nx = 500
>>> dx = L / nx
Expand Down Expand Up @@ -56,11 +56,7 @@

>>> eq = DiffusionTerm(coeff=(1, 1)) == 0

>>> import fipy.solvers.solver
>>> if fipy.solvers.solver_suite == 'petsc':
... solver = GeneralSolver(precon='lu')
... else:
... solver = GeneralSolver()
>>> solver = LinearLUSolver()

We perform one implicit timestep to achieve steady state

Expand Down
10 changes: 8 additions & 2 deletions examples/diffusion/steadyState/mesh1D/inputPeriodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@
solver has no fixed value and can become unstable.

>>> eq = TransientTerm(coeff=1e-8) - DiffusionTerm()
>>> eq.solve(var=var, dt=1.)

The initial residual is much larger than the norm of the right-hand-side
vector, so we use `"initial"` tolerance scaling with a tolerance that will
drive to an accurate solution.

>>> solver = eq.getDefaultSolver(criterion="initial", tolerance=1e-8)
>>> eq.solve(var=var, dt=1., solver=solver)

>>> if __name__ == '__main__':
... viewer.plot()

The result of the calculation will be the average value over the domain.

>>> print(var.allclose((valueLeft + valueRight) / 2., rtol = 1e-5))
1
True

"""
from __future__ import unicode_literals
Expand Down
9 changes: 6 additions & 3 deletions examples/diffusion/steadyState/mesh1D/tri2Dinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
:func:`~fipy.meshes.factoryMeshes.Grid1D` object.

Here, one time step is executed to implicitly find the steady state
solution.
solution. We increase the solver tolerance from the default
:math:`10^{-5}` in order to achieve a good solution.

>>> DiffusionTerm().solve(var)
>>> eq = DiffusionTerm()
>>> solver = eq.getDefaultSolver(tolerance=1e-8)
>>> eq.solve(var, solver=solver)

To test the solution, the analytical result is required. The `x`
coordinates from the mesh are gathered and the length of the domain,
Expand All @@ -30,7 +33,7 @@
tolerance of `1e-10`.

>>> print(var.allclose(analyticalArray))
1
True

"""
from __future__ import print_function
Expand Down
8 changes: 6 additions & 2 deletions examples/diffusion/steadyState/mesh20x20/tri2Dinput.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
"""

This input file again solves a 2D diffusion problem on a triangular mesh.
We increase the solver tolerance from the default :math:`10^{-5}` in order
to achieve a good solution.

>>> DiffusionTerm().solve(var)
>>> eq = DiffusionTerm()
>>> solver = eq.getDefaultSolver(tolerance=1e-10)
>>> eq.solve(var, solver=solver)

The result is again tested in the same way:

>>> Lx = nx * dx
>>> x = mesh.cellCenters[0]
>>> analyticalArray = valueLeft + (valueRight - valueLeft) * x / Lx
>>> print(var.allclose(analyticalArray, rtol = 1e-8))
1
True

"""
from __future__ import unicode_literals
Expand Down
6 changes: 4 additions & 2 deletions examples/diffusion/steadyState/mesh50x50/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

The result is again tested in the same way:

>>> DiffusionTerm().solve(var)
>>> eq = DiffusionTerm()
>>> solver = eq.getDefaultSolver(tolerance=1e-10)
>>> eq.solve(var, solver=solver)
>>> Lx = nx * dx
>>> x = mesh.cellCenters[0]
>>> analyticalArray = valueLeft + (valueRight - valueLeft) * x / Lx
>>> print(var.allclose(analyticalArray, rtol = 1e-9))
1
True

"""
from __future__ import unicode_literals
Expand Down
6 changes: 4 additions & 2 deletions examples/diffusion/steadyState/mesh50x50/tri2Dinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@

The result is again tested in the same way:

>>> DiffusionTerm().solve(var)
>>> eq = DiffusionTerm()
>>> solver = eq.getDefaultSolver(tolerance=1e-10)
>>> eq.solve(var, solver=solver)
>>> Lx = nx * dx
>>> x = mesh.cellCenters[0]
>>> analyticalArray = valueLeft + (valueRight - valueLeft) * x / Lx
>>> print(var.allclose(analyticalArray, atol = 1e-7))
1
True

"""
from __future__ import unicode_literals
Expand Down
Loading
Loading