Commit c7294d77eff5aaf843ca9e448991db5ce22d0dbd
- Diff rendering mode:
- inline
- side by side
fdtd_plane.py
(4 / 4)
|   | |||
| 13 | 13 | new_hfield = grid.Plane(shape=(301,301), timestep=1, spacestep=2*3*10**8) | |
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | for step in range(1,300): | ||
| 16 | for step in range(1,30): | ||
| 17 | 17 | new_efield.y[151,151] += float(mpmath.sin(step*mpmath.pi/6.125))*2 | |
| 18 | 18 | new_efield = update_efield( new_efield, new_hfield ) | |
| 19 | 19 | new_hfield.z[151,151] += float(mpmath.sin(step*mpmath.pi/6.125))*2 | |
| … | … | ||
| 43 | 43 | pylab.savefig("result_slice/fdtd_plane_slice-%s.png" % str(step)) | |
| 44 | 44 | pylab.clf() | |
| 45 | 45 | ||
| 46 | os.system("open result") | ||
| 47 | os.system("open result_slice") | ||
| 48 | print "done" | ||
| 46 | if "Darwin" in os.uname(): | ||
| 47 | os.system("open result") | ||
| 48 | os.system("open result_slice") |
|   | |||
| 7 | 7 | """ | |
| 8 | 8 | """ | |
| 9 | 9 | new_efield = grid.Plane( abuffer = efield ) | |
| 10 | |||
| 10 | 11 | (xaxis,yaxis) = efield.x.shape | |
| 12 | |||
| 11 | 13 | for i in range(1,xaxis-1): | |
| 12 | 14 | for j in range(1,yaxis-1): | |
| 13 | 15 | if (i+j)%2 == 1: | |
| 14 | 16 | pass | |
| 17 | |||
| 15 | 18 | return new_efield | |
| 16 | 19 | ||
| 17 | 20 |
lib/fdtd/grid.py
(5 / 5)
|   | |||
| 33 | 33 | Two dimension grid object | |
| 34 | 34 | """ | |
| 35 | 35 | ||
| 36 | def __init__(self, abuffer=None, shape=None, eps=None, mu=None, sigmae=None, sigmah=None, timestep=None, spacestep=None): | ||
| 36 | def __init__(self, abuffer=None, shape=None, eps=epsilon_0, mu=mu_0, sigmae=0, sigmah=0, timestep=None, spacestep=None): | ||
| 37 | 37 | """ | |
| 38 | 38 | Give one of shape or abuffer to initialize Plane object. | |
| 39 | 39 | ||
| … | … | ||
| 69 | 69 | self.y = numpy.zeros(shape, dtype="float128") | |
| 70 | 70 | self.z = numpy.zeros(shape, dtype="float128") | |
| 71 | 71 | ||
| 72 | self.eps = numpy.ndarray(shape=self.x.shape, dtype="float128"); self.eps[0:,0:] = (eps or epsilon_0) | ||
| 73 | self.mu = numpy.ndarray(shape=self.x.shape, dtype="float128"); self.mu[0:,0:] = (mu or mu_0) | ||
| 74 | self.sigmae = numpy.ndarray(shape=self.x.shape, dtype="float128"); self.sigmae[0:,0:] = (sigmae or 0) | ||
| 75 | self.sigmah = numpy.ndarray(shape=self.x.shape, dtype="float128"); self.sigmah[0:,0:] = (sigmah or 0) | ||
| 72 | self.eps = numpy.ndarray(shape=self.x.shape, dtype="float128"); self.eps[0:,0:] = eps | ||
| 73 | self.mu = numpy.ndarray(shape=self.x.shape, dtype="float128"); self.mu[0:,0:] = mu | ||
| 74 | self.sigmae = numpy.ndarray(shape=self.x.shape, dtype="float128"); self.sigmae[0:,0:] = sigmae | ||
| 75 | self.sigmah = numpy.ndarray(shape=self.x.shape, dtype="float128"); self.sigmah[0:,0:] = sigmah | ||
| 76 | 76 | ||
| 77 | 77 | self.timestep = (timestep or 1) | |
| 78 | 78 | self.spacestep = (spacestep or 1) |

