From e98e8bfbb534c9560ff9cfa991adc124357452ec Mon Sep 17 00:00:00 2001 From: Helge Gehring Date: Tue, 29 Dec 2020 10:59:12 +0100 Subject: [PATCH] meep-simulation: fixed heights --- gdshelpers/simulation/simulation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdshelpers/simulation/simulation.py b/gdshelpers/simulation/simulation.py index 7ba0fda..01c8221 100644 --- a/gdshelpers/simulation/simulation.py +++ b/gdshelpers/simulation/simulation.py @@ -66,7 +66,8 @@ def init_sim(self, **kwargs): :param kwargs: Parameters which are directly passed to Meep """ - z_min, z_max = [np.min([structure[z_] for structure in self.structures]) for z_ in ['z_min', 'z_max']] + z_min = np.min([structure['z_min'] for structure in self.structures]) + z_max = np.max([structure['z_max'] for structure in self.structures]) bounds = geometric_union((geometric_union(x['structure']) for x in self.structures)).bounds size = np.array((bounds[2] - bounds[0], bounds[3] - bounds[1], (z_max - z_min))) @@ -87,8 +88,7 @@ def init_sim(self, **kwargs): for polygon in fracture_intelligently(obj, np.inf, np.inf): structures += [ mp.Prism(vertices=[ - mp.Vector3(*point, - 0 if self.reduce_to_2d else (structure['z_max'] + structure['z_min']) / 2) + mp.Vector3(*point, 0 if self.reduce_to_2d else structure['z_min']) for point in polygon.exterior.coords[:-1]], material=structure['material'], height=structure['z_max'] - structure['z_min'])]