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') ax2 = fig.add_subplot(2, 3, 4) ax2.imshow(fields.get('ex')[:, :, nz / 2].T, vmin=-1.1, vmax=1.1)
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() fig = plt.figure(figsize=(12, 8)) imag = plt.imshow(np.zeros((nx, ny), fields.dtype).T,
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)
# Modified: import numpy as np import sys from kemp.fdtd3d.naive import Fields, Core, Pbc, IncidentDirect, Pml, Drude nx, ny, nz = 2, 250, 300 tmax, tgap = 1000, 10 npml = 10 # instances fields = Fields(nx, ny, nz) Drude(fields, (0, -30, 0), (-1, -1, -1), \ ep_inf=9.0685, drude_freq=2*np.pi*2155.6*1e12, gamma=2*np.pi*18.36*1e12) Pbc(fields, 'x') Pml(fields, ('', '-', '+-'), npml) Core(fields) tfunc = lambda tstep: 50 * np.sin(0.05 * tstep) IncidentDirect(fields, 'ex', (0, 0.6, 0.5), (-1, 0.6, 0.5), tfunc) # plot import matplotlib.pyplot as plt plt.ion() fig = plt.figure(figsize=(12, 8)) imag = plt.imshow(np.zeros((ny, nz), fields.dtype).T, interpolation='nearest', origin='lower', vmin=-1.1, vmax=1.1)