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 87169 : NumberDensity::NumberDensity() : 33 87169 : valueIS_(0.0) 34 : { 35 87169 : } 36 : 37 16901 : NumberDensity::NumberDensity(double numberdensity) : 38 16901 : valueIS_(numberdensity) 39 : { 40 16901 : } 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 85305 : NumberDensity::NumberDensity(double numberdensity, NumberDensity::Units units) 55 : { 56 85305 : if(units == NumberDensity::UnitInverseCubicCentiMeter) { 57 84505 : valueIS_ = 1.0E+6 * numberdensity; 58 800 : } else if(units == NumberDensity::UnitInverseCubicMeter) { 59 800 : valueIS_ = numberdensity; 60 : } else { 61 : // Exception: unknown number density unit. S.I. unit (m**-3) used by default. 62 0 : valueIS_ = numberdensity; 63 : } 64 85305 : } 65 : 66 392187 : NumberDensity::~NumberDensity() 67 : { 68 392187 : } 69 : 70 800 : double NumberDensity::get(const std::string &units) const 71 : { 72 800 : if(units == "cm**-3" || units == "CM**-3") { 73 0 : return 1.0E-6 * valueIS_; 74 800 : } else if(units == "m**-3" || units == "M**-3") { 75 0 : return valueIS_; 76 : } else { 77 : // Exception: unknown number density unit. S.I. unit (m**-3) used by default. 78 800 : return valueIS_; 79 : } 80 : } 81 : 82 84505 : double NumberDensity::get(NumberDensity::Units units) const 83 : { 84 84505 : if(units == NumberDensity::UnitInverseCubicCentiMeter) { 85 84505 : 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