(self, curfield_type, fname_prefix, output_k, component)
| 666 | f["c.i"] = np.imag(reshaped_field) |
| 667 | |
| 668 | def _output_vector_field(self, curfield_type, fname_prefix, output_k, component): |
| 669 | components = ["x", "y", "z"] |
| 670 | kpoint_index = self.mode_solver.get_kpoint_index() |
| 671 | curfield_band = self.mode_solver.curfield_band |
| 672 | fname = f"{curfield_type}.k{kpoint_index:02d}.b{curfield_band:02d}" |
| 673 | |
| 674 | if component >= 0: |
| 675 | fname += f".{components[component]}" |
| 676 | |
| 677 | description = "{} field, kpoint {}, band {}, freq={:.6g}".format( |
| 678 | curfield_type, kpoint_index, curfield_band, self.freqs[curfield_band - 1] |
| 679 | ) |
| 680 | |
| 681 | fname = self._create_fname(fname, fname_prefix, True) |
| 682 | if verbosity.mpb > 0: |
| 683 | print(f"Outputting fields to {fname}...") |
| 684 | |
| 685 | with h5py.File(fname, "w") as f: |
| 686 | f["description"] = description.encode() |
| 687 | f["Bloch wavevector"] = np.array(output_k) |
| 688 | self._write_lattice_vectors(f) |
| 689 | |
| 690 | if curfield_type != "v": |
| 691 | self.mode_solver.multiply_bloch_phase() |
| 692 | |
| 693 | for c_idx, c in enumerate(components): |
| 694 | if component >= 0 and c_idx != component: |
| 695 | continue |
| 696 | |
| 697 | dims = self.mode_solver.get_dims() |
| 698 | field = np.empty(np.prod(dims) * 3, np.complex128) |
| 699 | self.mode_solver.get_curfield_cmplx(field) |
| 700 | component_field = field[c_idx::3].reshape(dims) |
| 701 | |
| 702 | name = f"{c}.r" |
| 703 | f[name] = np.real(component_field) |
| 704 | name = f"{c}.i" |
| 705 | f[name] = np.imag(component_field) |
| 706 | |
| 707 | def _output_scalar_field(self, curfield_type, fname_prefix): |
| 708 | components = ["x", "y", "z"] |
no test coverage detected