Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | List of all members
PhQ::Energy< NumericType > Class Template Reference

Energy physical quantity. Can represent any kind of energy, such as kinetic energy, potential energy, internal energy, and so on. The time rate of change of energy is power; see PhQ::Power, PhQ::Time, and PhQ::Frequency. More...

#include "Energy.hpp"

Public Member Functions

 Energy ()=default
 Default constructor. Constructs an energy quantity with an uninitialized value. More...
 
 Energy (const NumericType value, const Unit::Energy unit)
 Constructor. Constructs an energy quantity with a given value expressed in a given energy unit. More...
 
constexpr Energy (const Power< NumericType > &power, const Time< NumericType > &time)
 Constructor. Constructs an energy quantity from a given power and time using the definition of power. More...
 
constexpr Energy (const Power< NumericType > &power, const Frequency< NumericType > &frequency)
 Constructor. Constructs an energy quantity from a given power and frequency using the definition of power. More...
 
constexpr Energy (const SpecificEnergy< NumericType > &specific_energy, const Mass< NumericType > &mass)
 Constructor. Constructs an energy quantity from a given specific energy quantity and mass using the definition of specific energy. More...
 
constexpr Energy (const TransportEnergyConsumption< NumericType > &transport_energy_consumption, const Length< NumericType > &length)
 Constructor. Constructs an energy quantity from a given transport energy consumption and length using the definition of transport energy consumption. More...
 
 ~Energy () noexcept=default
 Destructor. Destroys this energy quantity. More...
 
constexpr Energy (const Energy< NumericType > &other)=default
 Copy constructor. Constructs an energy quantity by copying another one. More...
 
template<typename OtherNumericType >
constexpr Energy (const Energy< OtherNumericType > &other)
 Copy constructor. Constructs an energy quantity by copying another one. More...
 
constexpr Energy (Energy< NumericType > &&other) noexcept=default
 Move constructor. Constructs an energy quantity by moving another one. More...
 
constexpr Energy< NumericType > & operator= (const Energy< NumericType > &other)=default
 Copy assignment operator. Assigns this energy quantity by copying another one. More...
 
template<typename OtherNumericType >
constexpr Energy< NumericType > & operator= (const Energy< OtherNumericType > &other)
 Copy assignment operator. Assigns this energy quantity by copying another one. More...
 
constexpr Energy< NumericType > & operator= (Energy< NumericType > &&other) noexcept=default
 Move assignment operator. Assigns this energy quantity by moving another one. More...
 
constexpr Energy< NumericType > operator+ (const Energy< NumericType > &energy) const
 
constexpr Energy< NumericType > operator- (const Energy< NumericType > &energy) const
 
constexpr Energy< NumericType > operator* (const NumericType number) const
 
constexpr Power< NumericType > operator* (const Frequency< NumericType > &frequency) const
 
constexpr Energy< NumericType > operator/ (const NumericType number) const
 
constexpr Power< NumericType > operator/ (const Time< NumericType > &time) const
 
constexpr Time< NumericType > operator/ (const Power< NumericType > &power) const
 
constexpr SpecificEnergy< NumericType > operator/ (const Mass< NumericType > &mass) const
 
constexpr Mass< NumericType > operator/ (const SpecificEnergy< NumericType > &specific_energy) const
 
constexpr TransportEnergyConsumption< NumericType > operator/ (const Length< NumericType > &length) const
 
constexpr Length< NumericType > operator/ (const TransportEnergyConsumption< NumericType > &transport_energy_consumption) const
 
constexpr NumericType operator/ (const Energy< NumericType > &energy) const noexcept
 
constexpr void operator+= (const Energy< NumericType > &energy) noexcept
 
constexpr void operator-= (const Energy< NumericType > &energy) noexcept
 
constexpr void operator*= (const NumericType number) noexcept
 
constexpr void operator/= (const NumericType number) noexcept
 
constexpr double Value () const noexcept
 Value of this physical quantity expressed in its standard unit of measure. More...
 
double Value (const Unit::Energy unit) const
 Value of this physical quantity expressed in a given unit of measure. More...
 
