The ADCME library (Automatic Differentiation Library for Computational and Mathematical Engineering) aims at general and scalable inverse modeling in scientific computing with gradient-based optimization techniques. It is built on the deep learning framework TensorFlow, which provides the automatic differentiation and parallel computing backend. The dataflow model adopted by the framework makes it suitable for high performance computing and inverse modeling in scientific computing. The design principles and methodologies are summarized in the slides.
Several features of the library are
- MATLAB-style syntax. Write
A*B
for matrix production instead oftf.matmul(A,B)
. - Custom operators. Implement operators in C/C++ for bottleneck parts; incorporate legacy code or specially designed C/C++ code in
ADCME
; differentiate implicit schemes. - Numerical Scheme. Easy to implement numerical schemes for solving PDEs.
- Physics Constrained Learning. Embed neural network into PDEs and solve with any numerical schemes, including implicit and iterative schemes.
- Static graphs. Compilation time computational graph optimization; automatic parallelism for your simulation codes.
- Custom optimizers. Large scale constrained optimization? Use
CustomOptimizer
to integrate your favorite optimizer. - Sparse linear algebra. Sparse linear algebra library tailored for scientific computing.
Start building your forward and inverse modeling using ADCME today!
Documentation | Tutorial | Research |
---|---|---|
Installation
⚠️ The latest version only supports Julia≧1.3.
⚠️ PyCall
is forced to use the default interpreter by ADCME
. Do not try to reset the interpreter by rebuilding PyCall
.
Install Julia
Install
ADCME
julia> ]
pkg> add ADCME
- (Optional) Test
ADCME.jl
julia> ]
pkg> test ADCME
See Troubleshooting if you encounter any compilation problems.
- (Optional) Enable GPU Support
To enable GPU support, first, make sure
nvcc
is available from your environment (e.g., typenvcc
in your shell and you should get the location of the executable binary file).
ENV["GPU"] = 1
Pkg.build("ADCME")
For manual installation without access to the internet, see here.
Tutorial
For a detailed tutorial, click here. Consider solving the following problem
-bu''(x)+u(x) = f(x), x∈[0,1], u(0)=u(1)=0
where
f(x) = 8 + 4x - 4x²
Assume that we have observed u(0.5)=1
, we want to estimate b
. The true value, in this case, should be b=1
.
using LinearAlgebra
using ADCME
n = 101 # number of grid nodes in [0,1]
h = 1/(n-1)
x = LinRange(0,1,n)[2:end-1]
b = Variable(10.0) # we use Variable keyword to mark the unknowns
A = diagm(0=>2/h^2*ones(n-2), -1=>-1/h^2*ones(n-3), 1=>-1/h^2*ones(n-3))
B = b*A + I # I stands for the identity matrix
f = @. 4*(2 + x - x^2)
u = B\f # solve the equation using built-in linear solver
ue = u[div(n+1,2)] # extract values at x=0.5
loss = (ue-1.0)^2
# Optimization
sess = Session(); init(sess)
BFGS!(sess, loss)
println("Estimated b = ", run(sess, b))
Expected output
Estimated b = 0.9995582304494237
The gradients can be obtained very easily. For example, if we want the gradients of loss
with respect to b
, the following code will create a Tensor for the gradient
julia> gradients(loss, b)
PyObject
Under the hood, a computational graph is created for gradients back-propagation.
For more documentation, see here.
Featured Applications
Constitutive Modeling | Seismic Inversion | Coupled Two-Phase Flow and Time-lapse FWI | Calibrating Jump Diffusion |
---|---|---|---|
Domain specific software based on ADCME
ADSeismic.jl: Inverse Problems in Earthquake Location/Source-Time Function, FWI, Rupture Process
FwiFlow.jl: Seismic Inversion, Two-phase Flow, Coupled seismic and flow equations
NNFEM.jl: Constitutive Modeling, Elasticity, Plasticity, Hyperelasticity, Finite Element Method on Unstructured Grid
LICENSE
ADCME.jl is released under MIT License. See License for details.