The Durham Adaptive Optics Simulation Platform (DASP): Current status

The Durham Adaptive Optics Simulation Platform (DASP) is a Monte-Carlo modelling tool used for the simulation of astronomical and solar adaptive optics systems. In recent years, this tool has been used to predict the expected performance of the forthcoming extremely large telescope adaptive optics systems, and has seen the addition of several modules with new features, including Fresnel optics propagation and extended object wavefront sensing. Here, we provide an overview of the features of DASP and the situations in which it can be used. Additionally, the user tools for configuration and control are described.

The Durham adaptive optics (AO) simulation platform (DASP) has been under development since the early 1990s. Its current framework was established in 2006 to meet the challenges of modelling the forthcoming extremely large telescopes, with primary mirror diameters of over 20 m. Since 2006, DASP has been regularly developed to improve computational performance, increase simulation fidelity, and expand the number of features that can be modelled. It uses a modular design, allowing new developments and algorithms to be added whilst maintaining compatibility. DASP is developed primarily in Python and C, and uses pthreads and

Motivation and significance
The Earth's atmosphere has a perturbing effect on incident starlight, meaning that the effective spatial resolution of large telescopes (typically anything larger than 20 cm diameter) is limited. By using AO systems, the distorted wavefronts of incident light can be measured and have a correction applied so that the effective resolution is improved, thus enabling scientific observations to be made. Designing an AO system to meet complex scientific requirements is an involved process, and modelling of the system performance is necessary. Additionally, investigation of new algorithms, techniques and concepts also requires verification by simulation.

Scientific contribution of DASP
DASP was developed to meet the needs of AO system designers, and has previously been used to model the expected performance of several of the forthcoming Extremely Large Telescope (ELT) instruments, including MOSAIC [1,2], MAORY [3] and HIRES. Recent developments have also introduced an extended object (wide field-of-view) wavefront sensor module, enabling DASP to be used for the modelling of solar AO systems (e.g. European Solar Telescope [4]). Additionally, existing instruments have also been modelled to demonstrate that proposed novel techniques can improve the AO system performance [5,6]. DASP enables AO system designers to explore the large parameter spaces associated with AO system development, allowing system design trade-offs to be made in an informed manner, with typical parameters including AO system order, number of guide stars, and wavefront sensor pixel scale. DASP is used to design and optimize new AO systems, and to verify performance of existing systems. DASP can be a crucial tool for understanding the AO error budget, allowing cost-effective decisions to be made about the design optimizations that can be performed to allow a given design to meet its required performance targets.
DASP has seen adoption within the AO community, and is now used for forthcoming ELT instruments [3,7], for the 10.4 m Gran Telescopio Canarias, the Kunlun Dark Universe Survey Telescope [8], the Chinese 2.16 m telescope [9] and for the proposed 12 m Chinese Large Optical Telescope.

Using DASP
DASP can be operated on any Linux computer, and also under the OS-X operating system. Once installed, the user will typically generate a new simulation configuration using the daspbuilder tool, which allows the user to select a number of configuration options covering most AO configurations, including single conjugate AO (SCAO), multi-conjugate adaptive optics (MCAO), ground layer AO (GLAO), laser tomographic AO (LTAO) and multi-object AO (MOAO). This generates the necessary configuration files, which can then be edited by the user. Alternatively, for more complex simulations, a daspsetup tool can be used to graphically design an AO system. This simulation is then executed to model AO performance. A further description of DASP usage is given in Section 3

Other AO simulations
There are a number of other Monte Carlo AO simulation tools freely available to the community, including YAO [10], CAOS [11], SOAPY [12], MAOS [13] and OOMAO [14]. OCTOPUS [15] is another Monte Carlo AO simulation tool, which is available from the European Southern Observatory upon request. However, none of these offer the combined performance and extended object wavefront sensing capabilities of DASP. In addition, a number of analytical modelling tools also exist, including PAOLA [16] and CIBOLA [17], though these tools are used for rapid prototyping and do not offer high fidelity.

