Exemplo n.º 1
0
    def allocate_coeff(s):
        CpmlNonKappa.allocate_coeff(s)

        if s.Npmlx == s.Npml or s.Npmlx == 0:
            pass
        else:
            s.bEx = sc.zeros(2 * (s.Npmlx + 1), 'f')
            s.aEx = sc.zeros(2 * (s.Npmlx + 1), 'f')
            s.bHx = sc.zeros(2 * (s.Npmlx + 1), 'f')
            s.aHx = sc.zeros(2 * (s.Npmlx + 1), 'f')

            Nsum = s.Nx_sum_list
            Nrsum = s.Nx_reverse_sum_list

            if myrank <= s.f_end_rank:
                pt0 = Nsum[myrank - 1] + 1
                slE = slH = slice(pt0, pt0 + s.Npmlx)

                s.bEx[1:s.Npmlx + 1] = s.bE[slE]
                s.aEx[1:s.Npmlx + 1] = s.aE[slE]
                s.bHx[1:s.Npmlx + 1] = s.bH[slH]
                s.aHx[1:s.Npmlx + 1] = s.aH[slH]

            elif myrank >= s.b_start_rank:
                pt0 = Nrsum[myrank + 1]
                slE = slice(-pt0 - s.Npmlx - 1, -pt0 - 1)
                slH = slice(-pt0 - s.Npmlx, -pt0)
                if myrank == Nnode - 1: slH = slice(-s.Npmlx, None)

                s.bEx[s.Npmlx + 1:-1] = s.bE[slE]
                s.aEx[s.Npmlx + 1:-1] = s.aE[slE]
                s.bHx[s.Npmlx + 2:] = s.bH[slH]
                s.aHx[s.Npmlx + 2:] = s.aH[slH]
Exemplo n.º 2
0
	def allocate_coeff( s ):
		CpmlNonKappa.allocate_coeff( s )

		if s.Npmlx == s.Npml or s.Npmlx == 0:
			pass
		else:
			s.bEx = sc.zeros( 2*(s.Npmlx+1), 'f' )
			s.aEx = sc.zeros( 2*(s.Npmlx+1), 'f' )
			s.bHx = sc.zeros( 2*(s.Npmlx+1), 'f' )
			s.aHx = sc.zeros( 2*(s.Npmlx+1), 'f' )

			Nsum = s.Nx_sum_list
			Nrsum = s.Nx_reverse_sum_list

			if myrank <= s.f_end_rank:
				pt0 = Nsum[myrank-1] + 1
				slE = slH = slice( pt0, pt0 + s.Npmlx )

				s.bEx[1:s.Npmlx+1] = s.bE[slE]
				s.aEx[1:s.Npmlx+1] = s.aE[slE]
				s.bHx[1:s.Npmlx+1] = s.bH[slH]
				s.aHx[1:s.Npmlx+1] = s.aH[slH]

			elif myrank >= s.b_start_rank:
				pt0 = Nrsum[myrank+1]
				slE = slice( -pt0 -s.Npmlx -1, -pt0 -1 )
				slH = slice( -pt0 -s.Npmlx, -pt0 )
				if myrank == Nnode-1: slH = slice( -s.Npmlx, None )

				s.bEx[s.Npmlx+1:-1] = s.bE[slE]
				s.aEx[s.Npmlx+1:-1] = s.aE[slE]
				s.bHx[s.Npmlx+2:] = s.bH[slH]
				s.aHx[s.Npmlx+2:] = s.aH[slH]
Exemplo n.º 3
0
	def allocate_psi ( s ):
		s.apply_direction = list_replace( s.apply_direction, 0, '' )
		CpmlNonKappa.allocate_psi( s )

		if myrank <= s.f_end_rank:
			s.apply_direction = list_replace( s.apply_direction, 0, 'f' )
		elif myrank >= s.b_start_rank:
			s.apply_direction = list_replace( s.apply_direction, 0, 'b' )
		else:
			s.apply_direction = list_replace( s.apply_direction, 0, '' )

		s.allocate_psix( s.Npmlx )
Exemplo n.º 4
0
    def allocate_psi(s):
        s.apply_direction = list_replace(s.apply_direction, 0, '')
        CpmlNonKappa.allocate_psi(s)

        if myrank <= s.f_end_rank:
            s.apply_direction = list_replace(s.apply_direction, 0, 'f')
        elif myrank >= s.b_start_rank:
            s.apply_direction = list_replace(s.apply_direction, 0, 'b')
        else:
            s.apply_direction = list_replace(s.apply_direction, 0, '')

        s.allocate_psix(s.Npmlx)
