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.023333256891798472
Newton iteration 2energy = 8.74986115049552<A u 2 , A u 2 >_{-1}^0.5 = 0.00010232159281106644
Newton iteration 3energy = 8.749861145260668<A u 3 , A u 3 >_{-1}^0.5 = 5.078987224012008e-08
Newton iteration 4energy = 8.749861145260665<A u 4 , A u 4 >_{-1}^0.5 = 2.660591778816807e-13
Newton iteration 5energy = 8.749861145260663<A u 5 , A u 5 >_{-1}^0.5 = 8.426522104140955e-16
loadstep 1
Newton iteration 0energy = 8.74958389295778<A u 0 , A u 0 >_{-1}^0.5 = 0.016596117905399742
Newton iteration 1energy = 8.749710099853518<A u 1 , A u 1 >_{-1}^0.5 = 0.02295846531196424
Newton iteration 2energy = 8.74944730043396<A u 2 , A u 2 >_{-1}^0.5 = 0.00014213684546165322
Newton iteration 3energy = 8.749447290438315<A u 3 , A u 3 >_{-1}^0.5 = 2.3248036060126863e-06
Newton iteration 4energy = 8.749447290435603<A u 4 , A u 4 >_{-1}^0.5 = 6.324688723112501e-10
Newton iteration 5energy = 8.74944729043561<A u 5 , A u 5 >_{-1}^0.5 = 1.5520997642201327e-15
loadstep 2
Newton iteration 0energy = 8.748898149085237<A u 0 , A u 0 >_{-1}^0.5 = 0.016356974930046602
Newton iteration 1energy = 8.749005270899884<A u 1 , A u 1 >_{-1}^0.5 = 0.021893030422316412
Newton iteration 2energy = 8.74876626125895<A u 2 , A u 2 >_{-1}^0.5 = 0.00020820420955274568
Newton iteration 3energy = 8.748766239907328<A u 3 , A u 3 >_{-1}^0.5 = 4.890175581200758e-06
Newton iteration 4energy = 8.748766239895366<A u 4 , A u 4 >_{-1}^0.5 = 2.6645298462080275e-09
Newton iteration 5energy = 8.74876623989537<A u 5 , A u 5 >_{-1}^0.5 = 2.3981863873217434e-15
loadstep 3
Newton iteration 0energy = 8.747955304179662<A u 0 , A u 0 >_{-1}^0.5 = 0.015982097567623515
Newton iteration 1energy = 8.748035438675364<A u 1 , A u 1 >_{-1}^0.5 = 0.02029265962104067
Newton iteration 2energy = 8.74783004804966<A u 2 , A u 2 >_{-1}^0.5 = 0.00026379360268680916
Newton iteration 3energy = 8.747830013747695<A u 3 , A u 3 >_{-1}^0.5 = 7.2468461669091075e-06
Newton iteration 4energy = 8.74783001372143<A u 4 , A u 4 >_{-1}^0.5 = 4.743749155033251e-09
Newton iteration 5energy = 8.747830013721432<A u 5 , A u 5 >_{-1}^0.5 = 3.3666942738643443e-15
loadstep 4
Newton iteration 0energy = 8.746771024519141<A u 0 , A u 0 >_{-1}^0.5 = 0.015501109791218748
Newton iteration 1energy = 8.74682187533878<A u 1 , A u 1 >_{-1}^0.5 = 0.018360230816922642
Newton iteration 2energy = 8.74665369248594<A u 2 , A u 2 >_{-1}^0.5 = 0.00029905973521468184
Newton iteration 3energy = 8.746653648294211<A u 3 , A u 3 >_{-1}^0.5 = 8.720266784080817e-06
Newton iteration 4energy = 8.746653648256187<A u 4 , A u 4 >_{-1}^0.5 = 5.243157063711433e-09
Newton iteration 5energy = 8.746653648256178<A u 5 , A u 5 >_{-1}^0.5 = 4.538435622060422e-15
loadstep 5
Newton iteration 0energy = 8.745362725155784<A u 0 , A u 0 >_{-1}^0.5 = 0.014946280903324794
Newton iteration 1energy = 8.745386481617508<A u 1 , A u 1 >_{-1}^0.5 = 0.01629331058397641
Newton iteration 2energy = 8.745253992323274<A u 2 , A u 2 >_{-1}^0.5 = 0.00031320636583578344
Newton iteration 3energy = 8.745253943722172<A u 3 , A u 3 >_{-1}^0.5 = 9.043133594045577e-06
Newton iteration 4energy = 8.745253943681277<A u 4 , A u 4 >_{-1}^0.5 = 4.217411640449136e-09
Newton iteration 5energy = 8.745253943681275<A u 5 , A u 5 >_{-1}^0.5 = 4.304948352095118e-15
loadstep 6
Newton iteration 0energy = 8.74374838218437<A u 0 , A u 0 >_{-1}^0.5 = 0.01434775782852572
Newton iteration 1energy = 8.743749777088043<A u 1 , A u 1 >_{-1}^0.5 = 0.014249383991944023
Newton iteration 2energy = 8.743648409960425<A u 2 , A u 2 >_{-1}^0.5 = 0.00030935224514727546
Newton iteration 3energy = 8.74364836243308<A u 3 , A u 3 >_{-1}^0.5 = 8.385269208622498e-06
Newton iteration 4energy = 8.743648362397929<A u 4 , A u 4 >_{-1}^0.5 = 2.6943217408271055e-09
Newton iteration 5energy = 8.743648362397927<A u 5 , A u 5 >_{-1}^0.5 = 4.671066892918988e-15
loadstep 7
Newton iteration 0energy = 8.741945650331859<A u 0 , A u 0 >_{-1}^0.5 = 0.013730754995718351
Newton iteration 1energy = 8.741930193837286<A u 1 , A u 1 >_{-1}^0.5 = 0.012333805584163944
Newton iteration 2energy = 8.741854223708538<A u 2 , A u 2 >_{-1}^0.5 = 0.000292140011323971
Newton iteration 3energy = 8.741854181238816<A u 3 , A u 3 >_{-1}^0.5 = 7.1304843823761555e-06
Newton iteration 4energy = 8.741854181213386<A u 4 , A u 4 >_{-1}^0.5 = 1.443676324390437e-09
Newton iteration 5energy = 8.741854181213387<A u 5 , A u 5 >_{-1}^0.5 = 4.04283264416106e-15
loadstep 8
Newton iteration 0energy = 8.739971288694946<A u 0 , A u 0 >_{-1}^0.5 = 0.013114590303568577
Newton iteration 1energy = 8.739944123846232<A u 1 , A u 1 >_{-1}^0.5 = 0.010604193396438567
Newton iteration 2energy = 8.739887948591905<A u 2 , A u 2 >_{-1}^0.5 = 0.0002663295272890766
Newton iteration 3energy = 8.739887913241445<A u 3 , A u 3 >_{-1}^0.5 = 5.663180361368218e-06
Newton iteration 4energy = 8.73988791322541<A u 4 , A u 4 >_{-1}^0.5 = 6.721140060338551e-10
Newton iteration 5energy = 8.73988791322541<A u 5 , A u 5 >_{-1}^0.5 = 5.101592176013858e-15
loadstep 9
Newton iteration 0energy = 8.737840839887605<A u 0 , A u 0 >_{-1}^0.5 = 0.012512967634852405
Newton iteration 1energy = 8.737806211240574<A u 1 , A u 1 >_{-1}^0.5 = 0.009082216012715725
Newton iteration 2energy = 8.737764991099095<A u 2 , A u 2 >_{-1}^0.5 = 0.00023605086032088917
Newton iteration 3energy = 8.737764963298767<A u 3 , A u 3 >_{-1}^0.5 = 4.2588566241965745e-06
Newton iteration 4energy = 8.737764963289697<A u 4 , A u 4 >_{-1}^0.5 = 2.779241792984806e-10
Newton iteration 5energy = 8.737764963289692<A u 5 , A u 5 >_{-1}^0.5 = 5.353807715414755e-15
loadstep 10
Newton iteration 0energy = 8.735568492367701<A u 0 , A u 0 >_{-1}^0.5 = 0.011934876423801583
Newton iteration 1energy = 8.735529630935627<A u 1 , A u 1 >_{-1}^0.5 = 0.007766170839235342
Newton iteration 2energy = 8.735499482232091<A u 2 , A u 2 >_{-1}^0.5 = 0.00020450737376983825
Newton iteration 3energy = 8.735499461348875<A u 3 , A u 3 >_{-1}^0.5 = 3.0651565882486283e-06
Newton iteration 4energy = 8.73549946134418<A u 4 , A u 4 >_{-1}^0.5 = 1.0318435375399616e-10
Newton iteration 5energy = 8.735499461344187<A u 5 , A u 5 >_{-1}^0.5 = 6.939222989218416e-15
loadstep 11
Newton iteration 0energy = 8.733167062934966<A u 0 , A u 0 >_{-1}^0.5 = 0.011385659634359103
Newton iteration 1energy = 8.733126286742358<A u 1 , A u 1 >_{-1}^0.5 = 0.006641200507715863
Newton iteration 2energy = 8.73310423373717<A u 2 , A u 2 >_{-1}^0.5 = 0.00017394935932964746
Newton iteration 3energy = 8.73310421862043<A u 3 , A u 3 >_{-1}^0.5 = 2.1295353784157576e-06
Newton iteration 4energy = 8.733104218618157<A u 4 , A u 4 >_{-1}^0.5 = 3.432821684048829e-11
Newton iteration 5energy = 8.733104218618156<A u 5 , A u 5 >_{-1}^0.5 = 6.6053212930142355e-15
loadstep 12
Newton iteration 0energy = 8.730648051299827<A u 0 , A u 0 >_{-1}^0.5 = 0.010868004311014336
Newton iteration 1energy = 8.730606944098009<A u 1 , A u 1 >_{-1}^0.5 = 0.005686407124586052
Newton iteration 2energy = 8.730590772260674<A u 2 , A u 2 >_{-1}^0.5 = 0.000145787974329764
Newton iteration 3energy = 8.730590761638542<A u 3 , A u 3 >_{-1}^0.5 = 1.438507618898889e-06
Newton iteration 4energy = 8.730590761637513<A u 4 , A u 4 >_{-1}^0.5 = 9.987970008197302e-12
Newton iteration 5energy = 8.730590761637515<A u 5 , A u 5 >_{-1}^0.5 = 6.7867922752453645e-15
loadstep 13
Newton iteration 0energy = 8.728021733357684<A u 0 , A u 0 >_{-1}^0.5 = 0.010382755786041208
Newton iteration 1energy = 8.727981327547454<A u 1 , A u 1 >_{-1}^0.5 = 0.004879274848128358
Newton iteration 2energy = 8.727969418133107<A u 2 , A u 2 >_{-1}^0.5 = 0.00012076675565393962
Newton iteration 3energy = 8.727969410842498<A u 3 , A u 3 >_{-1}^0.5 = 9.505936904464194e-07
Newton iteration 4energy = 8.727969410842045<A u 4 , A u 4 >_{-1}^0.5 = 2.3272127173245064e-12
Newton iteration 5energy = 8.727969410842046<A u 5 , A u 5 >_{-1}^0.5 = 7.149530188431884e-15
loadstep 14
Newton iteration 0energy = 8.725297271534668<A u 0 , A u 0 >_{-1}^0.5 = 0.009929540146487182
Newton iteration 1energy = 8.725258204221733<A u 1 , A u 1 >_{-1}^0.5 = 0.004198138558006176
Newton iteration 2energy = 8.72524938609619<A u 2 , A u 2 >_{-1}^0.5 = 9.914194784642498e-05
Newton iteration 3energy = 8.725249381182058<A u 3 , A u 3 >_{-1}^0.5 = 6.177654278381545e-07
Newton iteration 4energy = 8.72524938118187<A u 4 , A u 4 >_{-1}^0.5 = 2.711716359736078e-13
Newton iteration 5energy = 8.725249381181873<A u 5 , A u 5 >_{-1}^0.5 = 7.036732056962797e-15
loadstep 15
Newton iteration 0energy = 8.722482828966841<A u 0 , A u 0 >_{-1}^0.5 = 0.009507217507448339
Newton iteration 1energy = 8.722445463379158<A u 1 , A u 1 >_{-1}^0.5 = 0.0036233812629864453
Newton iteration 2energy = 8.722438893461836<A u 2 , A u 2 >_{-1}^0.5 = 8.084475895316411e-05
Newton iteration 3energy = 8.722438890193898<A u 3 , A u 3 >_{-1}^0.5 = 3.966168556411748e-07
Newton iteration 4energy = 8.72243889019382<A u 4 , A u 4 >_{-1}^0.5 = 1.533420522505671e-13
Newton iteration 5energy = 8.722438890193823<A u 5 , A u 5 >_{-1}^0.5 = 7.386259382693848e-15
loadstep 16
Newton iteration 0energy = 8.719585679907679<A u 0 , A u 0 >_{-1}^0.5 = 0.009114200423683239
Newton iteration 1energy = 8.71955019483647<A u 1 , A u 1 >_{-1}^0.5 = 0.003137871066388539
Newton iteration 2energy = 8.71954526698477<A u 2 , A u 2 >_{-1}^0.5 = 6.56129082787406e-05
Newton iteration 3energy = 8.719545264832135<A u 3 , A u 3 >_{-1}^0.5 = 2.5253728556283254e-07
Newton iteration 4energy = 8.719545264832098<A u 4 , A u 4 >_{-1}^0.5 = 1.5072650596116781e-13
Newton iteration 5energy = 8.7195452648321<A u 5 , A u 5 >_{-1}^0.5 = 7.602033686226241e-15
loadstep 17
Newton iteration 0energy = 8.716612312372295<A u 0 , A u 0 >_{-1}^0.5 = 0.008748671018670029
Newton iteration 1energy = 8.716578765757584<A u 1 , A u 1 >_{-1}^0.5 = 0.0027269789363858965
Newton iteration 2energy = 8.716575043606785<A u 2 , A u 2 >_{-1}^0.5 = 5.3088307720234416e-05
Newton iteration 3energy = 8.7165750421975<A u 3 , A u 3 >_{-1}^0.5 = 1.5999780592387015e-07
Newton iteration 4energy = 8.716575042197478<A u 4 , A u 4 >_{-1}^0.5 = 9.231608532906341e-14
loadstep 18
Newton iteration 0energy = 8.71356852125604<A u 0 , A u 0 >_{-1}^0.5 = 0.00840872493274433
Newton iteration 1energy = 8.713536894279306<A u 1 , A u 1 >_{-1}^0.5 = 0.002378388543340845
Newton iteration 2energy = 8.713534062707833<A u 2 , A u 2 >_{-1}^0.5 = 4.288363853579171e-05
Newton iteration 3energy = 8.71353406178825<A u 3 , A u 3 >_{-1}^0.5 = 1.011409122434024e-07
Newton iteration 4energy = 8.713534061788247<A u 4 , A u 4 >_{-1}^0.5 = 4.87027114702587e-14
loadstep 19
Newton iteration 0energy = 8.710459491487786<A u 0 , A u 0 >_{-1}^0.5 = 0.008092463808711758
Newton iteration 1energy = 8.710429718569646<A u 1 , A u 1 >_{-1}^0.5 = 0.0020818210591133984
Newton iteration 2energy = 8.710427549016906<A u 2 , A u 2 >_{-1}^0.5 = 3.462358568402642e-05
Newton iteration 3energy = 8.710427548417456<A u 3 , A u 3 >_{-1}^0.5 = 6.393535767376952e-08
Newton iteration 4energy = 8.710427548417451<A u 4 , A u 4 >_{-1}^0.5 = 2.4483507954611064e-14
loadstep 20
Newton iteration 0energy = 8.70728987152168<A u 0 , A u 0 >_{-1}^0.5 = 0.0077980523333226704
Newton iteration 1energy = 8.707261860397317<A u 1 , A u 1 >_{-1}^0.5 = 0.0018287420131056097
Newton iteration 2energy = 8.707260186220783<A u 2 , A u 2 >_{-1}^0.5 = 2.7967298759405255e-05
Newton iteration 3energy = 8.707260185829663<A u 3 , A u 3 >_{-1}^0.5 = 4.048982179653789e-08
Newton iteration 4energy = 8.707260185829663<A u 4 , A u 4 >_{-1}^0.5 = 1.4057381311612987e-14
loadstep 21
Newton iteration 0energy = 8.70406383785694<A u 0 , A u 0 >_{-1}^0.5 = 0.0075237512984224295
Newton iteration 1energy = 8.704037482792225<A u 1 , A u 1 >_{-1}^0.5 = 0.0016120839035623045
Newton iteration 2energy = 8.704036181791693<A u 2 , A u 2 >_{-1}^0.5 = 2.261808346036807e-05
Newton iteration 3energy = 8.704036181535885<A u 3 , A u 3 >_{-1}^0.5 = 2.572573184915226e-08
Newton iteration 4energy = 8.704036181535882<A u 4 , A u 4 >_{-1}^0.5 = 1.0624338163146723e-14
loadstep 22
Newton iteration 0energy = 8.70078515144342<A u 0 , A u 0 >_{-1}^0.5 = 0.007267934720808067
Newton iteration 1energy = 8.700760341771408<A u 1 , A u 1 >_{-1}^0.5 = 0.0014259991983513916
Newton iteration 2energy = 8.700759323787844<A u 2 , A u 2 >_{-1}^0.5 = 1.8325128467416225e-05
Newton iteration 3energy = 8.700759323619925<A u 3 , A u 3 >_{-1}^0.5 = 1.6417044657312312e-08
Newton iteration 4energy = 8.70075932361992<A u 4 , A u 4 >_{-1}^0.5 = 9.201530713354385e-15
loadstep 23
Newton iteration 0energy = 8.697457206873455<A u 0 , A u 0 >_{-1}^0.5 = 0.00702909657257236
Newton iteration 1energy = 8.697433832371452<A u 1 , A u 1 >_{-1}^0.5 = 0.0012656480113987828
Newton iteration 2energy = 8.69743303046547<A u 2 , A u 2 >_{-1}^0.5 = 1.4880754837123108e-05
Newton iteration 3energy = 8.697433030354746<A u 3 , A u 3 >_{-1}^0.5 = 1.0531743740413506e-08
Newton iteration 4energy = 8.697433030354746<A u 4 , A u 4 >_{-1}^0.5 = 9.325326135180215e-15
loadstep 24
Newton iteration 0energy = 8.694083075231845<A u 0 , A u 0 >_{-1}^0.5 = 0.006805850912313123
Newton iteration 1energy = 8.694061029385738<A u 1 , A u 1 >_{-1}^0.5 = 0.0011270194997519576
Newton iteration 2energy = 8.694060393539427<A u 2 , A u 2 >_{-1}^0.5 = 1.2115520218285045e-05
Newton iteration 3energy = 8.694060393466039<A u 3 , A u 3 >_{-1}^0.5 = 6.796117025839151e-09
Newton iteration 4energy = 8.694060393466035<A u 4 , A u 4 >_{-1}^0.5 = 9.068576534833638e-15
loadstep 25
Newton iteration 0energy = 8.690665541411896<A u 0 , A u 0 >_{-1}^0.5 = 0.006596927974879926
Newton iteration 1energy = 8.69064472328174<A u 1 , A u 1 >_{-1}^0.5 = 0.0010067836587979312
Newton iteration 2energy = 8.690644215881647<A u 2 , A u 2 >_{-1}^0.5 = 9.892619993494837e-06
Newton iteration 3energy = 8.690644215832712<A u 3 , A u 3 >_{-1}^0.5 = 4.413429314679904e-09
Newton iteration 4energy = 8.690644215832714<A u 4 , A u 4 >_{-1}^0.5 = 9.778772918089897e-15
loadstep 26
Newton iteration 0energy = 8.687207136625545<A u 0 , A u 0 >_{-1}^0.5 = 0.006401167928270521
Newton iteration 1energy = 8.687187451796238<A u 1 , A u 1 >_{-1}^0.5 = 0.0009021693868917711
Newton iteration 2energy = 8.687187044377275<A u 2 , A u 2 >_{-1}^0.5 = 8.102402299811085e-06
Newton iteration 3energy = 8.687187044344453<A u 3 , A u 3 >_{-1}^0.5 = 2.8852458980348257e-09
Newton iteration 4energy = 8.68718704434445<A u 4 , A u 4 >_{-1}^0.5 = 8.886053057777458e-15
loadstep 27
Newton iteration 0energy = 8.68371016675213<A u 0 , A u 0 >_{-1}^0.5 = 0.006217513423094516
Newton iteration 1energy = 8.683691527695355<A u 1 , A u 1 >_{-1}^0.5 = 0.0008108646767203564
Newton iteration 2energy = 8.683691198580748<A u 2 , A u 2 >_{-1}^0.5 = 6.657405275634138e-06
Newton iteration 3energy = 8.683691198558591<A u 3 , A u 3 >_{-1}^0.5 = 1.8991869917874413e-09
Newton iteration 4energy = 8.68369119855859<A u 4 , A u 4 >_{-1}^0.5 = 9.33150345818032e-15
loadstep 28
Newton iteration 0energy = 8.680176737089983<A u 0 , A u 0 >_{-1}^0.5 = 0.006045001663943573
Newton iteration 1energy = 8.680159063155786<A u 1 , A u 1 >_{-1}^0.5 = 0.0007309351468242922
Newton iteration 2energy = 8.680158795736729<A u 2 , A u 2 >_{-1}^0.5 = 5.488076199275711e-06
Newton iteration 3energy = 8.68015879572167<A u 3 , A u 3 >_{-1}^0.5 = 1.2588616227609485e-09
Newton iteration 4energy = 8.680158795721663<A u 4 , A u 4 >_{-1}^0.5 = 9.001134676153649e-15
loadstep 29
Newton iteration 0energy = 8.676608774000314<A u 0 , A u 0 >_{-1}^0.5 = 0.005882756463901591
Newton iteration 1energy = 8.676591991183995<A u 1 , A u 1 >_{-1}^0.5 = 0.0006607576199664254
Newton iteration 2energy = 8.676591772658249<A u 2 , A u 2 >_{-1}^0.5 = 4.539191566203341e-06
Newton iteration 3energy = 8.67659177264795<A u 3 , A u 3 >_{-1}^0.5 = 8.402927252166068e-10
Newton iteration 4energy = 8.67659177264795<A u 4 , A u 4 >_{-1}^0.5 = 9.804781007122496e-15
loadstep 30
Newton iteration 0energy = 8.673008043866378<A u 0 , A u 0 >_{-1}^0.5 = 0.005729980564003032
Newton iteration 1energy = 8.672992084446872<A u 1 , A u 1 >_{-1}^0.5 = 0.0005989659685142517
Newton iteration 2energy = 8.672991904888457<A u 2 , A u 2 >_{-1}^0.5 = 3.76692558714429e-06
Newton iteration 3energy = 8.672991904881362<A u 3 , A u 3 >_{-1}^0.5 = 5.648276913429671e-10
Newton iteration 4energy = 8.672991904881364<A u 4 , A u 4 >_{-1}^0.5 = 8.856314683710285e-15
loadstep 31
Newton iteration 0energy = 8.669376169731839<A u 0 , A u 0 >_{-1}^0.5 = 0.005585948379564026
Newton iteration 1energy = 8.669360971844453<A u 1 , A u 1 >_{-1}^0.5 = 0.0005444069229864554
Newton iteration 2energy = 8.669360823513486<A u 2 , A u 2 >_{-1}^0.5 = 3.1364842018525257e-06
Newton iteration 3energy = 8.669360823508566<A u 3 , A u 3 >_{-1}^0.5 = 3.823056496565365e-10
Newton iteration 4energy = 8.669360823508566<A u 4 , A u 4 >_{-1}^0.5 = 9.167105917157476e-15
loadstep 32
Newton iteration 0energy = 8.665714645931029<A u 0 , A u 0 >_{-1}^0.5 = 0.005449999256850864
Newton iteration 1energy = 8.665700153115054<A u 1 , A u 1 >_{-1}^0.5 = 0.0004961039573416707
Newton iteration 2energy = 8.665700029942759<A u 2 , A u 2 >_{-1}^0.5 = 2.6202145911736405e-06
Newton iteration 3energy = 8.66570002993933<A u 3 , A u 3 >_{-1}^0.5 = 2.6053927556008274e-10
Newton iteration 4energy = 8.665700029939332<A u 4 , A u 4 >_{-1}^0.5 = 9.356668988874247e-15
loadstep 33
Newton iteration 0energy = 8.662024850979378<A u 0 , A u 0 >_{-1}^0.5 = 0.005321531272677356
Newton iteration 1energy = 8.662011011726086<A u 1 , A u 1 >_{-1}^0.5 = 0.00045322771796919923
Newton iteration 2energy = 8.662010908928279<A u 2 , A u 2 >_{-1}^0.5 = 2.1961049304068934e-06
Newton iteration 3energy = 8.662010908925868<A u 3 , A u 3 >_{-1}^0.5 = 1.787546814518984e-10
Newton iteration 4energy = 8.662010908925867<A u 4 , A u 4 >_{-1}^0.5 = 1.0391992896076542e-14
loadstep 34
Newton iteration 0energy = 8.658308058954264<A u 0 , A u 0 >_{-1}^0.5 = 0.005199995577454912
Newton iteration 1energy = 8.658294826270653<A u 1 , A u 1 >_{-1}^0.5 = 0.0004150717562679263
Newton iteration 2energy = 8.658294740056048<A u 2 , A u 2 >_{-1}^0.5 = 1.8465991940605346e-06
Newton iteration 3energy = 8.658294740054345<A u 3 , A u 3 >_{-1}^0.5 = 1.234537032652579e-10
Newton iteration 4energy = 8.658294740054341<A u 4 , A u 4 >_{-1}^0.5 = 1.0407193435903823e-14
loadstep 35
Newton iteration 0energy = 8.65456544956376<A u 0 , A u 0 >_{-1}^0.5 = 0.0050848912624765945
Newton iteration 1energy = 8.65455278056102<A u 1 , A u 1 >_{-1}^0.5 = 0.00038103256412839803
Newton iteration 2energy = 8.654552707909858<A u 2 , A u 2 >_{-1}^0.5 = 1.5576634314058568e-06
Newton iteration 3energy = 8.654552707908648<A u 3 , A u 3 >_{-1}^0.5 = 8.581282279802305e-11
Newton iteration 4energy = 8.654552707908644<A u 4 , A u 4 >_{-1}^0.5 = 1.0206839945383989e-14
loadstep 36
Newton iteration 0energy = 8.650798117073078<A u 0 , A u 0 >_{-1}^0.5 = 0.0049757607212704445
Newton iteration 1energy = 8.650785972584172<A u 1 , A u 1 >_{-1}^0.5 = 0.0003505931062016911
Newton iteration 2energy = 8.65078591107931<A u 2 , A u 2 >_{-1}^0.5 = 1.318051220837467e-06
Newton iteration 3energy = 8.650785911078438<A u 3 , A u 3 >_{-1}^0.5 = 6.002693325013193e-11
Newton iteration 4energy = 8.65078591107844<A u 4 , A u 4 >_{-1}^0.5 = 1.0236703803488628e-14
loadstep 37
Newton iteration 0energy = 8.647007078234466<A u 0 , A u 0 >_{-1}^0.5 = 0.004872185468874145
Newton iteration 1energy = 8.646995422462584<A u 1 , A u 1 >_{-1}^0.5 = 0.00032330919910225544
Newton iteration 2energy = 8.64699537015994<A u 2 , A u 2 >_{-1}^0.5 = 1.1187260507761323e-06
Newton iteration 3energy = 8.646995370159313<A u 3 , A u 3 >_{-1}^0.5 = 4.224850408830822e-11
Newton iteration 4energy = 8.646995370159317<A u 4 , A u 4 >_{-1}^0.5 = 1.0621572313021625e-14
loadstep 38
Newton iteration 0energy = 8.643193279346297<A u 0 , A u 0 >_{-1}^0.5 = 0.004773782380896337
Newton iteration 1energy = 8.643182079544074<A u 1 , A u 1 >_{-1}^0.5 = 0.000298798213829677
Newton iteration 2energy = 8.643182034872755<A u 2 , A u 2 >_{-1}^0.5 = 9.52406944143284e-07
Newton iteration 3energy = 8.643182034872298<A u 3 , A u 3 >_{-1}^0.5 = 2.9912537588936945e-11
Newton iteration 4energy = 8.643182034872297<A u 4 , A u 4 >_{-1}^0.5 = 1.1152485359155634e-14
loadstep 39
Newton iteration 0energy = 8.639357602549433<A u 0 , A u 0 >_{-1}^0.5 = 0.004680200314254123
Newton iteration 1energy = 8.639346828727849<A u 1 , A u 1 >_{-1}^0.5 = 0.00027672967851042897
Newton iteration 2energy = 8.639346790412747<A u 2 , A u 2 >_{-1}^0.5 = 8.132106830748512e-07
Newton iteration 3energy = 8.639346790412409<A u 3 , A u 3 >_{-1}^0.5 = 2.1303962012760666e-11
Newton iteration 4energy = 8.639346790412409<A u 4 , A u 4 >_{-1}^0.5 = 1.0687749718927477e-14
loadstep 40
Newton iteration 0energy = 8.635500871454596<A u 0 , A u 0 >_{-1}^0.5 = 0.004591117072856486
Newton iteration 1energy = 8.635490496119774<A u 1 , A u 1 >_{-1}^0.5 = 0.000256817439502861
Newton iteration 2energy = 8.635490463121288<A u 2 , A u 2 >_{-1}^0.5 = 6.96369696588762e-07
Newton iteration 3energy = 8.63549046312104<A u 3 , A u 3 >_{-1}^0.5 = 1.5258038041722634e-11
Newton iteration 4energy = 8.635490463121046<A u 4 , A u 4 >_{-1}^0.5 = 9.797542966775124e-15
loadstep 41
Newton iteration 0energy = 8.631623856181335<A u 0 , A u 0 >_{-1}^0.5 = 0.0045062366837518835
Newton iteration 1energy = 8.631613854097235<A u 1 , A u 1 >_{-1}^0.5 = 0.00023881310384761905
Newton iteration 2energy = 8.631613825564186<A u 2 , A u 2 >_{-1}^0.5 = 5.980092038845475e-07
Newton iteration 3energy = 8.631613825564012<A u 3 , A u 3 >_{-1}^0.5 = 1.0989732739715857e-11
Newton iteration 4energy = 8.63161382556401<A u 4 , A u 4 >_{-1}^0.5 = 1.0566674948699998e-14
loadstep 42
Newton iteration 0energy = 8.627727277879043<A u 0 , A u 0 >_{-1}^0.5 = 0.004425286951922338
Newton iteration 1energy = 8.627717625853819<A u 1 , A u 1 >_{-1}^0.5 = 0.000222500538176723
Newton iteration 2energy = 8.627717601086363<A u 2 , A u 2 >_{-1}^0.5 = 5.149708083929144e-07
Newton iteration 3energy = 8.62771760108623<A u 3 , A u 3 >_{-1}^0.5 = 7.95688143526686e-12
Newton iteration 4energy = 8.627717601086221<A u 4 , A u 4 >_{-1}^0.5 = 9.694944409532752e-15
loadstep 43
Newton iteration 0energy = 8.623811812790498<A u 0 , A u 0 >_{-1}^0.5 = 0.004348017264588367
Newton iteration 1energy = 8.623802489484435<A u 1 , A u 1 >_{-1}^0.5 = 0.00020769124099746003
Newton iteration 2energy = 8.623802467904822<A u 2 , A u 2 >_{-1}^0.5 = 4.4467253792206394e-07
Newton iteration 3energy = 8.623802467904726<A u 3 , A u 3 >_{-1}^0.5 = 5.7930767451170954e-12
Newton iteration 4energy = 8.623802467904728<A u 4 , A u 4 >_{-1}^0.5 = 1.0055384685996374e-14
loadstep 44
Newton iteration 0energy = 8.61987809591114<A u 0 , A u 0 >_{-1}^0.5 = 0.004274196618550027
Newton iteration 1energy = 8.619869081664056<A u 1 , A u 1 >_{-1}^0.5 = 0.00019422043896745035
Newton iteration 2energy = 8.619869062793466<A u 2 , A u 2 >_{-1}^0.5 = 3.8499753039589156e-07
Newton iteration 3energy = 8.61986906279339<A u 3 , A u 3 >_{-1}^0.5 = 4.238577717818233e-12
Newton iteration 4energy = 8.619869062793391<A u 4 , A u 4 >_{-1}^0.5 = 1.0379398970338644e-14
loadstep 45
Newton iteration 0energy = 8.615926724290006<A u 0 , A u 0 >_{-1}^0.5 = 0.004203611846893203
Newton iteration 1energy = 8.615918000966204<A u 1 , A u 1 >_{-1}^0.5 = 0.00018194378505230092
Newton iteration 2energy = 8.61591798440625<A u 2 , A u 2 >_{-1}^0.5 = 3.342052816452393e-07
Newton iteration 3energy = 8.6159179844062<A u 3 , A u 3 >_{-1}^0.5 = 3.11766000387222e-12
Newton iteration 4energy = 8.615917984406195<A u 4 , A u 4 >_{-1}^0.5 = 1.095546033113022e-14
loadstep 46
Newton iteration 0energy = 8.611958260012726<A u 0 , A u 0 >_{-1}^0.5 = 0.004136066023665786
Newton iteration 1energy = 8.611949810861685<A u 1 , A u 1 >_{-1}^0.5 = 0.00017073455836671554
Newton iteration 2energy = 8.611949796279683<A u 2 , A u 2 >_{-1}^0.5 = 2.908606830419023e-07
Newton iteration 3energy = 8.611949796279646<A u 3 , A u 3 >_{-1}^0.5 = 2.303416199605961e-12
Newton iteration 4energy = 8.611949796279646<A u 4 , A u 4 >_{-1}^0.5 = 1.0361751774798041e-14
loadstep 47
Newton iteration 0energy = 8.60797323290172<A u 0 , A u 0 >_{-1}^0.5 = 0.004071377027468514
Newton iteration 1energy = 8.607965042432856<A u 1 , A u 1 >_{-1}^0.5 = 0.00016048128328699233
Newton iteration 2energy = 8.60796502954998<A u 2 , A u 2 >_{-1}^0.5 = 2.5377714578235357e-07
Newton iteration 3energy = 8.607965029549941<A u 3 , A u 3 >_{-1}^0.5 = 1.7098736054220895e-12
Newton iteration 4energy = 8.607965029549941<A u 4 , A u 4 >_{-1}^0.5 = 1.0047527251952996e-14
loadstep 48
Newton iteration 0energy = 8.60397214296444<A u 0 , A u 0 >_{-1}^0.5 = 0.004009376246981265
Newton iteration 1energy = 8.603964196834543<A u 1 , A u 1 >_{-1}^0.5 = 0.00015108569999672377
Newton iteration 2energy = 8.603964185416244<A u 2 , A u 2 >_{-1}^0.5 = 2.2197087632654756e-07
Newton iteration 3energy = 8.603964185416224<A u 3 , A u 3 >_{-1}^0.5 = 1.2767174516901622e-12
Newton iteration 4energy = 8.603964185416222<A u 4 , A u 4 >_{-1}^0.5 = 1.0331549186208653e-14
loadstep 49
Newton iteration 0energy = 8.599955462616865<A u 0 , A u 0 >_{-1}^0.5 = 0.003949907413232469
Newton iteration 1energy = 8.59994774752875<A u 1 , A u 1 >_{-1}^0.5 = 0.00014246103024151877
Newton iteration 2energy = 8.599947737377077<A u 2 , A u 2 >_{-1}^0.5 = 1.946240282764713e-07
Newton iteration 3energy = 8.599947737377056<A u 3 , A u 3 >_{-1}^0.5 = 9.55578078070243e-13
Newton iteration 4energy = 8.599947737377057<A u 4 , A u 4 >_{-1}^0.5 = 1.1402016803504034e-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
[ ]: