Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
#include <units/physical/si/acceleration.h>
|
2020-03-01 14:44:45 +01:00
|
|
|
#include <units/physical/si/constants.h>
|
2020-01-14 12:50:30 +01:00
|
|
|
#include <units/physical/si/density.h>
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
#include <units/physical/si/force.h>
|
2020-01-14 12:50:30 +01:00
|
|
|
#include <units/physical/si/length.h>
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
#include <units/physical/si/mass.h>
|
2020-01-14 12:50:30 +01:00
|
|
|
#include <units/physical/si/time.h>
|
|
|
|
#include <units/physical/si/volume.h>
|
2020-03-01 14:44:45 +01:00
|
|
|
#include <units/format.h>
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
#include <cassert>
|
|
|
|
|
2020-01-14 12:50:30 +01:00
|
|
|
namespace {
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
|
2020-05-08 22:39:24 +02:00
|
|
|
using namespace units::physical;
|
|
|
|
using namespace units::physical::si::literals;
|
2020-01-14 12:50:30 +01:00
|
|
|
|
2020-03-01 14:44:45 +01:00
|
|
|
using m = si::metre;
|
|
|
|
using kg = si::kilogram;
|
|
|
|
using N = si::newton;
|
|
|
|
using m3 = si::cubic_metre;
|
|
|
|
using kgpm3 = si::kilogram_per_metre_cub;
|
2020-01-14 12:50:30 +01:00
|
|
|
|
2020-03-17 17:13:18 +01:00
|
|
|
inline constexpr auto g = si::si2019::standard_gravity<>;
|
2020-01-14 12:50:30 +01:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
struct Box {
|
2020-09-09 19:20:35 +02:00
|
|
|
static constexpr auto air_density = 1.225_q_kg_per_m3;
|
2020-01-14 12:50:30 +01:00
|
|
|
|
2020-03-01 14:44:45 +01:00
|
|
|
si::length<m> length;
|
|
|
|
si::length<m> width;
|
|
|
|
si::length<m> height;
|
2020-01-14 12:50:30 +01:00
|
|
|
|
|
|
|
struct contents {
|
2020-03-01 14:44:45 +01:00
|
|
|
si::density<kgpm3> density = air_density;
|
2020-01-14 12:50:30 +01:00
|
|
|
} contents;
|
|
|
|
|
2020-03-01 14:44:45 +01:00
|
|
|
constexpr Box(const si::length<m>& l, const si::length<m>& w, const si::length<m>& h) : length{l}, width{w}, height{h} {}
|
2020-01-14 12:50:30 +01:00
|
|
|
|
2020-03-01 14:44:45 +01:00
|
|
|
constexpr si::force<N> filled_weight() const
|
2020-01-14 12:50:30 +01:00
|
|
|
{
|
2020-03-01 14:44:45 +01:00
|
|
|
const si::volume<m3> volume = length * width * height;
|
|
|
|
const si::mass<kg> mass = contents.density * volume;
|
|
|
|
return mass * g;
|
2020-01-14 12:50:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-01 14:44:45 +01:00
|
|
|
constexpr si::length<m> fill_level(const si::mass<kg>& measured_mass) const
|
2020-01-14 12:50:30 +01:00
|
|
|
{
|
2020-03-01 14:44:45 +01:00
|
|
|
return height * (measured_mass * g) / filled_weight();
|
2020-01-14 12:50:30 +01:00
|
|
|
}
|
|
|
|
|
2020-03-01 14:44:45 +01:00
|
|
|
constexpr si::volume<m3> spare_capacity(const si::mass<kg>& measured_mass) const
|
2020-01-14 12:50:30 +01:00
|
|
|
{
|
|
|
|
return (height - fill_level(measured_mass)) * width * length;
|
|
|
|
}
|
|
|
|
|
2020-03-01 14:44:45 +01:00
|
|
|
constexpr void set_contents_density(const si::density<kgpm3>& density_in)
|
2020-01-14 12:50:30 +01:00
|
|
|
{
|
|
|
|
assert(density_in > air_density);
|
|
|
|
contents.density = density_in;
|
|
|
|
}
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2020-09-09 19:20:35 +02:00
|
|
|
auto box = Box(1000.0_q_mm, 500.0_q_mm, 200.0_q_mm);
|
|
|
|
box.set_contents_density(1000.0_q_kg_per_m3);
|
2020-01-14 12:50:30 +01:00
|
|
|
|
2020-09-09 19:20:35 +02:00
|
|
|
const auto fill_time = 200.0_q_s; // time since starting fill
|
|
|
|
const auto measured_mass = 20.0_q_kg; // measured mass at fill_time
|
2020-01-14 12:50:30 +01:00
|
|
|
|
2020-03-01 14:44:45 +01:00
|
|
|
std::cout << "mp-units box example...\n";
|
2020-01-14 12:50:30 +01:00
|
|
|
std::cout << "fill height at " << fill_time << " = " << box.fill_level(measured_mass) << " ("
|
|
|
|
<< (box.fill_level(measured_mass) / box.height) * 100 << "% full)\n";
|
|
|
|
std::cout << "spare_capacity at " << fill_time << " = " << box.spare_capacity(measured_mass) << '\n';
|
|
|
|
std::cout << "input flow rate after " << fill_time << " = " << measured_mass / fill_time << '\n';
|
|
|
|
std::cout << "float rise rate = " << box.fill_level(measured_mass) / fill_time << '\n';
|
2020-03-01 14:44:45 +01:00
|
|
|
const auto fill_time_left = (box.height / box.fill_level(measured_mass) - 1) * fill_time;
|
2020-01-14 12:50:30 +01:00
|
|
|
std::cout << "box full E.T.A. at current flow rate = " << fill_time_left << '\n';
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
}
|