Exemplo n.º 5
0
	def __init__( s, Nx_list, Npml, apply_direction ):
		s.Nx_list = list( Nx_list )
		CpmlNonKappa.__init__( s, Npml, apply_direction )

		s.Nx_sum_list, s.Nx_reverse_sum_list = s.calc_Nx_sum_list()
		s.Nx_list.insert( 0, 0 )

		s.f_end_rank, s.b_start_rank = s.calc_participant_rank()
		if 'f' not in apply_direction[0]: s.f_end_rank = 0
		if 'b' not in apply_direction[0]: s.b_start_rank = Nnode
		if s.f_end_rank == s.b_start_rank:
			if myrank == 0: 
				print 'Cpml Error: f_end_rank is equal to b_start_rank.'
			sys.exit(0)

		s.Npmlx = s.calc_Npmlx()
Exemplo n.º 6
0
    def __init__(s, Nx_list, Npml, apply_direction):
        s.Nx_list = list(Nx_list)
        CpmlNonKappa.__init__(s, Npml, apply_direction)

        s.Nx_sum_list, s.Nx_reverse_sum_list = s.calc_Nx_sum_list()
        s.Nx_list.insert(0, 0)

        s.f_end_rank, s.b_start_rank = s.calc_participant_rank()
        if 'f' not in apply_direction[0]: s.f_end_rank = 0
        if 'b' not in apply_direction[0]: s.b_start_rank = Nnode
        if s.f_end_rank == s.b_start_rank:
            if myrank == 0:
                print 'Cpml Error: f_end_rank is equal to b_start_rank.'
            sys.exit(0)

        s.Npmlx = s.calc_Npmlx()
Exemplo n.º 7
0
#!/usr/bin/env python

from kufdtd.common import *
from kufdtd.dim3.cpu.base import *
from kufdtd.dim3.cpu.matter import Dielectric, DrudeAde
from kufdtd.dim3.cpu.cpml import CpmlNonKappa

#--------------------------------------------------------------------
Nx, Ny, Nz = 200, 200, 32
dx = 10e-9
tmax = 1000
Ncore = 8

Npml = 15

Cpml = CpmlNonKappa(Npml, ('fb', 'fb', 'fb'))

#--------------------------------------------------------------------
S = Dielectric(Nx, Ny, Nz, dx, Ncore)

S.allocate_main()
S.allocate_coeff()

Drude = DrudeAde(Nx, Ny, Nz, 0, 0, 0, S)
Drude.allocate_main()
Drude.allocate_coeff()

epr = 9.0685
pfreq = 2 * pi * 2155.6 * 1e12 / sc.sqrt(epr)
gamma = 2 * pi * 18.36 * 1e12
Exemplo n.º 8
0
from kufdtd.common import *
from kufdtd.dim3.cpu.base import *
from kufdtd.dim3.cpu.matter import Dielectric, DrudeAde
from kufdtd.dim3.cpu.cpml import CpmlNonKappa


#--------------------------------------------------------------------
Nx, Ny, Nz = 200, 200, 32
dx = 10e-9
tmax = 1000
Ncore = 8

Npml = 15

Cpml = CpmlNonKappa( Npml, ('fb','fb','fb') )

#--------------------------------------------------------------------
S = Dielectric( Nx, Ny, Nz, dx, Ncore )

S.allocate_main()
S.allocate_coeff()

Drude = DrudeAde( Nx, Ny, Nz, 0, 0, 0, S )
Drude.allocate_main()
Drude.allocate_coeff()

epr = 9.0685
pfreq = 2*pi*2155.6*1e12/sc.sqrt(epr)
gamma = 2*pi*18.36*1e12
Output_ez_yz = OutputMpi('Ez', node_Nx_list, (Nx / 2, None, None),
                         (Nx / 2, None, None), spartial_step)
Output_ez_yz_2 = OutputMpi('Ez', node_Nx_list, (Nx / 2, 10, None),
                           (Nx / 2, 100, None), spartial_step)
#Output_ez_yz_2 = OutputMpi( 'Ez', node_Nx_list, (Nx/2, 10, 20), (Nx/2, 100, 20), spartial_step )
output_list = [Output_ez, Output_ex, Output_ez_yz, Output_ez_yz_2]

