This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Nonlinear Material Law from Table

+2 votes

Hello,

I would like to use the NonlinearVariationalProblem with a nonlinear material which depends on the solution (e.g. in Maxwell equations the material gets saturated if the magnetic field is high enough). The material law is given as a chi(grad(u)) table and is interpolated between the given nodes (linear, spline, ...). I would like to do something like this:

a = chi(grad(u)) * inner(grad(u), grad(v)) * dx 

Is there a way to utilize the automatic differentiation feature and the nonlinear variational solver for this? or is it necessary to explicitly implement the newton method?

thanks
Florian

asked Jul 22, 2015 by florian_bruckner FEniCS Novice (380 points)

1 Answer

+1 vote
 
Best answer

To enjoy the differentiation and Newton method chi would need to be implemented using UFL. I suppose that a table, you mention, would result in piece-wise expression which can be implemented using UFL Conditional. (Differentiation of Conditional is correct assuming that the expression is continuous.)

But I warn you that a deeply-nested combination of Conditionals (implementing a long table) may not scale well with the size of the table.

Implementing the table using DOLFIN Expression (possibly C++ expression for performance), treating the term using fixed-point, may be useful and efficient.

EDIT: I can imagine, the latter approach could be improved by the derivative of chi dchi provided by the code providing chi.

u = Function(V)
chi, dchi = compute_material_data(u) # returns Expressions
v = TestFunction(V)
F = chi*inner(grad(u), grad(v))*dx - rhs
dF  = derivative(F, u) + dchi*inner(grad(u), grad(v))*dx # or using UFL replace
solve(F == 0, bcs=bcs, J=dF)

Note this can really work as a proper Newton method if Expressions chi and dchi have a reference to u and update their values dynamically within each Newton step.

answered Jul 27, 2015 by Jan Blechta FEniCS Expert (51,420 points)
edited Jul 29, 2015 by Jan Blechta

Added a comment how derivative of chi could be specified manually if available.

...