Hi @jarvin,
A few helpful (hopefully) points to consider: first, it’s recommended to post minimal working code examples: Read before posting: How do I get my question answered?. Running this code
gives
File "/home/connor/Documents/fenics/code.py", line 14
clsdform_T = alpha * dolfin.inner(S * **expterm**, v)*dolfin.dx
^
SyntaxError: invalid syntax
It’s easiest for people to assist if they don’t have to debug your code. It’s also recommended to post the full error message that you receive.
Second, don’t confuse the functions T and S with the function spaces on which they live. In your code, you have defined S
and T
as dolfin.FunctionSpace
s. I’m not an expert, but I wouldn’t expect UFL operations to be supported on function spaces. Instead, you should use the test and trial functions in your weak form.
Exponentiation (using the UFL operator dolfin.exp
) and division seem to work for me when I replace the FunctionSpace
s S
and T
with the trial and test functions v
, w
, phi
, and theta
defined on those function spaces:
import dolfin
alpha = 1
beta = 1
gamma_s = 1
# Create the Mesh
mesh = dolfin.IntervalMesh(10, 0, 1)
T = dolfin.FunctionSpace(mesh, 'CG', 2)
S = dolfin.FunctionSpace(mesh, 'CG', 2)
# FEM Discretization
v = dolfin.TestFunction(T)
phi = dolfin.TrialFunction(T)
w = dolfin.TestFunction(S)
theta = dolfin.TrialFunction(S)
clsdform_T = alpha * dolfin.inner(theta*dolfin.exp(-beta/phi), v)*dolfin.dx
clsdform_S = -gamma_s * dolfin.inner(phi*dolfin.exp(-beta/theta), w)*dolfin.dx
(Please note that I have not attempted to determine the correct weak form for this problem.)
A final note: since you are solving a nonlinear problem, you should use Function
s (not TrialFunction
s) in your weak form, as the nonlinear Poisson demo explains.