-
Notifications
You must be signed in to change notification settings - Fork 393
Adding heat flux units with tests #431
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.
Good job adding all these units!
I found some things you can take a look at.
{ | ||
public class HeatFluxTests : HeatFluxTestsBase | ||
{ | ||
protected override double BtuPerSquareFootHourInOneWattPerSquareMeter => 3.16998331e-1; |
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.
- I think your BTU units are what is called BTU (IT)?
We've seen those before, not sure what IT stands for. International?
For BTU
I get 3.15459
(rounded):
https://www.theunitconverter.com/btu-hour-square-foot-to-watt-square-meter-conversion/
For BTU (IT)
I get 0.316998331
, same as you:
http://www.unitconversion.org/heat-flux-density/watts-per-square-meter-to-btus-it--per-hour-per-square-foot-conversion.html
There is also BTU (th)
: 0.317210471
Here is a pretty complete table:
http://www.unitconversion.org/unit_converter/heat-flux-density-ex.html
- Both links use the naming
BTU/Hour Square Foot
andBTU/h∙ft²
, which would translate toBtuPerHourSquareFoot
. Would that be a more widely used naming thanBtuPerSquareFootHour
?
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.
That is correct, this is the international table BTU, not thermochemical. Do you distinguish anywhere? I did not see any examples. I would generally prefer to stick with it. To quote the American Physical Society:
The International Table (IT) calorie has been adopted in the publications of the Energy Information Administration of the U.S. Department of Energy (DOE/EIA) (3) and of the International Energy Agency of the Organization for Economic Co-operation and Development (OECD/IEA) (4). In view of the importance of these publications, it is reasonable to view the IT calorie as being the preferred unit for discussions of energy production and use, but there is no universally adopted practice (see also the discussion of Btu, below).
I think you are correct about the ordering with names. I will change this.
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.
I'm no domain expert and not really familiar with these IT and Th variants myself.
We don't have a guideline on these yet, but here is what we have so far:
- SpecificEnergy.CaloriePerGram
- SpecificEntropy.CaloriePerGramKelvin
- Energy.Calorie
- Energy.BritishThermalUnit
So we don't already specify variant for calories or BTU. Not sure if these are IT or Th, or what is the most widely used. I don't find any mention of IT and Th in existing units, so I may have been confused by the Therm
unit with abbreviation th
.
I recall these after some discussions and googling in earlier issues, but searching I only found these so I guess we haven't thought too much about it yet:
#322 (comment) (SpecificEntropy)
#85 (BTU)
So. If I am to conclude on anything => no, we don't currently specify IT or Th and we don't distinguish them. The question is, should we? Would you know what makes the most sense?
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.
I have not distinguished, but I can't say that is true for everyone. IT seems to be pretty standard.
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.
Since it seems we have been using IT before and you also find that the most natural, I suggest we stick with it until someone comes around and actually needs the Th variant and a way to distinguish them.
protected override double BtuPerSquareFootMinuteInOneWattPerSquareMeter => 5.28330551e-3; | ||
protected override double BtuPerSquareFootSecondInOneWattPerSquareMeter => 8.80550918e-5; | ||
protected override double BtuPerSquareInchSecondInOneWattPerSquareMeter => 6.11493693e-7; | ||
protected override double CalPerSquareCentiMeterSecondInOneWattPerSquareMeter => 2.39005736e-5; |
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.
I think I prefer typing these fully out, Calories
and Kilocalories
.
And again, you have two variants Calorie (IT)
and Calorie (th)
.
No idea what they are, but they keep showing up:
http://www.unitconversion.org/unit_converter/heat-flux-density-ex.html
"Localization": [ | ||
{ | ||
"Culture": "en-US", | ||
"Abbreviations": [ "BTU/in²/s" ] |
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.
Would BtuPerSecondSquareInch
and BTU/(s∙in²)
be better? Ref comments above about naming.
Same for units below.
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.
Yes, I will change this.
] | ||
}, | ||
{ | ||
"SingularName": "KiloCalPerSquareMeterHour", |
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.
I think you can remove KiloCalPerSquareMeterHour
, since you already have a prefix Kilo
in CalPerSquareCentiMeterSecond
?
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.
Wouldn't the Kilo prefix only apply to CalPerSquareCentiMeterSecond? [CalPerSquareCentiMeterSecond and KiloCalPerSquareCentiMeterSecond].
This case is m²/hr, not centimeter as above.
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.
Ah I misread. But you can change this to CalPerSquareMeterHour
and add Kilo
as prefix to get both Cal and Kilocal, if that makes sense to you.
If you don't need that, then keep this and fix the case-typo KiloCal
-> Kilocal
.
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.
It isn't very common so I just fixed the case
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.
Comments on latest changes
protected override double BtuPerHourSquareFootInOneWattPerSquareMeter => 3.16998331e-1; | ||
protected override double BtuPerMinuteSquareFootInOneWattPerSquareMeter => 5.28330551e-3; | ||
protected override double BtuPerSecondSquareFootInOneWattPerSquareMeter => 8.80550918e-5; | ||
protected override double BtuPerSecondSquareInchInOneWattPerSquareMeter => 6.11493693e-7; |
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.
I can't seem to locate a source to verify this one, but my attempt on the calculator based on BtuPerSecondSquareFootInOneWattPerSquareMeter
gives me the same.
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.
I checked Google and WolframAlpha
protected override double BtuPerMinuteSquareFootInOneWattPerSquareMeter => 5.28330551e-3; | ||
protected override double BtuPerSecondSquareFootInOneWattPerSquareMeter => 8.80550918e-5; | ||
protected override double BtuPerSecondSquareInchInOneWattPerSquareMeter => 6.11493693e-7; | ||
protected override double CalPerSecondSquareCentimeterInOneWattPerSquareMeter => 2.39005736e-5; |
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.
Will you rename all Cal
to Calorie
as well? For consistency with existing units.
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.
Absolutely. Consistency is good!
protected override double CentiwattsPerSquareMeterInOneWattPerSquareMeter => 1e2; | ||
protected override double DeciwattsPerSquareMeterInOneWattPerSquareMeter => 1e1; | ||
protected override double KilocalPerSecondSquareCentimeterInOneWattPerSquareMeter => 2.39005736e-8; | ||
protected override double KilocalPerHourSquareMeterInOneWattPerSquareMeter => 8.6042065e-1; |
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.
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 like I made the mistake here. I used thermochemical not IT :)
Fix and verify: WolframAlpha
"FromUnitToBaseFunc": "x*1.16222222", | ||
"FromBaseToUnitFunc": "x/1.16222222", | ||
"Localization": [ | ||
{ | ||
"Culture": "en-US", | ||
"Abbreviations": [ "kcal/m²/hr" ] | ||
"Abbreviations": [ "kcal/hr·m²" ] |
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.
You need to add parantheses here and for the above units, like: kcal/(hr·m²)
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.
I have never seen it written this way. Order of operations should already take care of it, no? https://www.pentairthermal.com/Images/EN-IndustrialHeatTracingUnitConversionTable-AR-H57432_tcm432-26156.pdf
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.
Hm, good point. I'm not really sure what are the conventions on this, but I too have seen the form without the parantheses. I thought precedence was not universal for math, but rather chosen and defined per programming language.
https://en.wikipedia.org/wiki/Order_of_operations
Here it seems that division by x is treated just like an multiplication of 1/x
, and if I got that right then kcal/hr·m²
becomes kcal*(1/hr)*m²
- which is not correct.
https://math.berkeley.edu/~gbergman/misc/numbers/ord_ops.html
Here it seems there is no universally agreed upon order, so use parantheses instead.
Do you know if there is any litterature backing up the form of not using parantheses and still being unambiguous? I'm not familiar in this territory.
"Localization": [ | ||
{ | ||
"Culture": "en-US", | ||
"Abbreviations": [ "BTU/hr·ft²" ] |
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.
Now I look at the others, I suspect I should abbreviate hr to h, correct?
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.
Yes we have a guideline to use h
, unless it would go against a widely used convention.
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.
"FromUnitToBaseFunc": "x*1.16222222", | ||
"FromBaseToUnitFunc": "x/1.16222222", | ||
"Localization": [ | ||
{ | ||
"Culture": "en-US", | ||
"Abbreviations": [ "kcal/m²/hr" ] | ||
"Abbreviations": [ "kcal/hr·m²" ] |
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.
I have never seen it written this way. Order of operations should already take care of it, no? https://www.pentairthermal.com/Images/EN-IndustrialHeatTracingUnitConversionTable-AR-H57432_tcm432-26156.pdf
I saw some other ideas floated around about base dimensions. They would be very useful. I thought about adding the following, even if not used yet: {
"Name": "HeatFlux",
"BaseUnit": "WattPerSquareMeter",
"XmlDoc": "Heat flux is the flow of energy per unit of area per unit of time",
"BaseUnitDimensions":
{
"Length": 0,
"Mass": 1,
"Time": -3,
"ElectricCurrent": 0,
"ThermodynamicTemperature": 0,
"AmountOfSubstance": 0,
"LuminousIntensity": 0
}
} |
I'd love to. Thanks for pointing me to it. Would you be opposed to adding this info to the json files even if not yet currently used? I decided on the format above vs the si array as it is a bit more explicit. |
I wouldn't want to add it before it is actually used, no. I don't want to risk not completing the feature and having stuff in the JSON that is not in use, and confuse the next guy reading it. |
Sounds good. Thanks! Is there anything else for this pull request? |
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.
A few more :-)
new CulturesForEnumValue((int) HeatFluxUnit.BtuPerSecondSquareFoot, | ||
new[] | ||
{ | ||
new AbbreviationsForCulture("en-US", "BTU/s·ft²"), |
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.
We need to nail this form first. I personally find it ambiguous the way it reads now, but I am no domain expert on this.
A quick google tells me that the these forms are used:
Btu (IT)/s/ft²
Btu/(s.ft2)
Btu (IT)/second/ft²
Btuth·in/(h·ft2·°F)
(just consider the form here)
So from this, I conclude that we need to use parantheses or use a second division. What do you think?
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.
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.
Alright, I'm sold :-) We will keep this form then since at least in the context of these units they seem commonly used.
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.
Sounds good.
}, | ||
{ | ||
"SingularName": "KilocaloriePerHourSquareMeter", | ||
"PluralName": "KilocaloriePerHourSquareMeter", |
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.
Plural: Kilocalories
}, | ||
{ | ||
"SingularName": "CaloriePerSecondSquareCentimeter", | ||
"PluralName": "CaloriePerSecondSquareCentimeter", |
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.
Plural: Calories
}, | ||
{ | ||
"SingularName": "BtuPerHourSquareFoot", | ||
"PluralName": "BtuPerHourSquareFoot", |
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.
Plural: Btus
}, | ||
{ | ||
"SingularName": "BtuPerSecondSquareFoot", | ||
"PluralName": "BtuPerSecondSquareFoot", |
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.
Plural: Btus
}, | ||
{ | ||
"SingularName": "BtuPerSecondSquareInch", | ||
"PluralName": "BtuPerSecondSquareInch", |
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.
Plural: Btus
}, | ||
{ | ||
"SingularName": "WattPerSquareFoot", | ||
"PluralName": "WattPerSquareFoot", |
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.
Plural: Watts
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.
Do you expect BaseUnit to also be WattsPerSquareMeter? I used WattPerSquareMeter based on what I saw in Irradiance
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.
Use SingularName for BaseUnit. ;)
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.
BaseUnit needs to be singular and match exactly one of the SingularName
entries in the JSON, plural is only used to generate proper names of methods and properties, such as double val = myLength.Meters
and double val = myHeatFlux.WattsPerSquareFoot
.
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.
Excellent, thanks for the info. Good to get acquainted as I plan to contribute in the future :)
}, | ||
{ | ||
"SingularName": "WattPerSquareInch", | ||
"PluralName": "WattPerSquareInch", |
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.
Plural: Watts
Hope everything is fixed up now! |
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!
Good job on this 😃
Nuget 3.97 is on the way out 👍 |
Thanks! |
Adding heat flux. My first contribution so I hope everything is in order. Thank you!