示例#1
0
    boundary_potential_charge[i] = charge_potential[ boundary_positions[i,2], boundary_positions[i,1], boundary_positions[i,0] ]


#calculate influence charge density
boundary_potential_charge = -boundary_interaction_matrix_inv.dot(boundary_potential_charge)


#expand it into whole field and output
charge_potential = numpy.zeros( [Nz, Ny, Nx], dtype=float )

for i in numpy.arange( 0, len(boundary_positions) ):
    
    charge_potential[ boundary_positions[i,2], boundary_positions[i,1], boundary_positions[i,0] ] = boundary_potential_charge[0,i]

dielectric_tools.write_scalar_vtk( charge_potential, "influence_charge.vtk" )


#calculate potential of influence charge
tmp_grid_fft = numpy.fft.rfftn(charge_potential)

for z in numpy.arange(0, Nz):
    for y in numpy.arange(0, Ny):
        for x in numpy.arange(0, Nx/2+1):
        
            if (x,y,z) == (0,0,0):
                tmp_grid_fft[z,y,x] = 0.0
            else:
                tmp_grid_fft[z,y,x] = tmp_grid_fft[z,y,x] * (-4.0) * numpy.pi * lbkt * h**2 * 0.5 / ( numpy.cos( 2.0 * numpy.pi * x / Nx ) + numpy.cos( 2.0 * numpy.pi * y / Ny ) + numpy.cos( 2.0 * numpy.pi * z / Nz ) - 3.0 )

charge_potential = numpy.fft.irfftn( tmp_grid_fft )

# calculate influence charge density
boundary_potential_charge = -boundary_interaction_matrix_inv.dot(boundary_potential_charge)


# expand it into whole field and output
charge_potential = numpy.zeros([Nz, Ny, Nx], dtype=float)

for i in numpy.arange(0, len(boundary_positions)):

    charge_potential[
        boundary_positions[i, 2], boundary_positions[i, 1], boundary_positions[i, 0]
    ] = boundary_potential_charge[0, i]

dielectric_tools.write_scalar_vtk(charge_potential, "influence_charge.vtk")


# calculate potential of influence charge
tmp_grid_fft = numpy.fft.rfftn(charge_potential)

for z in numpy.arange(0, Nz):
    for y in numpy.arange(0, Ny):
        for x in numpy.arange(0, Nx / 2 + 1):

            if (x, y, z) == (0, 0, 0):
                tmp_grid_fft[z, y, x] = 0.0
            else:
                tmp_grid_fft[z, y, x] = (
                    tmp_grid_fft[z, y, x]
                    * (-4.0)