LCOV - code coverage report
Current view: top level - atmosphere/ATM/test - AtmProfileTest.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 40 40 100.0 %
Date: 2024-12-11 20:54:31 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*******************************************************************************
       2             :  * ALMA - Atacama Large Millimeter Array
       3             :  * (c) Instituto de Estructura de la Materia, 2011
       4             :  * (in the framework of the ALMA collaboration).
       5             :  * All rights reserved.
       6             :  * 
       7             :  * This library is free software; you can redistribute it and/or
       8             :  * modify it under the terms of the GNU Lesser General Public
       9             :  * License as published by the Free Software Foundation; either
      10             :  * version 2.1 of the License, or (at your option) any later version.
      11             :  * 
      12             :  * This library is distributed in the hope that it will be useful,
      13             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      15             :  * Lesser General Public License for more details.
      16             :  * 
      17             :  * You should have received a copy of the GNU Lesser General Public
      18             :  * License along with this library; if not, write to the Free Software
      19             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      20             :  *******************************************************************************/
      21             : 
      22             : #include <string>
      23             : #include <vector>
      24             : #include <iostream>
      25             : using namespace std;
      26             : 
      27             : 
      28             : #include <atmosphere/ATM/ATMPercent.h>
      29             : #include <atmosphere/ATM/ATMPressure.h>
      30             : #include <atmosphere/ATM/ATMNumberDensity.h>
      31             : #include <atmosphere/ATM/ATMMassDensity.h>
      32             : #include <atmosphere/ATM/ATMTemperature.h>
      33             : #include <atmosphere/ATM/ATMLength.h>
      34             : #include <atmosphere/ATM/ATMHumidity.h>
      35             : #include <atmosphere/ATM/ATMProfile.h>
      36             : //using namespace telcal::atm;
      37             : using namespace atm;
      38             : 
      39             :   /** \brief A C++ main code to test the <a href="classatm_1_1AtmProfile.html">AtmProfile</a> Class 
      40             :    *
      41             :    *   The test is structured as follows:
      42             :    *         - Creates the object "myProfile" using the <a href="classatm_1_1AtmProfile.html#z7_1">longest constructor </a>
      43             :    *           of the Class <a href="classatm_1_1AtmProfile.html">AtmProfile</a>.          
      44             :    *         - Gets the number of layers of "myProfile" using the operator 
      45             :    *           <a href="classatm_1_1AtmProfile.html#z7_21">.getNumLayer()</a> of the Class <a href="classatm_1_1AtmProfile.html">AtmProfile</a>.
      46             :    *         - Lists different physical and chemical parameters layer by layer, using operators such as  
      47             :    *           <a href="classatm_1_1AtmProfile.html#z7_29">.getLayerWaterVaporMassDensity(unsigned int i)</a> of the Class <a href="classatm_1_1AtmProfile.html">AtmProfile</a>.
      48             :    *
      49             :    * The ouput of this test should be as follows:
      50             :    *
      51             :    * <b>    
      52             :    * AtmProfileTest: BASIC ATMOSPHERIC PARAMETERS TO GENERATE REFERENCE ATMOSPHERIC PROFILE  <br>
      53             :    * AtmProfileTest:    <br>
      54             :    * AtmProfileTest: Ground temperature T:         270 K <br>
      55             :    * AtmProfileTest: Ground pressure P:            560 mb <br>
      56             :    * AtmProfileTest: Relative humidity rh:         20 % <br>
      57             :    * AtmProfileTest: Scale height h0:              2 km <br>
      58             :    * AtmProfileTest: Pressure step dp:             5 mb <br>
      59             :    * AtmProfileTest: Altitude alti:                5000 m <br>
      60             :    * AtmProfileTest: Attitude top atm profile atmh:48 km <br>
      61             :    * AtmProfileTest: Pressure step factordp1:      1.1  <br>
      62             :    * AtmProfileTest: Tropospheric lapse rate:    -5.6 K/km <br>
      63             :    * AtmProfileTest: Atmospheric type:             tropical <br>
      64             :    * AtmProfileTest:    <br>
      65             :    * AtmProfileTest:    <br>
      66             :    * AtmProfileTest: Object myProfile built with the AtmProfile CONSTRUCTOR and the above entries <br>
      67             :    *   <br>
      68             :    * AtmProfileTest: Number of layers returned:  22 <br>
      69             :    * AtmProfileTest: Layer parameters:   <br>
      70             :    * AtmProfileTest:  P: 554.977 mb  T: 269.598 K  Thickness: 143.444 m  WaterVapor: 0.000762199 kg m-3  WaterVapor: 2.5504e+22 m-3  CO: 1.93876e+18 m-3  O3: 5.62901e+17 m-3  N2O: 4.76212e+18 m-3  <br>
      71             :    * AtmProfileTest:  P: 543.967 mb  T: 268.706 K  Thickness: 175.101 m  WaterVapor: 0.000703854 kg m-3  WaterVapor: 2.35517e+22 m-3  CO: 1.90629e+18 m-3  O3: 5.58954e+17 m-3  N2O: 4.68575e+18 m-3 <br>
      72             :    * AtmProfileTest:  P: 530.751 mb  T: 267.615 K  Thickness: 214.579 m  WaterVapor: 0.000638519 kg m-3  WaterVapor: 2.13656e+22 m-3  CO: 1.86583e+18 m-3  O3: 5.54106e+17 m-3  N2O: 4.59355e+18 m-3 <br>
      73             :    * AtmProfileTest:  P: 514.888 mb  T: 266.275 K  Thickness: 264.252 m  WaterVapor: 0.000566481 kg m-3  WaterVapor: 1.89551e+22 m-3  CO: 1.81512e+18 m-3  O3: 5.48123e+17 m-3  N2O: 4.48208e+18 m-3 <br>
      74             :    * AtmProfileTest:  P: 495.844 mb  T: 264.618 K  Thickness: 327.475 m  WaterVapor: 0.000488584 kg m-3  WaterVapor: 1.63486e+22 m-3  CO: 1.75116e+18 m-3  O3: 5.40691e+17 m-3  N2O: 4.34711e+18 m-3 <br>
      75             :    * AtmProfileTest:  P: 472.979 mb  T: 262.555 K  Thickness: 409.147 m  WaterVapor: 0.000406408 kg m-3  WaterVapor: 1.35988e+22 m-3  CO: 1.66905e+18 m-3  O3: 5.31317e+17 m-3  N2O: 4.18305e+18 m-3 <br>
      76             :    * AtmProfileTest:  P: 445.521 mb  T: 259.963 K  Thickness: 516.736 m  WaterVapor: 0.00032243 kg m-3  WaterVapor: 1.07889e+22 m-3  CO: 1.56532e+18 m-3  O3: 5.19589e+17 m-3  N2O: 3.98414e+18 m-3 <br>
      77             :    * AtmProfileTest:  P: 412.536 mb  T: 256.662 K  Thickness: 662.272 m  WaterVapor: 0.000240119 kg m-3  WaterVapor: 8.03464e+21 m-3  CO: 1.43556e+18 m-3  O3: 5.01384e+17 m-3  N2O: 3.74538e+18 m-3 <br>
      78             :    * AtmProfileTest:  P: 372.891 mb  T: 252.381 K  Thickness: 866.58 m  WaterVapor: 0.000163845 kg m-3  WaterVapor: 5.48243e+21 m-3  CO: 1.26268e+18 m-3  O3: 4.89541e+17 m-3  N2O: 3.44722e+18 m-3 <br>
      79             :    * AtmProfileTest:  P: 325.19 mb  T: 246.68 K  Thickness: 1169.46 m  WaterVapor: 9.84855e-05 kg m-3  WaterVapor: 3.29543e+21 m-3  CO: 1.03631e+18 m-3  O3: 4.87238e+17 m-3  N2O: 3.07023e+18 m-3 <br>
      80             :    * AtmProfileTest:  P: 267.67 mb  T: 238.76 K  Thickness: 1658.92 m  WaterVapor: 4.85606e-05 kg m-3  WaterVapor: 1.62489e+21 m-3  CO: 7.6885e+17 m-3  O3: 5.03793e+17 m-3  N2O: 2.58146e+18 m-3 <br>
      81             :    * AtmProfileTest:  P: 256.935 mb  T: 230.765 K  Thickness: 1000 m  WaterVapor: 2.49802e-05 kg m-3  WaterVapor: 8.35865e+20 m-3  CO: 5.53847e+17 m-3  O3: 5.37164e+17 m-3  N2O: 2.16403e+18 m-3 <br>
      82             :    * AtmProfileTest:  P: 257.26 mb  T: 224.015 K  Thickness: 1000 m  WaterVapor: 1.51513e-05 kg m-3  WaterVapor: 5.06978e+20 m-3  CO: 3.99903e+17 m-3  O3: 5.63587e+17 m-3  N2O: 1.87717e+18 m-3 <br>
      83             :    * AtmProfileTest:  P: 211.112 mb  T: 215.315 K  Thickness: 1625 m  WaterVapor: 7.86037e-06 kg m-3  WaterVapor: 2.63017e+20 m-3  CO: 2.48942e+17 m-3  O3: 5.7276e+17 m-3  N2O: 1.56008e+18 m-3 <br>
      84             :    * AtmProfileTest:  P: 158.866 mb  T: 203.315 K  Thickness: 2000 m  WaterVapor: 3.17588e-06 kg m-3  WaterVapor: 1.06268e+20 m-3  CO: 1.23924e+17 m-3  O3: 5.91703e+17 m-3  N2O: 1.1682e+18 m-3 <br>
      85             :    * AtmProfileTest:  P: 114.088 mb  T: 191.865 K  Thickness: 2000 m  WaterVapor: 1.16834e-06 kg m-3  WaterVapor: 3.90939e+19 m-3  CO: 5.57264e+16 m-3  O3: 1.47198e+18 m-3  N2O: 7.62395e+17 m-3 <br>
      86             :    * AtmProfileTest:  P: 81.0467 mb  T: 190.615 K  Thickness: 2000 m  WaterVapor: 4.29808e-07 kg m-3  WaterVapor: 1.43819e+19 m-3  CO: 2.61142e+16 m-3  O3: 2.77652e+18 m-3  N2O: 4.64509e+17 m-3 <br>
      87             :    * AtmProfileTest:  P: 50.4577 mb  T: 201.065 K  Thickness: 3750 m  WaterVapor: 1.02088e-07 kg m-3  WaterVapor: 3.41599e+18 m-3  CO: 1.54239e+16 m-3  O3: 3.93168e+18 m-3  N2O: 2.3445e+17 m-3 <br>
      88             :    * AtmProfileTest:  P: 27.4549 mb  T: 212.515 K  Thickness: 4000 m  WaterVapor: 1.47072e-08 kg m-3  WaterVapor: 4.9212e+17 m-3  CO: 1.04872e+16 m-3  O3: 4.55929e+18 m-3  N2O: 1.03582e+17 m-3 <br>
      89             :    * AtmProfileTest:  P: 15.0592 mb  T: 221.315 K  Thickness: 4000 m  WaterVapor: 1.99041e-09 kg m-3  WaterVapor: 6.66012e+16 m-3  CO: 7.05928e+15 m-3  O3: 3.23216e+18 m-3  N2O: 4.5226e+16 m-3 <br>
      90             :    * AtmProfileTest:  P: 8.2977 mb  T: 230.215 K  Thickness: 4250 m  WaterVapor: 2.53052e-10 kg m-3  WaterVapor: 8.46739e+15 m-3  CO: 4.4967e+15 m-3  O3: 1.76311e+18 m-3  N2O: 1.69912e+16 m-3 <br>
      91             :    * AtmProfileTest:  P: 4.09633 mb  T: 241.315 K  Thickness: 6000 m  WaterVapor: 1.95133e-11 kg m-3  WaterVapor: 6.52935e+14 m-3  CO: 2.56843e+15 m-3  O3: 6.47884e+17 m-3  N2O: 3.88669e+15 m-3  <br> 
      92             :    */
      93           1 : int main()
      94             : {  
      95             :   // double h_div_k=0.04799274551;        // plank/boltz in units of K/GHz
      96             : 
      97             :   // Atmospheretype   atmType = tropical; // Atmospheric type (to reproduce behavior above the tropopause)
      98           1 :   unsigned int atmType = 1; // TROPICAL
      99           2 :   Temperature      T( 270.0,"K" );     // Ground temperature
     100           2 :   Pressure         P( 560.0,"mb");     // Ground Pressure
     101           2 :   Humidity         H(  20.0,"%" );     // Ground Relative Humidity (indication)
     102           2 :   Length         Alt(  5000,"m" );     // Altitude of the site 
     103           2 :   Length         WVL(   2.0,"km");     // Water vapor scale height
     104           1 :   double         TLR=  -5.6      ;     // Tropospheric lapse rate (must be in K/km)
     105           2 :   Length      topAtm(  48.0,"km");     // Upper atm. boundary for calculations
     106           2 :   Pressure     Pstep(  5.0,"mb");     // Primary pressure step
     107           1 :   double   PstepFact=         1.1;     // Pressure step ratio between two consecutive layers
     108             : 
     109             : 
     110           1 :   cout<<" AtmProfileTest: BASIC ATMOSPHERIC PARAMETERS TO GENERATE REFERENCE ATMOSPHERIC PROFILE"<<endl; 
     111           1 :   cout<<" AtmProfileTest:   "<<endl;
     112           1 :   cout<<" AtmProfileTest: Ground temperature T:         " << T.get()         << " K"    <<endl; 
     113           1 :   cout<<" AtmProfileTest: Ground pressure P:            " << P.get("mb")     << " mb"   <<endl; 
     114           1 :   cout<<" AtmProfileTest: Relative humidity rh:         " << H.get("%")      << " %"    <<endl; 
     115           1 :   cout<<" AtmProfileTest: Scale height h0:              " << WVL.get("km")   << " km"   <<endl; 
     116           1 :   cout<<" AtmProfileTest: Pressure step dp:             " << Pstep.get("mb") << " mb"   <<endl; 
     117           1 :   cout<<" AtmProfileTest: Altitude alti:                " << Alt.get()       << " m"    <<endl; 
     118           1 :   cout<<" AtmProfileTest: Attitude top atm profile atmh:" << topAtm.get("km")<< " km"   <<endl; 
     119           1 :   cout<<" AtmProfileTest: Pressure step factordp1:      " << PstepFact          << " "    <<endl; 
     120           1 :   cout<<" AtmProfileTest: Tropospheric lapse rate:    " << TLR                << " K/km" <<endl;
     121             : 
     122           1 :   AtmProfile myProfile( Alt, P, T, TLR, H, WVL, Pstep, PstepFact,  topAtm, atmType );
     123             : 
     124           1 :   cout<<" AtmProfileTest: Atmospheric type:             " << myProfile.getAtmosphereType() <<endl;
     125           1 :   cout<<" AtmProfileTest:   "<<endl;
     126           1 :   cout<<" AtmProfileTest:   "<<endl;
     127             : 
     128           1 :   cout<<" AtmProfileTest: Object myProfile built with the AtmProfile CONSTRUCTOR and the above entries"<<endl; 
     129           1 :   cout<<"  "<<endl;
     130           1 :   cout<<" AtmProfileTest: Number of layers returned:  " << myProfile.getNumLayer() <<endl;
     131           1 :   cout<<" AtmProfileTest: Layer parameters:  " <<endl;
     132             :   
     133             :     
     134          31 :   for(unsigned int i=0; i<myProfile.getNumLayer(); i++){
     135          60 :     cout << " AtmProfileTest:  P: "          << myProfile.getLayerPressure(i).get("mb")    << " mb" 
     136          60 :          << "  T: "          << myProfile.getLayerTemperature(i).get("K")   << " K"
     137          60 :          << "  Thickness: "  << myProfile.getLayerThickness(i).get("m")   << " m"
     138          60 :          << "  WaterVapor: " << myProfile.getLayerWaterVaporMassDensity(i).get("kgm**-3")  << " kg m-3"
     139          60 :          << "  WaterVapor: " << myProfile.getLayerWaterVaporNumberDensity(i).get("m**-3")  << " m-3"
     140          60 :          << "  CO: "         << myProfile.getLayerCO(i).get("m**-3")          << " m-3"
     141          60 :          << "  O3: "         << myProfile.getLayerO3(i).get("m**-3")          << " m-3"
     142          30 :          << "  N2O: "        << myProfile.getLayerN2O(i).get("m**-3")         << " m-3" << endl;
     143             :   }
     144             : 
     145           1 : }

Generated by: LCOV version 1.16