Skip to content

Commit

Permalink
add test for conversion to joules
Browse files Browse the repository at this point in the history
  • Loading branch information
gnmerritt committed Apr 6, 2022
1 parent 929756c commit 51735c4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 3 additions & 3 deletions qudt/ontology/resources/v2_1_4/VOCAB_QUDT-UNITS-ALL-v2.1.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -20662,7 +20662,7 @@ unit:failures-in-time
rdfs:label "failures in time" ;
skos:prefLabel "failures in time" ;
.
unit:NM3-NAT-GAS:
unit:NM3-NAT-GAS
a qudt:Unit ;
dcterms:description "Normal Cubic Meter - One M3 of natural gas at 0c and 1.01325 bar (=37MJ)";
qudt:conversionMultiplier 3.7E7;
Expand All @@ -20672,7 +20672,7 @@ unit:failures-in-time
rdfs:isDefinedBy <http://qudt.org/2.1/vocab/unit> ;
rdfs:label "Normal Cubic Metre" ;
.
unit:SCM-NAT-GAS:
unit:SCM-NAT-GAS
a qudt:Unit ;
dcterms:description "Standard Cubic Metre - One M3 of natural gas at 15C and 1.01325 bar";
qudt:conversionMultiplier 3.9109E7;
Expand All @@ -20682,7 +20682,7 @@ unit:SCM-NAT-GAS:
rdfs:isDefinedBy <http://qudt.org/2.1/vocab/unit> ;
rdfs:label "Standard Cubic Metre" ;
.
unit:SFT3-NAT-GAS:
unit:SFT3-NAT-GAS
a qudt:Unit ;
dcterms:description "Standard Cubic Foot - One Ft3 of natural gas at 60f and 1.01325 bar";
qudt:conversionMultiplier 1.085E6;
Expand Down
4 changes: 4 additions & 0 deletions qudt/units/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ class EnergyUnit(object):
JOULE: Unit = UnitFactory.get_qudt('J')
BTU: Unit = UnitFactory.get_qudt('BTU_IT')
KWH: Unit = UnitFactory.get_qudt('KiloW-HR')

NM3_GAS: Unit = UnitFactory.get_qudt('NM3-NAT-GAS')
SCM_GAS: Unit = UnitFactory.get_qudt('SCM-NAT-GAS')
SFT3_GAS: Unit = UnitFactory.get_qudt('SFT3-NAT-GAS')
11 changes: 11 additions & 0 deletions test/units/energy_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,16 @@ def test_kwh_to_btu(self) -> None:
self.assertAlmostEqual(btu.value, 170607.08, 2)


class NormalNaturalGasTest(unittest.TestCase):
def test_gas_to_joules(self) -> None:
for gas in [EnergyUnit.NM3_GAS, EnergyUnit.SCM_GAS, EnergyUnit.SFT3_GAS]:
one_standard = Quantity(1, gas)
assert one_standard.unit is not None

joules = one_standard.convert_to(EnergyUnit.JOULE)
assert joules.value > 0
self.assertEqual(joules.unit, EnergyUnit.JOULE)


if __name__ == '__main__':
unittest.main()

0 comments on commit 51735c4

Please sign in to comment.