Skip to content
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

Parameterized quantities #475

Open
JohelEGP opened this issue Jul 28, 2023 · 2 comments
Open

Parameterized quantities #475

JohelEGP opened this issue Jul 28, 2023 · 2 comments
Labels
design Design-related discussion enhancement New feature or request high priority EXTRA URGENT
Milestone

Comments

@JohelEGP
Copy link
Collaborator

Parameterized quantities

I have identified 2 kinds of parameterized quantities.

Same quantity name for different quantities

This kind of quantity shares its name between different quantities in the parts of ISO 80000.
For example:

QUANTITY_SPEC(power, force* velocity, quantity_character::scalar);

// QUANTITY_SPEC(power, voltage* electric_current); // TODO conflicts with mechanical power

Same quantity, actually parameterized

Some quantities from ISO 80000-7:2019 (light and radiation)
are parameterized on a photometric condition.

Amount of substance is parameterized on “elementary entity” (ISO 80000-9:2019 9.2).
And thus many quantities in part 9 are equally parameterized.
The standard has some remarks on the structure of an “elementary entity”.
Like #35 (comment),

It would also help to have the input from people familiar with the domain.

Previous work

I had previously started a code specification for the quantities,
and this is how I did it.

struct context { };
inline constexpr context mechanics;
inline constexpr context thermodynamics;
inline constexpr context electromagnetism;
inline constexpr context light_and_optical_radiation;
inline constexpr context radiometry;
inline constexpr context acoustics;
inline constexpr context in_a_mixture;
inline constexpr context in_a_solution;
inline constexpr context pressure_basis;
inline constexpr context concentration_basis;
inline constexpr context atomic_physics;
inline constexpr context ionizing_radiation;

struct photometric_condition { };
inline constexpr photometric_condition photopic_vision = {};
inline constexpr photometric_condition scotopic_vision = {};
inline constexpr photometric_condition mesopic_vision  = {};

template<const context&> extern const quantity efficiency;
template<const context&> extern const quantity power;
template<const photometric_condition&> extern const quantity luminous_efficacy_of_radiation;
template<const photometric_condition&> extern const quantity maximum_luminous_efficacy;
template<const context& = light_and_optical_radiation> extern const quantity reflectance;
template<const context& = light_and_optical_radiation> extern const quantity transmittance;
template<const context&> extern const quantity linear_attenuation_coefficient;
template<const context&> extern const quantity mass_attenuation_coefficient;
template<const context&> extern const quantity standard_absolute_activity;
template<const context&> extern const quantity equilibrium_constant;
template<const context&> extern const quantity magnetic_dipole_moment;
template<const context&> extern const quantity radiant_energy;

// ### ISO 80000-4:2019, Part 4: Mechanics.
template<> inline constexpr auto power<mechanics> = defn<"𝘗", "𝘗 = 𝙁 ⋅ 𝙫", force("𝙁"), velocity("𝙫")>();

// ### IEC 80000-6:2008, Part 6: Electromagnetism.
inline constexpr auto power<electromagnetism> = defn<"𝘱", "𝘱 = 𝘶𝘪", voltage("𝘶"), electric_current("𝘪")>();

// ### ISO 80000-9:2019, Part 9: Physical chemistry and molecular physics.
inline constexpr auto number_of_entities   = defn<"𝘕(X)", "dim 𝘕(X) = 1">();
inline constexpr auto amount_of_substance  = defn<"𝘯(X)", "𝘯(X) = 𝘕(X)/𝘕_A", number_of_entities("𝘕(X)"), Avogadro_constant("𝘕_A")>();

template<> inline constexpr auto standard_absolute_activity<in_a_mixture> = defn<"𝜆_X^⊝", "𝜆_X^⊝ = 𝜆 ⃰_X(𝘱^⊝)", "𝘱^⊝ = 10⁵ Pa", absolute_activity("𝜆_X"), pressure("𝘱")>();

template<> inline constexpr auto standard_absolute_activity<in_a_solution> = defn<"𝜆_B^⊝", "𝜆_B^⊝ = lim_{∑𝘣_B→0}[𝜆_B((𝘱^⊝)𝘣^⊝/𝘣_B)]", "𝘱^⊝ = 10⁵ Pa", molality("𝘣"), absolute_activity("𝜆_B"), pressure("𝘱")>();

template<> inline constexpr auto equilibrium_constant<pressure_basis>      = defn<"𝘒_𝘱", "𝘒_𝘱 = ∏_B(𝘱_B)^{𝘷_B}", partial_pressure("𝘱"), stoichiometric_number_of_substance("𝘷_B")>();
template<> inline constexpr auto equilibrium_constant<concentration_basis> = defn<"𝘒_𝘤", "𝘒_𝘤 = ∏_B(𝘤_B)^{𝘷_B}", particle_concentration("𝘤"), stoichiometric_number_of_substance("𝘷_B")>();
  • The quantity above is not mp_units::quantity.
  • Those quantity templates are forward declarations.
    If it's parameterized on a context, it's later explicitly specialized.
    If it's parameterized on a photometric_condition,
    it's because it's used before it's defined by another parameterized quantity.
  • As is evident, I didn't get around implementing the structure of an “elementary entity” X.
@mpusz mpusz added the design Design-related discussion label Jul 28, 2023
@mpusz
Copy link
Owner

mpusz commented Jul 28, 2023

Yes, similar issues to power also exist for energy and efficiency.

@mpusz
Copy link
Owner

mpusz commented Jul 28, 2023

And yes, I also planned to make quantity_spec templated on photometric condition for light and radiation. I didn't realize it is the same case for power, energy, and efficiency though. Thanks for raising this issue!

mpusz added a commit that referenced this issue Aug 1, 2023
@mpusz mpusz added the enhancement New feature or request label Aug 23, 2023
@mpusz mpusz added the high priority EXTRA URGENT label Feb 28, 2024
@mpusz mpusz added this to the v2.4.0 milestone Jun 22, 2024
@mpusz mpusz modified the milestones: v2.4.0, v2.5.0 Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Design-related discussion enhancement New feature or request high priority EXTRA URGENT
Projects
None yet
Development

No branches or pull requests

2 participants