#--------------------------------------------------------------------
if myrank is not server:
    S = Dielectric(node_Nx_list[myrank - 1], Ny, Nz, dx, Ncore)

    S.allocate_main()
    S.allocate_coeff()
    S.set_coeff()

    Cpml = CpmlNonKappa(Npml, S)
    Cpml.allocate_psi()
    Cpml.allocate_coeff()

    if myrank == 1:
        pml_direction = ('f', 'fb', 'fb')
    elif myrank == Nnode:
        pml_direction = ('b', 'fb', 'fb')
    else:
        pml_direction = ('', 'fb', 'fb')

    target_list, mpi_func_list = calc_oddeven(myrank)
    for output in output_list:
        output.set_space(S)

    print '-' * 47
Exemplo n.º 10
0
Drude.allocate_coeff()

S.set_coeff()

Drude.pfreq_x[50:101,50:100,:] = pfreq
Drude.pfreq_y[50:100,50:101,:] = pfreq
Drude.pfreq_z[50:100,50:100,:] = pfreq
Drude.gamma_x[50:101,50:100,:] = gamma
Drude.gamma_y[50:100,50:101,:] = gamma
Drude.gamma_z[50:100,50:100,:] = gamma
Drude.set_coeff()

#--------------------------------------------------------------------
Npml = 15

Cpml = CpmlNonKappa( Npml, S )
Cpml.allocate_psi()
Cpml.allocate_coeff()

#--------------------------------------------------------------------
print '-'*47
print 'N(%d, %d, %d)' % (S.Nx, S.Ny, S.Nz)
print 'dx = %g' % S.dx
print 'dt = %g' % S.dt
print 'Npml = %g' % Cpml.Npml
print ''
S.print_memory_usage()
Drude.print_memory_usage()
Cpml.print_memory_usage()
print '-'*47
Exemplo n.º 11
0
#!/usr/bin/env python

from kufdtd.common import *
from kufdtd.dim3.cpu.base import *
from kufdtd.dim3.cpu.matter import Dielectric
from kufdtd.dim3.cpu.cpml import CpmlNonKappa

#--------------------------------------------------------------------
Nx, Ny, Nz = 200, 200, 32
dx = 10e-9
tmax = 1000
Ncore = 8

Npml = 15

Cpml = CpmlNonKappa(Npml, ('fb', 'fb', 'fb'))
#--------------------------------------------------------------------
S = Dielectric(Nx, Ny, Nz, dx, Ncore)

S.allocate_main()
S.allocate_coeff()
S.set_coeff()

Cpml.set_space(S)
Cpml.allocate_psi()
Cpml.allocate_coeff()

#--------------------------------------------------------------------
print '-' * 47
print 'N(%d, %d, %d)' % (S.Nx, S.Ny, S.Nz)
print 'dx = %g' % S.dx
# output data
pt1 = ( None, None, Nz/2 )
pt2 = ( None, None, Nz/2 )
spartial_step = ( 2, 2, 2 )

#--------------------------------------------------------------------

#--------------------------------------------------------------------
if myrank is not server:
	S = Dielectric( node_Nx_list[myrank-1], Ny, Nz, dx, Ncore )

	S.allocate_main()
	S.allocate_coeff()
	S.set_coeff()

	Cpml = CpmlNonKappa( Npml, S )
	Cpml.allocate_psi()
	Cpml.allocate_coeff()

	if myrank == 1:
		pml_direction = ( 'f', 'fb', 'fb' )
	elif myrank == Nnode:
		pml_direction = ( 'b', 'fb', 'fb' )
	else:
		pml_direction = ( '', 'fb', 'fb' )

	target_list, mpi_func_list = calc_oddeven( myrank )

	print '-'*47
	print 'myrank = %d, N(%d, %d, %d)' % (myrank, S.Nx, S.Ny, S.Nz)
	print 'dx = %g, dt = %g' % (S.dx, S.dt)
from kufdtd.dim3.cpu.matter import Dielectric
from kufdtd.dim3.cpu.cpml import CpmlNonKappa
from kufdtd.dim3.output import Output
from kufdtd.dim3.tfsf import Tfsf


#--------------------------------------------------------------------
Nx, Ny, Nz = 200, 200, 64
dx = 10e-9
tmax = 1000
Ncore = 8

Npml = 15
wavelength = 600e-9

Cpml = CpmlNonKappa( Npml, ('fb','fb','fb') )

Output_ey = Output( 'Ey', (None, None, Nz/2), (None, None, Nz/2) ) 
output_list = [Output_ey]

Src = Tfsf( (50, 50, 20), (150, 150, 40), ('fb','fb','fb'), wavelength, ['normal', 'x'], 0 )
src_list = [Src]

#--------------------------------------------------------------------
S = Dielectric( Nx, Ny, Nz, dx, Ncore )

S.allocate_main()
S.allocate_coeff()
S.set_coeff()

Cpml.set_space( S )