constexpr double StaticValue () const
 Value of this physical quantity expressed in a given unit of measure. This method can be evaluated statically at compile-time. More...
 
constexpr double & MutableValue () noexcept
 Returns the value of this physical quantity expressed in its standard unit of measure as a mutable value. More...
 
constexpr void SetValue (const double value) noexcept
 Sets the value of this physical quantity expressed in its standard unit of measure to the given value. More...
 
std::string Print () const
 Prints this physical quantity as a string. This physical quantity's value is expressed in its standard unit of measure. More...
 
std::string Print (const Unit::Energy unit) const
 Prints this physical quantity as a string. This physical quantity's value is expressed in the given unit of measure. More...
 
std::string JSON () const
 Serializes this physical quantity as a JSON message. This physical quantity's value is expressed in its standard unit of measure. More...
 
std::string JSON (const Unit::Energy unit) const
 Serializes this physical quantity as a JSON message. This physical quantity's value is expressed in the given unit of measure. More...
 
std::string XML () const
 Serializes this physical quantity as an XML message. This physical quantity's value is expressed in its standard unit of measure. More...
 
std::string XML (const Unit::Energy unit) const
 Serializes this physical quantity as an XML message. This physical quantity's value is expressed in the given unit of measure. More...
 
std::string YAML () const
 Serializes this physical quantity as a YAML message. This physical quantity's value is expressed in its standard unit of measure. More...
 
std::string YAML (const Unit::Energy unit) const
 Serializes this physical quantity as a YAML message. This physical quantity's value is expressed in the given unit of measure. More...
 

Static Public Member Functions

static constexpr Energy< NumericType > Zero ()
 Statically creates an energy quantity of zero. More...
 
template<Unit::Energy Unit>
static constexpr Energy< NumericType > Create (const NumericType value)
 Statically creates an energy quantity with a given value expressed in a given energy unit. More...
 
static constexpr const PhQ::DimensionsDimensions ()
 Physical dimension set of this physical quantity. More...
 
static constexpr Unit::Energy Unit ()
 Standard unit of measure for this physical quantity. This physical quantity's value is stored internally in this unit of measure. More...
 

Protected Attributes

double value
 Value of this physical quantity expressed in its standard unit of measure. More...
 

Private Member Functions

constexpr Energy (const NumericType value)
 Constructor. Constructs an energy quantity with a given value expressed in the standard energy unit. More...
 

Detailed Description

template<typename NumericType = double>
class PhQ::Energy< NumericType >

Energy physical quantity. Can represent any kind of energy, such as kinetic energy, potential energy, internal energy, and so on. The time rate of change of energy is power; see PhQ::Power, PhQ::Time, and PhQ::Frequency.

Definition at line 73 of file Energy.hpp.

Constructor & Destructor Documentation

◆ Energy() [1/10]

template<typename NumericType = double>
PhQ::Energy< NumericType >::Energy ( )
default

Default constructor. Constructs an energy quantity with an uninitialized value.

◆ Energy() [2/10]

template<typename NumericType = double>
PhQ::Energy< NumericType >::Energy ( const NumericType  value,
const Unit::Energy< NumericType >  unit 
)
inline

Constructor. Constructs an energy quantity with a given value expressed in a given energy unit.

Definition at line 80 of file Energy.hpp.

◆ Energy() [3/10]

template<typename NumericType = double>
constexpr PhQ::Energy< NumericType >::Energy ( const Power< NumericType > &  power,
const Time< NumericType > &  time 
)
constexpr

Constructor. Constructs an energy quantity from a given power and time using the definition of power.

◆ Energy() [4/10]

template<typename NumericType = double>
constexpr PhQ::Energy< NumericType >::Energy ( const Power< NumericType > &  power,
const Frequency< NumericType > &  frequency 
)
constexpr

Constructor. Constructs an energy quantity from a given power and frequency using the definition of power.

◆ Energy() [5/10]

template<typename NumericType = double>
constexpr PhQ::Energy< NumericType >::Energy ( const SpecificEnergy< NumericType > &  specific_energy,
const Mass< NumericType > &  mass 
)
constexpr

Constructor. Constructs an energy quantity from a given specific energy quantity and mass using the definition of specific energy.

