Skip to content

tmigot/PDENLPModels.jl

 
 

Repository files navigation

PDENLPModels

Documentation CI Coverage Release DOI
docs-stable docs-dev build-ci codecov 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 (y,u): Y -> ℜⁿ x ℜⁿ and κ ∈ ℜⁿ satisfying min ∫_Ω​ f(κ,y,u) dΩ​ s.t. y solution of a PDE(κ,u)=0 lcon <= c(κ,y,u) <= ucon lvar <= (κ,y,u) <= uvar$$

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.

Installation

] add PDENLPModels

The current version of PDENLPModels relies on Gridap v0.15.5.

Example

$$min_{y ∈ H^1_0,u ∈ H^1} 0.5 ∫_Ω​ |y(x) - yd(x)|^2dx + 0.5 * α * ∫_Ω​ |u|^2 s.t. -Δy = u + h, for x ∈ Ω y = 0, for x ∈ ∂Ω where yd(x) = -x[1]^2, h(x) = 1 and α = 1e-2.$$
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= 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) *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) *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")

References

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

How to Cite

If you use PDENLPModels.jl in your work, please cite using the format given in CITATION.cff.

Bug reports and discussions

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.

About

A NLPModel API for optimization problems with PDE-constraints

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Julia 100.0%