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.1b0.tar.gz (72.2 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.1b0-py3-none-any.whl (87.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fluxfem-0.1.1b0.tar.gz
  • Upload date:
  • Size: 72.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.14 Linux/6.11.0-1018-azure

File hashes

Hashes for fluxfem-0.1.1b0.tar.gz
Algorithm Hash digest
SHA256 5b5bb230720171f62fa6a51aaf7397d8374f0d2474f12924dc8a36d7ba09ae6e
MD5 8c2a059e9cc9fba59333f3881cb743aa
BLAKE2b-256 f852777b9171c77a5721849a1eedc572d5cfce6facfb1a2ba38493ef6873a695

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fluxfem-0.1.1b0-py3-none-any.whl
  • Upload date:
  • Size: 87.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.14 Linux/6.11.0-1018-azure

File hashes

Hashes for fluxfem-0.1.1b0-py3-none-any.whl
Algorithm Hash digest
SHA256 fba26025e42ca527f8dbf27d3f4b3ae9d4aa6cffb27642bad9d5734a413a96e5
MD5 ce922afbcfd9dc8053dd86012bbea652
BLAKE2b-256 35f6459656571cce7cb81d384ebd5013cf91f8cedac62d6d2840acc774d174bc

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