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

Method _output_scalar_field

python/solver.py:707–752  ·  view source on GitHub ↗
(self, curfield_type, fname_prefix)

Source from the content-addressed store, hash-verified

705 f[name] = np.imag(component_field)
706
707 def _output_scalar_field(self, curfield_type, fname_prefix):
708 components = ["x", "y", "z"]
709
710 if curfield_type == "n":
711 fname = "epsilon"
712 description = "dielectric function, epsilon"
713 elif curfield_type == "m":
714 fname = "mu"
715 description = "permeability mu"
716 else:
717 kpoint_index = self.mode_solver.get_kpoint_index()
718 curfield_band = self.mode_solver.curfield_band
719 fname = "{}pwr.k{:02d}.b{:02d}".format(
720 curfield_type.lower(), kpoint_index, curfield_band
721 )
722 descr_fmt = "{} field energy density, kpoint {}, band {}, freq={:.6g}"
723 description = descr_fmt.format(
724 curfield_type,
725 kpoint_index,
726 curfield_band,
727 self.freqs[curfield_band - 1],
728 )
729
730 parity_suffix = curfield_type not in "mn"
731 fname = self._create_fname(fname, fname_prefix, parity_suffix)
732 if verbosity.mpb > 0:
733 print(f"Outputting {fname}...")
734
735 with h5py.File(fname, "w") as f:
736 f["description"] = description.encode()
737 self._create_h5_dataset(f, "data")
738 self._write_lattice_vectors(f)
739
740 if curfield_type == "n":
741 for inv in [False, True]:
742 inv_str = "epsilon_inverse" if inv else "epsilon"
743 for c1 in range(3):
744 for c2 in range(c1, 3):
745 self.mode_solver.get_epsilon_tensor(c1, c2, 0, inv)
746 dataname = f"{inv_str}.{components[c1]}{components[c2]}"
747 self._create_h5_dataset(f, dataname)
748
749 if with_hermitian_epsilon() and c1 != c2:
750 self.mode_solver.get_epsilon_tensor(c1, c2, 1, inv)
751 dataname += ".i"
752 self._create_h5_dataset(f, dataname)
753
754 def _write_lattice_vectors(self, h5file):
755 lattice = np.zeros((3, 3))

Callers 1

output_field_to_fileMethod · 0.95

Calls 6

_create_fnameMethod · 0.95
_create_h5_datasetMethod · 0.95
with_hermitian_epsilonFunction · 0.85
get_kpoint_indexMethod · 0.80
get_epsilon_tensorMethod · 0.80

Tested by

no test coverage detected