units use and weird cases....suggestions needed
I'm using the units library to make sure values supplied to functions make sense, dimensionally, and are in the units expected. I've got a strange case I have to work with though. For the most part we've decided to standardize on the SI system. I write my functions to be system independent when possible, but most of what I'm working with is empirically based. For this I'll take the SI units expected and write the function only for that system (since other systems will use different equations entirely). The problem domain is fluid dynamics so enter the Kv and Cv values. Technically these are a measure of volumetric flow. For instance, Kv is defined as: the flow of water with temperature ranging 5 - 30 oC through a valve in cubic meters per hour (m3/h) with a pressure drop of 1 bar The problem is that engineers see this as a "unitless" value and treat it as having no units at all. They use Kv in SI based equations, not m3/s as we'd expect. Thus all equations being fed to us use Kv as if it were a natural part of the equation. Most of the time these dimensions do not compute dimensionally anyway but there's rare cases when they do. I have gotten the engineers (those giving me specs for code I write) to decide on Kv instead of doing both Kv and Cv (it's a basic conversion). The options I see are: 1. Convert both Kv and Cv into m3/s and require engineers to give equations with that in mind. This will be very unnatural for them though. 1a. Do the conversion but don't tell them I'm doing it. This one seems the least preferable as we've tried to make sure eng. documents and code match and further...it might be hard for maintenance developers later. 2. Pretend...just use m3ps and pretend I'm using Kv (m3/h). Don't convert or anything...just lie. I have a hard time with that one since it sort of goes against the purpose of the library and again would seem to introduce confusion for maintenance. 3. Use different types either in the form of a different unit "system" or using BOOST_STRONG_TYPEDEF...or something. What are some suggestions here?
The problem domain is fluid dynamics so enter the Kv and Cv values.
Technically these are a measure of volumetric flow. For instance, Kv is defined as:
the flow of water with temperature ranging 5 - 30 oC through a valve in cubic meters per hour (m3/h) with a pressure drop of 1 bar
The problem is that engineers see this as a "unitless" value and treat it as having no units at all. They use Kv in SI based equations, not m3/s as we'd expect. Thus all equations being fed to us use Kv as if it were a natural part of the equation.
Most of the time these dimensions do not compute dimensionally anyway but there's rare cases when they do. I have gotten the engineers (those giving me specs for code I write) to decide on Kv instead of doing both Kv and Cv (it's a basic conversion).
It's a little hard to see where the problem is without a concrete example. How about one equation and the corresponding function, with ancillary information about the expected units of inputs/output? Matthias
Matthias Schabel wrote:
The problem domain is fluid dynamics so enter the Kv and Cv values.
Technically these are a measure of volumetric flow. For instance, Kv is defined as:
the flow of water with temperature ranging 5 - 30 oC through a valve in cubic meters per hour (m3/h) with a pressure drop of 1 bar
The problem is that engineers see this as a "unitless" value and treat it as having no units at all. They use Kv in SI based equations, not m3/s as we'd expect. Thus all equations being fed to us use Kv as if it were a natural part of the equation.
Most of the time these dimensions do not compute dimensionally anyway but there's rare cases when they do. I have gotten the engineers (those giving me specs for code I write) to decide on Kv instead of doing both Kv and Cv (it's a basic conversion).
It's a little hard to see where the problem is without a concrete example. How about one equation and the corresponding function, with ancillary information about the expected units of inputs/output?
I'll try, but I'm not an engineer. I believe the "flow coefficient" (Kv) is mostly used in calculating flow through valves and fittings. It has a relationship with a "resistance coefficient" (K) in that: K = C1 * pi^2 * d^4 / Kv^2 Kv = C2 * pi * d^2 / K^.5 d is the valve diameter. C1 and C2 are really large numbers. The volumetric flow (Q) can then be found: Q = C * Kv * ( dP / p )^.5 Where C is a constant, dP is a pressure, and p is a density. That equation might look a bit different for SI (that's in some set of US units, not necessarily a true system) but the point is that Kv will still be in cubic meters per hour. TP410 states, "At the time of preparation of this paper there is no agreed international definition for flow coefficient in the terms of SI units." That was 50 years ago or something and it's not changed. It should be possible to convert Kv into m3/s but the equations the engineers work in, and thus will be giving me and are in our sources, simply do not use this unit for that variable even if everything else is in SI.
I'll try, but I'm not an engineer.
I believe the "flow coefficient" (Kv) is mostly used in calculating flow through valves and fittings. It has a relationship with a "resistance coefficient" (K) in that:
K = C1 * pi^2 * d^4 / Kv^2 Kv = C2 * pi * d^2 / K^.5
d is the valve diameter. C1 and C2 are really large numbers.
The volumetric flow (Q) can then be found:
Q = C * Kv * ( dP / p )^.5
Where C is a constant, dP is a pressure, and p is a density.
That equation might look a bit different for SI (that's in some set of US units, not necessarily a true system) but the point is that Kv will still be in cubic meters per hour. TP410 states, "At the time of preparation of this paper there is no agreed international definition for flow coefficient in the terms of SI units." That was 50 years ago or something and it's not changed.
Without referring to any particular unit system, you can see that Kv
has to have units of
U{Kv} = U{Q}/U{(dP/p)^.5}
= (L^3/T)/((M/(L T^2))/(M/L^3))^.5
= L^2
so your flow coefficient needs to have units of area. To get a correct
numerical value, you should just implement the internals of the
function so that the various inputs are converted to the units in
which the equation was defined originally...say you know that Kv is
0.42 (random choice) for flow in gallons per minute, pressure in psi,
and density in pounds/cubic inch. Then you can just convert Kv into SI
units (hack for definition of pounds-force per square inch - I'll add
those for the next release)...
#include
It should be possible to convert Kv into m3/s but the equations the engineers work in, and thus will be giving me and are in our sources, simply do not use this unit for that variable even if everything else is in SI.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Noah Roberts wrote:
I'm using the units library to make sure values supplied to functions make sense, dimensionally, and are in the units expected. I've got a strange case I have to work with though.
For the most part we've decided to standardize on the SI system. I write my functions to be system independent when possible, but most of what I'm working with is empirically based. For this I'll take the SI units expected and write the function only for that system (since other systems will use different equations entirely).
The problem domain is fluid dynamics so enter the Kv and Cv values.
Technically these are a measure of volumetric flow. For instance, Kv is defined as:
the flow of water with temperature ranging 5 - 30 oC through a valve in cubic meters per hour (m3/h) with a pressure drop of 1 bar
The problem is that engineers see this as a "unitless" value and treat it as having no units at all. They use Kv in SI based equations, not m3/s as we'd expect. Thus all equations being fed to us use Kv as if it were a natural part of the equation.
Most of the time these dimensions do not compute dimensionally anyway but there's rare cases when they do. I have gotten the engineers (those giving me specs for code I write) to decide on Kv instead of doing both Kv and Cv (it's a basic conversion).
The options I see are:
1. Convert both Kv and Cv into m3/s and require engineers to give equations with that in mind. This will be very unnatural for them though.
We've picked this course of action. It turns out that the flow coefficient is a volumetric flow over sqrt(pressure). Now I just need to figure out how to represent that in the dimension system of the library and all is good.
participants (2)
-
Matthias Schabel
-
Noah Roberts