Skip to content

Source slice#646

Closed
HomerReid wants to merge 14 commits intoNanoComp:masterfrom
homerredux:source_slice
Closed

Source slice#646
HomerReid wants to merge 14 commits intoNanoComp:masterfrom
homerredux:source_slice

Conversation

@HomerReid
Copy link
Contributor

The pure-text format of problem definitions in meep is very convenient for scripting, but without visual confirmation of the geometry you specified it can be easy to make inadvertent errors in e.g. the placement and size of geometrical entities. Visualization of the material geometry (e.g. output_epsilon) has been supported for a long time, but I wasn't aware of any similar functionality for source distributions. In addition to offering a useful sanity check on text-format input files, the ability to visualize the locations and amplitudes of sources may prove useful for analyzing the more complicated source distributions that arise in applications such as adjoint-based sensitivity analysis.

This PR extends the existing array_slice protocol, used thus far for field-component arrays, to the acquisition of source-component arrays. It adds a new routine named get_source_slice to the python and C++ interfaces, which is handled internally by adding a new branch to the existing do_get_array_slice master routine in array_slice.cpp. The C++ and python calling conventions are similar to those for get_array_slice / get_array: the user inputs a Volume and gets back a multidimensional array describing sources at the grid points it encompasses. The specific significance of the entries in the array depend on the input parameter source_slice_type, with 4 possibilities currently supported:

source_slice_type Significance of entries in source_slice array
Re Ex Real part of x-directed electric current amplitude
Im Hz Imag part of y-directed magnetic current amplitude
norm Sum of squared magnitudes of all source components
indicator Binary indicator: 1 or 0 for points with/without sources

As anticipated in the comments to #635, one use for source_slice functionality is to verify the implementation of sources defined by geometric_objects.. In python/examples/object_source.py I have put a somewhat contrived example code that illustrates bothgeometric_object_sources and source_slices. The code simply creates a geometry with three distinct source distributions--one conventional source defined by a Volume and two sources defined by geometric_objects (one Cylinder and one Prism)--and captures various types of source_slice to visualize aspects of the source distributions, which involve spatially-varying complex amplitudes in addition to the positional restrictions imposed by the defining geometric_objects.
source_slices

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 82.142% when pulling 898c311 on HomerReid:source_slice into 5be326d on stevengj:master.

Makefile.am Outdated
endif
#if WITH_LIBCTL
# SUBDIRS += scheme
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be uncommented

| `Re Ex` | Real part of *x*-directed electric source amplitude
| `Im Hy` | Imaginary part of *y*-directed magnetic source amplitude
| `norm` | Sum of squared magnitudes of all source components of all field types
| `indicator` | Binary indicator function: 1 if any source component has nonzero amplitude, 0 otherwise
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems more consistent with the other APIs if you just pass a component Ex, Hy, etcetera, and it gives you a complex array. Any other computations can be done in post-processing.

src/meep.hpp Outdated
public:
virtual ~source_indicator()=0;
virtual bool point_in_source(const vec &p)=0;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like PR #635 leaked into this PR. Can we separate the two?

@stevengj
Copy link
Collaborator

Looks good modulo the three comments above.

@stevengj stevengj closed this in #652 Jan 7, 2019
stevengj pushed a commit that referenced this pull request Jan 7, 2019
* updates

* updates

* updates

* updates

* updates

* updates

* updates

* updates

* source_slice

* updates

* removed overlap with geometric_object_source branch, uncommented out scheme inclusion from makefile.am

* Replace get_source_slice parsing with just component

* Update docs

* no need for slice_component!=Permeability
bencbartlett pushed a commit to bencbartlett/meep that referenced this pull request Sep 9, 2021
…mp#652)

* updates

* updates

* updates

* updates

* updates

* updates

* updates

* updates

* source_slice

* updates

* removed overlap with geometric_object_source branch, uncommented out scheme inclusion from makefile.am

* Replace get_source_slice parsing with just component

* Update docs

* no need for slice_component!=Permeability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants