I have been using MIT's MEEP for simulation of THz frequency light transmission in silicon photonics. I needed to make an array of flux detectors in MIT's MEEP so that I wouldn't have to write many (add-flux) blocks of code.
Scheme's map seemed like a good solution, yet, despite there being many people in many forums searching for a way to do this, an implementation of such code is sparse online. Thus, I wanted to share a way of doing it.
In the documentation on the MEEP wiki, adding flux detectors is done in the follow fashion:
(define-param fcen 0.25) ; pulse center frequency
(define-param df 0.4) ; pulse width (in frequency)
(define-param nfreq 4001) ; number of frequencies at which to compute flux
(define refl-det ; reflection detector
(add-flux freq_c pulse_width num_freqs
(make flux-region
(center some-x some-y)
(size 1 0))))
(define trans-det ; transmission detector
(add-flux freq_c pulse_width num_freqs
(make flux-region
(center some-other-x some-other-y)
(size 1 0))))
;;...;; code for running sources
(display-fluxes refl-det trans-det) ; MEEP's function for outputting flux for frequencies
So, if I want 20 transmission detectors and 20 reflection detectors, I would have to define 40 blocks by hard coding them...not good.
There are many variants which can be made on this code. The one presented below is for detectors in a straight line. It is also possible to implement one for detectors placed in a circular arrangement; however, that requires calculating your angles in another function and adding another variable to the detectors function.
The most important thing to remember is that the detectors must be contained in a list. Map by its nature makes a list, so this is why you don't define a list in the "detectors" function. Append just joins all of the lists into a bigger list. And you have to use "apply" for "display-fluxes" because you are using it on a list, not directly within the function. Hope this helps!