maltsev / UnitConversionBot

Telegram bot that converts units (e.g. feet → meters)
https://t.me/UnitConversionBot
GNU General Public License v3.0
8 stars 1 forks source link

Add conversion for Power/Torque, L/100km #1

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hello!

i just found your bot and really liked it. Very handy. This bot does not accept power or torque requests and it kindly asks me to ask you to teach the bot. ft-lb/Nm, hp/kW/PSare not supported. The fuel consumption conversion to L/100km in "/units/fuel_consumption.py" is also not finished. I have seen a few examples online and it seems doable. Though i am no developer nor mathematician. Below are the numbers necessary for conversion of torque and power:

|     | PS      | hp      | kW       |  
|-----|---------|---------|----------|
| 1PS | 1       | 0.98632 | 0.735499 | 
| 1hp | 1.01387 | 1       | 0.74570  |
| 1kW | 1.35962 | 1.34102 | 1        |

1 Nm is 0.74 ft-lb 1 ft-lb is 1.36 Nm

Thank you for your attention.

maltsev commented 4 years ago

Hi Lars,

The fuel consumption conversion to L/100km in "/units/fuel_consumption.py" is also not finished

Right. My function for conversion doesn't support inverse linear relationships (i.e., more L/100km result in less km/L), so I have to rewrite that part to add such conversions. Unfortunately, I don't have much time for that now :-/

PS ↔ hp ↔ kW and Nm ↔ ft-lb conversions seem to be non-inverse linear, right? So more PS/hp/kW always results in more kW/PS/hp?

ghost commented 4 years ago

Since you already have km/L, wouldnt the conversion to L/100km just be like this? 5 km/L = 100/5 = 20 L/100km?

The conversion of power/torque is done by multiplying. More X results in more Y, with power and torque.

maltsev commented 4 years ago

Since you already have km/L, wouldnt the conversion to L/100km just be like this? 5 km/L = 100/5 = 20 L/100km?

Right, but the function that does the conversion expects only one number, which it multiplies then with another number predefined. But in this case, the number should be divided and not multiplied. So I have to change that behavior, so it supports both multiplication and division.

The conversion of power/torque is done by multiplying. More X results in more Y, with power and torque.

Perfect! Then I think this week I'll be able to add these conversions.

ghost commented 4 years ago

Right, but the function that does the conversion expects only one number, which it multiplies then with another number predefined. But in this case, the number should be divided and not multiplied. So I have to change that behavior, so it supports both multiplication and division.

Ah right. I just checked in a python shell and "print 100/10.2" does exactly what i expect. Google confirms.

Perfect! Then I think this week I'll be able to add these conversions.

Thank you for your time!

maltsev commented 4 years ago

Done:

> 1 hp to PS
1.014 PS

> 1 ft-lb to n m
1.356 N-m

Since Nm name was already reserved for nanometers I changed it to N-m.

maltsev commented 4 years ago

For fuel conversion, I opened a new PR #2.