コード例 #1
0
def MakeCopperPlate(plate_id):

    points = gmshlib.ObjectList('plate' + str(plate_id) + '_p')
    centers = gmshlib.ObjectList('plate' + str(plate_id) + '_cp')

    points.Add(gmshlib.Point([0, 0, 0, lc]))
    points.Add(points[0].Translate([pitch / 2 - r_out, 0, 0]))
    centers.Add(points[0].Translate([pitch / 2, 0, 0]))
    points.Add(points[0].Translate([pitch / 2 + r_out, 0, 0]))
    points.Add(points[0].Translate([pitch, 0, 0]))

    points.Add(points[-1].Translate([0, pitch - r_out, 0]))
    centers.Add(points[-1].Translate([0, r_out, 0]))

    points.Add(centers[-1].Translate([-r_out, 0, 0]))
    points.Add(points[-1].Translate([-pitch + 2 * r_out, 0, 0]))
    centers.Add(points[-1].Translate([-r_out, 0, 0]))

    points.Add(centers[-1].Translate([0, -r_out, 0]))

    n_p0 = len(points)  # Save number of basic points
    #print (str(n_p0))
    curves = gmshlib.ObjectList('plate' + str(plate_id) + '_c')
    curves.Add(gmshlib.Line(points[0:2]))
    curves.Add(gmshlib.Circle([points[2], centers[0], points[1]]))
    curves.Add(gmshlib.Line(points[2:4]))

    curves.Add(gmshlib.Line(points[3:5]))
    curves.Add(gmshlib.Circle([points[5], centers[1], points[4]]))

    curves.Add(gmshlib.Line(points[5:7]))
    curves.Add(gmshlib.Circle([points[n_p0 - 1], centers[2],
                               points[n_p0 - 2]]))

    curves.Add(gmshlib.Line([points[n_p0 - 1], points[0]]))

    lineloops = gmshlib.ObjectList('plate' + str(plate_id) + '_ll')
    lineloops.Add(gmshlib.LineLoop(curves))

    surfaces = gmshlib.ObjectList('plate' + str(plate_id) + '_sf')
    surfaces.Add(gmshlib.RuledSurface(lineloops))

    return collections.OrderedDict([('points', points), ('centers', centers),
                                    ('curves', curves),
                                    ('lineloops', lineloops),
                                    ('surfaces', surfaces)])
コード例 #2
0
import collections

import gmshlib
f = open('gem.geo', 'w')

# Gem parameters
lc = 2.5  # um
pitch = 140  # um
r_out = 35  # um
r_cone = 30  # um
t_copper = 5  # um
t_kapton = 50  # um
##############################################################

points = gmshlib.ObjectList('p')
curves = gmshlib.ObjectList('c')
lineloops = gmshlib.ObjectList('ll')
surfaces = gmshlib.ObjectList('sf')
surfaceloops = gmshlib.ObjectList('sl')
volumes = gmshlib.ObjectList('volumes')

# Bottom of lower copper plate
##############################################################
tmp_points1 = []
points.Add(gmshlib.Point([0, 0, 0, lc]))

tmp_points1.append(points[-1])

points.Add(points[0].Translate([pitch / 2 - r_out, 0, 0]))
curves.Add(gmshlib.Line(points[:]))
コード例 #3
0
ファイル: test.py プロジェクト: thnam/garfieldpp_eg
#!/usr/bin/env python
# encoding: utf-8
import gmshlib
f = open('test.geo', 'w')

point = gmshlib.ObjectList('p')
point.Add(gmshlib.Point([2, 0, 0, .1]))
point.Add(point[-1].Translate(0, 1, 0))
point.Add(point[-1].Translate(-2, 0, 0))
point.Add(point[-1].Translate(0, -1, 0))

for i in range(len(point)):
    point.Add(point[i].Translate(0, 0, 5))

point.Write(f)

curve = gmshlib.LineList('c')
curve.PolyLines(point[0:4])
curve.PolyLines(point[4:8])
curve.Add(gmshlib.Line([point[4], point[0]]))
curve.Add(gmshlib.Line([point[1], point[5]]))
curve.Add(gmshlib.Line([point[6], point[2]]))
curve.Add(gmshlib.Line([point[3], point[7]]))

curve.Write(f)

lineloop = gmshlib.ObjectList('ll', start_index=100)
lineloop.Add(gmshlib.LineLoop(curve[0:4]))
lineloop.Add(gmshlib.LineLoop(curve[4:8]))
lineloop.Add(
    gmshlib.LineLoop([curve[0], curve[9], curve[4].Reverse(), curve[8]]))
コード例 #4
0
import sys
sys.path.append('../py_gmsh')

import gmshlib
f = open('cap.geo', 'w')

# Outer box
box1 = gmshlib.MakeRectangularBox(2, 2, 2, 0.2)
for key in box1:
    box1[key].Write(f)

# Inner box
box2 = gmshlib.MakeRectangularBox(1., 1., 1, 0.1, center=[0, 0, 0], box_id=1)
for key in box2:
    box2[key].Write(f)

ps = gmshlib.ObjectList('ps')
ps.Add(gmshlib.PhysicalSurface([box2['surfaces'][0]]))
ps.Add(gmshlib.PhysicalSurface([box2['surfaces'][-1]]))
ps.Write(f)

inner_sf = box2['surfaceloops']
outer_sf = box1['surfaceloops']
outer_vol = gmshlib.Volume([outer_sf[0], inner_sf[0]])
outer_vol.Write(f)

pv = gmshlib.ObjectList('pv')
pv.Add(gmshlib.PhysicalVolume([outer_vol, box2['volumes'][0]]))
pv.Add(gmshlib.PhysicalVolume(box2['volumes']))
pv.Write(f)
コード例 #5
0
ファイル: ctest.py プロジェクト: thnam/garfieldpp_eg
#!/usr/bin/env python
# encoding: utf-8
import gmshlib
f = open('newtest.geo','w')

p = gmshlib.ObjectList('p')
l = gmshlib.ObjectList('l')
ll = gmshlib.ObjectList('ll')
sf = gmshlib.ObjectList('sf')
sl = gmshlib.ObjectList('sl')
vl = gmshlib.ObjectList('vl')

p.Add(gmshlib.Point([0,0,0,0.5]))
p.Add(gmshlib.Point([0,4,0,0.5]))
p.Add(gmshlib.Point([0,8,0,0.5]))

l.Add(gmshlib.Circle(p[0:3]))

ext0 = l[-1].Extrude([10,0,0])

p.AddList(ext0['points'])
l.AddList(ext0['curves'])
ll.AddList(ext0['lineloops'])
#sf.AddList(ext0['surfaces'])

p.Add(p[1].Translate([5,0,0]))
p.Add(p[-1].Translate([0,1,0]))
p.Add(p[-1].Translate([1,0,0]))
p.Add(p[-1].Translate([0,-2,0]))

l.AddList(gmshlib.MakePolyLines(p[-4::1], prefix='pl'))