Module Development

The topics in this part focus on developing modules (as in writing a module, not as in developing the Module class). For concreteness, the documentation in this section assumes we are writing a module that computes the electric field at a point \(\vec{r}\), \(\vec{E}\left(\vec{r}\right)\), arising from a set of \(N\) point charges. Physically speaking, up to some constants, \(\vec{E}\left(\vec{r}\right)\) is given by:

\[\vec{E}(\vec{r}) = \sum_{i=1}^N \frac{q_i \hat{r}_i} {||\vec{r} - \vec{r}_i||^2}\]

where \(q_i\) is the charge of the \(i\)-th point charge, \(\vec{r}_i\) is a unit vector in the direction of \(\vec{r}_i\), and the \(i\)-th point charge is located at \(\vec{r}_i\). We further assume that there is a header file point_charge.hpp which defines the class PointCharge given by:

#pragma once
#include <array>

namespace pluginplay_examples {

using Point = std::array<double, 3>;

struct PointCharge {
    double m_charge;
    Point m_r;
};

} // namespace pluginplay_examples

and that the header file electric_field.hpp defines a property type ElectricField with an API:

Point ElectricField(Point, std::vector<PointCharge>);

Here the first argument is the point we are evaluating the electric field at, the second argument is the set of point charges, and the return is the value of the electric field at that point. Designing property types is a separate topic covered (TODO: add link).