Software description
DASP is comprised of a number of science modules, which model discrete parts of an AO system. These include wavefront between different science modules that create a simulation. This tool can be used to configure an initial simulation, which is then executed from the command line. Configuration of an AO simulation can be complicated when parallelization across multiple computing nodes is required, and the graphical tool simplifies this task. sensors (including Shack-Hartmann and Pyramid sensors), deformable mirrors (including zonal and modal), atmospheric models, wavefront reconstruction modules, and astronomical object models. This modular design means that it is also possible for the user to add modules which can then be used during a simulation (for example, another wavefront sensor type). These science modules are linked together to represent the flow of information through the AO system, as shown in Fig. 1.
DASP also contains a number of utility modules, which are used by the science modules, containing the necessary algorithms required by the simulation. User tools are also included, to analyse and display results, to communicate with running simulations, and to configure initial simulations. DASP offers good performance on laptops (for simulation of smaller scale systems, typically up to 10 m class diameter telescopes); and also HPC facilities for ELT modelling. Inter-node communication is based on the Message Passing Interface (MPI).
Once a simulation has been configured, it is run from the command line. After a set number of iterations (typically several thousand, depending on AO system type), the simulation then finishes, providing the user with AO performance metrics. Each iteration represents one simulation time-step, typically set by the integration time of wavefront sensors, of order 1 ms. It is usually necessary to model tens of seconds of real time in order to ensure that results are statistically valid. The simulation will typically run between 10-1000 times slower than real-time, depending on scale and complexity, though a simple system on a small (4 m) telescope can operate faster than real-time.
Using computationally efficient code allows large AO-related parameter spaces to be explored within reasonable timescales. For example, a typical ELT-scale wide-field AO simulation can be completed within about 12 h on a single server, where previously this would have taken many days to complete. This includes the required system calibrations (e.g. interaction matrix generation and reference slope computation), for a system with 6 laser guide stars each with 80 × 80 sub-apertures and a control matrix of size 10 GB, with sufficient temporal averaging to smooth the atmospheric turbulence effect (approximately 1 min of AO system time).
Top level modules are written in Python, which allows rapid development of new algorithms and modules, enabling users to tailor DASP for their own use. While a simulation is running, it can be queried and modified using both command line and graphical tools, useful for when initially configuring a simulation. It also provides a way of rapidly determining stability conditions for an AO simulation before further extensive parameter space exploration.

Software architecture
The DASP top-level directory structure separates the simulation into logical components: • base/ containing simulation glue modules with no scientific component.
• cmod/ containing C code used to accelerate the simulation. • docs/ containing documentation (including auto-generated API and user documentation).
• gui/ containing graphical user interfaces for simulation creation and control.
• science/ containing simulation science modules which represent a discrete part of an AO system.
• util/ containing utility modules with algorithms required by the simulation, which can also be used from a Python terminal by the user.
The science modules are used to form the structure of a simulation, and represent physical components. These all inherit from a base object providing a number of virtual methods to be inherited, which are called during initialization and for every iteration of the running simulation. The science modules can also import components from the util/ and cmod/ directories, which provide necessary algorithms and improved computational performance. The base directory also contains glue modules, for example to handle MPI connection and modules without scientific content, such as First In First Out (FIFO) buffers. Fig. 2 provides an overview of the relationship between DASP components.
A main DASP control object is instantiated, parses command line arguments and loads the specified configuration files. This object has a main control loop method, which is passed a list of instantiated base and science objects. These are then iterated over, calling the methods to compute the next iteration for each object.

Interaction and control
The control object also includes a communication thread which is used to allow external (user) connections to the running simulation. These connections can then be used to query and modify internal state, for example to alter the loop gain factor, pause the simulation, or to extract the current instantaneous AO system performance. This means that DASP can be used remotely on server computers, and that multiple simulations can be executed simultaneously, allowing the user to interact and connect to several simultaneously executing (independent) simulations. This allows a parameter space to be explored more rapidly. Additionally, multiple users can connect to a simulation simultaneously, to allow interaction and knowledge sharing.

Configuration
A DASP simulation structure is stored as an XML file, describing the links between the different science modules, and relevant multi-processor information (for example, on which process different science modules should be run, in the case of a multi-node simulation). This XML file is created using daspbuilder (command line) or daspsetup (graphical), and is then automatically parsed to generate a Python script.
A DASP simulation also requires one or more Python-based parameter files, which specify relevant parameters, dimension the system, and determine the outputs to be produced. The parameter file names are passed as command line parameters. The use of Python allows dynamic calculation of variables before execution, e.g. automated loading of external data files, and parsing of contents without requiring additional software tools.

Software functionalities
The functionality of DASP is provided by the science modules. These include: • Atmospheric phase screen generation: The atmosphere is modelled as a number of thin perturbing layers, which modify incident wavefront phase. A zonal extrusion technique is used [18] allowing screens of infinite length to be produced.
• Pupil phase generation: The perturbing phase introduced along a specified line of sight are identified and summed to give the perturbing phase at the telescope pupil, for this particular direction. Within DASP, both geometric ray tracing and Fresnel propagation can be used. Ray tracing is more computationally efficient and is the default option, though where high fidelity is important (e.g. photometry) Fresnel propagation should be selected, as scintillation effects are included. • Deformable mirrors: A deformable mirror is a key component in an AO system, used to mitigate the turbulent phase, with a surface shape that is commanded by the AO control system to match the predicted wavefront phase perturbation as closely as possible. Both modal and zonal deformable mirror (DM) models are available. Zonal DM models include influence function and interpolated DMs (with spline interpolation between actuators to create the DM surface). An AO system may contain multiple DMs. A magic DM is also available, which corrects wavefront phase up to a set modal order without requiring a wavefront sensor.
• Wavefront sensor and centroider: A wavefront sensor is used to estimate the perturbing wavefront phase along a particular line of sight, in the direction of a guide star. Within DASP, Shack-Hartmann and Pyramid sensors can be used, and include aspects such as noise, pixel scale, thresholding and various image processing techniques. The wavefront gradients are estimated by the centroiding component, which can use a number of algorithms, including centre of gravity or correlation.
• Reconstructor: A wavefront reconstructor module is responsible for conversion between wavefront gradient measurements to DM shape. Multiple reconstructor algorithms are available, including dense matrix multiplication (including least squares and minimum variance approaches), sparse matrix multiplication using a de-densified control matrix (as studied in [19]), conjugate gradient solvers with preconditioning, and algorithmic reconstructors, e.g. the Hierarchical Wavefront Reconstructor (HWR) [20].
• Point spread function (PSF) generation: The point spread function (PSF) provides an instantaneous and long term (integrated) performance metric along a given line of sight, and is essential for diagnosing AO system capabilities.
• Extended object (wide-field) imaging and wavefront sensing: Most AO simulations consider a single line of sight for each wavefront sensor or PSF. However, DASP contains an extended object module which is able to consider directions within a set field of view simultaneously, enabling high fidelity modelling of solar AO systems, and those with extended laser guide star (LGS) spots.
• Real-time simulation: DASP contains a module which allows linkage to a real-time control system, the Durham AO Real-time Controller (DARC) [21,22]. This therefore allows on-sky systems to be modelled, and algorithms within a real-time control system tested and developed, significantly reducing on-sky commissioning time. This hardware-inthe-loop capability is crucial for the forthcoming ELTs.
Additionally, the utility library also provides useful AO-related functions, including Zernike mode generation, pixel scale computation, point spread function (PSF) generation, etc.

Parsing results
Running a large number of simulations will generate a significant volume of performance data. Therefore DASP includes tools to allow the user to parse these data and extract relevant parameters into formats that can be used for further processing, analysis and display.

Illustrative examples
DASP provides the ability to flexibly create high fidelity simulations of AO systems. Fig. 3 shows a simulated solar AO wavefront sensor, demonstrating the extended object wavefront sensing capability of DASP. A video of this wavefront sensor is also available from SoftwareX. A closed loop solar SCAO simulation is presented in Appendix A. First, the relevant modules are imported and simulation initialization is performed, including instructions to perform initial calibrations (as with a real AO system). The science modules are then instantiated, and finally the main loop is entered.
This code (along with the associated parameter file) will then generate an output file which contains PSF information such as the Strehl ratio, FWHM, ensquared energy, PSF diameter enclosing 50% of energy and rms wavefront error. The PSF itself can also be saved.

Hardware-in-the-loop example
As discussed previously, DASP can be linked with an AO realtime control system to provide a hardware-in-the-loop simulation capability. Fig. 4 shows the simulation configuration that is used with the CANARY AO instrument [23], and is an illustrative example of how DASP can be used in real-world situations to significantly reduce on-sky commissioning time [6]. In this case, DASP is used to model the atmosphere, telescope, and AO system optics, providing input to the CANARY real-time control system, and updating the model in response to real-time control system outputs.

Conclusions
DASP is a modular and flexible Monte-Carlo simulation tool for AO systems. It offers high fidelity modelling with good computational performance. DASP is suitable for use at forthcoming extremely large telescope scales, yet also offers the ability to rapidly prototype and test new algorithms and concepts. DASP has been used for simulation of both existing and forthcoming AO systems, and has been verified against other AO simulation codes [19].