-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Hello,
recently I was investigating on using the unit BEL. Hereby, I discoverd some behaviour which I feel is counter-intuitive. Please see this code snippet:
// linear example
final Quantity<Length> _10_meter = Quantities.getQuantity(10, METRE);
final Quantity<Length> _11_meter = Quantities.getQuantity(11, METRE);
// test linear ratio
assertEquals(1.1, _11_meter.divide(_10_meter).getValue().doubleValue());
// exponential example
final Quantity<Level<Dimensionless>> _10_bel = Quantities.getQuantity(10, BEL);
final Quantity<Level<Dimensionless>> _11_bel = Quantities.getQuantity(11, BEL);
// test exponential ratio
final Quantity<?> ratio = _11_bel.divide(_10_bel); // is 1.04139 with unit ONE
assertEquals(10.0, ratio.getValue().doubleValue()); // fails, with ratio being 1.04139 (log10(11) = 1.04139)As for my understanding, a increase in the sound level by the factor of 10 raises it by one BEL (or more commonly known 10 dB). So, I would expect that the ratio between 11 B and 10 B (or 110 dB and 100 dB) is 10. Using the uom libraries, the result 1.04, however, which is equal to log10(11).
The same issue applies with multiplication:
// linear example
final Quantity<Length> _10_meter = Quantities.getQuantity(10, METRE);
// test linear multiplication
assertEquals(100, _10_meter.multiply(10).getValue().doubleValue());
// exponential example
final Quantity<Level<Dimensionless>> _10_bel = Quantities.getQuantity(10, BEL);
// test exponential ratio
final Quantity<Level<Dimensionless>> result = _10_bel.multiply(10); // is 1e10 with unit B
assertEquals(1.1, result.getValue().doubleValue()); // fails, with result being 1e10What seems to happen in the background is that my multiplying 10 Bel with by 10 it returns 100 Bel, which are then converted into a sound pressure of (10^10). However, the result already holds "10^10 B", which is not correct.
I assume this issue could be fixed by a change in the NonSI.java from a LogConverter to a ExpConverter
// current
public static final Unit<Level<Dimensionless>> BEL = (Unit) addUnit(ONE.transform(new LogConverter(10)), "Bel", "B", true);
// updated
public static final Unit<Level<Dimensionless>> BEL = (Unit) addUnit(ONE.transform(new ExpConverter(10)), "Bel", "B", true);@keilw Adressing this to you, as you're the autor of the current BEL definition.