tatva


Nametatva JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryLego-like building blocks for finite element analysis
upload_time2025-09-16 16:37:02
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
<img src="assets/logo-small.png" alt="drawing" width="400"/>
</p>
<p align="center">
Tatva (टत्तव) : Lego-like building blocks for FEM
</p>

</br>
`tatva` (is a Sanskrit word which means principle or elements of reality). True to its name, `tatva` provide fundamental Lego-like building blocks (elements) which can be used to construct complex finite element method (FEM) simulations. `tatva` is purely written in Python library for FEM simulations and is built on top of JAX and Equinox, making it easy to use FEM in a differentiable way.

## License

Copyright © 2025 ETH Zurich (Mohit Pundir)
`tatva` is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
`tatva` is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with `tatva`.  If not, see https://www.gnu.org/licenses/.


## Features

- Functional programming interface for FEM simulations
- Differentiable operations using JAX
- Support for linear, nonlinear, and mixed FEM simulations


## Installation

Clone the repository and install the package with pip:
```bash
pip install path/to/femsolver
```

You can also use pip to install directly from the GitLab repository. Make sure
you have access to the repository and have set up SSH keys for authentication.
```bash
pip install git+ssh://git@gitlab.ethz.ch/compmechmat/research/mohit-pundir/femsolver.git
```

