Cantera  3.0.0
Loading...
Searching...
No Matches
Units Class Reference

A representation of the units associated with a dimensional quantity. More...

#include <Units.h>

Detailed Description

A representation of the units associated with a dimensional quantity.

Used for converting quantities between unit systems and checking for dimensional consistency. Units objects are mainly used within UnitSystem class to convert values from a user-specified Unit system to Cantera's base units (SI + kmol).

Definition at line 34 of file Units.h.

Public Member Functions

 Units (double factor=1.0, double mass=0, double length=0, double time=0, double temperature=0, double current=0, double quantity=0)
 Create a Units object with the specified dimensions.
 
 Units (const string &units, bool force_unity=false)
 Create an object with the specified dimensions.
 
bool convertible (const Units &other) const
 Returns true if the specified Units are dimensionally consistent.
 
double factor () const
 Return the factor for converting from this unit to Cantera's base units.
 
Unitsoperator*= (const Units &other)
 Multiply two Units objects, combining their conversion factors and dimensions.
 
string str (bool skip_unity=true) const
 Provide a string representation of these Units.
 
Units pow (double exponent) const
 Raise these Units to a power, changing both the conversion factor and the dimensions of these Units.
 
bool operator== (const Units &other) const
 
double dimension (const string &primary) const
 Return dimension of primary unit component ("mass", "length", "time", "temperature", "current", or "quantity")
 

Private Member Functions

void scale (double k)
 Scale the unit by the factor k
 

Private Attributes

double m_factor = 1.0
 conversion factor to Cantera base units
 
double m_mass_dim = 0.0
 
double m_length_dim = 0.0
 
double m_time_dim = 0.0
 
double m_temperature_dim = 0.0
 
double m_current_dim = 0.0
 
double m_quantity_dim = 0.0
 
double m_pressure_dim = 0.0
 pseudo-dimension to track explicit pressure units
 
double m_energy_dim = 0.0
 pseudo-dimension to track explicit energy units
 

Friends

class UnitSystem
 

Constructor & Destructor Documentation

◆ Units() [1/2]

Units ( double  factor = 1.0,
double  mass = 0,
double  length = 0,
double  time = 0,
double  temperature = 0,
double  current = 0,
double  quantity = 0 
)
explicit

Create a Units object with the specified dimensions.

Definition at line 109 of file Units.cpp.

◆ Units() [2/2]

Units ( const string &  units,
bool  force_unity = false 
)
explicit

Create an object with the specified dimensions.

Parameters
unitsA string representation of the units. See UnitSystem for a description of the formatting options.
force_unityensure that conversion factor is equal to one

Definition at line 131 of file Units.cpp.

Member Function Documentation

◆ convertible()

bool convertible ( const Units other) const

Returns true if the specified Units are dimensionally consistent.

Definition at line 199 of file Units.cpp.

◆ factor()

double factor ( ) const
inline

Return the factor for converting from this unit to Cantera's base units.

Definition at line 53 of file Units.h.

◆ operator*=()

Units & operator*= ( const Units other)

Multiply two Units objects, combining their conversion factors and dimensions.

Definition at line 209 of file Units.cpp.

◆ str()

string str ( bool  skip_unity = true) const

Provide a string representation of these Units.

Parameters
skip_unitydo not print '1' if conversion factor is equal to one

Definition at line 234 of file Units.cpp.

◆ pow()

Units pow ( double  exponent) const

Raise these Units to a power, changing both the conversion factor and the dimensions of these Units.

Definition at line 223 of file Units.cpp.

◆ operator==()

bool operator== ( const Units other) const

Definition at line 290 of file Units.cpp.

◆ dimension()

double dimension ( const string &  primary) const

Return dimension of primary unit component ("mass", "length", "time", "temperature", "current", or "quantity")

Definition at line 303 of file Units.cpp.

◆ scale()

void scale ( double  k)
inlineprivate

Scale the unit by the factor k

Definition at line 75 of file Units.h.

Friends And Related Symbol Documentation

◆ UnitSystem

friend class UnitSystem
friend

Definition at line 87 of file Units.h.

Member Data Documentation

◆ m_factor

double m_factor = 1.0
private

conversion factor to Cantera base units

Definition at line 77 of file Units.h.

◆ m_mass_dim

double m_mass_dim = 0.0
private

Definition at line 78 of file Units.h.

◆ m_length_dim

double m_length_dim = 0.0
private

Definition at line 79 of file Units.h.

◆ m_time_dim

double m_time_dim = 0.0
private

Definition at line 80 of file Units.h.

◆ m_temperature_dim

double m_temperature_dim = 0.0
private

Definition at line 81 of file Units.h.

◆ m_current_dim

double m_current_dim = 0.0
private

Definition at line 82 of file Units.h.

◆ m_quantity_dim

double m_quantity_dim = 0.0
private

Definition at line 83 of file Units.h.

◆ m_pressure_dim

double m_pressure_dim = 0.0
private

pseudo-dimension to track explicit pressure units

Definition at line 84 of file Units.h.

◆ m_energy_dim

double m_energy_dim = 0.0
private

pseudo-dimension to track explicit energy units

Definition at line 85 of file Units.h.


The documentation for this class was generated from the following files: