-
Notifications
You must be signed in to change notification settings - Fork 393
Add StandardVolumeFlow quantity #870
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks!
I think it was a good idea to attack this simpler use case first, then think about how to convert to other conditions separately as discussed in #724 .
@rohahn This is almost done, what you're missing is adding the test cases. Step 4 in the wiki: https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit#4-fix-generated-test-stubs-to-resolve-compile-errors-tests You'll see the AppVeyor build failed due to the missing test cases: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing test cases.
Should it really be called StandardVolumeFlow? I am no expert in this but when it comes to mass flow controller devices who usually measure using the unit sccm, they actually measure the mass of the gas that is currently being let through, that is, the mass flow rate. From wikipedia:
|
If you search in Wolfram Alpha, it says Standard Volume Flow. So it seems there is not only a dispute about the meaning of standard but already about the name of the quantity. I first thought about adding the units to the MassFlow quantity, but discarded the idea, since I can not convert to the other units of the quantity. StandardMassFlow seemed wrong. |
From the perspective of a mass flow controller device I would have called it |
I already implemented the unit tests but forgot to add the generated files to git. I'll amend the commit and rebase it on your latest master. |
ad07cc4
to
b00a620
Compare
Codecov Report
@@ Coverage Diff @@
## master #870 +/- ##
==========================================
- Coverage 83.09% 82.69% -0.41%
==========================================
Files 287 291 +4
Lines 42987 44010 +1023
==========================================
+ Hits 35720 36393 +673
- Misses 7267 7617 +350
Continue to review full report at Codecov.
|
I am not sure how to increase the coverage in the generated code. |
Don't worry about it, generated code has less coverage than custom code.
That's all.
|
https://en.wikipedia.org/wiki/Standard_cubic_centimetres_per_minute
Okay, so it's a mass flow rate then. https://www.first-sensor.com/cms/upload/appnotes/AN_Massflow_E_11153.pdf
Wait, so it's a volumetric flow rate, at standard conditions, that can be translated to mass flow rate? https://en.wikipedia.org/wiki/Volumetric_flow_rate
The volumetric wiki seems onboard with sscm.
And this third one agrees. The measurement is volumetric at standard conditions that can be translated into mass flow, given the density of the material. I think the equation is pretty much this (source):
Even the wikis seem to contradict each other and I suspect the unit is in practice used interchangeably, but still think I'm a layman in this domain though, so I need you two guys to help agree on what we should go for here @bitbonk @rohahn 👍 |
LGTM |
We agreed on |
I thought standard volume flow meant the parameters for temperature and pressure was well-defined, are you saying we need to support different standards of temp/pressure in order to use this quantity? If so, then we did solve a similar need with ReferencePressure that may be useful to look at. |
Unfortunately it seems there are a lot of different standards. They could not even agree on the term standard, there is also the term normal. https://instrumentationandcontrol.net/difference-between-actual-standard-and-normal-flows.html#standards At the moment we don't need to calculate with these values, we just need the unit "sccm" in our generic UI. But of course it would be nice to have a full implementation. |
One option to support these other standards is to use different
abbreviations, like
RealCubicCentimeterPerMinute "sccm (real)"
Or similar.
See Volume gallon units as an example of conventions used in the library :
ImperialGallon "gal (imp.)"
UsGallon "gal (U.S.)"
|
9a14bbb
to
a40c4d4
Compare
I have not seen a notation that includes temperature and pressure yet. For our use case we just need the established unit names like "sccm". I am also not sure if it is necessary to work with different standards within one application. |
@angularsen What is the current state on this PR? Do you need additional changes? |
Ok, looks good to me! Let's start easy with this one, and tackle other standards later if the need arises. |
Nuget is on the way |
Great! Thanks for your support. |
Hi guys, I might be a bit late for this comment, but I work in a gas mass flowmeter and controller company and I just wanted to confirm and perhaps add a few things. First of all, I'm glad to see that you classified the final unit as a specific volumetric flow rather then a mass flow. This is often misleading and companies generally use inaccurate terms for simplicity reasons. In short, there are three categories :
As you can see, the naming between mass flow and standard volumetric flow is misleading. As for the actual flow standards, I can confirm that there are quite a few but in practice, the standard temperature is the the parameter that changes the most, I've actually never seen any other standard pressure then 1013 hPa, let alone humidity as most applications rely on dry gasses (there are few devices out there that can handle phase changes, you would only use mass flow in such applications). The point I'm trying to make is that Standard volumetric flow only makes sense if you are able to define a standard temperature and pressure, there are plenty of applications that involve using multiple standard conditions. Unfortunately converting between flow standards is not as simple as it seems. The issue is the chosen gas model, the simplest one is the ideal gas model : PV=nR*T
This model does not take into account the actual volume of the modecules and the forces that the molecules apply on one another, it thus looses its accuracy at higher pressures and temperatures (roughly above 5 bars). A better model does exists, the Van der Vaals equation whish solves this issue (https://en.wikipedia.org/wiki/Van_der_Waals_equation) but it requires solving a 3rd degree polynomial which is doable but harder to implement (I've got a python script for this if needed). Overall , suggest the following improvements :
|
@letherman255 Thanks a lot for great details, I was able to follow the reasoning. I'm happy to assist with conventions and how to best fit it into the library, but it's always best to have it implemented by someone who will be using the new functionality and know the domain well. |
@angularsen I would gladly give it a try, I'll need those features in my own applications anyways. I've just began using the library myself though, so I will need a bit of time to familiarize myself with it first before I can come up with a decent solution. |
@angularsen I started diving into the code and I think I have a few ideas. It seems to me that having an actual quantity for a standard flow is not the right way to go. A standard flow IS a volumetric flow (just a value conversion in relation to specific conditions), not an actual unit as the base units are exactly the same. Every volumetric flow unit can be used as a standard flow unit. Creating a new quantity for standard flow requires copying the entire volumetric flow quantity and call it standard flow, this would probably lead to a lack of consistency between volumetric flow and standard flow : Some units would be available in one quantity but not in the other which is already the case. I found that the pressure wrapper is a very similar issue as you wouldn't want to create 3 different quantities for Absolute, Gauge and Vacuum since the conversion simply relies on subtracting a reference pressure. In the case of a standard flow, the conversion is a bit trickier, requiring a more elaborate gas model, but the reasoning stays the same. At first glance, I would do the following:
The last step could be done later, I would first focus on getting the first two right. Would these changes fit in the library ? @rohahn what is your opinion on this matter ? |
@letherman255 Great, sounds like a good approach to me. Some comments.
|
@letherman255 a full implementation of the standard volume flow would be really nice. |
@rohahn thanks for the feedback. I've implemented the conversion with the ideal gas model for now. It will not be as convenient to use as the ReferencePressure given the number of flow standards aka, the standard temperature and pressure will likely either have to be specified every time or I'll have to add dedicated members:
I'll create a pull request once I'm done. |
Add the Standard Volume Flow quantity which represents the molar flow rate of a gas corrected to "standardized" conditions of temperature and pressure thus representing a fixed number of moles of gas regardless of composition and actual flow conditions.
This is a simple implementation which only adds the quantity with some common units but no complex conversion between different conditions.
Fixes #724