Nonlinear Problem - Darcy Flow
Dear all,
I'm using FEniCS to model a PDE that couples flow through a porous medium with solute transport. Here are several PDF's that explain the equations/boundary conditions, show the geometry, display the results, etc.
https:/
https:/
The second PDF describes how the problem is implemented in COMSOL, a commercial finite element program, and that's where I got the original idea. This one's the easier of the two to read through quickly.
I've tried implementing the problem using the NonlinearVariat
from dolfin import *
# PARAMETERS (SI units)
length = 300 # length of geometry
height = 150 # height of geometry
c_0 = 0.0 # initial concentration
c_br = 1.0 # brine concentration
theta = 0.1 # porosity
rho_b = 1400.0 # bulk density
rho_s = 1200.0 # brine density
rho_0 = 1000.0 # pristine water density
D_L = 3.56e-6 # molecular diffusion
kappa = 4.9346e-13 # permeability
beta = (rho_s-
g_const = 9.81 # gravitational acceleration
mu = .001 # dynamic viscosity
p_0 = 0.0 # reference pressure
# MESH
scale = 10
xnum = length/scale
ynum = height/scale
mesh = Rectangle(
n = FacetNormal(mesh)
# FUNCTION SPACE
# We will have two spaces, V1 and V2
# P1: Solute concentration (discretized linearly)
# P2: Pressure (discretized quadratically)
P1 = FunctionSpace(mesh, "Lagrange", 1)
P2 = FunctionSpace(mesh, "Lagrange", 2)
# Combine into mixed function space ME
ME = P1*P2
# q, d are the test functions for p and c (respectively)
du = TrialFunction(ME)
d,q = TestFunctions(ME)
u = Function(ME)
u_prev = Function(ME) # Solution from previous time-step
dc, dp = split(du)
c, p = split(u)
c_prev,p_prev = split(u_prev)
# VARIABLES (PART 1)
D = Expression(
rho = rho_0 + beta*c # density
rho_prev = rho_0 + beta*c_prev
v = -mu/kappa*
v_prev = -mu/kappa*
# initial pressure
p_init_e = Expression(
# BOUNDARY CONDITIONS
# Dirchlet conditions
def cbottom(x):
return x[1] < DOLFIN_EPS
cbrine = compile_
# We have a reference pressure p_0 in the upper left hand corner
# Enforce as a pointwise constraint
def corner(x):
return x[1]>height-
bcs = ([DirichletBC(
DirichletBC(
DirichletBC(
# INITIAL CONDITIONS
class InitialConditio
def __init__(self, c0, p0):
self.c0 = c0
self.p0 = p0
def eval(self, value, x):
value[0] = self.c0(x)
value[1] = self.p0(x)
def value_shape(self):
return (2,)
c_0 = Constant(c_0)
c_init = interpolate(c_0,P1)
p_init = interpolate(
u_init = InitialConditio
u.interpolate(
u_prev.
# TIME-STEPPING
# We'll use Crank-Nicholson
# Let gamma be the evolution parameter
gamma = 0.5
p_mid = (1.0-gamma)*p_prev + gamma*p
c_mid = (1.0-gamma)*c_prev + gamma*c
rho_mid = (1.0-gamma)
v_mid = (1.0-gamma)*v_prev + gamma*v
# WEAK FORMS
dt = Constant(0.0) # Initially we plot the stationary case
# For Darcy flow
F0 = rho*(c-c_prev)*d*dx - dt/theta*
# For solute transport
F1 = q*(rho/
F = F0 + F1
J = derivative(F,u,du)
# SOLVE!
# t = current time, T = end time
t = 0
T = 20*365*24*60*60
while (t<=0):
print "t =",t
problem = NonlinearVariat
solver = NonlinearVariat
prm = solver.parameters
#info(prm, True)
#print list_linear_
#print list_krylov_
prm['linear_
prm['precondit
prm['krylov_
prm['krylov_
prm['krylov_
prm['krylov_
set_log_
solver.solve()
end()
# Set dt to the Courant number
# dt = h/u
# dt = mesh.hmin(
t += dt
u_prev.assign(u)
#plot(p)
But when I try solving the problem, I get:
t = 0
Solving nonlinear variational problem.
Applying boundary conditions to linear system.
Applying boundary conditions to linear system.
Applying boundary conditions to linear system.
Assembling matrix over cells [=====> ] 15.1%
Assembling matrix over cells [======
Assembling matrix over cells [======
Assembling matrix over cells [======
Assembling matrix over cells [======
Applying boundary conditions to linear system.
Applying boundary conditions to linear system.
Applying boundary conditions to linear system.
Solving linear system of size 2387 x 2387 (PETSc Krylov solver).
PETSc Krylov solver starting to solve 2387 x 2387 system.
and from there it simply hangs. Do you have any suggestions as how I can determine what's wrong (i.e. get more output), and if there's anything else I'm missing. Thanks.
- Ben
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Benjamin Mayersohn for more information if necessary.