Changeset 4062 in Sophya for trunk/SophyaLib/BaseTools/sunitpcst.cc
- Timestamp:
- Apr 27, 2012, 12:26:07 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/sunitpcst.cc
r4056 r4062 7 7 \class Units 8 8 \ingroup BaseTools 9 Class for representing physical units 9 This class represents physical dimension and units. Static methods return Units 10 objects corresponding to the usual units, such as meter or watt 10 11 11 12 \code 12 // Create .... 13 Units w=Units::watt(); 14 cout << " Power unit (watt) : " << w.Name() << " (" << w << ")" << endl; 15 // define the speed SI unit (m/s) : 16 Units mos = Units::meter()/Units::second() ; 17 cout << " SI speed unit : " << mos << " -> "; mos.Print() ; 18 // mutiple of an existing unit : 19 Units mw=Units::watt().mega(); 20 cout << " Megawatt: " << mw.Name() << " (" << mw << ") -> "; mw.Print() ; 13 21 \endcode 14 22 */ … … 26 34 27 35 /* --Methode-- */ 36 /*! 37 The Units object is created by specifying its name and short name, and the integer powers 38 for the seven SI base physical quantities (length, mass, time \ldots), and the value of the 39 unit in term of the SI unit. 40 */ 28 41 Units::Units(const char* nom, const char* snom, int m, int kg, int s, r_8 val, int A, int K, int mol, int cd) 29 42 : mLength_(m), mMass_(kg), mTime_(s), mCurr_(A), … … 38 51 { 39 52 Set(un); 53 } 54 55 /* --Methode-- */ 56 Units::Units(Units const& un, r_8 scale, const char* nom, const char* snom) 57 { 58 Set(un); 59 mSI_Value_*=scale; 60 mName_=nom; 61 mShortName_=snom; 40 62 } 41 63 … … 179 201 \class PhysQty 180 202 \ingroup BaseTools 181 Class for representing physical quantities and constants 203 Class for representing physical quantities and constants. A physical quantity 204 has a unit and a value, and optionally a precision and/or a name. A number of 205 physical constants and standard quantities can be obtained as PhysQty objects 206 through static methods. 182 207 208 \sa SOPHYA::Units 209 183 210 \code 184 // Create .... 211 cout << " k_Boltzmann: " << PhysQty::k() << endl; 212 cout << " m_e: " << PhysQty::electron_mass() << endl; 213 // Conversion of a quantity to a different unit 214 PhysQty aj(Units::joule(), 25.); 215 PhysQty aev=aj.ConvertTo(Units::electronvolt().giga()); 216 cout << " A : " << aj << " -> " << aev << endl; 185 217 \endcode 186 218 */ … … 191 223 192 224 /* --Methode-- */ 225 //! Default constructor: zero valued dimensionless quantity 193 226 PhysQty::PhysQty() 194 227 : unit_(), val_(0.), prec_(0.) … … 197 230 198 231 /* --Methode-- */ 232 /*! 233 \brief standard constructor 234 The object is constructed through the specification of the unit \b u, the value \b val, 235 and optional relative precision \b prec (=delta val/val) and an optional name. 236 */ 199 237 PhysQty::PhysQty(Units const & u, r_8 val, r_8 prec, const char* nom) 200 238 : unit_(u), val_(val), prec_(prec), name_((nom==NULL)?"":nom) … … 203 241 204 242 /* --Methode-- */ 243 //! Copy constructor 205 244 PhysQty::PhysQty(PhysQty const & qty) 206 245 : unit_(qty.unit_), val_(qty.val_), prec_(qty.prec_), name_(qty.name_)
Note:
See TracChangeset
for help on using the changeset viewer.