This page was generated from unit-3.8-nonlmin/nonlmin.ipynb.
3.8 Nonlinear minimization problems¶
We consider problems of the form
[1]:
from ngsolve import *
from ngsolve.webgui import Draw
Scalar minimization problems¶
As a first example we take \(V = H^1_0\) and
The minimization is equivalent to solving the nonlinear PDE:
We solve the PDE with a Newton iteration.
[2]:
from netgen.geom2d import unit_square
mesh = Mesh (unit_square.GenerateMesh(maxh=0.2))
V = H1(mesh, order=4, dirichlet=[1,2,3,4])
u = V.TrialFunction()
To solve the problem we use the Variation
integrator. Based on the symbolic description of the energy functional, it is able to
evaluate the energy functional (
Energy
)
compute the Gateau derivative for a given \(u\) (
Apply
):
compute the second derivative (
AssembleLinearization
)
[3]:
a = BilinearForm (V, symmetric=True)
a += Variation ( (grad(u)*grad(u) + u**4-u) * dx)
Equivalent to:
a += (2 * grad(u) * grad(v) + 4*u*u*u*v - 1 * v)*dx
(which has the same form as the problems in the nonlinear example)
We recall the Newton iteration (cf. unit-3.7 ) we make the loop:
Given an initial guess \(u^0\)
loop over \(i=0,..\) until convergence:
Compute linearization: $A u^i + \delta `A(u^i) :nbsphinx-math:Delta `u^{i} = 0 $:
\(f^i = A u^i\)
\(B^i = \delta A(u^i)\)
Solve \(B^i \Delta u^i = -f^i\)
Update \(u^{i+1} = u^i + \Delta u^{i}\)
Evaluate stopping criteria
Evaluate \(E(u^{i+1})\)
As a stopping criteria we take \(\langle A u^i,\Delta u^i \rangle = \langle A u^i, A u^i \rangle_{(B^i)^{-1}}< \varepsilon\).
[4]:
def SolveNonlinearMinProblem(a,gfu,tol=1e-13,maxits=25):
res = gfu.vec.CreateVector()
du = gfu.vec.CreateVector()
for it in range(maxits):
print ("Newton iteration {:3}".format(it),end="")
print ("energy = {:16}".format(a.Energy(gfu.vec)),end="")
#solve linearized problem:
a.Apply (gfu.vec, res)
a.AssembleLinearization (gfu.vec)
inv = a.mat.Inverse(V.FreeDofs())
du.data = inv * res
#update iteration
gfu.vec.data -= du
#stopping criteria
stopcritval = sqrt(abs(InnerProduct(du,res)))
print ("<A u",it,", A u",it,">_{-1}^0.5 = ", stopcritval)
if stopcritval < tol:
break
Redraw(blocking=True)
[5]:
gfu = GridFunction (V)
gfu.vec[:] = 0
sceneu = Draw(gfu,mesh,"u")
SolveNonlinearMinProblem(a,gfu)
print ("energy = ", a.Energy(gfu.vec))
Newton iteration 0energy = 0.0<A u 0 , A u 0 >_{-1}^0.5 = 0.13255949695477584
Newton iteration 1energy = -0.008785666770072002<A u 1 , A u 1 >_{-1}^0.5 = 1.110760041466411e-05
Newton iteration 2energy = -0.008785666831761395<A u 2 , A u 2 >_{-1}^0.5 = 2.8074721184641564e-13
Newton iteration 3energy = -0.008785666831761397<A u 3 , A u 3 >_{-1}^0.5 = 3.3534118580780286e-17
energy = -0.008785666831761397
Again, a Newton for minimization is shipped with NGSolve:
[6]:
from ngsolve.solvers import *
gfu.vec[:] = 0
NewtonMinimization(a,gfu)
sceneu.Redraw()
Newton iteration 0
Energy: 0.0
err = 0.1325594969547758
Newton iteration 1
Energy: -0.008785666770072002
err = 1.1107600414641456e-05
Newton iteration 2
Energy: -0.008785666831761395
err = 2.807487362219202e-13
Nonlinear elasticity¶
We consider a beam which is fixed on one side and is subject to gravity only. We assume a Neo-Hookean hyperelastic material. The model is a nonlinear minimization problem with
where \(\mu\) and \(\lambda\) are the Lamé parameters and \(F = I + D v\) where \(v: \Omega \to \mathbb{R}^2\) is the sought for displacement.
[7]:
import netgen.geom2d as geom2d
from ngsolve import *
from ngsolve.webgui import Draw
geo = geom2d.SplineGeometry()
pnums = [ geo.AddPoint (x,y,maxh=0.01) for x,y in [(0,0), (1,0), (1,0.1), (0,0.1)] ]
for p1,p2,bc in [(0,1,"bot"), (1,2,"right"), (2,3,"top"), (3,0,"left")]:
geo.Append(["line", pnums[p1], pnums[p2]], bc=bc)
mesh = Mesh(geo.GenerateMesh(maxh=0.05))
[8]:
# E module and poisson number:
E, nu = 210, 0.2
# Lamé constants:
mu = E / 2 / (1+nu)
lam = E * nu / ((1+nu)*(1-2*nu))
V = VectorH1(mesh, order=2, dirichlet="left")
u = V.TrialFunction()
#gravity:
force = CoefficientFunction( (0,-1) )
[9]:
def Pow(a, b):
return exp (log(a)*b)
def NeoHook (C):
return 0.5 * mu * (Trace(C-I) + 2*mu/lam * Pow(Det(C), -lam/2/mu) - 1)
I = Id(mesh.dim)
F = I + Grad(u)
C = F.trans * F
factor = Parameter(1.0)
a = BilinearForm(V, symmetric=True)
a += Variation( NeoHook (C).Compile() * dx
-factor * (InnerProduct(force,u) ).Compile() * dx)
We want to solve the minimization problem for \(\gamma = 5\). Due to the high nonlinearity in the problem, the Newton iteration will not convergence with any initial guess. We approach the case \(\gamma = 5\) by solving problems with \(\gamma = i/10\) for \(i=1,..,50\) and taking the solution of the previous problem as an initial guess.
[10]:
gfu = GridFunction(V)
gfu.vec[:] = 0
sceneu = Draw (gfu, mesh, "u")
SetVisualization (deformation=True)
res = gfu.vec.CreateVector()
du = gfu.vec.CreateVector()
for loadstep in range(50):
print ("loadstep", loadstep)
factor.Set ((loadstep+1)/10)
SolveNonlinearMinProblem(a,gfu)
sceneu.Redraw()
loadstep 0
Newton iteration 0energy = 8.750000000000005<A u 0 , A u 0 >_{-1}^0.5 = 0.016678382390755288
Newton iteration 1energy = 8.750132585936578<A u 1 , A u 1 >_{-1}^0.5 = 0.023333256891798576
Newton iteration 2energy = 8.74986115049552<A u 2 , A u 2 >_{-1}^0.5 = 0.00010232159281117413
Newton iteration 3energy = 8.749861145260668<A u 3 , A u 3 >_{-1}^0.5 = 5.078987230934345e-08
Newton iteration 4energy = 8.749861145260665<A u 4 , A u 4 >_{-1}^0.5 = 2.661579380060487e-13
Newton iteration 5energy = 8.749861145260663<A u 5 , A u 5 >_{-1}^0.5 = 8.225695167307351e-16
loadstep 1
Newton iteration 0energy = 8.749583892957778<A u 0 , A u 0 >_{-1}^0.5 = 0.016596117905447468
Newton iteration 1energy = 8.749710099853527<A u 1 , A u 1 >_{-1}^0.5 = 0.022958465312257894
Newton iteration 2energy = 8.74944730043396<A u 2 , A u 2 >_{-1}^0.5 = 0.00014213684552075314
Newton iteration 3energy = 8.749447290438315<A u 3 , A u 3 >_{-1}^0.5 = 2.3248036083484098e-06
Newton iteration 4energy = 8.749447290435603<A u 4 , A u 4 >_{-1}^0.5 = 6.324688781684219e-10
Newton iteration 5energy = 8.74944729043561<A u 5 , A u 5 >_{-1}^0.5 = 1.672080396498094e-15
loadstep 2
Newton iteration 0energy = 8.748898149085237<A u 0 , A u 0 >_{-1}^0.5 = 0.01635697493005621
Newton iteration 1energy = 8.749005270899884<A u 1 , A u 1 >_{-1}^0.5 = 0.02189303042236316
Newton iteration 2energy = 8.74876626125895<A u 2 , A u 2 >_{-1}^0.5 = 0.00020820420956604055
Newton iteration 3energy = 8.748766239907326<A u 3 , A u 3 >_{-1}^0.5 = 4.8901755827964345e-06
Newton iteration 4energy = 8.748766239895367<A u 4 , A u 4 >_{-1}^0.5 = 2.664529908879819e-09
Newton iteration 5energy = 8.74876623989537<A u 5 , A u 5 >_{-1}^0.5 = 2.1545219373426666e-15
loadstep 3
Newton iteration 0energy = 8.747955304179662<A u 0 , A u 0 >_{-1}^0.5 = 0.015982097567591464
Newton iteration 1energy = 8.748035438675357<A u 1 , A u 1 >_{-1}^0.5 = 0.020292659620855413
Newton iteration 2energy = 8.747830048049662<A u 2 , A u 2 >_{-1}^0.5 = 0.0002637936026354171
Newton iteration 3energy = 8.747830013747695<A u 3 , A u 3 >_{-1}^0.5 = 7.246846163852253e-06
Newton iteration 4energy = 8.74783001372143<A u 4 , A u 4 >_{-1}^0.5 = 4.743748703193207e-09
Newton iteration 5energy = 8.747830013721432<A u 5 , A u 5 >_{-1}^0.5 = 3.616311928992526e-15
loadstep 4
Newton iteration 0energy = 8.746771024519141<A u 0 , A u 0 >_{-1}^0.5 = 0.015501109791087814
Newton iteration 1energy = 8.746821875338771<A u 1 , A u 1 >_{-1}^0.5 = 0.01836023081624558
Newton iteration 2energy = 8.746653692485939<A u 2 , A u 2 >_{-1}^0.5 = 0.0002990597350145664
Newton iteration 3energy = 8.746653648294211<A u 3 , A u 3 >_{-1}^0.5 = 8.720266772328203e-06
Newton iteration 4energy = 8.746653648256187<A u 4 , A u 4 >_{-1}^0.5 = 5.24315662816797e-09
Newton iteration 5energy = 8.74665364825618<A u 5 , A u 5 >_{-1}^0.5 = 4.328294634052801e-15
loadstep 5
Newton iteration 0energy = 8.745362725155786<A u 0 , A u 0 >_{-1}^0.5 = 0.014946280903332443
Newton iteration 1energy = 8.745386481617505<A u 1 , A u 1 >_{-1}^0.5 = 0.016293310584009953
Newton iteration 2energy = 8.745253992323276<A u 2 , A u 2 >_{-1}^0.5 = 0.000313206365846639
Newton iteration 3energy = 8.745253943722172<A u 3 , A u 3 >_{-1}^0.5 = 9.04313359446376e-06
Newton iteration 4energy = 8.745253943681277<A u 4 , A u 4 >_{-1}^0.5 = 4.217411575929172e-09
Newton iteration 5energy = 8.745253943681275<A u 5 , A u 5 >_{-1}^0.5 = 4.559164415717114e-15
loadstep 6
Newton iteration 0energy = 8.74374838218437<A u 0 , A u 0 >_{-1}^0.5 = 0.014347757828630747
Newton iteration 1energy = 8.743749777088052<A u 1 , A u 1 >_{-1}^0.5 = 0.014249383992409447
Newton iteration 2energy = 8.743648409960423<A u 2 , A u 2 >_{-1}^0.5 = 0.0003093522452984288
Newton iteration 3energy = 8.74364836243308<A u 3 , A u 3 >_{-1}^0.5 = 8.385269217571552e-06
Newton iteration 4energy = 8.743648362397929<A u 4 , A u 4 >_{-1}^0.5 = 2.6943222965375834e-09
Newton iteration 5energy = 8.743648362397927<A u 5 , A u 5 >_{-1}^0.5 = 4.265851838312984e-15
loadstep 7
Newton iteration 0energy = 8.741945650331859<A u 0 , A u 0 >_{-1}^0.5 = 0.013730754995759296
Newton iteration 1energy = 8.74193019383729<A u 1 , A u 1 >_{-1}^0.5 = 0.012333805584321456
Newton iteration 2energy = 8.741854223708538<A u 2 , A u 2 >_{-1}^0.5 = 0.0002921400113760417
Newton iteration 3energy = 8.741854181238816<A u 3 , A u 3 >_{-1}^0.5 = 7.1304843842849655e-06
Newton iteration 4energy = 8.741854181213386<A u 4 , A u 4 >_{-1}^0.5 = 1.4436768240037753e-09
Newton iteration 5energy = 8.741854181213387<A u 5 , A u 5 >_{-1}^0.5 = 4.262573923423666e-15
loadstep 8
Newton iteration 0energy = 8.739971288694946<A u 0 , A u 0 >_{-1}^0.5 = 0.013114590303641569
Newton iteration 1energy = 8.739944123846238<A u 1 , A u 1 >_{-1}^0.5 = 0.010604193396712067
Newton iteration 2energy = 8.739887948591901<A u 2 , A u 2 >_{-1}^0.5 = 0.0002663295273824012
Newton iteration 3energy = 8.739887913241445<A u 3 , A u 3 >_{-1}^0.5 = 5.663180365496771e-06
Newton iteration 4energy = 8.73988791322541<A u 4 , A u 4 >_{-1}^0.5 = 6.721145933415297e-10
Newton iteration 5energy = 8.739887913225408<A u 5 , A u 5 >_{-1}^0.5 = 4.80875665732802e-15
loadstep 9
Newton iteration 0energy = 8.737840839887603<A u 0 , A u 0 >_{-1}^0.5 = 0.012512967634820831
Newton iteration 1energy = 8.737806211240576<A u 1 , A u 1 >_{-1}^0.5 = 0.009082216012610009
Newton iteration 2energy = 8.737764991099096<A u 2 , A u 2 >_{-1}^0.5 = 0.00023605086028194344
Newton iteration 3energy = 8.737764963298767<A u 3 , A u 3 >_{-1}^0.5 = 4.258856622325151e-06
Newton iteration 4energy = 8.737764963289697<A u 4 , A u 4 >_{-1}^0.5 = 2.779241978161679e-10
Newton iteration 5energy = 8.737764963289692<A u 5 , A u 5 >_{-1}^0.5 = 6.1418577774628076e-15
loadstep 10
Newton iteration 0energy = 8.735568492367701<A u 0 , A u 0 >_{-1}^0.5 = 0.011934876423785106
Newton iteration 1energy = 8.73552963093563<A u 1 , A u 1 >_{-1}^0.5 = 0.007766170839182753
Newton iteration 2energy = 8.73549948223209<A u 2 , A u 2 >_{-1}^0.5 = 0.00020450737374954478
Newton iteration 3energy = 8.735499461348876<A u 3 , A u 3 >_{-1}^0.5 = 3.0651565873007505e-06
Newton iteration 4energy = 8.73549946134418<A u 4 , A u 4 >_{-1}^0.5 = 1.0318410567450001e-10
Newton iteration 5energy = 8.735499461344189<A u 5 , A u 5 >_{-1}^0.5 = 6.1574063877941515e-15
loadstep 11
Newton iteration 0energy = 8.733167062934966<A u 0 , A u 0 >_{-1}^0.5 = 0.011385659634348408
Newton iteration 1energy = 8.73312628674236<A u 1 , A u 1 >_{-1}^0.5 = 0.006641200507693204
Newton iteration 2energy = 8.733104233737167<A u 2 , A u 2 >_{-1}^0.5 = 0.0001739493593252799
Newton iteration 3energy = 8.733104218620428<A u 3 , A u 3 >_{-1}^0.5 = 2.129535379620661e-06
Newton iteration 4energy = 8.733104218618156<A u 4 , A u 4 >_{-1}^0.5 = 3.432853656464424e-11
Newton iteration 5energy = 8.733104218618156<A u 5 , A u 5 >_{-1}^0.5 = 6.179372477428042e-15
loadstep 12
Newton iteration 0energy = 8.730648051299827<A u 0 , A u 0 >_{-1}^0.5 = 0.010868004310983588
Newton iteration 1energy = 8.730606944098007<A u 1 , A u 1 >_{-1}^0.5 = 0.005686407124508259
Newton iteration 2energy = 8.730590772260673<A u 2 , A u 2 >_{-1}^0.5 = 0.00014578797430277076
Newton iteration 3energy = 8.73059076163854<A u 3 , A u 3 >_{-1}^0.5 = 1.43850761805062e-06
Newton iteration 4energy = 8.730590761637513<A u 4 , A u 4 >_{-1}^0.5 = 9.988067426584181e-12
Newton iteration 5energy = 8.730590761637513<A u 5 , A u 5 >_{-1}^0.5 = 6.8769167105590945e-15
loadstep 13
Newton iteration 0energy = 8.728021733357686<A u 0 , A u 0 >_{-1}^0.5 = 0.010382755786018829
Newton iteration 1energy = 8.72798132754746<A u 1 , A u 1 >_{-1}^0.5 = 0.004879274848075253
Newton iteration 2energy = 8.727969418133108<A u 2 , A u 2 >_{-1}^0.5 = 0.00012076675563494456
Newton iteration 3energy = 8.7279694108425<A u 3 , A u 3 >_{-1}^0.5 = 9.505936905068618e-07
Newton iteration 4energy = 8.727969410842045<A u 4 , A u 4 >_{-1}^0.5 = 2.3264985884817412e-12
Newton iteration 5energy = 8.727969410842048<A u 5 , A u 5 >_{-1}^0.5 = 6.8896690523432285e-15
loadstep 14
Newton iteration 0energy = 8.725297271534666<A u 0 , A u 0 >_{-1}^0.5 = 0.009929540146497379
Newton iteration 1energy = 8.725258204221735<A u 1 , A u 1 >_{-1}^0.5 = 0.004198138558029775
Newton iteration 2energy = 8.72524938609619<A u 2 , A u 2 >_{-1}^0.5 = 9.914194785388828e-05
Newton iteration 3energy = 8.725249381182058<A u 3 , A u 3 >_{-1}^0.5 = 6.177654275476132e-07
Newton iteration 4energy = 8.72524938118187<A u 4 , A u 4 >_{-1}^0.5 = 2.708226033824133e-13
Newton iteration 5energy = 8.725249381181872<A u 5 , A u 5 >_{-1}^0.5 = 8.013383813739961e-15
loadstep 15
Newton iteration 0energy = 8.72248282896684<A u 0 , A u 0 >_{-1}^0.5 = 0.009507217507470465
Newton iteration 1energy = 8.72244546337916<A u 1 , A u 1 >_{-1}^0.5 = 0.0036233812630321847
Newton iteration 2energy = 8.722438893461836<A u 2 , A u 2 >_{-1}^0.5 = 8.084475896702669e-05
Newton iteration 3energy = 8.722438890193898<A u 3 , A u 3 >_{-1}^0.5 = 3.9661685500887504e-07
Newton iteration 4energy = 8.722438890193818<A u 4 , A u 4 >_{-1}^0.5 = 1.5319090856131928e-13
Newton iteration 5energy = 8.722438890193823<A u 5 , A u 5 >_{-1}^0.5 = 7.435188870624238e-15
loadstep 16
Newton iteration 0energy = 8.719585679907679<A u 0 , A u 0 >_{-1}^0.5 = 0.009114200423702716
Newton iteration 1energy = 8.719550194836472<A u 1 , A u 1 >_{-1}^0.5 = 0.0031378710664224574
Newton iteration 2energy = 8.719545266984772<A u 2 , A u 2 >_{-1}^0.5 = 6.561290828819087e-05
Newton iteration 3energy = 8.719545264832139<A u 3 , A u 3 >_{-1}^0.5 = 2.525372865815696e-07
Newton iteration 4energy = 8.719545264832098<A u 4 , A u 4 >_{-1}^0.5 = 1.5057042073179863e-13
Newton iteration 5energy = 8.719545264832098<A u 5 , A u 5 >_{-1}^0.5 = 8.13439433458963e-15
loadstep 17
Newton iteration 0energy = 8.716612312372297<A u 0 , A u 0 >_{-1}^0.5 = 0.008748671018667371
Newton iteration 1energy = 8.716578765757584<A u 1 , A u 1 >_{-1}^0.5 = 0.002726978936378575
Newton iteration 2energy = 8.716575043606786<A u 2 , A u 2 >_{-1}^0.5 = 5.3088307717759304e-05
Newton iteration 3energy = 8.7165750421975<A u 3 , A u 3 >_{-1}^0.5 = 1.5999780533599802e-07
Newton iteration 4energy = 8.71657504219748<A u 4 , A u 4 >_{-1}^0.5 = 9.240837105873956e-14
loadstep 18
Newton iteration 0energy = 8.713568521256038<A u 0 , A u 0 >_{-1}^0.5 = 0.008408724932748055
Newton iteration 1energy = 8.713536894279306<A u 1 , A u 1 >_{-1}^0.5 = 0.0023783885433465253
Newton iteration 2energy = 8.713534062707833<A u 2 , A u 2 >_{-1}^0.5 = 4.288363853753871e-05
Newton iteration 3energy = 8.71353406178825<A u 3 , A u 3 >_{-1}^0.5 = 1.0114091346355786e-07
Newton iteration 4energy = 8.713534061788245<A u 4 , A u 4 >_{-1}^0.5 = 4.865671048764449e-14
loadstep 19
Newton iteration 0energy = 8.710459491487788<A u 0 , A u 0 >_{-1}^0.5 = 0.008092463808702106
Newton iteration 1energy = 8.710429718569646<A u 1 , A u 1 >_{-1}^0.5 = 0.002081821059098702
Newton iteration 2energy = 8.710427549016906<A u 2 , A u 2 >_{-1}^0.5 = 3.4623585677951934e-05
Newton iteration 3energy = 8.710427548417456<A u 3 , A u 3 >_{-1}^0.5 = 6.393535769673621e-08
Newton iteration 4energy = 8.710427548417453<A u 4 , A u 4 >_{-1}^0.5 = 2.5621800357692153e-14
loadstep 20
Newton iteration 0energy = 8.70728987152168<A u 0 , A u 0 >_{-1}^0.5 = 0.007798052333314451
Newton iteration 1energy = 8.707261860397317<A u 1 , A u 1 >_{-1}^0.5 = 0.0018287420130939324
Newton iteration 2energy = 8.707260186220783<A u 2 , A u 2 >_{-1}^0.5 = 2.7967298757767892e-05
Newton iteration 3energy = 8.707260185829664<A u 3 , A u 3 >_{-1}^0.5 = 4.048982222756301e-08
Newton iteration 4energy = 8.707260185829663<A u 4 , A u 4 >_{-1}^0.5 = 1.4885675497864682e-14
loadstep 21
Newton iteration 0energy = 8.70406383785694<A u 0 , A u 0 >_{-1}^0.5 = 0.0075237512984265825
Newton iteration 1energy = 8.704037482792224<A u 1 , A u 1 >_{-1}^0.5 = 0.0016120839035681908
Newton iteration 2energy = 8.704036181791693<A u 2 , A u 2 >_{-1}^0.5 = 2.261808346136178e-05
Newton iteration 3energy = 8.704036181535885<A u 3 , A u 3 >_{-1}^0.5 = 2.572573254033779e-08
Newton iteration 4energy = 8.704036181535882<A u 4 , A u 4 >_{-1}^0.5 = 1.0787052595370211e-14
loadstep 22
Newton iteration 0energy = 8.70078515144342<A u 0 , A u 0 >_{-1}^0.5 = 0.007267934720804574
Newton iteration 1energy = 8.700760341771408<A u 1 , A u 1 >_{-1}^0.5 = 0.001425999198346473
Newton iteration 2energy = 8.700759323787844<A u 2 , A u 2 >_{-1}^0.5 = 1.8325128466013545e-05
Newton iteration 3energy = 8.700759323619925<A u 3 , A u 3 >_{-1}^0.5 = 1.6417045175198894e-08
Newton iteration 4energy = 8.70075932361992<A u 4 , A u 4 >_{-1}^0.5 = 8.738776156859684e-15
loadstep 23
Newton iteration 0energy = 8.697457206873455<A u 0 , A u 0 >_{-1}^0.5 = 0.007029096572568504
Newton iteration 1energy = 8.697433832371452<A u 1 , A u 1 >_{-1}^0.5 = 0.0012656480113940809
Newton iteration 2energy = 8.697433030465469<A u 2 , A u 2 >_{-1}^0.5 = 1.4880754836034847e-05
Newton iteration 3energy = 8.697433030354746<A u 3 , A u 3 >_{-1}^0.5 = 1.0531743837183756e-08
Newton iteration 4energy = 8.697433030354746<A u 4 , A u 4 >_{-1}^0.5 = 7.97894508341449e-15
loadstep 24
Newton iteration 0energy = 8.694083075231845<A u 0 , A u 0 >_{-1}^0.5 = 0.006805850912318838
Newton iteration 1energy = 8.694061029385738<A u 1 , A u 1 >_{-1}^0.5 = 0.0011270194997571796
Newton iteration 2energy = 8.694060393539427<A u 2 , A u 2 >_{-1}^0.5 = 1.2115520218371166e-05
Newton iteration 3energy = 8.694060393466039<A u 3 , A u 3 >_{-1}^0.5 = 6.796116884659747e-09
Newton iteration 4energy = 8.694060393466035<A u 4 , A u 4 >_{-1}^0.5 = 8.85894868016414e-15
loadstep 25
Newton iteration 0energy = 8.690665541411896<A u 0 , A u 0 >_{-1}^0.5 = 0.006596927974879257
Newton iteration 1energy = 8.69064472328174<A u 1 , A u 1 >_{-1}^0.5 = 0.0010067836587969085
Newton iteration 2energy = 8.690644215881647<A u 2 , A u 2 >_{-1}^0.5 = 9.892619993518303e-06
Newton iteration 3energy = 8.690644215832712<A u 3 , A u 3 >_{-1}^0.5 = 4.413429832686527e-09
Newton iteration 4energy = 8.690644215832712<A u 4 , A u 4 >_{-1}^0.5 = 9.352395752428968e-15
loadstep 26
Newton iteration 0energy = 8.687207136625545<A u 0 , A u 0 >_{-1}^0.5 = 0.006401167928265712
Newton iteration 1energy = 8.687187451796238<A u 1 , A u 1 >_{-1}^0.5 = 0.0009021693868869216
Newton iteration 2energy = 8.687187044377275<A u 2 , A u 2 >_{-1}^0.5 = 8.102402299360474e-06
Newton iteration 3energy = 8.687187044344453<A u 3 , A u 3 >_{-1}^0.5 = 2.8852464097068642e-09
Newton iteration 4energy = 8.68718704434445<A u 4 , A u 4 >_{-1}^0.5 = 8.62068123268755e-15
loadstep 27
Newton iteration 0energy = 8.68371016675213<A u 0 , A u 0 >_{-1}^0.5 = 0.006217513423105497
Newton iteration 1energy = 8.683691527695357<A u 1 , A u 1 >_{-1}^0.5 = 0.0008108646767330388
Newton iteration 2energy = 8.683691198580748<A u 2 , A u 2 >_{-1}^0.5 = 6.657405277539553e-06
Newton iteration 3energy = 8.683691198558591<A u 3 , A u 3 >_{-1}^0.5 = 1.8991875152329574e-09
Newton iteration 4energy = 8.68369119855859<A u 4 , A u 4 >_{-1}^0.5 = 8.31381277190115e-15
loadstep 28
Newton iteration 0energy = 8.680176737089983<A u 0 , A u 0 >_{-1}^0.5 = 0.006045001663946513
Newton iteration 1energy = 8.680159063155784<A u 1 , A u 1 >_{-1}^0.5 = 0.000730935146826445
Newton iteration 2energy = 8.680158795736729<A u 2 , A u 2 >_{-1}^0.5 = 5.488076199860775e-06
Newton iteration 3energy = 8.68015879572167<A u 3 , A u 3 >_{-1}^0.5 = 1.2588616627003492e-09
Newton iteration 4energy = 8.680158795721663<A u 4 , A u 4 >_{-1}^0.5 = 8.249289632673943e-15
loadstep 29
Newton iteration 0energy = 8.676608774000314<A u 0 , A u 0 >_{-1}^0.5 = 0.00588275646389783
Newton iteration 1energy = 8.676591991183995<A u 1 , A u 1 >_{-1}^0.5 = 0.000660757619962145
Newton iteration 2energy = 8.676591772658249<A u 2 , A u 2 >_{-1}^0.5 = 4.539191566126867e-06
Newton iteration 3energy = 8.67659177264795<A u 3 , A u 3 >_{-1}^0.5 = 8.40289945980431e-10
Newton iteration 4energy = 8.67659177264795<A u 4 , A u 4 >_{-1}^0.5 = 9.418652161231354e-15
loadstep 30
Newton iteration 0energy = 8.673008043866378<A u 0 , A u 0 >_{-1}^0.5 = 0.005729980563998529
Newton iteration 1energy = 8.672992084446872<A u 1 , A u 1 >_{-1}^0.5 = 0.0005989659685106328
Newton iteration 2energy = 8.672991904888457<A u 2 , A u 2 >_{-1}^0.5 = 3.76692558678857e-06
Newton iteration 3energy = 8.672991904881362<A u 3 , A u 3 >_{-1}^0.5 = 5.648286277050621e-10
Newton iteration 4energy = 8.672991904881364<A u 4 , A u 4 >_{-1}^0.5 = 9.809473912030201e-15
loadstep 31
Newton iteration 0energy = 8.669376169731839<A u 0 , A u 0 >_{-1}^0.5 = 0.005585948379563473
Newton iteration 1energy = 8.669360971844453<A u 1 , A u 1 >_{-1}^0.5 = 0.0005444069229851316
Newton iteration 2energy = 8.669360823513486<A u 2 , A u 2 >_{-1}^0.5 = 3.136484201519974e-06
Newton iteration 3energy = 8.669360823508566<A u 3 , A u 3 >_{-1}^0.5 = 3.82307045461158e-10
Newton iteration 4energy = 8.669360823508566<A u 4 , A u 4 >_{-1}^0.5 = 1.050679476747547e-14
loadstep 32
Newton iteration 0energy = 8.66571464593103<A u 0 , A u 0 >_{-1}^0.5 = 0.005449999256849206
Newton iteration 1energy = 8.665700153115052<A u 1 , A u 1 >_{-1}^0.5 = 0.0004961039573403354
Newton iteration 2energy = 8.665700029942759<A u 2 , A u 2 >_{-1}^0.5 = 2.6202145914449875e-06
Newton iteration 3energy = 8.66570002993933<A u 3 , A u 3 >_{-1}^0.5 = 2.605405858097632e-10
Newton iteration 4energy = 8.66570002993933<A u 4 , A u 4 >_{-1}^0.5 = 9.291317177394058e-15
loadstep 33
Newton iteration 0energy = 8.662024850979378<A u 0 , A u 0 >_{-1}^0.5 = 0.005321531272685377
Newton iteration 1energy = 8.662011011726086<A u 1 , A u 1 >_{-1}^0.5 = 0.0004532277179771657
Newton iteration 2energy = 8.662010908928279<A u 2 , A u 2 >_{-1}^0.5 = 2.1961049308536914e-06
Newton iteration 3energy = 8.66201090892587<A u 3 , A u 3 >_{-1}^0.5 = 1.7875556424130604e-10
Newton iteration 4energy = 8.662010908925868<A u 4 , A u 4 >_{-1}^0.5 = 9.941728243278747e-15
loadstep 34
Newton iteration 0energy = 8.658308058954264<A u 0 , A u 0 >_{-1}^0.5 = 0.0051999955774563265
Newton iteration 1energy = 8.658294826270655<A u 1 , A u 1 >_{-1}^0.5 = 0.00041507175626998954
Newton iteration 2energy = 8.658294740056048<A u 2 , A u 2 >_{-1}^0.5 = 1.8465991940801326e-06
Newton iteration 3energy = 8.658294740054345<A u 3 , A u 3 >_{-1}^0.5 = 1.2345632294967938e-10
Newton iteration 4energy = 8.658294740054341<A u 4 , A u 4 >_{-1}^0.5 = 1.0587488731531352e-14
loadstep 35
Newton iteration 0energy = 8.65456544956376<A u 0 , A u 0 >_{-1}^0.5 = 0.005084891262479123
Newton iteration 1energy = 8.65455278056102<A u 1 , A u 1 >_{-1}^0.5 = 0.000381032564132211
Newton iteration 2energy = 8.654552707909858<A u 2 , A u 2 >_{-1}^0.5 = 1.5576634313315837e-06
Newton iteration 3energy = 8.65455270790865<A u 3 , A u 3 >_{-1}^0.5 = 8.581373036197404e-11
Newton iteration 4energy = 8.654552707908646<A u 4 , A u 4 >_{-1}^0.5 = 9.269272096440546e-15
loadstep 36
Newton iteration 0energy = 8.650798117073078<A u 0 , A u 0 >_{-1}^0.5 = 0.0049757607212759965
Newton iteration 1energy = 8.65078597258417<A u 1 , A u 1 >_{-1}^0.5 = 0.00035059310620755014
Newton iteration 2energy = 8.65078591107931<A u 2 , A u 2 >_{-1}^0.5 = 1.318051220854502e-06
Newton iteration 3energy = 8.65078591107844<A u 3 , A u 3 >_{-1}^0.5 = 6.002781364799486e-11
Newton iteration 4energy = 8.65078591107844<A u 4 , A u 4 >_{-1}^0.5 = 1.0485738527131265e-14
loadstep 37
Newton iteration 0energy = 8.647007078234466<A u 0 , A u 0 >_{-1}^0.5 = 0.004872185468872917
Newton iteration 1energy = 8.646995422462584<A u 1 , A u 1 >_{-1}^0.5 = 0.00032330919910142
Newton iteration 2energy = 8.64699537015994<A u 2 , A u 2 >_{-1}^0.5 = 1.118726050930792e-06
Newton iteration 3energy = 8.646995370159313<A u 3 , A u 3 >_{-1}^0.5 = 4.224721621797406e-11
Newton iteration 4energy = 8.646995370159317<A u 4 , A u 4 >_{-1}^0.5 = 9.729232839510669e-15
loadstep 38
Newton iteration 0energy = 8.643193279346296<A u 0 , A u 0 >_{-1}^0.5 = 0.00477378238089766
Newton iteration 1energy = 8.643182079544076<A u 1 , A u 1 >_{-1}^0.5 = 0.00029879821383155936
Newton iteration 2energy = 8.643182034872753<A u 2 , A u 2 >_{-1}^0.5 = 9.524069438793206e-07
Newton iteration 3energy = 8.643182034872298<A u 3 , A u 3 >_{-1}^0.5 = 2.9914301717461894e-11
Newton iteration 4energy = 8.643182034872295<A u 4 , A u 4 >_{-1}^0.5 = 1.06610155587749e-14
loadstep 39
Newton iteration 0energy = 8.639357602549433<A u 0 , A u 0 >_{-1}^0.5 = 0.0046802003142568304
Newton iteration 1energy = 8.639346828727849<A u 1 , A u 1 >_{-1}^0.5 = 0.00027672967851285834
Newton iteration 2energy = 8.639346790412748<A u 2 , A u 2 >_{-1}^0.5 = 8.132106828501678e-07
Newton iteration 3energy = 8.63934679041241<A u 3 , A u 3 >_{-1}^0.5 = 2.1306059963602598e-11
Newton iteration 4energy = 8.639346790412409<A u 4 , A u 4 >_{-1}^0.5 = 1.0681843509166904e-14
loadstep 40
Newton iteration 0energy = 8.635500871454596<A u 0 , A u 0 >_{-1}^0.5 = 0.004591117072857296
Newton iteration 1energy = 8.635490496119774<A u 1 , A u 1 >_{-1}^0.5 = 0.000256817439502574
Newton iteration 2energy = 8.635490463121286<A u 2 , A u 2 >_{-1}^0.5 = 6.963696966283656e-07
Newton iteration 3energy = 8.63549046312104<A u 3 , A u 3 >_{-1}^0.5 = 1.5258323053214198e-11
Newton iteration 4energy = 8.635490463121046<A u 4 , A u 4 >_{-1}^0.5 = 8.827150842568554e-15
loadstep 41
Newton iteration 0energy = 8.631623856181335<A u 0 , A u 0 >_{-1}^0.5 = 0.0045062366837491
Newton iteration 1energy = 8.631613854097237<A u 1 , A u 1 >_{-1}^0.5 = 0.00023881310384552478
Newton iteration 2energy = 8.631613825564186<A u 2 , A u 2 >_{-1}^0.5 = 5.98009204103875e-07
Newton iteration 3energy = 8.631613825564012<A u 3 , A u 3 >_{-1}^0.5 = 1.0990488900140723e-11
Newton iteration 4energy = 8.63161382556401<A u 4 , A u 4 >_{-1}^0.5 = 1.055859156574069e-14
loadstep 42
Newton iteration 0energy = 8.627727277879044<A u 0 , A u 0 >_{-1}^0.5 = 0.004425286951923272
Newton iteration 1energy = 8.62771762585382<A u 1 , A u 1 >_{-1}^0.5 = 0.00022250053817710115
Newton iteration 2energy = 8.627717601086363<A u 2 , A u 2 >_{-1}^0.5 = 5.149708084000054e-07
Newton iteration 3energy = 8.62771760108623<A u 3 , A u 3 >_{-1}^0.5 = 7.959422772728941e-12
Newton iteration 4energy = 8.627717601086221<A u 4 , A u 4 >_{-1}^0.5 = 1.1206272235192536e-14
loadstep 43
Newton iteration 0energy = 8.623811812790498<A u 0 , A u 0 >_{-1}^0.5 = 0.004348017264586569
Newton iteration 1energy = 8.623802489484435<A u 1 , A u 1 >_{-1}^0.5 = 0.00020769124099631234
Newton iteration 2energy = 8.623802467904822<A u 2 , A u 2 >_{-1}^0.5 = 4.446725375445635e-07
Newton iteration 3energy = 8.623802467904726<A u 3 , A u 3 >_{-1}^0.5 = 5.793013765299362e-12
Newton iteration 4energy = 8.623802467904728<A u 4 , A u 4 >_{-1}^0.5 = 1.0530521273070294e-14
loadstep 44
Newton iteration 0energy = 8.619878095911142<A u 0 , A u 0 >_{-1}^0.5 = 0.004274196618547073
Newton iteration 1energy = 8.619869081664056<A u 1 , A u 1 >_{-1}^0.5 = 0.00019422043896448316
Newton iteration 2energy = 8.619869062793466<A u 2 , A u 2 >_{-1}^0.5 = 3.849975301478303e-07
Newton iteration 3energy = 8.61986906279339<A u 3 , A u 3 >_{-1}^0.5 = 4.239278501511616e-12
Newton iteration 4energy = 8.619869062793391<A u 4 , A u 4 >_{-1}^0.5 = 1.11580184480003e-14
loadstep 45
Newton iteration 0energy = 8.615926724290007<A u 0 , A u 0 >_{-1}^0.5 = 0.0042036118468920195
Newton iteration 1energy = 8.615918000966204<A u 1 , A u 1 >_{-1}^0.5 = 0.00018194378505178904
Newton iteration 2energy = 8.615917984406249<A u 2 , A u 2 >_{-1}^0.5 = 3.3420528126933616e-07
Newton iteration 3energy = 8.6159179844062<A u 3 , A u 3 >_{-1}^0.5 = 3.1172942690788893e-12
Newton iteration 4energy = 8.615917984406195<A u 4 , A u 4 >_{-1}^0.5 = 1.0330726651365844e-14
loadstep 46
Newton iteration 0energy = 8.611958260012726<A u 0 , A u 0 >_{-1}^0.5 = 0.0041360660236643134
Newton iteration 1energy = 8.611949810861685<A u 1 , A u 1 >_{-1}^0.5 = 0.00017073455836505666
Newton iteration 2energy = 8.611949796279685<A u 2 , A u 2 >_{-1}^0.5 = 2.9086068319968975e-07
Newton iteration 3energy = 8.611949796279646<A u 3 , A u 3 >_{-1}^0.5 = 2.3030356237034256e-12
Newton iteration 4energy = 8.611949796279646<A u 4 , A u 4 >_{-1}^0.5 = 1.1820708404389974e-14
loadstep 47
Newton iteration 0energy = 8.60797323290172<A u 0 , A u 0 >_{-1}^0.5 = 0.004071377027471576
Newton iteration 1energy = 8.607965042432857<A u 1 , A u 1 >_{-1}^0.5 = 0.00016048128329030782
Newton iteration 2energy = 8.60796502954998<A u 2 , A u 2 >_{-1}^0.5 = 2.5377714592362046e-07
Newton iteration 3energy = 8.607965029549941<A u 3 , A u 3 >_{-1}^0.5 = 1.7113756425527599e-12
Newton iteration 4energy = 8.607965029549941<A u 4 , A u 4 >_{-1}^0.5 = 1.0304094715684442e-14
loadstep 48
Newton iteration 0energy = 8.60397214296444<A u 0 , A u 0 >_{-1}^0.5 = 0.004009376246978417
Newton iteration 1energy = 8.603964196834545<A u 1 , A u 1 >_{-1}^0.5 = 0.00015108569999442697
Newton iteration 2energy = 8.603964185416244<A u 2 , A u 2 >_{-1}^0.5 = 2.219708759576467e-07
Newton iteration 3energy = 8.603964185416224<A u 3 , A u 3 >_{-1}^0.5 = 1.2754769699119674e-12
Newton iteration 4energy = 8.603964185416222<A u 4 , A u 4 >_{-1}^0.5 = 1.1159291624241635e-14
loadstep 49
Newton iteration 0energy = 8.599955462616867<A u 0 , A u 0 >_{-1}^0.5 = 0.00394990741323281
Newton iteration 1energy = 8.59994774752875<A u 1 , A u 1 >_{-1}^0.5 = 0.0001424610302423851
Newton iteration 2energy = 8.599947737377077<A u 2 , A u 2 >_{-1}^0.5 = 1.9462402808326612e-07
Newton iteration 3energy = 8.599947737377056<A u 3 , A u 3 >_{-1}^0.5 = 9.559087923180946e-13
Newton iteration 4energy = 8.59994773737706<A u 4 , A u 4 >_{-1}^0.5 = 1.1705547967954596e-14
Allen-Cahn equation¶
The Allen-Cahn equations describe the process of phase separation and is the (\(L^2\)) gradient-flow equation to the energy
i.e. the solution to the Allen-Cahn equation solves
The quantity \(u\) is an indicator for a phase where \(-1\) refers to one phase and \(1\) to another phase.
The equation has two driving forces:
\(u\) is pulled into one of the two minima (\(-1\) and \(1\)) of the nonlinear term \(u^2(1-u^2)\) (separation of the phases)
the diffusion term scaled with \(\varepsilon\) enforces a smooth transition between the two phases. \(\varepsilon\) determines the size of the transition layer
We use the “SymbolicEnergy” feature to formulate the energy minimization problem and combine it with an implicit Euler discretization:
which we can interpreted as a nonlinear minimization problem again with the energy
To solve the nonlinear equation at every time step we again rely on Newton’s method.
[11]:
from ngsolve import *
from ngsolve.webgui import Draw
from netgen.geom2d import *
periodic = SplineGeometry()
pnts = [ (0,0), (1,0), (1,1), (0,1) ]
pnums = [periodic.AppendPoint(*p) for p in pnts]
lright = periodic.Append ( ["line", pnums[0], pnums[1]],bc="periodic")
btop = periodic.Append ( ["line", pnums[1], pnums[2]], bc="periodic")
periodic.Append ( ["line", pnums[3], pnums[2]], leftdomain=0, rightdomain=1, copy=lright, bc="periodic")
periodic.Append ( ["line", pnums[0], pnums[3]], leftdomain=0, rightdomain=1, copy=btop, bc="periodic")
mesh = Mesh (periodic.GenerateMesh(maxh=0.2))
V = Periodic(H1(mesh, order=4, dirichlet=[]))
u = V.TrialFunction()
eps = 4e-3
dt = 1e-1
gfu = GridFunction(V)
gfuold = GridFunction(V)
a = BilinearForm (V, symmetric=False)
a += Variation( (eps/2*grad(u)*grad(u) + ((1-u*u)*(1-u*u))
+ 0.5/dt*(u-gfuold)*(u-gfuold)) * dx)
[12]:
from math import pi
gfu = GridFunction(V)
gfu.Set(sin(2*pi*x))
#gfu.Set(sin(1e8*x)) #<- essentially a random function
sceneu = Draw(gfu,mesh,"u")
SetVisualization (deformation=True)
t = 0
[13]:
for timestep in range(50):
gfuold.vec.data = gfu.vec
SolveNonlinearMinProblem(a,gfu)
sceneu.Redraw()
t += dt
print("t = ", t)
Newton iteration 0energy = 0.41450274940004017<A u 0 , A u 0 >_{-1}^0.5 = 0.28092276820769385
Newton iteration 1energy = 0.37690042628264986<A u 1 , A u 1 >_{-1}^0.5 = 0.019175684672928434
Newton iteration 2energy = 0.3767159640889083<A u 2 , A u 2 >_{-1}^0.5 = 9.62988096864071e-05
Newton iteration 3energy = 0.3767159594520977<A u 3 , A u 3 >_{-1}^0.5 = 2.5081413874453625e-09
Newton iteration 4energy = 0.37671595945209774<A u 4 , A u 4 >_{-1}^0.5 = 2.770950400879142e-16
t = 0.1
Newton iteration 0energy = 0.3438887218899856<A u 0 , A u 0 >_{-1}^0.5 = 0.2359984304769602
Newton iteration 1energy = 0.3171274464604802<A u 1 , A u 1 >_{-1}^0.5 = 0.013451013644986742
Newton iteration 2energy = 0.3170367744533889<A u 2 , A u 2 >_{-1}^0.5 = 4.663240800351902e-05
Newton iteration 3energy = 0.31703677336608915<A u 3 , A u 3 >_{-1}^0.5 = 5.769081036770765e-10
Newton iteration 4energy = 0.3170367733660891<A u 4 , A u 4 >_{-1}^0.5 = 3.104600909251941e-16
t = 0.2
Newton iteration 0energy = 0.2955287970166734<A u 0 , A u 0 >_{-1}^0.5 = 0.18333961760859702
Newton iteration 1energy = 0.27922061920053365<A u 1 , A u 1 >_{-1}^0.5 = 0.008020159823637686
Newton iteration 2energy = 0.2791884145175679<A u 2 , A u 2 >_{-1}^0.5 = 1.6280453338856004e-05
Newton iteration 3energy = 0.27918841438504094<A u 3 , A u 3 >_{-1}^0.5 = 6.88277206865018e-11
Newton iteration 4energy = 0.2791884143850408<A u 4 , A u 4 >_{-1}^0.5 = 3.5918508178786496e-16
t = 0.30000000000000004
Newton iteration 0energy = 0.2670098660513399<A u 0 , A u 0 >_{-1}^0.5 = 0.13329903037709695
Newton iteration 1energy = 0.25831307616871746<A u 1 , A u 1 >_{-1}^0.5 = 0.0041875315462804544
Newton iteration 2energy = 0.2583043023901654<A u 2 , A u 2 >_{-1}^0.5 = 4.3728797510974884e-06
Newton iteration 3energy = 0.2583043023806044<A u 3 , A u 3 >_{-1}^0.5 = 4.8743476603423805e-12
Newton iteration 4energy = 0.2583043023806044<A u 4 , A u 4 >_{-1}^0.5 = 3.5485559099999397e-16
t = 0.4
Newton iteration 0energy = 0.25217569665415823<A u 0 , A u 0 >_{-1}^0.5 = 0.09212757625004177
Newton iteration 1energy = 0.24799278266903632<A u 1 , A u 1 >_{-1}^0.5 = 0.0019803055518447786
Newton iteration 2energy = 0.2479908212283336<A u 2 , A u 2 >_{-1}^0.5 = 9.675293371219298e-07
Newton iteration 3energy = 0.24799082122786548<A u 3 , A u 3 >_{-1}^0.5 = 2.351718624444368e-13
Newton iteration 4energy = 0.2479908212278656<A u 4 , A u 4 >_{-1}^0.5 = 3.5285019118579734e-16
t = 0.5
Newton iteration 0energy = 0.24516469919769227<A u 0 , A u 0 >_{-1}^0.5 = 0.06142246901372681
Newton iteration 1energy = 0.24329614316799697<A u 1 , A u 1 >_{-1}^0.5 = 0.0008742001822322159
Newton iteration 2energy = 0.243295761000651<A u 2 , A u 2 >_{-1}^0.5 = 1.8736246218623535e-07
Newton iteration 3energy = 0.24329576100063338<A u 3 , A u 3 >_{-1}^0.5 = 8.837199141043262e-15
t = 0.6
Newton iteration 0energy = 0.24206890764107003<A u 0 , A u 0 >_{-1}^0.5 = 0.03998278353294713
Newton iteration 1energy = 0.24127447024481935<A u 1 , A u 1 >_{-1}^0.5 = 0.00036914563244039837
Newton iteration 2energy = 0.24127440210648102<A u 2 , A u 2 >_{-1}^0.5 = 3.3396140007954435e-08
Newton iteration 3energy = 0.24127440210648043<A u 3 , A u 3 >_{-1}^0.5 = 5.392904101207391e-16
t = 0.7
Newton iteration 0energy = 0.24076206680029597<A u 0 , A u 0 >_{-1}^0.5 = 0.02565432378296499
Newton iteration 1energy = 0.24043427961385436<A u 1 , A u 1 >_{-1}^0.5 = 0.0001521836948922547
Newton iteration 2energy = 0.2404342680336267<A u 2 , A u 2 >_{-1}^0.5 = 5.749334331966722e-09
Newton iteration 3energy = 0.24043426803362666<A u 3 , A u 3 >_{-1}^0.5 = 4.0723660057673715e-16
t = 0.7999999999999999
Newton iteration 0energy = 0.2402247958434406<A u 0 , A u 0 >_{-1}^0.5 = 0.016360129469374974
Newton iteration 1energy = 0.24009130447406016<A u 1 , A u 1 >_{-1}^0.5 = 6.260945027184524e-05
Newton iteration 2energy = 0.24009130251406763<A u 2 , A u 2 >_{-1}^0.5 = 1.0310386702794883e-09
Newton iteration 3energy = 0.2400913025140676<A u 3 , A u 3 >_{-1}^0.5 = 4.430990996815971e-16
t = 0.8999999999999999
Newton iteration 0energy = 0.2400060001527204<A u 0 , A u 0 >_{-1}^0.5 = 0.010467378997427187
Newton iteration 1energy = 0.23995130728175787<A u 1 , A u 1 >_{-1}^0.5 = 2.660330565795448e-05
Newton iteration 2energy = 0.23995130692788802<A u 2 , A u 2 >_{-1}^0.5 = 2.2781443109275827e-10
Newton iteration 3energy = 0.23995130692788808<A u 3 , A u 3 >_{-1}^0.5 = 4.520167645921635e-16
t = 0.9999999999999999
Newton iteration 0energy = 0.23991591345508823<A u 0 , A u 0 >_{-1}^0.5 = 0.006815543354962078
Newton iteration 1energy = 0.2398927141233959<A u 1 , A u 1 >_{-1}^0.5 = 1.2418172737585205e-05
Newton iteration 2energy = 0.23989271404629017<A u 2 , A u 2 >_{-1}^0.5 = 7.456015681141339e-11
Newton iteration 3energy = 0.23989271404629015<A u 3 , A u 3 >_{-1}^0.5 = 4.857526180759073e-16
t = 1.0999999999999999
Newton iteration 0energy = 0.23987719120231832<A u 0 , A u 0 >_{-1}^0.5 = 0.0046219617602749
Newton iteration 1energy = 0.2398665191876579<A u 1 , A u 1 >_{-1}^0.5 = 6.8803322449782575e-06
Newton iteration 2energy = 0.2398665191639883<A u 2 , A u 2 >_{-1}^0.5 = 3.373660269756489e-11
Newton iteration 3energy = 0.23986651916398838<A u 3 , A u 3 >_{-1}^0.5 = 4.51866572779697e-16
t = 1.2
Newton iteration 0energy = 0.239858912438348<A u 0 , A u 0 >_{-1}^0.5 = 0.0033643229589345896
Newton iteration 1energy = 0.23985325717204478<A u 1 , A u 1 >_{-1}^0.5 = 4.626816464814933e-06
Newton iteration 2energy = 0.239853257161341<A u 2 , A u 2 >_{-1}^0.5 = 1.83404666236353e-11
Newton iteration 3energy = 0.23985325716134107<A u 3 , A u 3 >_{-1}^0.5 = 4.4167890039517904e-16
t = 1.3
Newton iteration 0energy = 0.23984885075665663<A u 0 , A u 0 >_{-1}^0.5 = 0.002682345350752739
Newton iteration 1energy = 0.23984525547226224<A u 1 , A u 1 >_{-1}^0.5 = 3.580510801938737e-06
Newton iteration 2energy = 0.23984525546585217<A u 2 , A u 2 >_{-1}^0.5 = 1.122826298267855e-11
Newton iteration 3energy = 0.23984525546585217<A u 3 , A u 3 >_{-1}^0.5 = 4.497655034487545e-16
t = 1.4000000000000001
Newton iteration 0energy = 0.23984219437981988<A u 0 , A u 0 >_{-1}^0.5 = 0.00232416801404013
Newton iteration 1energy = 0.23983949487484169<A u 1 , A u 1 >_{-1}^0.5 = 3.0009604397547507e-06
Newton iteration 2energy = 0.23983949487033884<A u 2 , A u 2 >_{-1}^0.5 = 7.511495133264662e-12
Newton iteration 3energy = 0.23983949487033895<A u 3 , A u 3 >_{-1}^0.5 = 4.457271102231051e-16
t = 1.5000000000000002
Newton iteration 0energy = 0.23983704669748698<A u 0 , A u 0 >_{-1}^0.5 = 0.0021291987319734737
Newton iteration 1energy = 0.23983478088560456<A u 1 , A u 1 >_{-1}^0.5 = 2.6257686686933636e-06
Newton iteration 2energy = 0.2398347808821573<A u 2 , A u 2 >_{-1}^0.5 = 5.384331218074664e-12
Newton iteration 3energy = 0.23983478088215732<A u 3 , A u 3 >_{-1}^0.5 = 4.0108515124668936e-16
t = 1.6000000000000003
Newton iteration 0energy = 0.23983265244268792<A u 0 , A u 0 >_{-1}^0.5 = 0.0020100557693737047
Newton iteration 1energy = 0.23983063294882798<A u 1 , A u 1 >_{-1}^0.5 = 2.3525389446384635e-06
Newton iteration 2energy = 0.2398306329460608<A u 2 , A u 2 >_{-1}^0.5 = 4.068146969940559e-12
Newton iteration 3energy = 0.23983063294606083<A u 3 , A u 3 >_{-1}^0.5 = 4.3910814781746883e-16
t = 1.7000000000000004
Newton iteration 0energy = 0.2398287030787631<A u 0 , A u 0 >_{-1}^0.5 = 0.0019252122100653665
Newton iteration 1energy = 0.239826850357478<A u 1 , A u 1 >_{-1}^0.5 = 2.1365289236943262e-06
Newton iteration 2energy = 0.23982685035519563<A u 2 , A u 2 >_{-1}^0.5 = 3.1940413812410494e-12
Newton iteration 3energy = 0.2398268503551957<A u 3 , A u 3 >_{-1}^0.5 = 4.3239790916168463e-16
t = 1.8000000000000005
Newton iteration 0energy = 0.23982506567647988<A u 0 , A u 0 >_{-1}^0.5 = 0.0018564195832818957
Newton iteration 1energy = 0.2398233429163234<A u 1 , A u 1 >_{-1}^0.5 = 1.9563579521165098e-06
Newton iteration 2energy = 0.2398233429144098<A u 2 , A u 2 >_{-1}^0.5 = 2.576532197084369e-12
Newton iteration 3energy = 0.23982334291440977<A u 3 , A u 3 >_{-1}^0.5 = 4.168337545674308e-16
t = 1.9000000000000006
Newton iteration 0energy = 0.23982167713524788<A u 0 , A u 0 >_{-1}^0.5 = 0.0017958971457824545
Newton iteration 1energy = 0.23982006481970106<A u 1 , A u 1 >_{-1}^0.5 = 1.8009639637079065e-06
Newton iteration 2energy = 0.23982006481807935<A u 2 , A u 2 >_{-1}^0.5 = 2.1180629067376886e-12
Newton iteration 3energy = 0.23982006481807938<A u 3 , A u 3 >_{-1}^0.5 = 4.275446995367114e-16
t = 2.0000000000000004
Newton iteration 0energy = 0.23981850280918926<A u 0 , A u 0 >_{-1}^0.5 = 0.001740310776358378
Newton iteration 1energy = 0.23981698871896923<A u 1 , A u 1 >_{-1}^0.5 = 1.6641243579421696e-06
Newton iteration 2energy = 0.23981698871758456<A u 2 , A u 2 >_{-1}^0.5 = 1.7645509925176325e-12
Newton iteration 3energy = 0.2398169887175845<A u 3 , A u 3 >_{-1}^0.5 = 4.1963762805438165e-16
t = 2.1000000000000005
Newton iteration 0energy = 0.23981552021572586<A u 0 , A u 0 >_{-1}^0.5 = 0.0016881769354288318
Newton iteration 1energy = 0.2398140954528447<A u 1 , A u 1 >_{-1}^0.5 = 1.5420178269083415e-06
Newton iteration 2energy = 0.23981409545165577<A u 2 , A u 2 >_{-1}^0.5 = 1.4844233174577358e-12
Newton iteration 3energy = 0.23981409545165577<A u 3 , A u 3 >_{-1}^0.5 = 4.02205045000741e-16
t = 2.2000000000000006
Newton iteration 0energy = 0.23981271253222786<A u 0 , A u 0 >_{-1}^0.5 = 0.0016387829756173893
Newton iteration 1energy = 0.23981136990222032<A u 1 , A u 1 >_{-1}^0.5 = 1.4320930678395655e-06
Newton iteration 2energy = 0.2398113699011948<A u 2 , A u 2 >_{-1}^0.5 = 1.2579829091911714e-12
Newton iteration 3energy = 0.2398113699011948<A u 3 , A u 3 >_{-1}^0.5 = 4.212159800438489e-16
t = 2.3000000000000007
Newton iteration 0energy = 0.2398100659309837<A u 0 , A u 0 >_{-1}^0.5 = 0.0015917433542050894
Newton iteration 1energy = 0.23980879925623955<A u 1 , A u 1 >_{-1}^0.5 = 1.3325202176466422e-06
Newton iteration 2energy = 0.2398087992553517<A u 2 , A u 2 >_{-1}^0.5 = 1.072191835063917e-12
Newton iteration 3energy = 0.23980879925535173<A u 3 , A u 3 >_{-1}^0.5 = 3.9147779396855535e-16
t = 2.400000000000001
Newton iteration 0energy = 0.23980756843352935<A u 0 , A u 0 >_{-1}^0.5 = 0.0015468169239539241
Newton iteration 1energy = 0.2398063722398347<A u 1 , A u 1 >_{-1}^0.5 = 1.2419105209608674e-06
Newton iteration 2energy = 0.23980637223906348<A u 2 , A u 2 >_{-1}^0.5 = 9.181606100885629e-13
Newton iteration 3energy = 0.2398063722390635<A u 3 , A u 3 >_{-1}^0.5 = 4.204249177876161e-16
t = 2.500000000000001
Newton iteration 0energy = 0.23980520937673644<A u 0 , A u 0 >_{-1}^0.5 = 0.0015038307895702187
Newton iteration 1energy = 0.23980407873345475<A u 1 , A u 1 >_{-1}^0.5 = 1.1591642352896874e-06
Newton iteration 2energy = 0.23980407873278287<A u 2 , A u 2 >_{-1}^0.5 = 7.894063470258062e-13
Newton iteration 3energy = 0.23980407873278284<A u 3 , A u 3 >_{-1}^0.5 = 4.294231133646188e-16
t = 2.600000000000001
Newton iteration 0energy = 0.23980297913275267<A u 0 , A u 0 >_{-1}^0.5 = 0.001462647788622576
Newton iteration 1energy = 0.2398019095592319<A u 1 , A u 1 >_{-1}^0.5 = 1.0833827515316492e-06
Newton iteration 2energy = 0.23980190955864508<A u 2 , A u 2 >_{-1}^0.5 = 6.810990802114164e-13
Newton iteration 3energy = 0.23980190955864508<A u 3 , A u 3 >_{-1}^0.5 = 4.2753009248048324e-16
t = 2.700000000000001
Newton iteration 0energy = 0.2398008689398244<A u 0 , A u 0 >_{-1}^0.5 = 0.0014231520130885233
Newton iteration 1energy = 0.23979985634253928<A u 1 , A u 1 >_{-1}^0.5 = 1.0138146157404198e-06
Newton iteration 2energy = 0.23979985634202533<A u 2 , A u 2 >_{-1}^0.5 = 5.894808712628097e-13
Newton iteration 3energy = 0.23979985634202533<A u 3 , A u 3 >_{-1}^0.5 = 4.1422756115981907e-16
t = 2.800000000000001
Newton iteration 0energy = 0.23979887078562834<A u 0 , A u 0 >_{-1}^0.5 = 0.0013852419317702752
Newton iteration 1energy = 0.23979791141117418<A u 1 , A u 1 >_{-1}^0.5 = 9.498204696464258e-07
Newton iteration 2energy = 0.239797911410723<A u 2 , A u 2 >_{-1}^0.5 = 5.116112791307342e-13
Newton iteration 3energy = 0.2397979114107231<A u 3 , A u 3 >_{-1}^0.5 = 4.076450029822525e-16
t = 2.9000000000000012
Newton iteration 0energy = 0.23979697731840338<A u 0 , A u 0 >_{-1}^0.5 = 0.0013488268130407179
Newton iteration 1energy = 0.23979606771576892<A u 1 , A u 1 >_{-1}^0.5 = 8.908491345635657e-07
Newton iteration 2energy = 0.23979606771537218<A u 2 , A u 2 >_{-1}^0.5 = 4.452475244786126e-13
Newton iteration 3energy = 0.2397960677153721<A u 3 , A u 3 >_{-1}^0.5 = 4.3922489477725524e-16
t = 3.0000000000000013
Newton iteration 0energy = 0.23979518177481676<A u 0 , A u 0 >_{-1}^0.5 = 0.0013138246473699483
Newton iteration 1energy = 0.23979431876380208<A u 1 , A u 1 >_{-1}^0.5 = 8.36420596492343e-07
Newton iteration 2energy = 0.23979431876345225<A u 2 , A u 2 >_{-1}^0.5 = 3.884509019712542e-13
Newton iteration 3energy = 0.23979431876345225<A u 3 , A u 3 >_{-1}^0.5 = 4.301690284769913e-16
t = 3.1000000000000014
Newton iteration 0energy = 0.23979347791918174<A u 0 , A u 0 >_{-1}^0.5 = 0.0012801607964436092
Newton iteration 1energy = 0.23979265856330648<A u 1 , A u 1 >_{-1}^0.5 = 7.86113458671679e-07
Newton iteration 2energy = 0.23979265856299747<A u 2 , A u 2 >_{-1}^0.5 = 3.3969874372684423e-13
Newton iteration 3energy = 0.23979265856299747<A u 3 , A u 3 >_{-1}^0.5 = 4.3004324600663537e-16
t = 3.2000000000000015
Newton iteration 0energy = 0.2397918599911152<A u 0 , A u 0 >_{-1}^0.5 = 0.0012477670242682008
Newton iteration 1energy = 0.23979108157404128<A u 1 , A u 1 >_{-1}^0.5 = 7.395554015632387e-07
Newton iteration 2energy = 0.23979108157376783<A u 2 , A u 2 >_{-1}^0.5 = 2.9777915336040986e-13
Newton iteration 3energy = 0.23979108157376777<A u 3 , A u 3 >_{-1}^0.5 = 3.9547542266396893e-16
t = 3.3000000000000016
Newton iteration 0energy = 0.23979032265987657<A u 0 , A u 0 >_{-1}^0.5 = 0.0012165807486120865
Newton iteration 1energy = 0.23978958266470105<A u 1 , A u 1 >_{-1}^0.5 = 6.964157409186844e-07
Newton iteration 2energy = 0.23978958266445857<A u 2 , A u 2 >_{-1}^0.5 = 2.6157855623946123e-13
Newton iteration 3energy = 0.23978958266445852<A u 3 , A u 3 >_{-1}^0.5 = 4.283654302417877e-16
t = 3.4000000000000017
Newton iteration 0energy = 0.23978886098419994<A u 0 , A u 0 >_{-1}^0.5 = 0.0011865444318763026
Newton iteration 1energy = 0.23978815707515655<A u 1 , A u 1 >_{-1}^0.5 = 6.56399492291637e-07
Newton iteration 2energy = 0.23978815707494122<A u 2 , A u 2 >_{-1}^0.5 = 2.302948265576988e-13
Newton iteration 3energy = 0.2397881570749413<A u 3 , A u 3 >_{-1}^0.5 = 4.086979269954084e-16
t = 3.5000000000000018
Newton iteration 0energy = 0.23978747037675902<A u 0 , A u 0 >_{-1}^0.5 = 0.0011576050677765749
Newton iteration 1energy = 0.23978680038297534<A u 1 , A u 1 >_{-1}^0.5 = 6.19242549160231e-07
Newton iteration 2energy = 0.23978680038278374<A u 2 , A u 2 >_{-1}^0.5 = 2.0315531529176785e-13
Newton iteration 3energy = 0.23978680038278372<A u 3 , A u 3 >_{-1}^0.5 = 3.9756498266179526e-16
t = 3.600000000000002
Newton iteration 0energy = 0.23978614657259592<A u 0 , A u 0 >_{-1}^0.5 = 0.0011297137384427701
Newton iteration 1energy = 0.23978550847362343<A u 1 , A u 1 >_{-1}^0.5 = 5.84707704590533e-07
Newton iteration 2energy = 0.23978550847345248<A u 2 , A u 2 >_{-1}^0.5 = 1.7958897594683527e-13
Newton iteration 3energy = 0.23978550847345256<A u 3 , A u 3 >_{-1}^0.5 = 4.0775697916972084e-16
t = 3.700000000000002
Newton iteration 0energy = 0.23978488560097597<A u 0 , A u 0 >_{-1}^0.5 = 0.0011028252260448733
Newton iteration 1energy = 0.2397842775138649<A u 1 , A u 1 >_{-1}^0.5 = 5.525813242295787e-07
Newton iteration 2energy = 0.23978427751371223<A u 2 , A u 2 >_{-1}^0.5 = 1.5907479433745375e-13
Newton iteration 3energy = 0.23978427751371229<A u 3 , A u 3 >_{-1}^0.5 = 4.256689574317313e-16
t = 3.800000000000002
Newton iteration 0energy = 0.23978368376023024<A u 0 , A u 0 >_{-1}^0.5 = 0.001076897668351713
Newton iteration 1energy = 0.23978310392795166<A u 1 , A u 1 >_{-1}^0.5 = 5.226705343920618e-07
Newton iteration 2energy = 0.2397831039278152<A u 2 , A u 2 >_{-1}^0.5 = 1.4116224904179915e-13
Newton iteration 3energy = 0.2397831039278151<A u 3 , A u 3 >_{-1}^0.5 = 4.174221029815967e-16
t = 3.900000000000002
Newton iteration 0energy = 0.23978253759521045<A u 0 , A u 0 >_{-1}^0.5 = 0.0010518922507697856
Newton iteration 1energy = 0.2397819843762649<A u 1 , A u 1 >_{-1}^0.5 = 4.948008225696191e-07
Newton iteration 2energy = 0.23978198437614234<A u 2 , A u 2 >_{-1}^0.5 = 1.2547261891036262e-13
Newton iteration 3energy = 0.2397819843761424<A u 3 , A u 3 >_{-1}^0.5 = 4.0416552040613763e-16
t = 4.000000000000002
Newton iteration 0energy = 0.23978144387704142<A u 0 , A u 0 >_{-1}^0.5 = 0.0010277729293769811
Newton iteration 1energy = 0.2397809157361111<A u 1 , A u 1 >_{-1}^0.5 = 4.6881397441626697e-07
Newton iteration 2energy = 0.23978091573600113<A u 2 , A u 2 >_{-1}^0.5 = 1.1181144187446951e-13
Newton iteration 3energy = 0.23978091573600113<A u 3 , A u 3 >_{-1}^0.5 = 4.016687422136611e-16
t = 4.100000000000001
Newton iteration 0energy = 0.23978039958490083<A u 0 , A u 0 >_{-1}^0.5 = 0.0010045061807557245
Newton iteration 1energy = 0.23977989508442546<A u 1 , A u 1 >_{-1}^0.5 = 4.44566287255703e-07
Newton iteration 2energy = 0.23977989508432665<A u 2 , A u 2 >_{-1}^0.5 = 9.980130671726263e-14
t = 4.200000000000001
Newton iteration 0energy = 0.2397794018895898<A u 0 , A u 0 >_{-1}^0.5 = 0.0009820607753089098
Newton iteration 1energy = 0.23977891968215984<A u 1 , A u 1 >_{-1}^0.5 = 4.219270158055787e-07
Newton iteration 2energy = 0.23977891968207077<A u 2 , A u 2 >_{-1}^0.5 = 8.925950644743311e-14
t = 4.300000000000001
Newton iteration 0energy = 0.23977844813869198<A u 0 , A u 0 >_{-1}^0.5 = 0.0009604075713616538
Newton iteration 1energy = 0.23977798696016697<A u 1 , A u 1 >_{-1}^0.5 = 4.007770120387171e-07
Newton iteration 2energy = 0.23977798696008668<A u 2 , A u 2 >_{-1}^0.5 = 7.994196152771886e-14
t = 4.4
Newton iteration 0energy = 0.23977753584314124<A u 0 , A u 0 >_{-1}^0.5 = 0.0009395193278036805
Newton iteration 1energy = 0.23977709450641457<A u 1 , A u 1 >_{-1}^0.5 = 3.8100753085926176e-07
Newton iteration 2energy = 0.239777094506342<A u 2 , A u 2 >_{-1}^0.5 = 7.179512773894963e-14
t = 4.5
Newton iteration 0energy = 0.239776662665046<A u 0 , A u 0 >_{-1}^0.5 = 0.0009193705333654081
Newton iteration 1energy = 0.23977624005438256<A u 1 , A u 1 >_{-1}^0.5 = 3.625191772482667e-07
Newton iteration 2energy = 0.23977624005431677<A u 2 , A u 2 >_{-1}^0.5 = 6.453622746009833e-14
t = 4.6
Newton iteration 0energy = 0.23977582640662712<A u 0 , A u 0 >_{-1}^0.5 = 0.0008999372508832096
Newton iteration 1energy = 0.2397754214725149<A u 1 , A u 1 >_{-1}^0.5 = 3.4522097539002697e-07
Newton iteration 2energy = 0.23977542147245537<A u 2 , A u 2 >_{-1}^0.5 = 5.818393855479234e-14
t = 4.699999999999999
Newton iteration 0energy = 0.23977502500015624<A u 0 , A u 0 >_{-1}^0.5 = 0.0008811969751174315
Newton iteration 1energy = 0.239774636754615<A u 1 , A u 1 >_{-1}^0.5 = 3.29029543283108e-07
Newton iteration 2energy = 0.23977463675456087<A u 2 , A u 2 >_{-1}^0.5 = 5.252888457043041e-14
t = 4.799999999999999
Newton iteration 0energy = 0.23977425649878278<A u 0 , A u 0 >_{-1}^0.5 = 0.0008631285028569205
Newton iteration 1energy = 0.2397738840110826<A u 1 , A u 1 >_{-1}^0.5 = 3.138683589703107e-07
Newton iteration 2energy = 0.23977388401103322<A u 2 , A u 2 >_{-1}^0.5 = 4.751561654199766e-14
t = 4.899999999999999
Newton iteration 0energy = 0.23977351906815902<A u 0 , A u 0 >_{-1}^0.5 = 0.0008457118141865206
Newton iteration 1energy = 0.23977316146090577<A u 1 , A u 1 >_{-1}^0.5 = 2.9966710699954903e-07
Newton iteration 2energy = 0.23977316146086092<A u 2 , A u 2 >_{-1}^0.5 = 4.3025917851734007e-14
t = 4.999999999999998
Minimal energy extension (postscript in unit-2.1.3 )¶
[14]:
from netgen.geom2d import unit_square
mesh = Mesh(unit_square.GenerateMesh(maxh=0.1))
fes_ho = Discontinuous(H1(mesh, order=10))
fes_lo = H1(mesh, order=1, dirichlet=".*")
fes_lam = Discontinuous(H1(mesh, order=1))
fes = fes_ho*fes_lo*fes_lam
uho, ulo, lam = fes.TrialFunction()
[15]:
a = BilinearForm(fes)
a += Variation(0.5 * grad(uho)*grad(uho)*dx
- 1*uho*dx
+ (uho-ulo)*lam*dx(element_vb=BBND))
gfu = GridFunction(fes)
solvers.Newton(a=a, u=gfu)
Draw(gfu.components[0])
Newton iteration 0
err = 0.39346141669994983
Newton iteration 1
err = 1.8488788182878563e-15
[15]:
BaseWebGuiScene
The minimization problem is solved by the solution of the PDE:
under the constraint
[ ]: