Skip to content

Merge added dimensions and units #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions include/boost/units/physical_dimensions/drag_factor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
// unit/quantity manipulation and conversion
//
// Copyright (C) 2003-2008 Matthias Christian Schabel
// Copyright (C) 2008 Steven Watanabe
// Copyright (C) 2015 Michael William Powell
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_UNITS_DRAG_FACTOR_DERIVED_DIMENSION_HPP
#define BOOST_UNITS_DRAG_FACTOR_DERIVED_DIMENSION_HPP

#include <boost/units/derived_dimension.hpp>
#include <boost/units/physical_dimensions/length.hpp>

namespace boost {

namespace units {

/// derived dimension for drag factor : L^-1
typedef derived_dimension<length_base_dimension,-1>::type drag_factor_dimension;

} // namespace units

} // namespace boost

#endif // BOOST_UNITS_DRAG_FACTOR_DERIVED_DIMENSION_HPP
31 changes: 31 additions & 0 deletions include/boost/units/physical_dimensions/molar_mass.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
// unit/quantity manipulation and conversion
//
// Copyright (C) 2003-2008 Matthias Christian Schabel
// Copyright (C) 2008 Steven Watanabe
// Copyright (C) 2015 Michael William Powell
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_UNITS_MOLAR_MASS_DERIVED_DIMENSION_HPP
#define BOOST_UNITS_MOLAR_MASS_DERIVED_DIMENSION_HPP

#include <boost/units/derived_dimension.hpp>
#include <boost/units/physical_dimensions/mass.hpp>
#include <boost/units/physical_dimensions/amount.hpp>

namespace boost {

namespace units {

/// derived dimension for molar mass : M Amount^-1
typedef derived_dimension<mass_base_dimension,1,
amount_base_dimension,-1>::type molar_mass_dimension;

} // namespace units

} // namespace boost

#endif // BOOST_UNITS_MOLAR_MASS_DERIVED_DIMENSION_HPP
46 changes: 46 additions & 0 deletions include/boost/units/physical_dimensions/specific_gas_constant.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
// unit/quantity manipulation and conversion
//
// Copyright (C) 2003-2008 Matthias Christian Schabel
// Copyright (C) 2008 Steven Watanabe
// Copyright (C) 2015 Michael William Powell
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_UNITS_SPECIFIC_GAS_CONSTANT_DERIVED_DIMENSION_HPP
#define BOOST_UNITS_SPECIFIC_GAS_CONSTANT_DERIVED_DIMENSION_HPP

#include <boost/units/derived_dimension.hpp>
#include <boost/units/physical_dimensions/length.hpp>
#include <boost/units/physical_dimensions/time.hpp>
#include <boost/units/physical_dimensions/temperature.hpp>

//#include <boost/units/physical_dimensions/energy.hpp>
//#include <boost/units/physical_dimensions/mass.hpp>

namespace boost {

namespace units {

///// derived dimension for specific gas constant : J M^-1 Theta^-1
//typedef derived_dimension<energy_dimension,1,
// mass_base_dimension,-1,
// temperature_base_dimension,-1>::type specific_gas_constant_dimension;

/// derived dimension for specific gas constant : J M^-1 Theta^-1
/// which effectively reduces to : L^-2 T^-2 Theta^-1
typedef derived_dimension<length_base_dimension,2,
temperature_base_dimension,-1,
time_base_dimension,-2>::type specific_gas_constant_dimension;

//typedef derived_dimension<energy_dimension, 1,
// mass_base_dimension, -1,
// temperature_base_dimension, -1>::type specific_gas_constant_dimension2;

} // namespace units

} // namespace boost

#endif // BOOST_UNITS_SPECIFIC_GAS_CONSTANT_DERIVED_DIMENSION_HPP
3 changes: 3 additions & 0 deletions include/boost/units/systems/si.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <boost/units/systems/si/current.hpp>
#include <boost/units/systems/si/dimensionless.hpp>
#include <boost/units/systems/si/dose_equivalent.hpp>
#include <boost/units/systems/si/drag_factor.hpp>
#include <boost/units/systems/si/dynamic_viscosity.hpp>
#include <boost/units/systems/si/electric_charge.hpp>
#include <boost/units/systems/si/electric_potential.hpp>
Expand All @@ -54,6 +55,7 @@
#include <boost/units/systems/si/magnetic_flux_density.hpp>
#include <boost/units/systems/si/mass.hpp>
#include <boost/units/systems/si/mass_density.hpp>
#include <boost/units/systems/si/molar_mass.hpp>
#include <boost/units/systems/si/moment_of_inertia.hpp>
#include <boost/units/systems/si/momentum.hpp>
#include <boost/units/systems/si/permeability.hpp>
Expand All @@ -65,6 +67,7 @@
#include <boost/units/systems/si/resistance.hpp>
#include <boost/units/systems/si/resistivity.hpp>
#include <boost/units/systems/si/solid_angle.hpp>
#include <boost/units/systems/si/specific_gas_constant.hpp>
#include <boost/units/systems/si/surface_density.hpp>
#include <boost/units/systems/si/surface_tension.hpp>
#include <boost/units/systems/si/temperature.hpp>
Expand Down
36 changes: 36 additions & 0 deletions include/boost/units/systems/si/drag_factor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
// unit/quantity manipulation and conversion
//
// Copyright (C) 2003-2008 Matthias Christian Schabel
// Copyright (C) 2008 Steven Watanabe
// Copyright (C) 2015 Michael William Powell
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_UNITS_SI_DRAG_FACTOR_HPP
#define BOOST_UNITS_SI_DRAG_FACTOR_HPP