> [!note]
> We strongly recommend to always use a virtual environment. We further
> recommend using [uv](https://docs.astral.sh/uv/).



## Usage


A complete guide on how to use `femsolver` is available in the [course notes](https://gitlab.ethz.ch/compmechmat/teaching/stcm/course-notes).

Some of the examples are available in the `examples/notebooks` directory.

## Roadmap

The roadmap for `femsolver` is to be updated as we progress with the development. Currently, the roadmap is as follows:

- [ ] Add support for Hermite elements for beam analysis (**Mohit**)
- [ ] Add support for shell elements for plate analysis (**Flavio**)

Currently, the roadmap for different applications/examples/use-cases of `femsolver` is as follows:

- [x] Add example for linear elasticity (**Mohit**)
- [x] Add example for nonlinear elasticity (**Mohit**)
- [x] Add example for Dirichlet BCs as constraints (**Mohit**)
- [x] Add example for matrix-free solvers (with Dirichlet BCs) (**Mohit**)
- [x] Add example for contact problems with penalty method (**Mohit**)
- [x] Add example for contact problems with Lagrange multipliers (**Flavio**)
- [ ] Add example for contact problems with augmented Lagrangian method (**Flavio**)
- [ ] Add example for contact problems with Nitsche method (**Flavio**)
- [x] Add example for cohesive fracture problems (**Mohit**)
- [x] Add example for cohesive fracture problems under quasi-static loading (**Mohit**)
- [x] Add example for cohesive fracture problems in dynamics (**Mohit**)
- [x] Add example for thermal-mechanical coupled problems (**Mohit**)
- [ ] Add example for phase-field fracture coupled problems (**Mohit**)


## Dense vs Sparse 

A unique aspect of `femsolver` is that it can handle both dense and sparse matrices. This is achieved by using the library `sparsejac` that allows automatic differentiation of a functional based on a sparsity pattern. This significantly reduces the memory consumption. For more details on how the automatic differentiation can be done using sparsity pattern, please check the link below:

- ![Paper](https://arxiv.org/html/2501.17737v1)</br>
- ![Github: sparsejac](https://github.com/mfschubert/sparsejac)</br>
- ![Github: Sparsediffax, python interface for the paper](https://github.com/gdalle/sparsediffax)</br>

## Profiling

### Time usage profiling

Below we provide the computational time for the assembly of the sparse stiffness matrix for linear elasticity problem. The code is available in `benchmarking/profiling_time.py`.


![Assembly Time](benchmarking/assembly_time_cpu.png)

The time above doesnot account for the compilation time  of the functions. In JAX, the first time a function is called, it is compiled and repeated calls are faster. This compilation time is not included in the time above. The time above is for a single core of a CPU. 



### Memory usage profiling

We use pprof to profile the memory usage. Please follow the instruction on JAX's documentation on profiling  ![Link to documentation](https://docs.jax.dev/en/latest/device_memory_profiling.html). Using `go` and `pprof`.

For 20000 degrees of freedom and a sparse linear elastic framework (`benchmarking/profiling_memory_usage.py`), a total of `15 MB` memory is used on `CPU`. The distribution of memory usage is as follows:

![](benchmarking/profile001.svg)


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tatva",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Mohit Pundir <mpundir@ethz.ch>, Flavio Lorez <florez@ethz.ch>",
    "download_url": "https://files.pythonhosted.org/packages/00/68/84ec51434e0b1b2da3988111cad0cdfd7d8edaf4bc6da5ac1012865b6f83/tatva-0.1.2.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n<img src=\"assets/logo-small.png\" alt=\"drawing\" width=\"400\"/>\n</p>\n<p align=\"center\">\nTatva (\u091f\u0924\u094d\u0924\u0935) : Lego-like building blocks for FEM\n</p>\n\n</br>\n`tatva` (is a Sanskrit word which means principle or elements of reality). True to its name, `tatva` provide fundamental Lego-like building blocks (elements) which can be used to construct complex finite element method (FEM) simulations. `tatva` is purely written in Python library for FEM simulations and is built on top of JAX and Equinox, making it easy to use FEM in a differentiable way.\n\n## License\n\nCopyright \u00a9 2025 ETH Zurich (Mohit Pundir)\n`tatva` is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n`tatva` is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.\nYou should have received a copy of the GNU Lesser General Public License along with `tatva`.  If not, see https://www.gnu.org/licenses/.\n\n\n## Features\n\n- Functional programming interface for FEM simulations\n- Differentiable operations using JAX\n- Support for linear, nonlinear, and mixed FEM simulations\n\n\n## Installation\n\nClone the repository and install the package with pip:\n```bash\npip install path/to/femsolver\n```\n\nYou can also use pip to install directly from the GitLab repository. Make sure\nyou have access to the repository and have set up SSH keys for authentication.\n```bash\npip install git+ssh://git@gitlab.ethz.ch/compmechmat/research/mohit-pundir/femsolver.git\n```\n\n> [!note]\n> We strongly recommend to always use a virtual environment. We further\n> recommend using [uv](https://docs.astral.sh/uv/).\n\n\n\n## Usage\n\n\nA complete guide on how to use `femsolver` is available in the [course notes](https://gitlab.ethz.ch/compmechmat/teaching/stcm/course-notes).\n\nSome of the examples are available in the `examples/notebooks` directory.\n\n## Roadmap\n\nThe roadmap for `femsolver` is to be updated as we progress with the development. Currently, the roadmap is as follows:\n\n- [ ] Add support for Hermite elements for beam analysis (**Mohit**)\n- [ ] Add support for shell elements for plate analysis (**Flavio**)\n\nCurrently, the roadmap for different applications/examples/use-cases of `femsolver` is as follows:\n\n- [x] Add example for linear elasticity (**Mohit**)\n- [x] Add example for nonlinear elasticity (**Mohit**)\n- [x] Add example for Dirichlet BCs as constraints (**Mohit**)\n- [x] Add example for matrix-free solvers (with Dirichlet BCs) (**Mohit**)\n- [x] Add example for contact problems with penalty method (**Mohit**)\n- [x] Add example for contact problems with Lagrange multipliers (**Flavio**)\n- [ ] Add example for contact problems with augmented Lagrangian method (**Flavio**)\n- [ ] Add example for contact problems with Nitsche method (**Flavio**)\n- [x] Add example for cohesive fracture problems (**Mohit**)\n- [x] Add example for cohesive fracture problems under quasi-static loading (**Mohit**)\n- [x] Add example for cohesive fracture problems in dynamics (**Mohit**)\n- [x] Add example for thermal-mechanical coupled problems (**Mohit**)\n- [ ] Add example for phase-field fracture coupled problems (**Mohit**)\n\n\n## Dense vs Sparse \n\nA unique aspect of `femsolver` is that it can handle both dense and sparse matrices. This is achieved by using the library `sparsejac` that allows automatic differentiation of a functional based on a sparsity pattern. This significantly reduces the memory consumption. For more details on how the automatic differentiation can be done using sparsity pattern, please check the link below:\n\n- ![Paper](https://arxiv.org/html/2501.17737v1)</br>\n- ![Github: sparsejac](https://github.com/mfschubert/sparsejac)</br>\n- ![Github: Sparsediffax, python interface for the paper](https://github.com/gdalle/sparsediffax)</br>\n\n## Profiling\n\n### Time usage profiling\n\nBelow we provide the computational time for the assembly of the sparse stiffness matrix for linear elasticity problem. The code is available in `benchmarking/profiling_time.py`.\n\n\n![Assembly Time](benchmarking/assembly_time_cpu.png)\n\nThe time above doesnot account for the compilation time  of the functions. In JAX, the first time a function is called, it is compiled and repeated calls are faster. This compilation time is not included in the time above. The time above is for a single core of a CPU. \n\n\n\n### Memory usage profiling\n\nWe use pprof to profile the memory usage. Please follow the instruction on JAX's documentation on profiling  ![Link to documentation](https://docs.jax.dev/en/latest/device_memory_profiling.html). Using `go` and `pprof`.\n\nFor 20000 degrees of freedom and a sparse linear elastic framework (`benchmarking/profiling_memory_usage.py`), a total of `15 MB` memory is used on `CPU`. The distribution of memory usage is as follows:\n\n![](benchmarking/profile001.svg)\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Lego-like building blocks for finite element analysis",
    "version": "0.1.2",
    "project_urls": {
        "repository": "https://gitlab.ethz.ch/smec/software/tatva"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "115198ae95d58eb03aa5233d5d4db49500aa53f04e8344f5d3e17c98c1d9201b",
                "md5": "f86a1f6b64a316a1bee3a1611458f00a",
                "sha256": "7dbfcfcfbccb993e9e460a9fe1535c1322e4fecd3176f0205db7c67df820a044"
            },
            "downloads": -1,
            "filename": "tatva-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f86a1f6b64a316a1bee3a1611458f00a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 20997,
            "upload_time": "2025-09-16T16:36:58",
            "upload_time_iso_8601": "2025-09-16T16:36:58.356145Z",
            "url": "https://files.pythonhosted.org/packages/11/51/98ae95d58eb03aa5233d5d4db49500aa53f04e8344f5d3e17c98c1d9201b/tatva-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "006884ec51434e0b1b2da3988111cad0cdfd7d8edaf4bc6da5ac1012865b6f83",
                "md5": "0d8d5d37a278a76d77288efb7b1fc015",
                "sha256": "2a61cb6330a1993dab5b57e73725474efec81d7019c28e54687fbff92a353f71"
            },
            "downloads": -1,
            "filename": "tatva-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "0d8d5d37a278a76d77288efb7b1fc015",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 5608770,
            "upload_time": "2025-09-16T16:37:02",
            "upload_time_iso_8601": "2025-09-16T16:37:02.937026Z",
            "url": "https://files.pythonhosted.org/packages/00/68/84ec51434e0b1b2da3988111cad0cdfd7d8edaf4bc6da5ac1012865b6f83/tatva-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-16 16:37:02",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "tatva"
}
        
Elapsed time: 4.89766s