unitsofmeasurement / uom-systems

Units of Measurement Systems
http://www.uom.systems
Other
36 stars 17 forks source link

USCustomary Horsepower is calculated as Metric Horsepower #186

Closed PHMT-CW closed 3 years ago

PHMT-CW commented 3 years ago

I've been doing some unit conversions and discovered that the USCustomary class defines a Horsepower unit that is in fact calculated as Metric Horsepower instead of Mechanical Horsepower (equivalent to Imperial Horsepower). Since this is USCustomary it would make sense that the unit used is Mechanical Horsepower instead.

1 hp(I) = 745.699872 W 
hp(I) = P(W) / 745.699872

Code change:

public static final Unit<Power> HORSEPOWER = addUnit(WATT.multiply(745.699872), "Horsepower", "HP");
keilw commented 3 years ago

At least related to cars and motor engines both are required, in fact the Metric Horsepower looks even more widely used in that sense, so I would not remove the current one without a proper replacement. I'm a bit unsure where the right place is for it, one option could be NonSI in the SI Units module.

keilw commented 3 years ago

There is also a HORSEPOWER in CLDR, @PHMT-CW do you have a quick chance to compare if they are the same or one differs from the other? I would try to refrain from adding anything to NonSI that is not in Table 8 of the SI Brochure and Horsepower isn't, so Unicode CLDR also defining both a US/Imperial CUP and a CUP_METRIC there already sounds like a good place to add a Metric Horsepower while keeping USCustomary to the US version.

PHMT-CW commented 3 years ago

@keilw it looks like based off the equation the HORSEPOWER unit in CLDR is the Mechanical / Imperial Horsepower and is different to the one specified in the USCustomary, if you look at the wiki on horsepower all three general types of horsepower are roughly the same but not exact. Anyway, at this stage I've simply defined my own custom units for my work which involve horsepower and based off your comments about not wanting to change it up to much, how about we compromise on a simple name change for the horsepower constant to be consistent with the type it is.

USCustomary (with a minor change the value constant for more accuracy): public static final Unit<Power> METRIC_HORSEPOWER = addUnit(WATT.multiply(735.49875), "Horsepower", "HP");

CLDR (my test cases confirm the conversion between HP and Watts to be accurate): public static final Unit<Power> MECHANICAL_HORSEPOWER = addUnit(new ProductUnit<Power>(FOOT_INTERNATIONAL.multiply(POUND_FORCE).divide(SECOND)));

Lastly (you might need to find a place to put this one) Electrical Horsepower is most commonly used within the US to define the power output for electric motors. All other places around the world generally express electric motors power output in Watts or Kilowatts. public static final Unit<Power> ELECTRICAL_HORSEPOWER = addUnit(WATT.multiply(746), "Horsepower", "HP");

keilw commented 3 years ago

Well there are several Horsepower Definitions and beside the electrical even the boiler variant could matter somewhere, but possibly just in the "energy" module of https://github.com/unitsofmeasurement/uom-domain. If we added anything to the CLDR it should match its naming conventions already in place like HORSEPOWER (a unit the CLDR itself defined) and we might take the freedom to add a HORSEPOWER_METRIC similar to CUP_METRIC, etc. but not completely deviate from its naming conventions.