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

Method get_source

python/simulation.py:4057–4075  ·  view source on GitHub ↗

Return an array of complex values of the [source](#source) amplitude for `component` over the given `vol` or `center`/`size`. The array has the same dimensions as that returned by [`get_array`](#array-slices). Not supported for [cylindrical coordinates](Python_Tutori

(self, component, vol=None, center=None, size=None)

Source from the content-addressed store, hash-verified

4055 raise ValueError(f"Invalid type of dft object: {dft_swigobj}")
4056
4057 def get_source(self, component, vol=None, center=None, size=None):
4058 """
4059 Return an array of complex values of the [source](#source) amplitude for
4060 `component` over the given `vol` or `center`/`size`. The array has the same
4061 dimensions as that returned by [`get_array`](#array-slices).
4062 Not supported for [cylindrical coordinates](Python_Tutorials/Cylindrical_Coordinates.md).
4063 """
4064 if vol is None and center is None and size is None:
4065 v = self.fields.total_volume()
4066 else:
4067 v = self._volume_from_kwargs(vol, center, size)
4068 dim_sizes = np.zeros(3, dtype=np.uintp)
4069 mp._get_array_slice_dimensions(self.fields, v, dim_sizes, True, False)
4070 dims = [s for s in dim_sizes if s != 0]
4071 arr = np.zeros(
4072 dims, dtype=np.complex64 if mp.is_single_precision() else np.complex128
4073 )
4074 self.fields.get_source_slice(v, component, arr)
4075 return arr
4076
4077 def get_array_metadata(
4078 self, vol=None, center=None, size=None, dft_cell=None, return_pw=False

Callers 1

test_source_sliceMethod · 0.80

Calls 3

_volume_from_kwargsMethod · 0.95
total_volumeMethod · 0.80
get_source_sliceMethod · 0.80

Tested by 1

test_source_sliceMethod · 0.64