Coil model meshing using netgen.occ

Hi, I am trying to model a coil using the following Python script.

from ngsolve import *
from netgen.occ import *
from ngsolve.webgui import Draw

wp = WorkPlane(Axes((0,0,0), n=(-1, 0, 0),h=(0, 0, 1)))

t1 = 90+25.41
t2 = 90-25.41
wp.MoveTo(1.142,0).LineTo(1.142, 0.453432).Direction(0,1).Arc((0.122+0.060),t1)\
.LineTo(-0.038088,0.180828).Arc((0.122+0.060), t2)\
.LineTo(-0.142000,0.016432).LineTo(-0.142000,0)\
.LineTo(-0.020000,0).LineTo(-0.020000,0.016432).Direction(0,1).Arc(0.060, -t2)\
.LineTo(0.934257,0.507629).Arc(0.060, -t1)\
.LineTo(1.020000,0.453432).LineTo(1.020000,0).Close()

coil = wp.Face()
coil = coil.Extrude(Vec(0.122,0,0)).mat('coil')
mesh = Mesh(OCCGeometry(coil, dim=3).GenerateMesh(maxh=0.01)).Curve(2)
Draw(mesh)

If I change maxh to 0.02, the kernel dies, and an extremely fine mesh is generated at the corner of the coil connection, as shown in the attached figure.

Also if I change to .Curve(1), again the kernel dies.

If anyone knows of a solution, please advise me.

You have very short edges, which lead to the strong refinement. I found them by that piece of code:

wp = WorkPlane(Axes((0,0,0), n=(-1, 0, 0),h=(0, 0, 1)))

t1 = 90+25.41
t2 = 90-25.41
wp.MoveTo(1.142,0).LineTo(1.142, 0.453432, "line1").Direction(0,1).Arc((0.122+0.060),t1, "arc1")\
.LineTo(-0.038088,0.180828, "line2").Arc((0.122+0.060), t2, "arc2")\
.LineTo(-0.142000,0.016432, "lineA").LineTo(-0.142000,0, "lineB")\
.LineTo(-0.020000,0, "LineC").LineTo(-0.020000,0.016432, "LineE").Direction(0,1).Arc(0.060, -t2)\
.LineTo(0.934257,0.507629).Arc(0.060, -t1)\
.LineTo(1.020000,0.453432).LineTo(1.020000,0).Close()
coil = wp.Face()
Draw (coil);

for e in coil.edges:
    print (e.name, e.mass)

from which I got

line1 0.453432
arc1 0.3665997771302513
line2 1.0185057932195303
arc2 0.2051700858230911
lineA 7.363461048520112e-06
lineB 0.016432
LineC 0.12199999999999998
LineE 0.016432
None 0.06763848983178825
None 1.0185160409475835
None 0.12085706938359922
None 2.9123676747634944e-06
None 0.453432
None 0.12199999999999989

Certainly, you want to skip lineA, and the other very short edge.

Joachim