# From the Meep tutorial: plotting permittivity and fields of a straight waveguide
import meep as mp
cell = mp.Vector3(10, 10, 0)
geometry = [mp.Block(mp.Vector3(0.1, 0.1, mp.inf),center=mp.Vector3(4,4),material=mp.Medium(epsilon=1.1),)]
sources = [mp.Source(mp.ContinuousSource(frequency=0.8), component=mp.Ez, center=mp.Vector3(0, 0))]
pml_layers = [mp.PML(1.0)]
resolution = 10
sim = mp.Simulation(cell_size=cell,boundary_layers=pml_layers,geometry=geometry,sources=sources,resolution=resolution,)
sim.run(mp.at_beginning(mp.output_epsilon),mp.to_appended("ez", mp.at_every(0.05, mp.output_efield_z)),until=20)
Initializing structure...
time for choose_chunkdivision = 8.29697e-05 s
Working in 2D dimensions.
Computational cell is 10 x 10 x 0 with resolution 10
block, center = (4,4,0)
size (0.1,0.1,1e+20)
axes (1,0,0), (0,1,0), (0,0,1)
dielectric constant epsilon diagonal = (1.1,1.1,1.1)
time for set_epsilon = 0.019645 s
-----------
creating output file "./eps-000000.00.h5"...
creating output file "./ez.h5"...
run 0 finished at t = 20.0 (400 timesteps)
import h5py
import numpy as np
# Abre el archivo HDF5 en modo lectura
with h5py.File('eps-000000.00.h5', 'r') as f:
# Muestra las claves principales del archivo
print(f"Claves principales del archivo: {list(f.keys())}")
with h5py.File('eps-000000.00.h5', 'r') as f:
dataset = f['eps']
data_array = np.array(dataset)
import matplotlib.pyplot as plt
plt.imshow(data_array)
import h5py
import numpy as np
# Abre el archivo HDF5 en modo lectura
with h5py.File('ez.h5', 'r') as f:
# Muestra las claves principales del archivo
print(f"Claves principales del archivo: {list(f.keys())}")
with h5py.File('ez.h5', 'r') as f:
dataset2 = f['ez']
data_array2 = np.array(dataset2)