Example #1
0
sys.path.append(os.path.expanduser('~'))
from kemp.fdtd3d.naive import Fields, Core, Pbc, IncidentDirect

tmax = 150
tfunc = lambda tstep: np.sin(0.05 * tstep)

# plot
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rc('image', interpolation='nearest', origin='lower')
plt.ion()
fig = plt.figure(figsize=(14, 8))

# z-axis
nx, ny, nz = 180, 160, 2
fields = Fields(nx, ny, nz, segment_nbytes=16)
Core(fields)
Pbc(fields, 'xyz')
IncidentDirect(fields, 'ey', (20, 0, 0), (20, ny - 1, nz - 1), tfunc)
IncidentDirect(fields, 'ex', (0, 20, 0), (nx - 1, 20, nz - 1), tfunc)

for tstep in xrange(1, tmax + 1):
    fields.update_e()
    fields.update_h()

ax1 = fig.add_subplot(2, 3, 1)
ax1.imshow(fields.get('ey')[:, :, nz / 2].T, vmin=-1.1, vmax=1.1)
ax1.set_title('%s, ey[20,:,:]' % repr(fields.ns))
ax1.set_xlabel('x')
ax1.set_ylabel('y')
Example #2
0
import numpy as np

import sys, os
sys.path.append(os.path.expanduser('~'))
from kemp.fdtd3d.naive import Fields, Core, Pbc, IncidentDirect, Pml

nx, ny, nz = 250, 300, 4
tmax, tgap = 300, 20

# instances
fields = Fields(nx, ny, nz, segment_nbytes=16)
Core(fields)
Pbc(fields, 'yz')
Pml(fields, ('+', '', ''))

tfunc = lambda tstep: 50 * np.sin(0.05 * tstep)
#IncidentDirect(fields, 'ez', (120, 0, 0), (120, ny-1, nz-1), tfunc)
#IncidentDirect(fields, 'ez', (0, 20, 0), (nx-1, 20, nz-1), tfunc)
IncidentDirect(fields, 'ez', (150, ny / 2, 0), (150, ny / 2, nz - 1), tfunc)

print fields.instance_list

# plot
import matplotlib.pyplot as plt
plt.ioff()
fig = plt.figure(figsize=(12, 8))
imag = plt.imshow(np.zeros((nx, ny), fields.dtype).T,
                  interpolation='nearest',
                  origin='lower',
                  vmin=-1.1,
                  vmax=1.1)

tmax = 150
tfunc = lambda tstep: np.sin(0.05 * tstep)

# plot
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rc('image', interpolation='nearest', origin='lower')
plt.ion()
fig = plt.figure(figsize=(14,8))


# z-axis
nx, ny, nz = 180, 160, 2
fields = Fields(nx, ny, nz, segment_nbytes=16)
Core(fields)
Pbc(fields, 'xyz')
IncidentDirect(fields, 'ey', (20, 0, 0), (20, ny-1, nz-1), tfunc) 
IncidentDirect(fields, 'ex', (0, 20, 0), (nx-1, 20, nz-1), tfunc) 

for tstep in xrange(1, tmax+1):
    fields.update_e()
    fields.update_h()

ax1 = fig.add_subplot(2, 3, 1)
ax1.imshow(fields.get('ey')[:,:,nz/2].T, vmin=-1.1, vmax=1.1)
ax1.set_title('%s, ey[20,:,:]' % repr(fields.ns))
ax1.set_xlabel('x')
ax1.set_ylabel('y')
Example #4
0
import numpy as np

import sys, os
#sys.path.append( os.path.expanduser('~') )
from kemp.fdtd3d.naive import Fields, Core, Pbc, IncidentDirect

nx, ny, nz = 160, 140, 2
tmax, tgap = 150, 10

# instances
fields = Fields(nx, ny, nz)
Core(fields)
Pbc(fields, 'xyz')

tfunc = lambda tstep: np.sin(0.05 * tstep)
IncidentDirect(fields, 'ez', (20, 0, 0), (20, ny - 1, nz - 1), tfunc)
#IncidentDirect(fields, 'ez', (0, 20, 0), (nx-1, 20, nz-1), tfunc)

print fields.instance_list

# plot
import matplotlib.pyplot as plt
plt.ion()
fig = plt.figure(figsize=(12, 8))
imag = plt.imshow(np.zeros((nx, ny), fields.dtype).T,
                  interpolation='nearest',
                  origin='lower',
                  vmin=-1.1,
                  vmax=1.1)
plt.colorbar()
Example #5
0
import numpy as np

import sys, os
#sys.path.append( os.path.expanduser('~') )
from kemp.fdtd3d.naive import Fields, Core, Pbc, IncidentDirect, Pml

nx, ny, nz = 250, 300, 4
tmax, tgap = 3000, 50
npml = 10

# instances
fields = Fields(nx, ny, nz)
cex, cey, cez = fields.get_ces()
cex[:, :, :] /= 4.
cey[:, :, :] /= 4.
cez[:, :, :] /= 4.
Core(fields)
Pbc(fields, 'z')
Pml(fields, ('+-', '+-', ''), npml)

tfunc = lambda tstep: 50 * np.sin(0.05 * tstep)
IncidentDirect(fields, 'ez', (-50, 0.5, 0), (-50, 0.5, -1), tfunc)
#IncidentDirect(fields, 'ez', (50, 0.5, 0), (50, 0.5, -1), tfunc)
#IncidentDirect(fields, 'ez', (0.5, -50, 0), (0.5, -50, -1), tfunc)
#IncidentDirect(fields, 'ez', (0.3, 0.3, 0), (0.3, 0.3, -1), tfunc)

print fields.instance_list

# plot
import matplotlib.pyplot as plt
plt.ion()
Example #6
0
import numpy as np

import sys, os
sys.path.append( os.path.expanduser('~') )
from kemp.fdtd3d.naive import Fields, Core, Pbc, IncidentDirect, Pml


nx, ny, nz = 250, 300, 4
tmax, tgap = 300, 20 

# instances 
fields = Fields(nx, ny, nz, segment_nbytes=16)
Core(fields)
Pbc(fields, 'yz')
Pml(fields, ('+', '', ''))

tfunc = lambda tstep: 50 * np.sin(0.05 * tstep)
#IncidentDirect(fields, 'ez', (120, 0, 0), (120, ny-1, nz-1), tfunc) 
#IncidentDirect(fields, 'ez', (0, 20, 0), (nx-1, 20, nz-1), tfunc) 
IncidentDirect(fields, 'ez', (150, ny/2, 0), (150, ny/2, nz-1), tfunc) 

print fields.instance_list

# plot
import matplotlib.pyplot as plt
plt.ioff()
fig = plt.figure(figsize=(12,8))
imag = plt.imshow(np.zeros((nx, ny), fields.dtype).T, interpolation='nearest', origin='lower', vmin=-1.1, vmax=1.1)
plt.colorbar()

from matplotlib.patches import Rectangle