◆ Energy() [6/10]

template<typename NumericType = double>
constexpr PhQ::Energy< NumericType >::Energy ( const TransportEnergyConsumption< NumericType > &  transport_energy_consumption,
const Length< NumericType > &  length 
)
constexpr

Constructor. Constructs an energy quantity from a given transport energy consumption and length using the definition of transport energy consumption.

◆ ~Energy()

template<typename NumericType = double>
PhQ::Energy< NumericType >::~Energy ( )
defaultnoexcept

Destructor. Destroys this energy quantity.

◆ Energy() [7/10]

template<typename NumericType = double>
constexpr PhQ::Energy< NumericType >::Energy ( const Energy< NumericType > &  other)
constexprdefault

Copy constructor. Constructs an energy quantity by copying another one.

◆ Energy() [8/10]

template<typename NumericType = double>
template<typename OtherNumericType >
constexpr PhQ::Energy< NumericType >::Energy ( const Energy< OtherNumericType > &  other)
inlineexplicitconstexpr

Copy constructor. Constructs an energy quantity by copying another one.

Definition at line 109 of file Energy.hpp.

◆ Energy() [9/10]

template<typename NumericType = double>
constexpr PhQ::Energy< NumericType >::Energy ( Energy< NumericType > &&  other)
constexprdefaultnoexcept

Move constructor. Constructs an energy quantity by moving another one.

◆ Energy() [10/10]

template<typename NumericType = double>
constexpr PhQ::Energy< NumericType >::Energy ( const NumericType  value)
inlineexplicitconstexprprivate

Constructor. Constructs an energy quantity with a given value expressed in the standard energy unit.

Definition at line 196 of file Energy.hpp.

Member Function Documentation

◆ Create()

template<typename NumericType = double>
template<Unit::Energy Unit>
static constexpr Energy<NumericType> PhQ::Energy< NumericType >::Create ( const NumericType  value)
inlinestaticconstexpr

Statically creates an energy quantity with a given value expressed in a given energy unit.

Definition at line 136 of file Energy.hpp.

References PhQ::DimensionalScalar< Unit::Energy, double >::value.

◆ Dimensions()

static constexpr const PhQ::Dimensions& PhQ::DimensionalScalar< Unit::Energy , double >::Dimensions ( )
inlinestaticconstexprinherited

Physical dimension set of this physical quantity.

Definition at line 54 of file DimensionalScalar.hpp.

◆ JSON() [1/2]

std::string PhQ::DimensionalScalar< Unit::Energy , double >::JSON ( ) const
inlineinherited

Serializes this physical quantity as a JSON message. This physical quantity's value is expressed in its standard unit of measure.

Definition at line 107 of file DimensionalScalar.hpp.

◆ JSON() [2/2]

std::string PhQ::DimensionalScalar< Unit::Energy , double >::JSON ( const Unit::Energy  unit) const
inlineinherited

Serializes this physical quantity as a JSON message. This physical quantity's value is expressed in the given unit of measure.

Definition at line 117 of file DimensionalScalar.hpp.

◆ MutableValue()

constexpr double & PhQ::DimensionalScalar< Unit::Energy , double >::MutableValue ( )
inlineconstexprnoexceptinherited

Returns the value of this physical quantity expressed in its standard unit of measure as a mutable value.

Definition at line 83 of file DimensionalScalar.hpp.

◆ operator*() [1/2]

template<typename NumericType = double>
constexpr Power<NumericType> PhQ::Energy< NumericType >::operator* ( const Frequency< NumericType > &  frequency) const
constexpr

◆ operator*() [2/2]

template<typename NumericType = double>
constexpr Energy<NumericType> PhQ::Energy< NumericType >::operator* ( const NumericType  number) const
inlineconstexpr

Definition at line 149 of file Energy.hpp.

References PhQ::DimensionalScalar< Unit::Energy, double >::value.

◆ operator*=()

template<typename NumericType = double>
constexpr void PhQ::Energy< NumericType >::operator*= ( const NumericType  number)
inlineconstexprnoexcept

Definition at line 185 of file Energy.hpp.

