SplitFXM
1D Finite-Difference or Finite-Volume using asymmetric stencils with adaptive mesh refinement and steady-state solver using Newton and Split-Newton approach
What does 'split' mean?
The system is divided into multiple segments, and for ease of communication, let’s refer to the first segment of variables as "outer" and the remaining as "inner".
-
Holding the outer variables fixed, Newton iteration is performed recursively for the inner variables, using the sub-Jacobian associated with them, until convergence is reached.
-
One Newton step is then performed for the outer variables, while the inner variables are kept fixed, using the sub-Jacobian for the outer subsystem.
-
This process is repeated, alternating between solving the inner and outer subsystems, until the convergence criterion for the entire system (similar to standard Newton) is met.
Example:
Consider a system of 5 variables, with the split locations at indices [1, 4]. This results in the following segments:
a1(variables from 0 to 1)a2 a3 a4(variables from 1 to 4)a5(variable at index 4)
-
First, the innermost segment
a5is solved recursively using Newton's method while holding the variablesa1anda2 a3 a4) fixed. This step is repeated until the convergence criterion fora5is met. -
Next, one Newton step is taken for the segment
a2 a3 a4, witha5held fixed. This step is followed by solvinga5again till convergence. -
This alternating process repeats: solving for
a5until convergence, then one step fora2 a3 a4, and so on, until all subsystems converge.
Finally, one Newton step is performed for a1, with the other segments fixed. This completes one cycle of the split Newton process.
How to install and execute?
Just run
pip install splitfxm
There is an examples folder that contains a test model - Advection-Diffusion
You can define your own equations by simply creating a derived class from Model and adding to the _equations using existing or custom equations!
A basic driver program is as follows
from splitfxm.domain import Domain
from splitfxm.simulation import Simulation
from splitfxm.models.advection_diffusion import AdvectionDiffusion
from splitfxm.schemes import default_scheme
from splitfxm.visualize import draw
import matplotlib.pyplot as plt
# Define the problem
method = 'FVM'
m = AdvectionDiffusion(c=0.2, nu=0.001, method=method)
# nx, nb_left, nb_right, variables
d = Domain.from_size(20, 1, 1, ["u", "v", "w"])
ics = {"u": "gaussian", "v": "rarefaction", "w": "tophat"}
bcs = {
"u": {
"left": "periodic",
"right": "periodic"
},
"v": {
"left": {"dirichlet": 3},
"right": {"dirichlet": 4}
},
"w": {
"left": {"dirichlet": 2},
"right": "periodic"
}
}
s = Simulation(d, m, ics, bcs, default_scheme(method))
# Advance in time or to steady state
s.evolve(t_diff=0.1)
bounds = [[-1., -2., -2.], [5., 4., 3.]]
iter = s.steady_state(split=True, split_locs=[1, 2], bounds=bounds)
# Visualize
draw(d, "label")
plt.show()
How to build from source?
Since v0.4.0, SplitFXM utilizes Cython for accelerated computation. To build from source, you will need to install Cython and run the following command:
python setup.py build_ext --inplace
Run benchmark
There is a benchmark that is included, which compares the time it takes to generate both a sparse and dense Jacobian. The results are as follows:
For N=250,
| Method | Time |
|---|---|
| Dense | 45 seconds |
| Sparse | ~0.6 seconds |
The benchmark can be executed from the parent folder using the command
python -m pytest -s benchmark
How to run tests?
To run the tests, execute the following command from the parent folder:
python -m pytest tests
You can use the -s flag to show print outputs of the tests
How to get coverage?
To get coverage, execute the following command from the parent folder:
python -m pytest --cov=splitfxm --cov-report <option> tests
The option can be related to showing covered/missed lines or specifying the output format of the report. For example, to get a line-by-line report, use the following command:
python -m pytest --cov=splitfxm --cov-report term-missing tests
Whom to contact?
Please direct your queries to gpavanb1 for any questions.
You can also reach out to us on the SplitFXM Google Group
Acknowledgements
Special thanks to Cantera and WENO-Scalar for serving as an inspiration for code architecture.
Citing
If you are using SplitFXM in any scientific work, please make sure to cite as follows
@software{pavan_b_govindaraju_2025_14827049,
author = {Pavan B Govindaraju},
title = {gpavanb1/SplitFXM: v0.5.0},
month = feb,
year = 2025,
publisher = {Zenodo},
version = {v0.5.0},
doi = {10.5281/zenodo.14827049},
url = {https://doi.org/10.5281/zenodo.14827049},
}
Release files for splitfxm 0.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| splitfxm-0.5.2.tar.gz | 353.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| splitfxm-0.5.2-cp39-cp39-macosx_10_15_x86_64.whl | CPython 3.9 | CPython 3.9 | macOS 10.15+ x86-64 | Details |
Total release size: 930.2 kB
Release files / splitfxm-0.5.2.tar.gz
| Download URL | splitfxm-0.5.2.tar.gz |
|---|---|
| Size | 353.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b1d5ad78031f573c17709e3baa4ced6352892f74cd64b3810b226adb98dc074
|
|
BLAKE2b-256 checksum How to use checksums |
26b802551cdff9c45e02ae5962789a807fd5b05cf7b7d08831c278a8c7eb0fea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.1
|
Release files / splitfxm-0.5.2-cp39-cp39-macosx_10_15_x86_64.whl
| Download URL | splitfxm-0.5.2-cp39-cp39-macosx_10_15_x86_64.whl |
|---|---|
| Size | 577.0 kB |
| Tags | CPython 3.9 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
9a76ea80f182235885a4829d48e1bde3781912a6a910b18524ac9d68b05c59f2
|
|
BLAKE2b-256 checksum How to use checksums |
e1168a2cc00509caa08e9dec42360007b5fea19528c49617d5c4b2af05c83448
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.1
|