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

Method _get_field

python/solver.py:399–430  ·  view source on GitHub ↗
(self, f, band, bloch_phase)

Source from the content-addressed store, hash-verified

397 self.mode_solver.compute_field_divergence()
398
399 def _get_field(self, f, band, bloch_phase):
400 if self.mode_solver is None:
401 raise ValueError(
402 "Must call a run function before attempting to get a field"
403 )
404
405 if f == "b":
406 self.mode_solver.get_bfield(band)
407 elif f == "d":
408 self.mode_solver.get_dfield(band)
409 elif f == "e":
410 self.mode_solver.get_efield(band)
411 elif f == "h":
412 self.mode_solver.get_hfield(band)
413
414 dims = self.mode_solver.get_dims()
415
416 while len(dims) < 3:
417 dims += [1]
418
419 dims += [3]
420 arr = np.zeros(np.prod(dims), np.complex128)
421
422 if bloch_phase:
423 self.mode_solver.multiply_bloch_phase()
424
425 self.mode_solver.get_curfield_cmplx(arr)
426
427 arr = np.reshape(arr, dims)
428 return MPBArray(
429 arr, self.get_lattice(), self.current_k, bloch_phase=bloch_phase
430 )
431
432 def get_curfield_as_array(self, bloch_phase=True):
433 dims = self.mode_solver.get_dims()

Callers 4

get_bfieldMethod · 0.95
get_efieldMethod · 0.95
get_dfieldMethod · 0.95
get_hfieldMethod · 0.95

Calls 9

get_latticeMethod · 0.95
MPBArrayClass · 0.85
get_dimsMethod · 0.80
get_curfield_cmplxMethod · 0.80
get_bfieldMethod · 0.45
get_dfieldMethod · 0.45
get_efieldMethod · 0.45
get_hfieldMethod · 0.45
multiply_bloch_phaseMethod · 0.45

Tested by

no test coverage detected