References PhQ::DimensionalScalar< Unit::Energy, double >::value.

◆ operator+()

template<typename NumericType = double>
constexpr Energy<NumericType> PhQ::Energy< NumericType >::operator+ ( const Energy< NumericType > &  energy) const
inlineconstexpr

◆ operator+=()

template<typename NumericType = double>
constexpr void PhQ::Energy< NumericType >::operator+= ( const Energy< NumericType > &  energy)
inlineconstexprnoexcept

Definition at line 177 of file Energy.hpp.

References PhQ::DimensionalScalar< Unit::Energy, double >::value.

◆ operator-()

template<typename NumericType = double>
constexpr Energy<NumericType> PhQ::Energy< NumericType >::operator- ( const Energy< NumericType > &  energy) const
inlineconstexpr

◆ operator-=()

template<typename NumericType = double>
constexpr void PhQ::Energy< NumericType >::operator-= ( const Energy< NumericType > &  energy)
inlineconstexprnoexcept

Definition at line 181 of file Energy.hpp.

References PhQ::DimensionalScalar< Unit::Energy, double >::value.

◆ operator/() [1/8]

template<typename NumericType = double>
constexpr NumericType PhQ::Energy< NumericType >::operator/ ( const Energy< NumericType > &  energy) const
inlineconstexprnoexcept

Definition at line 173 of file Energy.hpp.

References PhQ::DimensionalScalar< Unit::Energy, double >::value.

◆ operator/() [2/8]

template<typename NumericType = double>
constexpr TransportEnergyConsumption<NumericType> PhQ::Energy< NumericType >::operator/ ( const Length< NumericType > &  length) const
constexpr

◆ operator/() [3/8]

template<typename NumericType = double>
constexpr SpecificEnergy<NumericType> PhQ::Energy< NumericType >::operator/ ( const Mass< NumericType > &  mass) const
constexpr

◆ operator/() [4/8]

template<typename NumericType = double>
constexpr Energy<NumericType> PhQ::Energy< NumericType >::operator/ ( const NumericType  number) const
inlineconstexpr

Definition at line 155 of file Energy.hpp.

References PhQ::DimensionalScalar< Unit::Energy, double >::value.

◆ operator/() [5/8]

template<typename NumericType = double>
constexpr Time<NumericType> PhQ::Energy< NumericType >::operator/ ( const Power< NumericType > &  power) const
constexpr

◆ operator/() [6/8]

template<typename NumericType = double>
constexpr Mass<NumericType> PhQ::Energy< NumericType >::operator/ ( const SpecificEnergy< NumericType > &  specific_energy) const
constexpr

◆ operator/() [7/8]

template<typename NumericType = double>
constexpr Power<NumericType> PhQ::Energy< NumericType >::operator/ ( const Time< NumericType > &  time) const
constexpr

◆ operator/() [8/8]

template<typename NumericType = double>
constexpr Length<NumericType> PhQ::Energy< NumericType >::operator/ ( const TransportEnergyConsumption< NumericType > &  transport_energy_consumption) const
constexpr

◆ operator/=()

template<typename NumericType = double>
constexpr void PhQ::Energy< NumericType >::operator/= ( const NumericType  number)
inlineconstexprnoexcept

Definition at line 189 of file Energy.hpp.

References PhQ::DimensionalScalar< Unit::Energy, double >::value.

◆ operator=() [1/3]

template<typename NumericType = double>
constexpr Energy<NumericType>& PhQ::Energy< NumericType >::operator= ( const Energy< NumericType > &  other)
constexprdefault

Copy assignment operator. Assigns this energy quantity by copying another one.

◆ operator=() [2/3]

template<typename NumericType = double>
template<typename OtherNumericType >
constexpr Energy<NumericType>& PhQ::Energy< NumericType >::operator= ( const Energy< OtherNumericType > &  other)
inlineconstexpr

Copy assignment operator. Assigns this energy quantity by copying another one.

Definition at line 120 of file Energy.hpp.

References PhQ::DimensionalScalar< UnitType, NumericType >::Value(), and PhQ::DimensionalScalar< Unit::Energy, double >::value.

◆ operator=() [3/3]

template<typename NumericType = double>
constexpr Energy<NumericType>& PhQ::Energy< NumericType >::operator= ( Energy< NumericType > &&  other)
constexprdefaultnoexcept

Move assignment operator. Assigns this energy quantity by moving another one.

◆ Print() [1/2]

std::string PhQ::DimensionalScalar< Unit::Energy , double >::Print ( ) const
inlineinherited

Prints this physical quantity as a string. This physical quantity's value is expressed in its standard unit of measure.

Definition at line 95 of file DimensionalScalar.hpp.

◆ Print() [2/2]

std::string PhQ::DimensionalScalar< Unit::Energy , double >::Print ( const Unit::Energy  unit) const
inlineinherited

Prints this physical quantity as a string. This physical quantity's value is expressed in the given unit of measure.

Definition at line 101 of file DimensionalScalar.hpp.

◆ SetValue()

constexpr void PhQ::DimensionalScalar< Unit::Energy , double >::SetValue ( const double  value)
inlineconstexprnoexceptinherited

Sets the value of this physical quantity expressed in its standard unit of measure to the given value.

Definition at line 89 of file DimensionalScalar.hpp.

◆ StaticValue()

constexpr double PhQ::DimensionalScalar< Unit::Energy , double >::StaticValue ( ) const
inlineconstexprinherited

Value of this physical quantity expressed in a given unit of measure. This method can be evaluated statically at compile-time.

Definition at line 77 of file DimensionalScalar.hpp.

◆ Unit()

static constexpr Unit::Energy PhQ::DimensionalScalar< Unit::Energy , double >::Unit ( )
inlinestaticconstexprinherited

Standard unit of measure for this physical quantity. This physical quantity's value is stored internally in this unit of measure.

Definition at line 60 of file DimensionalScalar.hpp.

◆ Value() [1/2]

constexpr double PhQ::DimensionalScalar< Unit::Energy , double >::Value ( ) const
inlineconstexprnoexceptinherited

Value of this physical quantity expressed in its standard unit of measure.

Definition at line 65 of file DimensionalScalar.hpp.

◆ Value() [2/2]

double PhQ::DimensionalScalar< Unit::Energy , double >::Value ( const Unit::Energy  unit) const
inlineinherited

Value of this physical quantity expressed in a given unit of measure.

Definition at line 70 of file DimensionalScalar.hpp.

◆ XML() [1/2]

std::string PhQ::DimensionalScalar< Unit::Energy , double >::XML ( ) const
inlineinherited

Serializes this physical quantity as an XML message. This physical quantity's value is expressed in its standard unit of measure.

Definition at line 127 of file DimensionalScalar.hpp.

◆ XML() [2/2]

std::string PhQ::DimensionalScalar< Unit::Energy , double >::XML ( const Unit::Energy  unit) const
inlineinherited

Serializes this physical quantity as an XML message. This physical quantity's value is expressed in the given unit of measure.

Definition at line 137 of file DimensionalScalar.hpp.

◆ YAML() [1/2]

std::string PhQ::DimensionalScalar< Unit::Energy , double >::YAML ( ) const
inlineinherited

Serializes this physical quantity as a YAML message. This physical quantity's value is expressed in its standard unit of measure.

Definition at line 147 of file DimensionalScalar.hpp.

◆ YAML() [2/2]

std::string PhQ::DimensionalScalar< Unit::Energy , double >::YAML ( const Unit::Energy  unit) const
inlineinherited

Serializes this physical quantity as a YAML message. This physical quantity's value is expressed in the given unit of measure.

Definition at line 157 of file DimensionalScalar.hpp.

◆ Zero()

template<typename NumericType = double>
static constexpr Energy<NumericType> PhQ::Energy< NumericType >::Zero ( )
inlinestaticconstexpr

Statically creates an energy quantity of zero.

Definition at line 129 of file Energy.hpp.

Member Data Documentation

◆ value

double PhQ::DimensionalScalar< Unit::Energy , double >::value
protectedinherited

Value of this physical quantity expressed in its standard unit of measure.

Definition at line 221 of file DimensionalScalar.hpp.


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