# How do I resolve issue with calling the PETSc function 'KSPSolve', with a PETSc error code of 76, indicating an error in an external library?

**URL:** <https://fenicsproject.discourse.group/t/how-do-i-resolve-issue-with-calling-the-petsc-function-kspsolve-with-a-petsc-error-code-of-76-indicating-an-error-in-an-external-library/14686>\
**Category:** General\
**Created:** [May 16, 2024, 4:57am UTC](https://fenicsproject.discourse.group/t/how-do-i-resolve-issue-with-calling-the-petsc-function-kspsolve-with-a-petsc-error-code-of-76-indicating-an-error-in-an-external-library/14686 "2024-05-16T04:57:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edwin\_Aigbokhan](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/edwin_aigbokhan/32/6867_2.png) [@Edwin\_Aigbokhan](https://fenicsproject.discourse.group/u/Edwin_Aigbokhan)\
**Post date:** [May 16, 2024, 4:57am UTC](https://fenicsproject.discourse.group/t/how-do-i-resolve-issue-with-calling-the-petsc-function-kspsolve-with-a-petsc-error-code-of-76-indicating-an-error-in-an-external-library/14686/1 "2024-05-16T04:57:57Z")

</div>

**1. Fenics/Dolfin version and Installation**  
I am running the code in google colab environment using DOLFIN version: 2019.2.0.dev0. I install Fenics via [Packages — FEM on Colab](https://fem-on-colab.github.io/packages.html).

**2. I encountered the error in this section of the code:**

```
# SOLUTION MECHANICAL VENTILATION ##########################
#for i, mult in enumerate(steps):
for i in np.arange(len(times)):
    # messages
    if dolfin.MPI.rank(dolfin.MPI.comm_world) == 0:
        print('Solving step '+str(i)+' ...')
    t = times[i]
    dtt = dts[i]
    presion = ps[i]
    dt.beta = dtt

    p_value.presiones=presion
    print('PRESSURE',presion,'TIME',t)

    # run fenics solver
    w0.assign(w)
    it, conv = solver.solve(NLproblem, w.vector())
    # Extract solution components
    u, p = w.split()
    u.rename("u", "displacement")
    p.rename("p", "pressure")

    if dolfin.MPI.rank(dolfin.MPI.comm_world) == 0:
        file_info.write('Step '+str(i)+ ' has converged in '+str(it)+' iterations \n')
        file_info.flush()

    # get volume, volume and flux
    Vi = dolfin.assemble(J*dx)
    Jacob.append(Vi/1000000)
    deltavol = dolfin.assemble(((J-J0)/dt)*dx)
    fluxes.append(deltavol*10**-6)
    presionestodas.append(presion)

```

**3. Here is the error Message:**  
RuntimeError Traceback (most recent call last)

in \<cell line: 8\>()  
222 # run fenics solver  
223 w0.assign(w)  
 → 224 it, conv = solver.solve(NLproblem, w.vector())  
225 # Extract solution components  
226 u, p = w.split()

/content/modelfunctions.py in solve(self, myproblem, x)  
347 # iterations  
348 if not self.dx.empty(): self.dx.zero()  
 → 349 self.krylov\_iterations += self.solver.solve(self.dx, self.b);  
350  
351 # Update solution

---

<div class="post-metadata">

**Author:** ![francesco-ballarin](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@francesco-ballarin](https://fenicsproject.discourse.group/u/francesco-ballarin)\
**Post date:** [May 16, 2024, 5:16am UTC](https://fenicsproject.discourse.group/t/how-do-i-resolve-issue-with-calling-the-petsc-function-kspsolve-with-a-petsc-error-code-of-76-indicating-an-error-in-an-external-library/14686/2 "2024-05-16T05:16:52Z")

</div>

That’s a good improvement over [Please i need assistance on how to resolve the PETScKrylovSolver's Error below](https://fenicsproject.discourse.group/t/please-i-need-assistance-on-how-to-resolve-the-petsckrylovsolvers-error-below/14559) but, sorry, that’s still not good enough.

We’ll need the whole code (e.g., to see how `NLproblem` is defined, and to possibly run the code ourselves). Please make it as minimal as possible (i.e., remove all parts which are not truly needed to get the error) otherwise it’ll be unlikely that anyone will spend their own free time to help you.

---

<div class="post-metadata">

**Author:** ![Edwin\_Aigbokhan](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/edwin_aigbokhan/32/6867_2.png) [@Edwin\_Aigbokhan](https://fenicsproject.discourse.group/u/Edwin_Aigbokhan)\
**Post date:** [May 16, 2024, 1:20pm UTC](https://fenicsproject.discourse.group/t/how-do-i-resolve-issue-with-calling-the-petsc-function-kspsolve-with-a-petsc-error-code-of-76-indicating-an-error-in-an-external-library/14686/3 "2024-05-16T13:20:41Z")

</div>

Good Morning Sir,

Thanks for your quick response to my case. I am actually understudying Lung poromechanics simulation in Fenics based on an existing code in Github site. Please find below the link to the full code:

[https://github.com/comp-medicine-uc/multiscale-lung-mechanics](https://github.com/comp-medicine-uc/multiscale-lung-mechanics)

Thanks

---

<div class="post-metadata">

**Author:** ![francesco-ballarin](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@francesco-ballarin](https://fenicsproject.discourse.group/u/francesco-ballarin)\
**Post date:** [May 16, 2024, 3:44pm UTC](https://fenicsproject.discourse.group/t/how-do-i-resolve-issue-with-calling-the-petsc-function-kspsolve-with-a-petsc-error-code-of-76-indicating-an-error-in-an-external-library/14686/4 "2024-05-16T15:44:15Z")

</div>

I can’t find any code in the repository, and looking at the git history it seems that the author has purposely deleted parts of the code.

It’s quite a heavy task to read an entire library, let alone if to get its bits and pieces one needs to process the git history. Due to that, I, and possibly other people in the community, won’t have the time to help. IMHO, your best option is to get in touch with the author of the repository.

---

<div class="post-metadata">

**Author:** ![Edwin\_Aigbokhan](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/edwin_aigbokhan/32/6867_2.png) [@Edwin\_Aigbokhan](https://fenicsproject.discourse.group/u/Edwin_Aigbokhan)\
**Post date:** [May 16, 2024, 3:59pm UTC](https://fenicsproject.discourse.group/t/how-do-i-resolve-issue-with-calling-the-petsc-function-kspsolve-with-a-petsc-error-code-of-76-indicating-an-error-in-an-external-library/14686/5 "2024-05-16T15:59:55Z")

</div>

Thanks for your quick response to my case. I am actually understudying Lung poromechanics simulation in Fenics based on an existing code in Github site. Please find below the link to the full code:

```
   https://github.com/comp-medicine-uc/multiscale-lung-mechanics

```

Thanks
