OPM / opm-parser

http://www.opm-project.org
11 stars 44 forks source link

Unit conversion involving temperature #1202

Closed totto82 closed 6 years ago

totto82 commented 6 years ago

While testing the energy module flow I notice an issue with unit conversion and temperature. For me it seems like the "constant" scaling factor is not taken into account. I added the following simple test to UnitTests.cpp and it fails on all 4.


BOOST_AUTO_TEST_CASE(Temperature) {
    auto field = UnitSystem::newFIELD();
    auto metric = UnitSystem::newMETRIC();

    BOOST_CHECK_CLOSE( 80.33 , field.from_si(UnitSystem::measure::temperature, 300.0) , 1.0e-6 );
    BOOST_CHECK_CLOSE( 26.85 , metric.from_si(UnitSystem::measure::temperature, 300.0) , 1.0e-6 );

    BOOST_CHECK_CLOSE( 310.928 , field.to_si(UnitSystem::measure::temperature, 100.0) , 1.0e-6 );
    BOOST_CHECK_CLOSE( 373.15 , metric.to_si(UnitSystem::measure::temperature, 100.0) , 1.0e-6 );

}
andlaus commented 6 years ago

hm, weird. I'll have a look. I think your test case should be added permanently, though.

andlaus commented 6 years ago

I think your test case should be added permanently, though.

scratch that, temperature is already tested by this test, it is just not yet correctly tested ;)