import meep as mp L = 40 H = 1 t_until=400 cell = mp.Vector3(2*L, L, 0) geometry = [mp.Block(mp.Vector3(L, 1, mp.inf),center=mp.Vector3(-L/2,-H/2),material=mp.Medium(epsilon=3.6*3.6),e1=[1.0, 0.0],e2=[0.0, 1.0]), mp.Block(mp.Vector3(1,H+1, mp.inf),center=mp.Vector3( 0, 0),material=mp.Medium(epsilon=3.6*3.6),e1=[1.0, 0.0],e2=[0.0, 1.0]), mp.Block(mp.Vector3(L, 1, mp.inf),center=mp.Vector3(+L/2,+H/2),material=mp.Medium(epsilon=3.6*3.6),e1=[1.0, 0.0],e2=[0.0, 1.0])] sources = [mp.Source(mp.ContinuousSource(frequency=0.1), component=mp.Ez, center=mp.Vector3(-L+2, -H/2))] pml_layers = [mp.PML(1.0)] resolution = 10 sim = mp.Simulation(cell_size=cell,boundary_layers=pml_layers,geometry=geometry,sources=sources,resolution=resolution,) from matplotlib import pyplot as plt plt.figure(dpi=100) sim.plot2D() plt.show() sim.run(until=t_until) plt.figure(dpi=100) sim.plot2D(fields=mp.Ez) plt.show() eps_data = sim.get_array(center=mp.Vector3(), size=cell, component=mp.Dielectric) ez_data = sim.get_array(center=mp.Vector3(), size=cell, component=mp.Ez) print(ez_data.shape) plt.imshow(ez_data)
plt.plot(ez_data[:,200],'-k') plt.plot(ez_data[:,210],'-b') plt.plot(ez_data[:,220],'-g') plt.plot(ez_data[:,230],'-r')

import numpy as np import math ############ FT i_0=500 i_I=800 I=i_I-i_0 Qx_i=0.0 Qx_f=1.0 NQx=1000 dQx=(Qx_f-Qx_i)/NQx EQx=np.zeros(NQx) QxV=np.zeros(NQx) ############# FT for ic in range(NQx): Qx = Qx_i+ic*dQx QxV[ic]=Qx Exr=0 Exi=0 for i in range(I): Exr=Exr+ez_data[i_0+i,int((L/2+H/2)*10)]*math.cos(2.0*math.pi*Qx*(i_0+i)/resolution) Exi=Exi+ez_data[i_0+i,int((L/2+H/2)*10)]*math.sin(2.0*math.pi*Qx*(i_0+i)/resolution) EQx[ic] = math.sqrt(Exr*Exr+Exi*Exi)
plt.plot(QxV,EQx) # Graficar # Personalización de la gráfica plt.title('Gráfica de la función y = x', fontsize=16) plt.xlabel('x', fontsize=14) plt.ylabel('y', fontsize=14) plt.axhline(0, color='black',linewidth=0.5, ls='--') # Línea horizontal en y=0 plt.axvline(0, color='black',linewidth=0.5, ls='--') # Línea vertical en x=0 plt.grid(color = 'gray', linestyle = '--', linewidth = 0.5) # Mostrar la gráfica plt.show()
