Nonlinear equation with space dependent term

Hello everyone, this is my first post, I am fairly new to fenics and I’m having an issue with the implementation of a non linear heat transport equation. I have this source term, dependent on the temperature and x y and z. How can I write this convolute term in my weak formulation to solve it? Thank you very much.Screenshot_28

Hi, what is \alpha(T) and R(T) ? T is a given function ? For the spatially dependent part you can use something like

a = ...
w = ...
l = ...
A = ...
R = ...
S = Expression("A*(1-R)*a*exp(a*x[2])*
                exp(-2*pow(x[0]/w,2)*exp(-2*pow(x[1]/l,2)", 
                A=A, R=R, a=a, w=w, l=l, degree=2)

Thanks for the response.
Alpha and R are functions depending on T, that is the main variable, it’s the temperature.

Could you give the implicit or explicit relationship for these variables, such that one can further help you.
One can use


x=SpatialCoordinate(mesh)
S = A*(1-R)*a*exp(a*x[2])*exp(-2*(x[0]/w)**2)*exp(-2*(x[1]/l)**2)

where you define your other variables prior in the script.

Thank you, these are the relationships for the variables, lam is a constant.
k = 1523.7*(T**(-1.226))
alpha = 4pik/lam
R = (7.188+k**2)/(21.912+k**2)

Thank you for the space dependent part, now I’m facing another issue, how can I use a numpy method as “exp” with a function?

Exp has its own dolfin function, which is loaded whenever you do either from dolfin import exp or from dolfin import *
MWE:

from dolfin import *
mesh = UnitSquareMesh(10,10)                                            
V = FunctionSpace(mesh, "CG", 1)                                        
x = SpatialCoordinate(mesh)                                             
u = Function(V)                                                         
a = exp(Constant(2)*u)                                                  
assemble(a*dx)