Error in ploting

Dear sir’

I am not able to understand the following error.

Solving linear variational problem.
/usr/lib/python3/dist-packages/matplotlib/quiver.py:678: RuntimeWarning: Mean of empty slice.
  amean = a[~self.Umask].mean()
/home/gangadhar/.local/lib/python3.8/site-packages/numpy/core/_methods.py:188: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)

You need to produce a minimal code example. See Read before posting: How do I get my question answered? for guidelines

1 Like

sorry, sir,
my geo file is

// Gmsh project created on Tue Mar 16 21:31:50 2021
SetFactory("OpenCASCADE");
//+
Point(1) = {0, -0.013, 0, 0.0003};
//+
Point(2) = {0.000255, -0.013, 0, 0.0003};
//+
Point(3) = {0, -0.05, 0, 0.05};
//+
Point(4) = {0.05, -0.05, 0, 0.05};
//+
Point(5) = {0.05, 0.05, 0, 0.05};
//+
Point(6) = {0.0011, 0.05, 0, 0.0003};
//+
Point(7) = {0.00084, 0.05, 0, 0.0003};
//+
Point(8) = {0.000255, 0.05, 0, 0.0003};
//+
Point(9) = {0, 0.05, 0, 0.0003};
//+
Point(10) = {0.000225, 0, 0, 0.0003};
//+
Point(11) = {0.00084, 0, 0, 0.0003};
//+
Point(12) = {0.0011, 0, 0, 0.0003};
//+
Line(1) = {5, 4};
//+
Line(2) = {4, 3};
//+
Line(3) = {3, 1};
//+
Line(4) = {1, 2};
//+
Line(5) = {1, 9};
//+
Line(6) = {9, 8};
//+
Line(7) = {8, 7};
//+
Line(8) = {7, 6};
//+
Line(9) = {6, 5};
//+
Point(13) = {0.0011, -0.00026, 0, 0.0003};
//+
Point(14) = {0.000225, -0.00026, 0, 0.0003};
//+
Line(10) = {8, 10};
//+
Line(11) = {14, 13};
//+
Line(12) = {14, 2};
//+
Line(13) = {10, 11};
//+
Line(14) = {12, 13};
//+
Line(15) = {11, 7};
//+
Line(16) = {6, 12};
//+
Curve Loop(1) = {3, 4, -12, 11, -14, -16, 9, 1, 2};
//+
Plane Surface(1) = {1};
//+
Curve Loop(2) = {15, -7, 10, 13};
//+
Plane Surface(2) = {2};
//+
Curve Loop(3) = {16, 14, -11, 12, -4, 5, 6, 10, 13, 15, 8};
//+
Plane Surface(3) = {3};
//+
Physical Surface(1) = {1};
//+
Physical Surface(2) = {2};
//+
Line(17) = {10, 14};
//+
Line(18) = {11, 12};
//+
Curve Loop(4) = {13, 18, 14, -11, -17};
//+
Plane Surface(4) = {4};
//+
Curve Loop(5) = {16, -18, 15, 8};
//+
Plane Surface(5) = {5};
//+
Curve Loop(6) = {6, 10, 17, 12, -4, 5};
//+
Plane Surface(6) = {6};
//+
Physical Surface(3) = {6, 4, 5};
//+
Physical Curve(4) = {3};
//+
Physical Curve(5) = {2, 1, 9};
//+
Physical Curve(6) = {7};
//+
Physical Curve(7) = {8, 16, 15, 10, 6, 5, 18, 13, 11, 14, 17, 12, 4};

I am getting an error when I will use ds(5) in rhs part.
code is here

a =r * m * dx \
- r * k_0 * T[0] * (srer_im * (H_phi[0]) + srer_re * (H_phi[1])) * ds(5) \
- r * k_0 * T[1] * (srer_im * (H_phi[1]) - srer_re * (H_phi[0])) * ds(5)

L = r * (T[0]+T[1]) * f * dx+ \
r * k_0 * T[0] * (srer_im * (- 2*H_phi_0_re) + srer_re * (- 2*H_phi_0_im)) * ds(5) +\
r * k_0 * T[1] * (srer_im * (- 2*H_phi_0_im) - srer_re * (- 2*H_phi_0_re)) * ds(5)

bc = DirichletBC(V, Constant((0.0, 0.0)), boundary, 4)

U = Function(V)

solve(a == L, U,bc,
solver_parameters={"linear_solver": "mumps", "preconditioner": "hypre_euclid"})

c=plot(U)
plt.colorbar(c)
plt.show()

and error is
Solving linear variational problem.
/usr/lib/python3/dist-packages/matplotlib/quiver.py:678: RuntimeWarning: Mean of empty slice.
amean = a[~self.Umask].mean()
/home/gangadhar/.local/lib/python3.8/site-packages/numpy/core/_methods.py:188: RuntimeWarning: invalid value encountered in double_scalars
ret = ret.dtype.type(ret / rcount)

This is not a minimal example, as you:

  1. Do not present a code that can reproduce the error (by copy paste into an empty editor).
  2. Remove all code that is not needed to reproduce the result. For instance, do you obtain an error if you simply use a built in mesh, i.e.:
from dolfin import *
import matplotlib.pyplot as plt
mesh = UnitSquareMesh(10,10)
u = Function(V)
c = plot(U)
plt.colorbar(c)
plt.show()

If you do not obtain an error using my code above, add in step after step from your bigger example, and find the source of your error.
You could also print the values in U, i.e.

print(U.vector().get_local())

and check the min and max values to check that they are bounded (not inf or nan).