MCPcopy Create free account
hub / github.com/NanoComp/meep / init_sim

Method init_sim

python/simulation.py:2458–2519  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2456 self.load_fields_file = load_fields_file
2457
2458 def init_sim(self):
2459 if self._is_initialized:
2460 return
2461
2462 materials = [
2463 g.material for g in self.geometry if isinstance(g.material, mp.Medium)
2464 ]
2465 if isinstance(self.default_material, mp.Medium):
2466 materials.append(self.default_material)
2467 for med in materials:
2468 if (
2469 (med.epsilon_diag.x < 1 and med.epsilon_diag.x > -mp.inf)
2470 or (med.epsilon_diag.y < 1 and med.epsilon_diag.y > -mp.inf)
2471 or (med.epsilon_diag.z < 1 and med.epsilon_diag.z > -mp.inf)
2472 ):
2473
2474 eps_warning = (
2475 "Epsilon < 1 may require adjusting the Courant parameter. "
2476 + "See the 'Numerical Stability' entry under the 'Materials' "
2477 + "section of the documentation"
2478 )
2479 warnings.warn(eps_warning, RuntimeWarning)
2480
2481 if self.structure is None:
2482 self._init_structure(self.k_point)
2483
2484 self.fields = mp.fields(
2485 self.structure,
2486 self.m if self.is_cylindrical else 0,
2487 self.k_point.z if self.special_kz and self.k_point else 0,
2488 not self.accurate_fields_near_cylorigin,
2489 self.loop_tile_base_db,
2490 self.loop_tile_base_eh,
2491 self.bfast_scaled_k,
2492 )
2493
2494 if self.force_all_components and self.dimensions != 1:
2495 self.fields.require_component(mp.Ez)
2496 self.fields.require_component(mp.Hz)
2497
2498 if self.using_real_fields():
2499 self.fields.use_real_fields()
2500 elif verbosity.meep > 0:
2501 print("Meep: using complex fields.")
2502
2503 if self.k_point:
2504 v = (
2505 Vector3(self.k_point.x, self.k_point.y)
2506 if self.special_kz
2507 else self.k_point
2508 )
2509 self.fields.use_bloch(py_v3_to_vec(self.dimensions, v, self.is_cylindrical))
2510
2511 self.add_sources()
2512
2513 for hook in self.init_sim_hooks:
2514 hook()
2515

Callers 15

initialize_fieldMethod · 0.95
meep_timeMethod · 0.95
timestepMethod · 0.95
round_timeMethod · 0.95
phase_in_materialMethod · 0.95
set_boundaryMethod · 0.95
_run_untilMethod · 0.95
_run_sources_untilMethod · 0.95
set_epsilonMethod · 0.95
add_sourcesMethod · 0.95

Calls 10

_init_structureMethod · 0.95
using_real_fieldsMethod · 0.95
add_sourcesMethod · 0.95
load_fieldsMethod · 0.95
Vector3Class · 0.90
py_v3_to_vecFunction · 0.85
fieldsMethod · 0.80
require_componentMethod · 0.80
use_real_fieldsMethod · 0.80
use_blochMethod · 0.45