refactor: natural units refactored

This commit is contained in:
Mateusz Pusz
2021-04-15 14:03:32 +02:00
parent cee27390e6
commit ec8c19b947
21 changed files with 537 additions and 38 deletions

View File

@@ -138,8 +138,15 @@ set(unitsSphinxDocs
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/transfer_rate.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/acceleration.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/constants.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/dimensions.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/energy.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/force.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/length.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/mass.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/momentum.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/speed.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/time.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/units.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/si_cgs.rst"

View File

@@ -4,6 +4,13 @@ Natural
.. toctree::
:maxdepth: 2
natural/dimensions
natural/units
natural/constants
natural/acceleration
natural/energy
natural/force
natural/length
natural/mass
natural/momentum
natural/speed
natural/time

View File

@@ -0,0 +1,4 @@
Acceleration
============
.. doxygenfile:: natural/acceleration.h

View File

@@ -1,4 +0,0 @@
Dimensions
==========
.. doxygenfile:: natural/dimensions.h

View File

@@ -0,0 +1,4 @@
Energy
======
.. doxygenfile:: natural/energy.h

View File

@@ -0,0 +1,4 @@
Force
=====
.. doxygenfile:: natural/force.h

View File

@@ -0,0 +1,4 @@
Length
======
.. doxygenfile:: natural/length.h

View File

@@ -0,0 +1,4 @@
Mass
====
.. doxygenfile:: natural/mass.h

View File

@@ -0,0 +1,4 @@
Momentum
========
.. doxygenfile:: natural/momentum.h

View File

@@ -0,0 +1,4 @@
Speed
=====
.. doxygenfile:: natural/speed.h

View File

@@ -0,0 +1,4 @@
Time
====
.. doxygenfile:: natural/time.h

View File

@@ -22,47 +22,48 @@
#pragma once
#include <units/isq/natural/length.h>
#include <units/isq/natural/time.h>
// IWYU pragma: begin_exports
#include <units/isq/dimensions.h>
#include <units/isq/dimensions/acceleration.h>
#include <units/isq/natural/units.h>
#include <units/quantity.h>
#include <units/reference.h>
#include <units/symbol_text.h>
// IWYU pragma: end_exports
namespace units::isq::natural {
struct dim_length : isq::dim_length<inverted_gigaelectronvolt> {};
template<UnitOf<dim_length> U, Representation Rep = double>
using length = quantity<dim_length, U, Rep>;
struct dim_time : isq::dim_time<inverted_gigaelectronvolt> {};
template<UnitOf<dim_time> U, Representation Rep = double>
using time = quantity<dim_time, U, Rep>;
struct dim_mass : isq::dim_mass<gigaelectronvolt> {};
template<UnitOf<dim_mass> U, Representation Rep = double>
using mass = quantity<dim_mass, U, Rep>;
struct dim_speed : isq::dim_speed<dim_speed, one, dim_length, dim_time> {};
template<UnitOf<dim_speed> U, Representation Rep = double>
using speed = quantity<dim_speed, U, Rep>;
struct dim_acceleration : isq::dim_acceleration<dim_acceleration, gigaelectronvolt, dim_length, dim_time> {};
template<UnitOf<dim_acceleration> U, Representation Rep = double>
using acceleration = quantity<dim_acceleration, U, Rep>;
struct dim_force : isq::dim_force<dim_force, square_gigaelectronvolt, dim_mass, dim_acceleration> {};
template<UnitOf<dim_force> U, Representation Rep = double>
using force = quantity<dim_force, U, Rep>;
#ifdef UNITS_REFERENCES
struct dim_momentum : isq::dim_momentum<dim_momentum, gigaelectronvolt, dim_mass, dim_speed> {};
template<UnitOf<dim_momentum> U, Representation Rep = double>
using momentum = quantity<dim_momentum, U, Rep>;
namespace acceleration_references {
struct dim_energy : isq::dim_energy<dim_energy, gigaelectronvolt, dim_force, dim_length> {};
template<UnitOf<dim_force> U, Representation Rep = double>
using energy = quantity<dim_force, U, Rep>;
inline constexpr auto GeV = reference<dim_acceleration, gigaelectronvolt>{};
// Typical UDLs will not work here as the same units are reused by many quantities.
// Should we define some strange ones (i.e. _q_mass_GeV)?
} // namespace acceleration_references
namespace references {
using namespace acceleration_references;
} // namespace references
#endif // UNITS_REFERENCES
} // namespace units::isq::natural
#ifdef UNITS_ALIASES
namespace units::aliases::isq::natural::inline acceleration {
template<Representation Rep = double> using GeV = units::isq::natural::acceleration<units::isq::natural::gigaelectronvolt, Rep>;
} // namespace units::aliases::isq::natural::inline acceleration
#endif // UNITS_ALIASES

View File

@@ -22,7 +22,7 @@
#pragma once
#include <units/isq/natural/dimensions.h>
#include <units/isq/natural/speed.h>
namespace units::isq::natural {

View File

@@ -0,0 +1,69 @@
// The MIT License (MIT)
//
// Copyright (c) 2018 Mateusz Pusz
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
#include <units/isq/natural/force.h>
#include <units/isq/natural/length.h>
// IWYU pragma: begin_exports
#include <units/isq/dimensions/energy.h>
#include <units/isq/natural/units.h>
#include <units/quantity.h>
#include <units/reference.h>
#include <units/symbol_text.h>
// IWYU pragma: end_exports
namespace units::isq::natural {
struct dim_energy : isq::dim_energy<dim_energy, gigaelectronvolt, dim_force, dim_length> {};
template<UnitOf<dim_energy> U, Representation Rep = double>
using energy = quantity<dim_energy, U, Rep>;
#ifdef UNITS_REFERENCES
namespace energy_references {
inline constexpr auto GeV = reference<dim_energy, gigaelectronvolt>{};
} // namespace energy_references
namespace references {
using namespace energy_references;
} // namespace references
#endif // UNITS_REFERENCES
} // namespace units::isq::natural
#ifdef UNITS_ALIASES
namespace units::aliases::isq::natural::inline energy {
template<Representation Rep = double> using GeV = units::isq::natural::energy<units::isq::natural::gigaelectronvolt, Rep>;
} // namespace units::aliases::isq::natural::inline energy
#endif // UNITS_ALIASES

View File

@@ -0,0 +1,69 @@
// The MIT License (MIT)
//
// Copyright (c) 2018 Mateusz Pusz
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
#include <units/isq/natural/acceleration.h>
#include <units/isq/natural/mass.h>
// IWYU pragma: begin_exports
#include <units/isq/dimensions/force.h>
#include <units/isq/natural/units.h>
#include <units/quantity.h>
#include <units/reference.h>
#include <units/symbol_text.h>
// IWYU pragma: end_exports
namespace units::isq::natural {
struct dim_force : isq::dim_force<dim_force, square_gigaelectronvolt, dim_mass, dim_acceleration> {};
template<UnitOf<dim_force> U, Representation Rep = double>
using force = quantity<dim_force, U, Rep>;
#ifdef UNITS_REFERENCES
namespace force_references {
inline constexpr auto GeV2 = reference<dim_force, square_gigaelectronvolt>{};
} // namespace force_references
namespace references {
using namespace force_references;
} // namespace references
#endif // UNITS_REFERENCES
} // namespace units::isq::natural
#ifdef UNITS_ALIASES
namespace units::aliases::isq::natural::inline force {
template<Representation Rep = double> using GeV2 = units::isq::natural::force<units::isq::natural::square_gigaelectronvolt, Rep>;
} // namespace units::aliases::isq::natural::inline force
#endif // UNITS_ALIASES

View File

@@ -0,0 +1,66 @@
// The MIT License (MIT)
//
// Copyright (c) 2018 Mateusz Pusz
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
// IWYU pragma: begin_exports
#include <units/isq/dimensions/length.h>
#include <units/isq/natural/units.h>
#include <units/quantity.h>
#include <units/reference.h>
#include <units/symbol_text.h>
// IWYU pragma: end_exports
namespace units::isq::natural {
struct dim_length : isq::dim_length<inverted_gigaelectronvolt> {};
template<UnitOf<dim_length> U, Representation Rep = double>
using length = quantity<dim_length, U, Rep>;
#ifdef UNITS_REFERENCES
namespace length_references {
inline constexpr auto inv_GeV = reference<dim_length, inverted_gigaelectronvolt>{};
} // namespace length_references
namespace references {
using namespace length_references;
} // namespace references
#endif // UNITS_REFERENCES
} // namespace units::isq::natural
#ifdef UNITS_ALIASES
namespace units::aliases::isq::natural::inline length {
template<Representation Rep = double> using inv_GeV = units::isq::natural::length<units::isq::natural::inverted_gigaelectronvolt, Rep>;
} // namespace units::aliases::isq::natural::inline length
#endif // UNITS_ALIASES

View File

@@ -0,0 +1,66 @@
// The MIT License (MIT)
//
// Copyright (c) 2018 Mateusz Pusz
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
// IWYU pragma: begin_exports
#include <units/isq/dimensions/mass.h>
#include <units/isq/natural/units.h>
#include <units/quantity.h>
#include <units/reference.h>
#include <units/symbol_text.h>
// IWYU pragma: end_exports
namespace units::isq::natural {
struct dim_mass : isq::dim_mass<gigaelectronvolt> {};
template<UnitOf<dim_mass> U, Representation Rep = double>
using mass = quantity<dim_mass, U, Rep>;
#ifdef UNITS_REFERENCES
namespace mass_references {
inline constexpr auto GeV = reference<dim_mass, gigaelectronvolt>{};
} // namespace mass_references
namespace references {
using namespace mass_references;
} // namespace references
#endif // UNITS_REFERENCES
} // namespace units::isq::natural
#ifdef UNITS_ALIASES
namespace units::aliases::isq::natural::inline mass {
template<Representation Rep = double> using GeV = units::isq::natural::mass<units::isq::natural::gigaelectronvolt, Rep>;
} // namespace units::aliases::isq::natural::inline mass
#endif // UNITS_ALIASES

View File

@@ -0,0 +1,69 @@
// The MIT License (MIT)
//
// Copyright (c) 2018 Mateusz Pusz
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
#include <units/isq/natural/mass.h>
#include <units/isq/natural/speed.h>
// IWYU pragma: begin_exports
#include <units/isq/dimensions/momentum.h>
#include <units/isq/natural/units.h>
#include <units/quantity.h>
#include <units/reference.h>
#include <units/symbol_text.h>
// IWYU pragma: end_exports
namespace units::isq::natural {
struct dim_momentum : isq::dim_momentum<dim_momentum, gigaelectronvolt, dim_mass, dim_speed> {};
template<UnitOf<dim_momentum> U, Representation Rep = double>
using momentum = quantity<dim_momentum, U, Rep>;
#ifdef UNITS_REFERENCES
namespace momentum_references {
inline constexpr auto GeV = reference<dim_momentum, gigaelectronvolt>{};
} // namespace momentum_references
namespace references {
using namespace momentum_references;
} // namespace references
#endif // UNITS_REFERENCES
} // namespace units::isq::natural
#ifdef UNITS_ALIASES
namespace units::aliases::isq::natural::inline momentum {
template<Representation Rep = double> using GeV = units::isq::natural::momentum<units::isq::natural::gigaelectronvolt, Rep>;
} // namespace units::aliases::isq::natural::inline momentum
#endif // UNITS_ALIASES

View File

@@ -23,7 +23,14 @@
#pragma once
// IWYU pragma: begin_exports
#include "dimensions.h"
#include "units.h"
#include "constants.h"
#include <units/isq/natural/acceleration.h>
#include <units/isq/natural/constants.h>
#include <units/isq/natural/energy.h>
#include <units/isq/natural/force.h>
#include <units/isq/natural/length.h>
#include <units/isq/natural/mass.h>
#include <units/isq/natural/momentum.h>
#include <units/isq/natural/natural.h>
#include <units/isq/natural/speed.h>
#include <units/isq/natural/time.h>
// IWYU pragma: end_exports

View File

@@ -0,0 +1,44 @@
// The MIT License (MIT)
//
// Copyright (c) 2018 Mateusz Pusz
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
#include <units/isq/natural/length.h>
#include <units/isq/natural/time.h>
// IWYU pragma: begin_exports
#include <units/generic/dimensionless.h>
#include <units/isq/dimensions/speed.h>
#include <units/isq/natural/units.h>
#include <units/quantity.h>
#include <units/reference.h>
#include <units/symbol_text.h>
// IWYU pragma: end_exports
namespace units::isq::natural {
struct dim_speed : isq::dim_speed<dim_speed, one, dim_length, dim_time> {};
template<UnitOf<dim_speed> U, Representation Rep = double>
using speed = quantity<dim_speed, U, Rep>;
} // namespace units::isq::natural

View File

@@ -0,0 +1,66 @@
// The MIT License (MIT)
//
// Copyright (c) 2018 Mateusz Pusz
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
// IWYU pragma: begin_exports
#include <units/isq/dimensions/time.h>
#include <units/isq/natural/units.h>
#include <units/quantity.h>
#include <units/reference.h>
#include <units/symbol_text.h>
// IWYU pragma: end_exports
namespace units::isq::natural {
struct dim_time : isq::dim_time<inverted_gigaelectronvolt> {};
template<UnitOf<dim_time> U, Representation Rep = double>
using time = quantity<dim_time, U, Rep>;
#ifdef UNITS_REFERENCES
namespace time_references {
inline constexpr auto inv_GeV = reference<dim_time, inverted_gigaelectronvolt>{};
} // namespace time_references
namespace references {
using namespace time_references;
} // namespace references
#endif // UNITS_REFERENCES
} // namespace units::isq::natural
#ifdef UNITS_ALIASES
namespace units::aliases::isq::natural::inline time {
template<Representation Rep = double> using inv_GeV = units::isq::natural::time<units::isq::natural::inverted_gigaelectronvolt, Rep>;
} // namespace units::aliases::isq::natural::inline time
#endif // UNITS_ALIASES