# Error: Unable to successfully call PETSc function 'MatSetValuesLocal'. \*\*\* Reason: PETSc error code is: 63 (Argument out of range)

**URL:** <https://fenicsproject.discourse.group/t/error-unable-to-successfully-call-petsc-function-matsetvalueslocal-reason-petsc-error-code-is-63-argument-out-of-range/14692>\
**Category:** General\
**Created:** [May 16, 2024, 10:54am UTC](https://fenicsproject.discourse.group/t/error-unable-to-successfully-call-petsc-function-matsetvalueslocal-reason-petsc-error-code-is-63-argument-out-of-range/14692 "2024-05-16T10:54:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kumar\_Pushpak](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/kumar_pushpak/32/6976_2.png) [@Kumar\_Pushpak](https://fenicsproject.discourse.group/u/Kumar_Pushpak)\
**Post date:** [May 16, 2024, 10:54am UTC](https://fenicsproject.discourse.group/t/error-unable-to-successfully-call-petsc-function-matsetvalueslocal-reason-petsc-error-code-is-63-argument-out-of-range/14692/1 "2024-05-16T10:54:30Z")

</div>

I am trying to solve Transient Heat equation on a 2D rectangle. I am a new user of fenics so the solution to my issue might be trivial. I am attaching my code below.  
"  
from dolfin import \*  
from mshr import \*  
import matplotlib.pyplot as plt  
import numpy as np  
#matplotlib notebook

L, H = 5, 0.3  
#cV = Constant(910e-6)\*rho  
k = Constant(237e-6)  
dt = Constant(0.)  
mesh = RectangleMesh(Point(0., 0.), Point(L, H), 100, 10, “crossed”)

def lateral\_sides(x, on\_boundary):  
return (near(x[0], 0) or near(x[0], L)) and on\_boundary  
def bottom(x, on\_boundary):  
return near(x[1], 0) and on\_boundary  
def top(x, on\_boundary):  
return near(x[1], H) and on\_boundary

VT = FunctionSpace(mesh, “CG”, 1)  
dT = Function(VT)  
T\_ = TestFunction(VT)  
T\_old = Function(VT)  
Delta\_T = Function(VT, name=“Temperature increase”)  
#aT = ((dT-T\_old)/dt_T\_ - dot(grad(dT), grad(T\_)))dx  
res = ((dT-T\_old)/dtT\_ - dot(k_grad(dT), grad(T\_)))_dx  
#(cV_(dTheta-Theta\_old)/dt_Theta\_ + dot(k_grad(dTheta), grad(Theta\_)))\*dx #- Constant(50)\*Theta\_\*dx

#LT = Constant(50)\*T\__dx  
 #form = ((dT-T\_old)/dt_T\_ - dot(grad(dT), grad(T\_)))\*dx

bcT = [DirichletBC(VT, Constant(500.), bottom),  
DirichletBC(VT, Constant(0.), top),  
DirichletBC(VT, Constant(0.), lateral\_sides)]  
#solve(aT == LT, Delta\_T, bcT)

Nincr = 10  
t = np.logspace(1, 4, Nincr+1)  
Nx = 100  
x = np.linspace(H, L, Nx)  
T\_res = np.zeros((Nx, Nincr+1))  
T = Function(VT)  
for (i, dti) in enumerate(np.diff(t)):  
print("Increment`nln " + str(i+1))  
dt.assign(dti)  
#solve(aT == LT, T, bcT)  
solve(res == 0, T, bcT)  
#solve(lhs(form) == rhs(form), T, bcT)  
T\_old.assign(T)  
T\_res[:, i+1] = [U(xi, 0.)[2] for xi in x]  
print(T\_res)  
"  
I am getting the following error whilst the first iteration:  
Error: Unable to successfully call PETSc function ‘MatSetValuesLocal’.  
\*\*\* Reason: PETSc error code is: 63 (Argument out of range).
