- Thank you received: 0
Meshing union of shapes
4 years 8 months ago #2495
by dfoiles
Meshing union of shapes was created by dfoiles
Hello everyone,
I am trying to create a mesh of a nanorod in water. I am intending for the nanorod to be a cylinder with two hemispherical endcaps inside a larger cylinder of water inside a larger cylinder of PML. However, when I run my script, I get an error. I have determined that the problem is when I try to add the endcaps of the nanorod to its main cylindrical body. Specifically, I get the error
File "<string>", line 2
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 1-2: malformed \N character escape
Start Findpoints
at which point, Netgen will hang permanently. I would really appreciate it if you could help me figure out why I am getting this error.
Thank you
Thank you
I am trying to create a mesh of a nanorod in water. I am intending for the nanorod to be a cylinder with two hemispherical endcaps inside a larger cylinder of water inside a larger cylinder of PML. However, when I run my script, I get an error. I have determined that the problem is when I try to add the endcaps of the nanorod to its main cylindrical body. Specifically, I get the error
File "<string>", line 2
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 1-2: malformed \N character escape
Start Findpoints
at which point, Netgen will hang permanently. I would really appreciate it if you could help me figure out why I am getting this error.
Thank you
Thank you
Attachments:
4 years 8 months ago - 4 years 8 months ago #2501
by matthiash
Replied by matthiash on topic Meshing union of shapes
Hello,
you can just add the whole sphere to the cylinder. It seems the mesher has problems identifiying the edge of the cylinder with the one of the hemisphere.
Best,
Matthias
you can just add the whole sphere to the cylinder. It seems the mesher has problems identifiying the edge of the cylinder with the one of the hemisphere.
Code:
from ngsolve import *
from netgen.csg import *
def Nanorod(aeff,ratio):
geo = CSGeometry()
radius = aeff*(2/(3*ratio-1))**(1/3)
length = 2 * radius * ratio
cyl_length = length/2 - radius
physical_space = length + 100
domain = physical_space + 150
sphere1 = Sphere(Pnt(0,-cyl_length,0),radius)
sphere2 = Sphere(Pnt(0,cyl_length,0),radius)
cyl1 = Cylinder(Pnt(0,-2*cyl_length,0),Pnt(0,2*cyl_length,0),radius)
cyl2 = Cylinder(Pnt(0,-2*physical_space,0),Pnt(0,2*physical_space,0),radius+100)
cyl3 = Cylinder(Pnt(0,-2*domain,0),Pnt(0,2*domain,0),radius+200).bc('outer')
box2 = OrthoBrick(Pnt(-physical_space,-physical_space,-physical_space),Pnt(physical_space,physical_space,physical_space))
box3 = OrthoBrick(Pnt(-domain,-domain,-domain),Pnt(domain,domain,domain)).bc('outer')
plane1 = Plane(Pnt(0,-cyl_length,0),Vec(0,-1,0))
plane2 = Plane(Pnt(0,cyl_length,0),Vec(0,1,0))
middle = cyl1*plane1*plane2
AuNP = (middle+sphere1+sphere2).mat('gold')
water = (cyl2*box2 - AuNP).mat('water')
pmldom = (cyl3*box3 - water).mat('pml')
geo.Add(AuNP)
geo.Add(water)
geo.Add(pmldom)
ngmesh = geo.GenerateMesh()
mesh = Mesh(ngmesh)
return mesh
mesh = Nanorod(40,1.6)
Draw(mesh)
Best,
Matthias
Last edit: 4 years 8 months ago by matthiash.
The following user(s) said Thank You: dfoiles
Time to create page: 0.104 seconds