#include <boost/units/systems/si/base.hpp>
#include <boost/units/physical_dimensions/drag_factor.hpp>

namespace boost {

namespace units {

namespace si {

typedef unit<drag_factor_dimension,si::system> drag_factor;

BOOST_UNITS_STATIC_CONSTANT(dragfactor, drag_factor);

// "K"

} // namespace si

} // namespace units

} // namespace boost

#endif // BOOST_UNITS_SI_DRAG_FACTOR_HPP
37 changes: 37 additions & 0 deletions include/boost/units/systems/si/molar_mass.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
// unit/quantity manipulation and conversion
//
// Copyright (C) 2003-2008 Matthias Christian Schabel
// Copyright (C) 2008 Steven Watanabe
// Copyright (C) 2015 Michael William Powell
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_UNITS_SI_MOLAR_MASS_HPP
#define BOOST_UNITS_SI_MOLAR_MASS_HPP

#include <boost/units/systems/si/base.hpp>
#include <boost/units/physical_dimensions/molar_mass.hpp>

namespace boost {

namespace units {

namespace si {

typedef unit<molar_mass_dimension,si::system> molar_mass;

BOOST_UNITS_STATIC_CONSTANT(kilogram_per_mole, molar_mass);
BOOST_UNITS_STATIC_CONSTANT(kilograms_per_mole, molar_mass);
BOOST_UNITS_STATIC_CONSTANT(kilogramme_per_mole, molar_mass);
BOOST_UNITS_STATIC_CONSTANT(kilogrammes_per_mole, molar_mass);

} // namespace si

} // namespace units

} // namespace boost

#endif // BOOST_UNITS_SI_MASS_DENSITY_HPP
37 changes: 37 additions & 0 deletions include/boost/units/systems/si/specific_gas_constant.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
// unit/quantity manipulation and conversion
//
// Copyright (C) 2003-2008 Matthias Christian Schabel
// Copyright (C) 2008 Steven Watanabe
// Copyright (C) 2015 Michael William Powell
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_UNITS_SI_SPECIFIC_GAS_CONSTANT_HPP
#define BOOST_UNITS_SI_SPECIFIC_GAS_CONSTANT_HPP

#include <boost/units/systems/si/base.hpp>
#include <boost/units/physical_dimensions/specific_gas_constant.hpp>

namespace boost {

namespace units {

namespace si {

typedef unit<specific_gas_constant_dimension,si::system> specific_gas_constant;

BOOST_UNITS_STATIC_CONSTANT(joule_per_kilogram_kelvins, specific_gas_constant);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you should add singular version of kelvins as well? I.e. joule_per_kilogram_kelvin and 3 other variants.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly, if I have a need for it, I will patch it. Other's contributions are also welcomed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a question of one's need, but of consistency...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The harder question is how to persuade the units system to accept a true energy (Joules) per mass (kilogram) temperature (kelvins). The closest I could come up with was to "manually" reduce the dimensions, which will work when you involve the quantity calculations, but does not appear to be technically correct, according to the Specific Gas Constant docs I was reading. I don't have any ready answers where that's concerned. Can you help with those bits?

BOOST_UNITS_STATIC_CONSTANT(joules_per_kilogram_kelvins, specific_gas_constant);
BOOST_UNITS_STATIC_CONSTANT(joule_per_kilogramme_kelvins, specific_gas_constant);
BOOST_UNITS_STATIC_CONSTANT(joules_per_kilogrammes_kelvins, specific_gas_constant);

} // namespace si

} // namespace units

} // namespace boost

#endif // BOOST_UNITS_SI_SPECIFIC_GAS_CONSTANT_HPP