MAOS
Multithreaded Adaptive Optics Simulator
Loading...
Searching...
No Matches
sim.h File Reference

Functions

void * perfevl_ievl (thread_t *info)
void * perfevl (sim_t *simu)
void prep_cachedm (sim_t *simu)
void calc_cachedm (sim_t *simu)
void filter_dm (sim_t *simu)
void update_dm (sim_t *simu)
void * wfsgrad (sim_t *simu)
void * wfsints (thread_t *thread_data)
void wfs_ideal_atm (sim_t *simu, dmat *opd, int iwfs, real alpha)
void * wfsgrad_iwfs (thread_t *info)
void * wfsgrad_post (thread_t *info)
void filter_fsm (sim_t *simu)

Detailed Description

Contains main simulation blocks.

Function Documentation

◆ perfevl_ievl()

void * perfevl_ievl ( thread_t * info)

Performance evaluation for each direction in parallel mode.

Parameters
[in,out]infoThread info. info->data is the simulation struct and [info->start, info->end) is the range of directions.
Returns
NULL.

◆ perfevl()

void * perfevl ( sim_t * simu)

Peformance evaluation on science FoV.

Evaluate performance by calling perfevl_ievl in parallel and then calls perfevl_mean to field average. Notice that the science FoV can be different from the DM fitting FoV, which is tuned to better sharpen the NGS

Todo
Write a standalone routine that can plot results, using techniques developped in drawdaemon.
Parameters
[in,out]simuThe simulation struct.
Returns
NULL.

◆ prep_cachedm()

void prep_cachedm ( sim_t * simu)

Prepares the DM caching structs that caches DM on fine sampled grid to speed up ray tracing with linear interpolation.

Because the DM has coarse sampling, and cubic influence functions, directly interpolate from the DM to the WFS and science OPD takes a lot of computation. We can speed up this process by first propagating the DM commands to a square grid that matches the sampling of the WFS or science OPD, and then propagate from the square grid to different WFS or science directions. For each sampling and each DM, we only need one fine sampled square grid that will cover all the different directions in the FoV of the WFSs or science. For the ground DM, we need a plane of 1/64m sampling that matches the WFS and science OPD. For the upper DM, we need to two planes, one at 1/64m for the LGS WFS and science OPD, and another one at 1/64 m (1-11.2/90) for the LGS due to cone effect. The square grid are on axis.

Parameters
[in,out]simuSimulation data. The DM cache grid and ray tracing threads are created.

◆ calc_cachedm()

void calc_cachedm ( sim_t * simu)

Partition the ray tracing by DM/Destination combinations, as well as segments in each combination to maximum efficiency.

Parameters
[in,out]simuSimulation data. The DM cache is updated from the current DM commands.

◆ filter_dm()

void filter_dm ( sim_t * simu)

Does the servo filtering by calling filter_cl() or using the open loop error directly.

Parameters
[in,out]simuSimulation data.

◆ update_dm()

void update_dm ( sim_t * simu)

Update various quantities upon updating dmreal.

Parameters
[in,out]simuSimulation data.

◆ wfsgrad()

void * wfsgrad ( sim_t * simu)

Calls wfsgrad_iwfs() to computes WFS gradient in parallel. It also includes operations on Gradients before tomography.

Parameters
[in,out]simuSimulation data.
Returns
NULL.

◆ wfsints()

void * wfsints ( thread_t * thread_data)

compute physical optics images and add to ints. be careful that fftw inverse fft doesn't have 1/n^2 scaling. this function lives inside the threading routine wfsgradx

Notice that the uplink have to have the same spatial sampling as the subaperture (dx). uplink psf has sampling lambda/(nlwvf*dx) subaperture has sampling lambda/(nwvf*dx) uplink otf has the sampling dx/lambda sampling as subaperture.

WHen notf is bigger than nwvf*embfac, the PSF is embeded which preserves the sampling. The uplink OTF need to be upsampled to dx/lambda *(nwvf/notf)

Parameters
[in,out]thread_dataThread data; data is a wfsints_t whose ints and pistatout are accumulated for subapertures from start to end.
Returns
NULL.

◆ wfs_ideal_atm()

void wfs_ideal_atm ( sim_t * simu,
dmat * opd,
int iwfs,
real alpha )

Propagate only controllable component of turbulence to WFS.

Parameters
[in]simuSimulation data.
[in,out]opdWFS OPD to accumulate into.
[in]iwfsIndex of the WFS.
[in]alphaScaling factor.

◆ wfsgrad_iwfs()

void * wfsgrad_iwfs ( thread_t * info)

computes close loop and pseudo open loop gradidents for both gometric and physical optics WFS. Calls wfsints() to accumulate WFS subapertures images in physical optics mode.

Parameters
[in]infoThread data; info->data is sim_t, which is updated, and info->start is the WFS index.
Returns
NULL.

◆ wfsgrad_post()

void * wfsgrad_post ( thread_t * info)

Post process gradients of each WFS (scaling, offset, saving and plotting). Every operation here should be in the Simulator not the Controller.

Parameters
[in]infoThread data; info->data is sim_t, which is updated, and WFS start to end are processed.
Returns
NULL.

◆ filter_fsm()

void filter_fsm ( sim_t * simu)

Servo filter for FSM commands.

Parameters
[in,out]simuSimulation data.