/*! @page pag_concepts_domain Domain

\section sec_domain Domain Averaging

A _domain_ under PMSCO is a discrete variant of a set of calculation parameters (including the atomic cluster)
that is derived from the same set of model parameters
and that contributes incoherently to the measured diffraction pattern.
A domain may be represented by special domain parameters that are not subject to optimization.

For instance, a real sample may have rotational domains that are not present in the cluster,
changing the symmetry from three-fold to six-fold.
Or, an adsorbate may be present in a number of different lateral configurations on the substrate.
In the first case, it may be sufficient to fold calculated data in the proper way to generate the same symmetry as in the measurement.
In the latter case, it may be necessary to execute a scattering calculation for each possible orientation or a representative number of possible orientations.

PMSCO provides the basic framework to spawn multiple calculations according to the number of domains (cf. \ref sec_tasks).
The actual data reduction from multiple domain to one measurement needs to be implemented on the project level.
This section explains the necessary steps.

1. Your project needs to populate the pmsco.project.Project.domains list.
   For each domain, add a dictionary of domain parameters,  e.g. <code>{'angle_azi': 15.0}</code>.
   At least one domain must be declared in a project, otherwise no calculation is executed.

2. The project may use the domain index of a task to build the cluster and parameter file as necessary.
   The pmsco.project.Project.create_cluster and pmsco.project.Project.create_params methods receive the index of the particular domain in addition to the model parameters.

3. The project combines the results of the calculations for the various domains into one dataset that can be compared to the measurement.
   The default method implemented in pmsco.project.Project just adds up all calculations with customizable weight.
   It uses the special model parameters `wdom1`, `wdom2`, ... (if defined, default 1) to weight each domain.
   If you need more control, override the pmsco.project.Project.combine_domains method and implement your own algorithm.

*/
