Пример #1
0
def initializeSurf(field_array, filename, param):

    surf_array = []

    files, surf_type, phi0_file = readSurf(
        filename)  # Read filenames for surfaces
    Nsurf = len(files)

    for i in range(Nsurf):
        print '\nReading surface %i from file ' % i + files[i]

        s = surfaces()

        s.surf_type = surf_type[i]

        if s.surf_type == 'dirichlet_surface' or s.surf_type == 'neumann_surface':
            s.phi0 = numpy.loadtxt(phi0_file[i])
            print '\nReading phi0 file for surface %i from ' % i + phi0_file[i]

        Area_null = []
        tic = time.time()
        s.vertex = readVertex(files[i] + '.vert', param.REAL)
        triangle_raw = readTriangle(files[i] + '.face', s.surf_type)
        toc = time.time()
        print 'Time load mesh: %f' % (toc - tic)
        Area_null = zeroAreas(s, triangle_raw, Area_null)
        s.triangle = numpy.delete(triangle_raw, Area_null, 0)
        print 'Removed areas=0: %i' % len(Area_null)

        # Look for regions inside/outside
        for j in range(Nsurf + 1):
            if len(field_array[j].parent) > 0:
                if field_array[j].parent[0] == i:  # Inside region
                    s.kappa_in = field_array[j].kappa
                    s.Ein = field_array[j].E
                    s.LorY_in = field_array[j].LorY
            if len(field_array[j].child) > 0:
                if i in field_array[j].child:  # Outside region
                    s.kappa_out = field_array[j].kappa
                    s.Eout = field_array[j].E
                    s.LorY_out = field_array[j].LorY

        if s.surf_type != 'dirichlet_surface' and s.surf_type != 'neumann_surface':
            s.E_hat = s.Ein / s.Eout
        else:
            s.E_hat = 1

        surf_array.append(s)
    return surf_array
Пример #2
0
def initializeSurf(field_array, filename, param):

    surf_array = []

    files, surf_type, phi0_file = readSurf(filename)      # Read filenames for surfaces
    Nsurf = len(files)

    for i in range(Nsurf):
        print '\nReading surface %i from file '%i + files[i]

        s = surfaces()

        s.surf_type = surf_type[i]

        if s.surf_type=='dirichlet_surface' or s.surf_type=='neumann_surface':
            s.phi0 = loadtxt(phi0_file[i])
            print '\nReading phi0 file for surface %i from '%i+phi0_file[i]

        Area_null = []
        tic = time.time()
        s.vertex = readVertex(files[i]+'.vert', param.REAL)
        triangle_raw = readTriangle(files[i]+'.face', s.surf_type)
        toc = time.time()
        print 'Time load mesh: %f'%(toc-tic)
        Area_null = zeroAreas(s, triangle_raw, Area_null)
        s.triangle = delete(triangle_raw, Area_null, 0)
        print 'Removed areas=0: %i'%len(Area_null)

        # Look for regions inside/outside
        for j in range(Nsurf+1):
            if len(field_array[j].parent)>0:
                if field_array[j].parent[0]==i:                 # Inside region
                    s.kappa_in = field_array[j].kappa
                    s.Ein      = field_array[j].E
                    s.LorY_in  = field_array[j].LorY
            if len(field_array[j].child)>0:
                if i in field_array[j].child:                # Outside region
                    s.kappa_out = field_array[j].kappa
                    s.Eout      = field_array[j].E
                    s.LorY_out  = field_array[j].LorY

        if s.surf_type!='dirichlet_surface' and s.surf_type!='neumann_surface':
            s.E_hat = s.Ein/s.Eout
        else:
            s.E_hat = 1

        surf_array.append(s)
    return surf_array
Пример #3
0
if len(sys.argv) > 5:
    name = sys.argv[5]
else:
    name = ''
if len(sys.argv) > 6:
    if sys.argv[6] == 'verbose':
        verbose = True
else:
    verbose = False

#outMesh = inMesh+'_rot'+sys.argv[3]+'_til'+sys.argv[4]
#outpqr = inpqr+'_rot'+sys.argv[3]+'_til'+sys.argv[4]
outMesh = inMesh + name
outpqr = inpqr + name

vert = readVertex(inMesh + '.vert', float)
xq, q, Nq = readpqr(inpqr + '.pqr', float)

#xq = array([[1.,0.,0.],[0.,0.,1.],[0.,1.,0.]])
#q = array([1.,-1.,1.])

#### Setup initial configuration
# Initial configuration: dipole parallel to y and outermost atom to center parallel to x
d = findDipole(xq, q)
normd = sqrt(sum(d * d))
normal = array([0, 1, 0])
normal2 = array([1, 0, 0])

angle = arccos(dot(d, normal) / normd)

## Align normal and dipole vectors
Пример #4
0
if len(sys.argv)>5:
    name = sys.argv[5]
else:
    name = ''
if len(sys.argv)>6:
    if sys.argv[6] == 'verbose':
        verbose = True
else:
    verbose = False

#outMesh = inMesh+'_rot'+sys.argv[3]+'_til'+sys.argv[4]
#outpqr = inpqr+'_rot'+sys.argv[3]+'_til'+sys.argv[4]
outMesh = inMesh + name
outpqr = inpqr + name

vert = readVertex(inMesh+'.vert', float)
xq, q, Nq = readpqr(inpqr+'.pqr', float)

#xq = array([[1.,0.,0.],[0.,0.,1.],[0.,1.,0.]])
#q = array([1.,-1.,1.])

#### Setup initial configuration
# Initial configuration: dipole parallel to y and outermost atom to center parallel to x
d = findDipole(xq,q)
normd = sqrt(sum(d*d))
normal  = array([0,1,0])
normal2 = array([1,0,0])

angle = arccos(dot(d, normal)/normd)

## Align normal and dipole vectors
Пример #5
0
        Area_aux = linalg.norm(normal_aux) / 2
        if Area_aux < 1e-10:
            Area_null.append(i)
    return Area_null


## Designed for a cube which faces are aligned with cartesian coordinates
meshFile = sys.argv[1]
x_right = float(sys.argv[2])
x_left = float(sys.argv[3])
y_top = float(sys.argv[4])
y_bott = float(sys.argv[5])
z_front = float(sys.argv[6])
z_back = float(sys.argv[7])

vertex = readVertex(meshFile + '.vert', float)
triangle_raw = readTriangle(meshFile + '.face', 'neumann_surface')

Area_null = []
Area_null = zeroAreas(vertex, triangle_raw, Area_null)
triangle = delete(triangle_raw, Area_null, 0)

if len(triangle) != len(triangle_raw):
    print '%i deleted triangles' % (len(triangle_raw) - len(triangle))

phi0 = zeros(len(triangle), float)

tri_ctr = average(vertex[triangle], axis=1)
print len(tri_ctr)
print len(triangle)
Пример #6
0
        normal_aux = cross(L0,L2)
        Area_aux = linalg.norm(normal_aux)/2
        if Area_aux<1e-10:
            Area_null.append(i)
    return Area_null 

## Designed for a cube which faces are aligned with cartesian coordinates
meshFile = sys.argv[1]
x_right = float(sys.argv[2])
x_left  = float(sys.argv[3])
y_top   = float(sys.argv[4])
y_bott  = float(sys.argv[5])
z_front = float(sys.argv[6])
z_back  = float(sys.argv[7])

vertex = readVertex(meshFile+'.vert', float)
triangle_raw = readTriangle(meshFile+'.face', 'neumann_surface')

Area_null = []
Area_null = zeroAreas(vertex, triangle_raw, Area_null)
triangle = delete(triangle_raw, Area_null, 0)

if len(triangle) != len(triangle_raw):
    print '%i deleted triangles'%(len(triangle_raw)-len(triangle))

phi0 = zeros(len(triangle), float)

tri_ctr = average(vertex[triangle], axis=1)
print len(tri_ctr)
print len(triangle)