Hi, If you return a `Medium` in your epsilon function, then you have to pass it to the `Simulation` with the `material_function` keyword argument instead of `epsilon_func`. See the section titled "material functions" under the `Medium` documentation here: http://meep.readthedocs.io/en/latest/Python_User_Interface/#medium. Additionally, I think you want `epsilon_function` to check `if vector.norm() < 1` instead of `vector.unit()`?
Chris On Wed, Jul 11, 2018 at 4:19 AM, Karl-Johan Olofsson < karol...@student.liu.se> wrote: > Hello. I would like to draw a hexagonal pyramid in MEEP using the python > interface. My first idea was to use a hexagonal prism and then use blocks > to "cut" the pyramid shape. That proved to be quite the nuisance so I > decided to use the epsilon function to draw the shape instead. Any ideas > what the best way might be? > > > Anyway, attempting to draw a simple circle using the epsilon function > gives me segmentation fault, please see the code below: > > import meep as mp > import numpy as np > import matplotlib.pyplot as plt > import math as math > > sxy=10 > resolution=10 > cell=mp.Vector3(sxy,sxy,0) > > def epsilon_function(vector): > > if vector.unit() < 1: > > return mp.Medium(epsilon=2) > > else: > > return mp.Medium(epsilon=1) > > sim=mp.Simulation(cell_size=cell, > #geometry=geometry, > epsilon_func=epsilon_function, > resolution=resolution) > > sim.run(until=1) > > eps_data = sim.get_array(center=mp.Vector3(), size=cell, > component=mp.Dielectric) > plt.figure(dpi=100) > plt.imshow(eps_data.transpose(), interpolation='spline36', cmap='binary') > plt.axis('on') > plt.show() > > Any help would be greatly appreciated > > Karl-Johan > > > > _______________________________________________ > meep-discuss mailing list > meep-discuss@ab-initio.mit.edu > http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss >
_______________________________________________ meep-discuss mailing list meep-discuss@ab-initio.mit.edu http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss