Documentation | CI | Coverage | Release | DOI |
---|---|---|---|---|
PDENLPModels specializes the NLPModel API to optimization problems with partial differential equations in the constraints. The package relies on Gridap.jl for the modeling and the computation of the derivatives. Find tutorials for using Gridap here.
We consider optimization problems of the form: Find functions
We refer to the the repository PDEOptimizationProblems for examples of problems of different types: calculus of variations, optimal control problem, PDE-constrained problems, and mixed PDE-contrained problems with both function and algebraic unknowns.
] add PDENLPModels
The current version of PDENLPModels relies on Gridap v0.15.5.
where
using Gridap, PDENLPModels
# Definition of the domain
n = 100
domain = (-1, 1, -1, 1)
partition = (n, n)
model = CartesianDiscreteModel(domain, partition)
# Definition of the spaces:
valuetype = Float64
reffe = ReferenceFE(lagrangian, valuetype, 2)
Xpde = TestFESpace(model, reffe; conformity = :H1, dirichlet_tags = "boundary")
y0(x) = 0.0
Ypde = TrialFESpace(Xpde, y0)
reffe_con = ReferenceFE(lagrangian, valuetype, 1)
Xcon = TestFESpace(model, reffe_con; conformity = :H1)
Ycon = TrialFESpace(Xcon)
# Integration machinery
trian = Triangulation(model)
degree = 1
dΩ = Measure(trian, degree)
# Objective function:
yd(x) = -x[1]^2
α = 1e-2
function f(y, u)
∫(0.5 * (yd - y) * (yd - y) + 0.5 * α * u * u) * dΩ
end
# Definition of the constraint operator
ω = π - 1 / 8
h(x) = -sin(ω * x[1]) * sin(ω * x[2])
function res(y, u, v)
∫(∇(v) ⊙ ∇(y) - v * u - v * h) * dΩ
end
# initial guess
npde = num_free_dofs(Ypde)
ncon = num_free_dofs(Ycon)
xin = zeros(npde + ncon)
nlp = GridapPDENLPModel(xin, f, trian, Ypde, Ycon, Xpde, Xcon, res, name = "Control elastic membrane")
Migot, T., Orban D., & Siqueira A. S. PDENLPModels.jl: A NLPModel API for optimization problems with PDE-constraints Journal of Open Source Software 7(80), 4736 (2022). 10.21105/joss.04736
Badia, S., & Verdugo, F. Gridap: An extensible Finite Element toolbox in Julia. Journal of Open Source Software, 5(52), 2520 (2020). 10.21105/joss.02520
If you use PDENLPModels.jl in your work, please cite using the format given in CITATION.cff.
If you think you found a bug, feel free to open an issue. Focused suggestions and requests can also be opened as issues. Before opening a pull request, start an issue or a discussion on the topic, please.
If you want to ask a question not suited for a bug report, feel free to start a discussion here. This forum is for general discussion about this repository and the JuliaSmoothOptimizers, so questions about any of our packages are welcome.