|
Boost Users : |
Subject: Re: [Boost-users] [units] Calculating air density
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2015-08-09 20:58:10
On Sun, Aug 9, 2015 at 2:31 PM, Michael Powell <mwpowellhtx_at_[hidden]> wrote:
> On Sun, Aug 9, 2015 at 1:55 PM, Michael Powell <mwpowellhtx_at_[hidden]> wrote:
>> On Sun, Aug 9, 2015 at 1:32 PM, Michael Powell <mwpowellhtx_at_[hidden]> wrote:
>>> On Sun, Aug 9, 2015 at 11:16 AM, Michael Powell <mwpowellhtx_at_[hidden]> wrote:
>>>> Hello,
>>>>
>>>> I'd like to calculate air density at altitude. Studying some notes on wikipedia:
A PR will be coming in the next day or so.
In the meantime, would someone like to see what could be done better than this:
http://github.com/mwpowellhtx/units/issues/2
The other item in the queue is pretty straightforward thus far:
http://github.com/mwpowellhtx/units/issues/1
Thank you...
>>> I am trying to derived a "specific gas constant" dimension, and
>>> corresponding units: usually in the form of (J/(kg K)).
>>>
>>> Mass and temperature dimensions are simple enough to build upon.
>>>
>>> However, energy? Not so much, or perhaps there is a better way that I
>>> am not grasping.
>>>
>>> /// 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>
>>> specific_gas_constant_dimension;
>>>
>>> Which is yielding some errors, this and a host of others:
>>>
>>> Error 19 error C2039: 'tag_type' : is not a member of
>>> 'boost::units::derived_dimension<boost::units::energy_dimension,1,boost::units::mass_base_dimension,-1,boost::units::temperature_base_dimension,-1,boost::units::dimensionless_type,0,boost::units::dimensionless_type,0,boost::units::dimensionless_type,0,boost::units::dimensionless_type,0,boost::units::dimensionless_type,0>'
>>> I:\Source\Boost.org\boost_1_58_0\installed\x64\include\boost-1_58\boost\units\detail\linear_algebra.hpp
>>> 701 1 Kingdom.Physics.Calculators
>>>
>>> My guess is for deriving a dimension from a derived dimension? Is
>>> there a better dimension to use for the energy component?
>>>
>>> Or am I wasting time trying to setup a dimension and I should simply
>>> build the units themselves?
>>>
>>> Or, do I really need to string together all the dimensions that
>>> constitute the energy dimension? or Joules ?
>>
>> Which, when I "do the math" on the dimensions, I'm not positive, but
>> the Mass components cancel themselves out (though their actual
>> quantities might not actually do so...), so I end up with something
>> like this?
>>
>> typedef derived_dimension<length_base_dimension,2,
>> time_base_dimension,-2,
>> temperature_base_dimension,-1>
>> specific_gas_constant_dimension;
>
> I persuaded the compilation to succeed with the following correction:
>
> typedef derived_dimension<length_base_dimension,2,
> time_base_dimension,-2,
> temperature_base_dimension,-1>::type
> specific_gas_constant_dimension;
>
> Which interestingly enough, perhaps there is a wrapper that I can
> incorporate an existing derived dimension? like energy_dimension?
>
> And just to prove it to myself (and the compiler):
>
> static const quantity<specific_gas_constant> dry_air_
> = 287.058*joules_per_kilogram_kelvins;
>
> Is the same as saying this:
>
> static const quantity<specific_gas_constant> dry_air_
> = 287.058*joules / (kilogram*kelvins);
>
>> Basically substituting and reducing from Joules (J) being energy,
>> which is M L^2 T^-2.
>>
>> Which should happen when we say something like this:
>>
>> quantity<specific_gas_constant> dry_air_ = 287.058*joules/(kilogram*kelvins);
>>
>> Or this for shorthand, with appropriate unit defined:
>>
>> quantity<specific_gas_constant> dry_air_ = 287.058*joules_per_kilogram_kelvins;
>>
>>> I suppose, consistent with the m.o. of consistency over convenience ...
>>>
>>> Thank you...
>>>
>>>> https://en.wikipedia.org/wiki/Density_of_air
>>>>
>>>> Symbol is typically Greek Rho, whose dimensions are generally M/L^3;
>>>> units will probably be kg/m^3, although I am also reading about
>>>> slugs/ft^3.
>>>>
>>>> Which incorporates a gas constant value:
>>>>
>>>> http://en.wikipedia.org/wiki/Gas_constant
>>>>
>>>> Whose units appear to be Joules/(Volume*Temp).
>>>>
>>>> I'm not seeing anything too terribly exotic there; all these units /
>>>> dimensions are present in Boost.Units?
>>>>
>>>> As is usually the case, it is interesting to see how the units library
>>>> "reduces" the units during code writing, compilation. Very impressive
>>>> indeed.
>>>>
>>>> Thank you...
>>>>
>>>> Best regards,
>>>>
>>>> Michael Powell
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