4#include "../../../catch2/catch.hpp"
6#define MX_NO_ERROR_REPORTS
18namespace unitTest::ao_sim_turbSubHarmonic_test
28TEST_CASE(
"turbSubHarmonic generates cosine and sine quadratures",
"[ao::sim::turbSubHarmonic]" )
34#ifdef MXLIB_BUILD_COVERAGE
35 constexpr uint32_t wfSz = 32;
36 constexpr uint32_t scrnSz = 64;
37 constexpr size_t trials = 8;
38 constexpr realT tiltRatioMargin = 0.5;
40 constexpr uint32_t wfSz = 64;
41 constexpr uint32_t scrnSz = 192;
42 constexpr size_t trials = 128;
43 constexpr realT tiltRatioMargin = 0.35;
51 atmosphereT atmosphere;
52 atmosphere.setup( wfSz, 0, &aosys, 1 );
53 atmosphere.setLayers( scrnSz );
56 preCalculated.
turbAtmo( &atmosphere );
57 preCalculated.
level( 1 );
72 atmosphere.normVar().seed( 12345 );
74 preCalculated.
screen( preScreen );
75 atmosphere.normVar().seed( 12345 );
76 directScreen.setZero();
77 direct.
screen( directScreen );
79 REQUIRE( ( preScreen - directScreen ).abs().maxCoeff() < 1e-12 );
81 realT xTiltMeanSq{ 0 };
82 realT yTiltMeanSq{ 0 };
83 for(
size_t trial = 0; trial < trials; ++trial )
86 preCalculated.
screen( preScreen );
90 for( uint32_t jj = 0; jj < scrnSz; ++jj )
92 realT y = jj - 0.5 * ( scrnSz - 1 );
93 for( uint32_t ii = 0; ii < scrnSz; ++ii )
95 realT x = ii - 0.5 * ( scrnSz - 1 );
96 xTilt += x * preScreen( ii, jj );
97 yTilt += y * preScreen( ii, jj );
101 xTiltMeanSq += xTilt * xTilt;
102 yTiltMeanSq += yTilt * yTilt;
105 xTiltMeanSq /= trials;
106 yTiltMeanSq /= trials;
108 REQUIRE( xTiltMeanSq > 1e-6 );
109 REQUIRE( yTiltMeanSq > 1e-6 );
110 REQUIRE( xTiltMeanSq / yTiltMeanSq == Approx( 1.0 ).margin( tiltRatioMargin ) );
Declares and defines an analytical AO system.
void setSingleLayer(realT r0, realT lam0, realT L0, realT l0, realT lz, realT vw, realT dir)
Set a single layer model.
Describes an analytic adaptive optics (AO) system.
void D(realT nD)
Set the value of the primary mirror diameter.
void lam_sci(realT nlam)
Set the science wavelength.
A class to manage low-frequency sub-harmonic phase screen generation in atmospheric turbulence.
void outerSubHarmonics(bool osh)
Set whether or not the outer subharmonics are included.
void turbAtmo(turbAtmosphereT *atm)
Set the pointer to the turbulent atmosphere.
void preCalc(bool pc)
Set whether or not to pre-calculate the modes.
void level(uint32_t ml)
Set the subharmonic level to apply.
void initGrid(uint32_t layerNo)
Allocate needed memory and initialize the subharmonic transform.
void screen(improc::eigenImage< realT > &scrn)
Generate a realization of the subharmonic phase screen and add it to the input screen.
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
TEST_CASE("turbSubHarmonic generates cosine and sine quadratures", "[ao::sim::turbSubHarmonic]")
Verifies real quadrature subharmonics generate isotropic nonzero tilt variance.
AO-system test type that forces local template instantiation under sanitizers.
A turbulent atmosphere simulator.
Declaration and definition of a turbulent atmosphere.
A class to manage low-frequency sub-harmonic phase screen generation in atmospheric turbulence.