How to set the complex coefficient of the differential equation?
5 months ago by
- \nabla ( [ \sigma + j \omega \varepsilon ] \nabla V) = 0
I solve the real part of the equation:
- \nabla ( [ \sigma ] \nabla V) = 0
using the following code:
As I understand it, I can not just make the coefficient complex because in that case I get ComplexWarning during the simulation.
from fenics import * # Mesh mesh = UnitCubeMesh(5, 5, 5) V = FunctionSpace(mesh, 'P', 1) # Boundary conditions u_Left = Constant(1) def boundary_Left(x, on_boundary): tol = 1e-14 return on_boundary and near(x, 0, tol) bc_L = DirichletBC(V, u_Left, boundary_Left) u_Right = Constant(0) def boundary_Right(x, on_boundary): tol = 1e-14 return on_boundary and near(x, 1, tol) bc_R = DirichletBC(V, u_Right, boundary_Right) # Problem u = TrialFunction(V) v = TestFunction(V) f = Constant(0) coefficient = Constant(1) # Coefficient, which should be complex a = coefficient * dot(grad(u), grad(v)) * dx L = f * v * dx u = Function(V) # Solve solve(a == L, u, [bc_L, bc_R])
How can I specify a complex coefficient for a differential equation?
Community: FEniCS Project
Please login to add an answer/comment or follow this question.