Line data Source code
1 : /******************************************************************************* 2 : * ALMA - Atacama Large Millimiter Array 3 : * (c) Instituto de Estructura de la Materia, 2009 4 : * 5 : * This library is free software; you can redistribute it and/or 6 : * modify it under the terms of the GNU Lesser General Public 7 : * License as published by the Free Software Foundation; either 8 : * version 2.1 of the License, or (at your option) any later version. 9 : * 10 : * This library is distributed in the hope that it will be useful, 11 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 : * Lesser General Public License for more details. 14 : * 15 : * You should have received a copy of the GNU Lesser General Public 16 : * License along with this library; if not, write to the Free Software 17 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 : * 19 : * "@(#) $Id: ATMNumberDensity.cpp Exp $" 20 : * 21 : * who when what 22 : * -------- -------- ---------------------------------------------- 23 : * pardo 24/03/09 created 24 : */ 25 : 26 : #include "ATMNumberDensity.h" 27 : 28 : 29 : 30 : ATM_NAMESPACE_BEGIN 31 : 32 249298 : NumberDensity::NumberDensity() : 33 249298 : valueIS_(0.0) 34 : { 35 249298 : } 36 : 37 110448 : NumberDensity::NumberDensity(double numberdensity) : 38 110448 : valueIS_(numberdensity) 39 : { 40 110448 : } 41 : 42 0 : NumberDensity::NumberDensity(double numberdensity, const std::string &units) 43 : { 44 0 : if(units == "cm**-3" || units == "CM**-3") { 45 0 : valueIS_ = 1.0E+6 * numberdensity; 46 0 : } else if(units == "m**-3" || units == "M**-3") { 47 0 : valueIS_ = numberdensity; 48 : } else { 49 : // Exception: unknown number density unit. S.I. unit (m**-3) used by default. 50 0 : valueIS_ = numberdensity; 51 : } 52 0 : } 53 : 54 247865 : NumberDensity::NumberDensity(double numberdensity, NumberDensity::Units units) 55 : { 56 247865 : if(units == NumberDensity::UnitInverseCubicCentiMeter) { 57 246246 : valueIS_ = 1.0E+6 * numberdensity; 58 1619 : } else if(units == NumberDensity::UnitInverseCubicMeter) { 59 1619 : valueIS_ = numberdensity; 60 : } else { 61 : // Exception: unknown number density unit. S.I. unit (m**-3) used by default. 62 0 : valueIS_ = numberdensity; 63 : } 64 247865 : } 65 : 66 1100117 : NumberDensity::~NumberDensity() 67 : { 68 1100117 : } 69 : 70 1862 : double NumberDensity::get(const std::string &units) const 71 : { 72 1862 : if(units == "cm**-3" || units == "CM**-3") { 73 250 : return 1.0E-6 * valueIS_; 74 1612 : } else if(units == "m**-3" || units == "M**-3") { 75 532 : return valueIS_; 76 : } else { 77 : // Exception: unknown number density unit. S.I. unit (m**-3) used by default. 78 1080 : return valueIS_; 79 : } 80 : } 81 : 82 245903 : double NumberDensity::get(NumberDensity::Units units) const 83 : { 84 245903 : if(units == NumberDensity::UnitInverseCubicCentiMeter) { 85 245903 : return 1.0E-6 * valueIS_; 86 0 : } else if(units == NumberDensity::UnitInverseCubicMeter) { 87 0 : return valueIS_; 88 : } else { 89 : // Exception: unknown number density unit. S.I. unit (m**-3) used by default. 90 0 : return valueIS_; 91 : } 92 : } 93 : 94 : ATM_NAMESPACE_END