1 #ifndef TEST_MODECHARACTERIZATION_H 2 #define TEST_MODECHARACTERIZATION_H 18 #include "modecharacterization.h" 24 double volts_sqr_to_dbm(
double voltage ) {
25 return 10.0 * log10( voltage / std::sqrt(0.05) );
31 data.power_dBm = volts_sqr_to_dbm( data.power_dBm );
35 inline double lorentzian(
double f,
double Q,
double f_0 ) {
38 double gamma = ( f_0 - f )/( fwhm/2.0 );
40 return 1.0/( 1.0 + gamma*gamma );
44 void TestModeCharacterization(
double f_0,
double Q, uint data_size ) {
46 std::vector< data_triple<double> > test_data;
47 test_data.reserve( data_size );
49 std::cout <<
"Testing mode characretizatipn.\n" 50 <<
"Test mode has center frequency of " 56 for( uint i = 0; i < data_size; i++ ) {
58 double cavity_length = 0.0;
59 double frequency =
static_cast<double>( i );
60 double power_dBm = lorentzian( frequency, Q, f_0 );
66 std::for_each( test_data.begin(), test_data.end(),
VoltsSqrTodBm() );
70 double computed_Q = characterization.Q();
71 double computed_f0 = characterization.f0();
73 std::cout <<
"Computed mode parameters.\n" 74 <<
"Center frequency of " 85 #endif // TEST_MODECHARACTERIZATION_H Definition: algorithm.cpp:16
Definition: test_modecharacterization.h:28
Definition: modecharacterization.h:17
Definition: generics.h:48