Boost logo

Boost Users :

Subject: Re: [Boost-users] [units] conversion factor for non-base
From: Matthias Schabel (boost_at_[hidden])
Date: 2010-04-22 12:55:19


> The flow coefficient is Q/sqrt(dP), a volumetric flow/sqrt(pressure).
> We have derived and defined a unit that would be the si standard for
> this quantity if there was one and things work fine. I have a runtime
> unit system that then converts between user values that make sense, to
> our internal si version that does not but works.
>
> However, now I want to write some alternative functions that use the
> actual units that engineers really use: Cv and Kv. I would like these
> alternative functions to then convert into this si unit we've created
> but the interface should distinguish between Cv, Kv, and my made up
> unit.
>
> The first part is easy: make a system that only contains this funky
> dimension and then use it to make quantities that are not in the si
> system.
>
> The second part is what I can't find. The conversion templates in
> conversion.hpp seem to specifically expect base units which at least the
> si part is not and my conversions should use my funky si unit as their
> basis. So the question I have is how can I write conversions such that
> I can do this:
>
> quantity<si::flow_coefficient> fc(42 * Kv);
>
> and this:
>
> void f(quantity<Kv::coefficient>);
> void f(quantity<Cv::coefficient>);
> void f(quantity<si::coefficient>);
>
> Where Kv and Cv are base units in their own systems.

The units all need to be dimensionally equivalent to be convertible. That is, as long as Cv::coefficient, Kv::coefficient, and si::coefficient have the same dimensions, and conversions are defined between all base units, conversion should work transparently. It's hard to provide more input without seeing the definitions for the three flow coefficients.

Matthias


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net