|
12 | 12 |
|
13 | 13 | from .field import Field |
14 | 14 | from .logger import Logger |
15 | | -from .materials import material_colors |
| 15 | +from .materials import material_colors, material_lib |
16 | 16 |
|
17 | 17 | try: |
18 | 18 | from mpi4py import MPI |
@@ -310,6 +310,7 @@ def mpi_gather_asGrid(self): |
310 | 310 | return _grid |
311 | 311 |
|
312 | 312 | def _prepare_stl_dicts(self): |
| 313 | + #Ensure all the stl data is stored in dicts |
313 | 314 | if type(self.stl_solids) is not dict: |
314 | 315 | if type(self.stl_solids) is str: |
315 | 316 | self.stl_solids = {'Solid 1' : self.stl_solids} |
@@ -355,6 +356,25 @@ def _prepare_stl_dicts(self): |
355 | 356 | self._assign_colors() |
356 | 357 | print('[!] If `stl_colors` is a list, it must have the same length as `stl_solids`.') |
357 | 358 |
|
| 359 | + if type(self.stl_materials) is not dict: |
| 360 | + if type(self.stl_materials) is str: |
| 361 | + self.stl_materials = {'Solid 1' : self.stl_materials} |
| 362 | + else: |
| 363 | + raise Exception('Attribute `stl_materials` must contain a string or a dictionary') |
| 364 | + |
| 365 | + for key in self.stl_solids.keys(): |
| 366 | + # if keys are str, convert to array using material library |
| 367 | + if type(self.stl_materials[key]) is str: |
| 368 | + mat_key = self.stl_materials[key].lower() |
| 369 | + eps_r = material_lib[mat_key][0] |
| 370 | + mu_r = material_lib[mat_key][1] |
| 371 | + |
| 372 | + self.stl_materials[key] = [eps_r, mu_r] |
| 373 | + |
| 374 | + if len(material_lib[mat_key]) == 3: |
| 375 | + sigma = material_lib[mat_key][2] |
| 376 | + self.stl_materials[key].append(sigma) |
| 377 | + |
358 | 378 | def _mark_cells_in_stl(self): |
359 | 379 | # Obtain masks with grid cells inside each stl solid |
360 | 380 | stl_tolerance = np.min([self.dx, self.dy, self.dz])*self.stl_tol |
@@ -655,8 +675,8 @@ def plot_solids(self, bounding_box=False, show_grid=False, anti_aliasing=None, |
655 | 675 | pl.add_mesh(self.grid, opacity=0., name='grid', show_scalar_bar=False) |
656 | 676 | for key in self.stl_solids: |
657 | 677 | color = self.stl_colors[key] |
658 | | - if self.stl_materials[key] == 'vacuum': |
659 | | - _opacity = 0.3 |
| 678 | + if self.stl_materials[key] == [1.0, 1.0, 0.0] or self.stl_materials[key] == [1.0, 1.0]: |
| 679 | + _opacity = 0.3 # vacuum |
660 | 680 | else: |
661 | 681 | _opacity = opacity |
662 | 682 | pl.add_mesh(self.read_stl(key), color=color, |
|
0 commit comments