Skip to main content

FluxFEM: A weak-form-centric differentiable finite element framework in JAX

Project description

License: Apache-2.0 Python Version CI CI

FluxFEM

A weak-form-centric differentiable finite element framework in JAX

Examples and Features

Example 1 : Diffusion

Optimization Process Pull-Down-0

Features

  • Built on JAX, enabling automatic differentiation and high-performance execution via grad, jit, vmap, and related transformations.

  • A FEM framework with a weak-form–centric API, emphasizing a smooth transition from theoretical formulations to practical code implementations.

  • Supports two assembly approaches: weak-form-based assembly and a tensor-based (scikit-fem–style) assembly.

  • enables to handle both Linear / Non-Linear Analysis with AD with JAX

Usage

This library provides two assembly approaches.

  • A weak-form-based assembly, where the variational form is written and assembled directly.
  • A tensor-based assembly, where trial and test functions are represented explicitly as tensors and assembled accordingly (in the style of scikit-fem).
    The first approach offers simplicity and convenience, as mathematical expressions can be written almost directly in code. However, for more complex operations, the second approach can be easier to implement in practice. This is because the weak-form-based assembly is ultimately transformed into the tensor-based representation internally during computation.

weak-form-based assembly

import fluxfem as ff

space = ff.make_hex_space(mesh, dim=3, intorder=2)
D = ff.isotropic_3d_D(1.0, 0.3)
bilinear_form = ff.BilinearForm.volume(
    lambda u, v, D: h_wf.ddot(v.sym_grad, D @ u.sym_grad) * h_wf.dOmega()
)
K_wf = space.assemble_bilinear_form(
    bilinear_form.get_compiled(),
    params=D,
)

tensor-based assembly (scikit-fem-style)

import fluxfem as ff
import numpy as np

def linear_elasticity_form(ctx: ff.FormContext, D: np.ndarray) -> ff.jnp.ndarray:
        Bu = h_num.sym_grad(ctx.trial)
        Bv = h_num.sym_grad(ctx.test)
        return h_num.ddot(Bv, D, Bu)


space = ff.make_hex_space(mesh, dim=3, intorder=2)
D = ff.isotropic_3d_D(1.0, 0.3)
K = space.assemble_bilinear_form(linear_elasticity_form, params=D)

Documentation

SetUp

You can install Scikit-Topt either via pip or Poetry.

Supported Python Versions

Scikit-Topt supports Python 3.10–3.13:

Choose one of the following methods:

Using pip

pip install fluxfem

Using poetry

poetry add fluxfem

Acknowledgements

I acknoldege everythings that made this work possible.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fluxfem-0.1.1a0.tar.gz (70.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fluxfem-0.1.1a0-py3-none-any.whl (87.6 kB view details)

Uploaded Python 3

File details

Details for the file fluxfem-0.1.1a0.tar.gz.

File metadata

  • Download URL: fluxfem-0.1.1a0.tar.gz
  • Upload date:
  • Size: 70.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.6 Linux/6.8.0-90-generic

File hashes

Hashes for fluxfem-0.1.1a0.tar.gz
Algorithm Hash digest
SHA256 24dc9497b8decdf6552cb33c5135becea81786ebae56890832a9fb482f52096c
MD5 8ad754ffcf2a84628ea378c48d22b7be
BLAKE2b-256 f8d071724504a0bc6c2ec10a7d9befc305e16395291193dbe6ad1513280f3699

See more details on using hashes here.

File details

Details for the file fluxfem-0.1.1a0-py3-none-any.whl.

File metadata

  • Download URL: fluxfem-0.1.1a0-py3-none-any.whl
  • Upload date:
  • Size: 87.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.6 Linux/6.8.0-90-generic

File hashes

Hashes for fluxfem-0.1.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1f5ed4ffd96908bb8613142eac7472a8d0adb7e47541b3511cf585674790dd6
MD5 bd44b9b86e35a2acd08c5c0bf0f00638
BLAKE2b-256 07d44b64a812fc6e06500ea2ed52b95b587703fbdd7534692e900d3b17e32e05

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page