All Projects → kailaix → AdFem.jl

kailaix / AdFem.jl

Licence: MIT license
Innovative, efficient, and computational-graph-based finite element simulator for inverse modeling

Programming Languages

julia
2034 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to AdFem.jl

Kinetic.jl
Universal modeling and simulation of fluid dynamics upon machine learning
Stars: ✭ 82 (+32.26%)
Mutual labels:  finite-element-methods, numerical-pdes
Tullio.jl
Stars: ✭ 231 (+272.58%)
Mutual labels:  automatic-differentiation
Enzyme.jl
Julia bindings for the Enzyme automatic differentiator
Stars: ✭ 90 (+45.16%)
Mutual labels:  automatic-differentiation
Chainrules.jl
forward and reverse mode automatic differentiation primitives for Julia Base + StdLibs
Stars: ✭ 162 (+161.29%)
Mutual labels:  automatic-differentiation
Dcpp
Automatic differentiation in C++; infinite differentiability of conditionals, loops, recursion and all things C++
Stars: ✭ 143 (+130.65%)
Mutual labels:  automatic-differentiation
Mitgcm
M.I.T General Circulation Model master code and documentation repository
Stars: ✭ 177 (+185.48%)
Mutual labels:  automatic-differentiation
Omeinsum.jl
One More Einsum for Julia! With runtime order-specification and high-level adjoints for AD
Stars: ✭ 72 (+16.13%)
Mutual labels:  automatic-differentiation
admc
Infinite order automatic differentiation for Monte Carlo with unnormalized probability distribution
Stars: ✭ 17 (-72.58%)
Mutual labels:  automatic-differentiation
Aerosandbox
Aircraft design optimization made fast through modern automatic differentiation. Plug-and-play analysis tools for aerodynamics, propulsion, structures, trajectory design, and much, much more.
Stars: ✭ 193 (+211.29%)
Mutual labels:  automatic-differentiation
Galacticoptim.jl
Local, global, and beyond optimization for scientific machine learning (SciML)
Stars: ✭ 155 (+150%)
Mutual labels:  automatic-differentiation
Backprop
Heterogeneous automatic differentiation ("backpropagation") in Haskell
Stars: ✭ 154 (+148.39%)
Mutual labels:  automatic-differentiation
Autograd.jl
Julia port of the Python autograd package.
Stars: ✭ 147 (+137.1%)
Mutual labels:  automatic-differentiation
Reversediff.jl
Reverse Mode Automatic Differentiation for Julia
Stars: ✭ 182 (+193.55%)
Mutual labels:  automatic-differentiation
Adcme.jl
Automatic Differentiation Library for Computational and Mathematical Engineering
Stars: ✭ 106 (+70.97%)
Mutual labels:  automatic-differentiation
MASA
Method of Manufactured Solutions Repository
Stars: ✭ 46 (-25.81%)
Mutual labels:  automatic-differentiation
Cppadcodegen
Source Code Generation for Automatic Differentiation using Operator Overloading
Stars: ✭ 77 (+24.19%)
Mutual labels:  automatic-differentiation
Taylorseries.jl
A julia package for Taylor polynomial expansions in one and several independent variables.
Stars: ✭ 151 (+143.55%)
Mutual labels:  automatic-differentiation
Qml
Introductions to key concepts in quantum machine learning, as well as tutorials and implementations from cutting-edge QML research.
Stars: ✭ 174 (+180.65%)
Mutual labels:  automatic-differentiation
omd
JAX code for the paper "Control-Oriented Model-Based Reinforcement Learning with Implicit Differentiation"
Stars: ✭ 43 (-30.65%)
Mutual labels:  automatic-differentiation
fem mesh matlab
MATLAB Toolbox for Handling 2D and 3D FEM Meshes
Stars: ✭ 23 (-62.9%)
Mutual labels:  finite-element-methods

Documentation

Documentation

AdFem is a finite element method open source library for inverse modeling in computational and mathematical engineering. It provides a set of reusable, flexible, and differentiable operators for building scalable and efficient simulators for partial differential equations.

AdFem is built on ADCME, an automatic differentiation library for computational and mathematical engineering. It was originally developed for prototyping inverse modeling algorithms using structured meshes but later evolved into a general and powerful tool with a scalable FEM backend MFEM.

Ad in AdFem stands for "automatic differentiation" or "adjoint".

Install Guide

using Pkg
Pkg.add("AdFem")

Forward Computation in AdFem

As an example, we consider solving the Poisson's equation in AdFem

Here

The weak form for the Poisson's equation is to solve a variational equation

The problem is easily translated in AdFem:

using AdFem
using PyPlot 

# forward computation
mmesh = Mesh(joinpath(PDATA, "twoholes_large.stl"))
xy = gauss_nodes(mmesh)
κ = @. sin(xy[:,1]) * (1+xy[:,2]^2) + 1.0
f = 1e5 * @. xy[:,1] + xy[:,2]
K = compute_fem_laplace_matrix1(κ, mmesh)
F = compute_fem_source_term1(f, mmesh)
bdnode = bcnode(mmesh)
K, F = impose_Dirichlet_boundary_conditions(K, F, bdnode, zeros(length(bdnode)))
sol = K\F

The above code shows how to use a linear finite element space to approximate the state variable on a given mesh, define boundary conditions, and construct the linear system.

Inverse Modeling

Most functions of AdFem, such as compute_fem_laplace_matrix1, compute_fem_source_term1, and impose_Dirichlet_boundary_conditions, are AD-capable, meaning that you can back-propagate gradients from their outputs to inputs. This enables you to conduct inverse modeling without writing extra substantial effort once the forward computation codes are implemented. AdFem constructs a static computational graph for finite element simulators: the computational graph is optimized before executation, and all computations are delegated to efficient C++ kernels.

Here we use a deep neural network to approximate κ(x) (fc is an ADCME function and stands for fully-connected):

nn_κ = squeeze(fc(xy, [20,20,20,1])) + 1
K = compute_fem_laplace_matrix1(nn_κ, mmesh)
F = compute_fem_source_term1(f, mmesh)
bdnode = bcnode(mmesh)
K, F = impose_Dirichlet_boundary_conditions(K, F, bdnode, zeros(length(bdnode)))
nn_sol = K\F
loss = sum((nn_sol - sol)^2)

sess = Session(); init(sess)
BFGS!(sess, loss)

Installation

AdFem is tested on Unix platform (Linux and Mac). To install the stable release:

using Pkg
Pkg.add("ADCME") # dependency
Pkg.add("AdFem")

To install the latest version:

using Pkg 
Pkg.add(PackageSpec(url="https://github.com/kailaix/AdFem.jl", rev="master")) 

To install with docker, here is the built docker image provided by @Ricahrd-Li, and please see docker install guide.

Research

AdFem is an open-source package that accompanies ADCME.jl for solving inverse problems involving partial differential equations (PDEs). AdFem provides users a rich collection of operators, which users can use to quickly build finite element/volumn codes for forward computation. More importantly, these operators can back-propagate gradients, and therefore users can calculate the gradients using the ideas of adjoint methods and reverse-mode automatic differention (these two concepts overlap). The advanced physics constrained learning (PCL) approach enables users to back-propagate gradients through iterative and nonlinear solvers efficiently. AdFem offers a flexible interface for experienced researchers to develop their own operators.

Some related research works can be found here:

  1. Physics constrained learning for data-driven inverse modeling from sparse observations
  2. Solving Inverse Problems in Steady State Navier-Stokes Equations using Deep Neural Networks
  3. Inverse Modeling of Viscoelasticity Materials using Physics Constrained Learning

License

AdFem is licensed under MIT License. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].