Commit 3ce1432be43d0624dce01ca82b665fa1335623f3
- Diff rendering mode:
- inline
- side by side
fdtd_plane.py
(9 / 7)
|   | |||
| 10 | 10 | # program start | |
| 11 | 11 | ||
| 12 | 12 | new_efield = grid.Plane(shape=(301,301), timestep=1, spacestep=2*3*10**8) | |
| 13 | new_efield.eps[180:,0:] *= 2 | ||
| 13 | 14 | new_hfield = grid.Plane(shape=(301,301), timestep=1, spacestep=2*3*10**8) | |
| 15 | new_hfield.eps[180:,0:] *= 2 | ||
| 14 | 16 | ||
| 15 | 17 | ||
| 16 | for step in range(1,30): | ||
| 17 | new_efield.y[151,151] += float(mpmath.sin(step*mpmath.pi/6.125))*2 | ||
| 18 | for step in range(1,600): | ||
| 19 | new_efield.y[150,150] += float(mpmath.sin(step*mpmath.pi/6.125))*2 | ||
| 18 | 20 | new_efield = update_efield( new_efield, new_hfield ) | |
| 19 | new_hfield.z[151,151] += float(mpmath.sin(step*mpmath.pi/6.125))*2 | ||
| 21 | new_hfield.z[150,150] += float(mpmath.sin(step*mpmath.pi/6.125))*2 | ||
| 20 | 22 | new_hfield = update_hfield( new_efield, new_hfield ) | |
| 21 | 23 | ||
| 22 | 24 | ||
| … | … | ||
| 30 | 30 | pylab.imshow( h, interpolation="quadric", norm=matplotlib.colors.Normalize(-0.3,0.3,True) ) | |
| 31 | 31 | pylab.colorbar() | |
| 32 | 32 | pylab.grid(True) | |
| 33 | pylab.savefig("result/fdtd_plane-%s.png" % str(step)) | ||
| 33 | pylab.savefig("result/fdtd_plane-%.3d.png" % step) | ||
| 34 | 34 | pylab.clf() | |
| 35 | 35 | ||
| 36 | d = numpy.array(new_hfield.z[0:,151], dtype="float") | ||
| 37 | print d[140:159] | ||
| 36 | d = numpy.array(new_hfield.z[0:,150], dtype="float") | ||
| 37 | |||
| 38 | 38 | for i in xrange(1,len(d)-1): | |
| 39 | 39 | if i%2==0: | |
| 40 | 40 | d[i] = ( d[i-1] + d[i+1] ) / 2 | |
| 41 | print d[140:159] | ||
| 41 | |||
| 42 | 42 | pylab.plot( d ) | |
| 43 | 43 | pylab.ylim((-0.3,0.3)) | |
| 44 | 44 | pylab.grid(True) |

