Hi everyone,
I’m trying to solve a 0D equation to use the result as the Neumann condition for a 1D equation. I get the following error code after the first iteration (iteration 0) of the solver:
Solving nonlinear variational problem.
Newton iteration 0: r (abs) = 2.026e+09 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
Traceback (most recent call last):
File “demo.py”, line 622, in
run(parameters)
File “demo.py”, line 366, in run
solver.solve()
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
*** fenics-support@googlegroups.com
*** Remember to include the error message listed below and, if possible,
*** include a minimal running example to reproduce the error.
*** -------------------------------------------------------------------------
*** Error: Unable to successfully call PETSc function ‘MatSetValuesLocal’.
*** Reason: PETSc error code is: 63 (Argument out of range).
*** Where: This error was encountered inside /build/dolfin-V0jMTP/dolfin->2018.1.0.post1/dolfin/la/PETScMatrix.cpp.
*** Process: 0
*** DOLFIN version: 2018.1.0
*** Git changeset: unknown
*** -------------------------------------------------------------------------
Here is the code (I left out the mesh, marking of the facets, declaration of the constants used in the FV, … to keep it simple):
p = 1
Ve = FiniteElement("CG", mesh.ufl_cell(),1)
V_ele = VectorElement("CG", mesh.ufl_cell(), 1, len(traps))
R_ele = FiniteElement("R", mesh.ufl_cell(), 0)
MS = FunctionSpace(mesh, MixedElement([Ve, R_ele, R_ele, Ve, Ve]))
#Solution and previous solution
U = Function(MS)
U_n = Function (MS)
dU = TrialFunction(MS)
testfunction_concentration, testfunction_P, testfunction_Cs, testfunction_t1, testfunction_t2 = TestFunction(MS)
#Initial pressure
e_p0 = Expression('Pmax', degree=1, Pmax=Pmax)
p0 = interpolate(e_p0, MS.sub(1).collapse())
assign(U_n.sub(1), p0)
#Splitting of U into concentration, pressure, surface concentration and trapped concentrations
u, P, Cs, u_t1, u_t2 = split(U)
u_n, P_n, Cs_n, u_tn1, u_tn2 = split(U_n)
n = FacetNormal(mesh)
F1 = 0
F1 += ((Cs - Cs_n)/dt)*testfunction_Cs*ds(1, domain=mesh) - nu_gas[0]*P*(1-Cs/n_s)**2*testfunction_Cs*ds(1, domain=mesh) \
+ 2*nu_des*Cs**2*testfunction_Cs*ds(1, domain=mesh) + nu_sb*Cs*testfunction_Cs*ds(1, domain=mesh) \
- nu_bs*(1-Cs/n_s)*u*testfunction_Cs*ds(1, domain=mesh)
F1 += l*(u - u_n)/dt*testfunction_concentration*ds(1, domain=mesh) - nu_sb*Cs*testfunction_concentration*ds(1, domain=mesh) \
+ nu_bs*(1-Cs/n_s)*u*testfunction_concentration*ds(1, domain=mesh)\
- D*assemble(dot(grad(u),n)*ds(1, domain=mesh))*(1-Cs/n_s)*testfunction_concentration*ds(1,domain=mesh)
F1 += ((P - P_n)/dt)*testfunction_P*ds(1, domain=mesh) - Ae*R*T/(Na*Vol1)*(2*nu_des*Cs**2 - \
nu_gas[0]*P*(1-Cs/n_s)**2)*testfunction_P*ds(1, domain=mesh)
while t < Time:
t += float(dt)
print("Current time", t," s")
J1 = derivative(F1, U, dU)
problem = NonlinearVariationalProblem(F1,U,bcs,J1)
solver = NonlinearVariationalSolver(problem)
solver.solve()
I’ve checked that i am using split(U)
and not U.split()
based on this previous question.
Could it be that I’m not using functions u_t1 and u_t2 in this first FV to solve (they are used in another formulation) ?