Add missing energy units. (#4223)
parent
72729b7c16
commit
07a5ba3e85
|
@ -43,20 +43,6 @@ DDH.conversions = DDH.conversions || {};
|
|||
rightValue: "",
|
||||
|
||||
customUnits: [
|
||||
// CUSTOM MASS UNITS
|
||||
{name: 'dekagram', factor: '10 grams'},
|
||||
{name: 'metricton', factor: '1 megagram'},
|
||||
{name: 'longton', factor: '1016.05 kilograms'},
|
||||
{name: 'shortton', factor: '907.185 kilograms'},
|
||||
{name: 'metricquintal', factor: '100 kilograms'},
|
||||
{name: 'usquintal', factor: '45.359237 kilograms'},
|
||||
{name: 'frenchquintal', factor: '148.95 kilograms'},
|
||||
{name: 'troyounce', factor: '31.1034768 grams'},
|
||||
{name: 'slug', factor: '14.593903 kilograms'},
|
||||
{name: 'tola', factor: '11.6638038 grams'},
|
||||
{name: 'carat', factor: '0.2 grams'},
|
||||
{name: 'atomicmassunit', factor: '0.000000001660538921 femtograms'},
|
||||
|
||||
// CUSTOM AREA UNITS
|
||||
{name: 'barn', factor: '0.00000000000000000000000000000001 hectare'},
|
||||
{name: 'rood', factor: '0.10117141 hectare'},
|
||||
|
@ -66,17 +52,6 @@ DDH.conversions = DDH.conversions || {};
|
|||
{name: 'sqcentimeter', factor: '0.0001 m2'},
|
||||
{name: 'sqmillimeter', factor: '100 sqcentimeter'},
|
||||
|
||||
// CUSTOM DURATION UNITS
|
||||
{name: "femtosecond", factor: "0.000000000000001 second"},
|
||||
{name: "picosecond", factor: "0.000000000001 second"},
|
||||
{name: "fortnight", factor: "2 week"},
|
||||
{name: "siderealyear", factor: "1.00001741 year"},
|
||||
|
||||
// CUSTOM ENERGY UNITS
|
||||
{name: 'kilojoule', factor: '1000 joules'},
|
||||
{name: 'gramcalorie', factor: '4.184 joules'},
|
||||
{name: 'kilocalorie', factor: '4184 joules'},
|
||||
|
||||
// CUSTOM DIGITAL UNITS
|
||||
{name: 'kbit', factor: '1000 b'},
|
||||
{name: 'mbit', factor: '1000000 b'},
|
||||
|
@ -88,6 +63,59 @@ DDH.conversions = DDH.conversions || {};
|
|||
{name: 'TB', factor: '1000 GB'},
|
||||
{name: 'PB', factor: '1000 TB'},
|
||||
|
||||
// CUSTOM DURATION UNITS
|
||||
{name: "femtosecond", factor: "0.000000000000001 second"},
|
||||
{name: "picosecond", factor: "0.000000000001 second"},
|
||||
{name: "fortnight", factor: "2 week"},
|
||||
{name: "siderealyear", factor: "1.00001741 year"},
|
||||
|
||||
// CUSTOM ENERGY UNITS
|
||||
{name: 'kilojoule', factor: '1000 joules'},
|
||||
{name: 'gramcalorie', factor: '4.184 joules'},
|
||||
{name: 'kilocalorie', factor: '4184 joules'},
|
||||
{name: 'footpound', factor: '1.35581795 joules'},
|
||||
{name: 'decielectronvolt', factor: '0.1 electronvolt'},
|
||||
{name: 'centielectronvolt', factor: '0.01 electronvolt'},
|
||||
{name: 'millielectronvolt', factor: '0.001 electronvolt'},
|
||||
{name: 'microelectronvolt', factor: '0.000001 electronvolt'},
|
||||
{name: 'nanoelectronvolt', factor: '0.000000001 electronvolt'},
|
||||
{name: 'picoelectronvolt', factor: '0.000000000001 electronvolt'},
|
||||
{name: 'femtoelectronvolt', factor: '0.000000000000001 electronvolt'},
|
||||
{name: 'attoelectronvolt', factor: '0.000000000000000001 electronvolt'},
|
||||
{name: 'zeptoelectronvolt', factor: '0.000000000000000000001 electronvolt'},
|
||||
{name: 'yoctoelectronvolt', factor: '0.000000000000000000000001 electronvolt'},
|
||||
{name: 'decaelectronvolt', factor: '10000000000000000 femtoelectronvolt'},
|
||||
{name: 'hectoelectronvolt', factor: '100000000000000000 femtoelectronvolt'},
|
||||
{name: 'kiloelectronvolt', factor: '1000000000000000000 femtoelectronvolt'},
|
||||
{name: 'megaelectronvolt', factor: '1000 kiloelectronvolt'},
|
||||
{name: 'gigaelectronvolt', factor: '1000000 kiloelectronvolt'},
|
||||
{name: 'teraelectronvolt', factor: '1000 gigaelectronvolt'},
|
||||
{name: 'petaelectronvolt', factor: '1000 teraelectronvolt'},
|
||||
{name: 'exaelectronvolt', factor: '1000 petaelectronvolt'},
|
||||
{name: 'zettaelectronvolt', factor: '1000 exaelectronvolt'},
|
||||
{name: 'yottaelectronvolt', factor: '1000 zettaelectronvolt'},
|
||||
|
||||
// CUSTOM FORCE UNITS
|
||||
{name: 'kilonewton', factor: '1000 newton'},
|
||||
{name: 'gramforce', factor: '0.00980665 newton'},
|
||||
{name: 'ounceforce', factor: '0.0625 poundforce'},
|
||||
{name: 'kilogramforce', factor: '1000 gramforce'},
|
||||
{name: 'metrictonforce', factor: '1000 kilogramforce'},
|
||||
|
||||
// CUSTOM MASS UNITS
|
||||
{name: 'dekagram', factor: '10 grams'},
|
||||
{name: 'metricton', factor: '1 megagram'},
|
||||
{name: 'longton', factor: '1016.05 kilograms'},
|
||||
{name: 'shortton', factor: '907.185 kilograms'},
|
||||
{name: 'metricquintal', factor: '100 kilograms'},
|
||||
{name: 'usquintal', factor: '45.359237 kilograms'},
|
||||
{name: 'frenchquintal', factor: '148.95 kilograms'},
|
||||
{name: 'troyounce', factor: '31.1034768 grams'},
|
||||
{name: 'slug', factor: '14.593903 kilograms'},
|
||||
{name: 'tola', factor: '11.6638038 grams'},
|
||||
{name: 'carat', factor: '0.2 grams'},
|
||||
{name: 'atomicmassunit', factor: '0.000000001660538921 femtograms'},
|
||||
|
||||
// CUSTOM POWER UNIT
|
||||
{name: 'kilowatt', factor: '1000 watt'},
|
||||
{name: 'megawatt', factor: '1000 kilowatt'},
|
||||
|
@ -96,13 +124,6 @@ DDH.conversions = DDH.conversions || {};
|
|||
{name: 'petawatt', factor: '1000 terawatt'},
|
||||
{name: 'exawatt', factor: '1000 petawatt'},
|
||||
|
||||
// CUSTOM FORCE UNITS
|
||||
{name: 'kilonewton', factor: '1000 newton'},
|
||||
{name: 'gramforce', factor: '0.00980665 newton'},
|
||||
{name: 'ounceforce', factor: '0.0625 poundforce'},
|
||||
{name: 'kilogramforce', factor: '1000 gramforce'},
|
||||
{name: 'metrictonforce', factor: '1000 kilogramforce'},
|
||||
|
||||
// CUSTOM PRESSURE UNITS
|
||||
{name: 'barye', factor: '0.000001 bar' },
|
||||
{name: 'Satm', factor: '1 atm'},
|
||||
|
@ -119,9 +140,9 @@ DDH.conversions = DDH.conversions || {};
|
|||
setUpCustomUnits: function() {
|
||||
for (var i = 0 ; i < this.customUnits.length ; i++) {
|
||||
math.createUnit(
|
||||
this.customUnits[i].name,
|
||||
this.customUnits[i].factor
|
||||
)
|
||||
this.customUnits[i].name,
|
||||
this.customUnits[i].factor
|
||||
)
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -295,14 +316,35 @@ DDH.conversions = DDH.conversions || {};
|
|||
energy: {
|
||||
name: "Energy",
|
||||
units: [
|
||||
{ symbol: 'joule', name: 'Joule' },
|
||||
{ symbol: 'kilojoule', name: 'Kilojoule' },
|
||||
{ symbol: 'gramcalorie', name: 'Gram Calorie' },
|
||||
{ symbol: 'kilocalorie', name: 'Kilo Calorie' },
|
||||
{ symbol: 'Wh', name: 'Watt Hour' },
|
||||
{ symbol: 'erg', name: 'Erg' },
|
||||
{ symbol: 'BTU', name: 'BTU' },
|
||||
{ symbol: 'electronvolt', name: 'Electronvolt' },
|
||||
{ symbol: 'joule', name: 'Joule' },
|
||||
{ symbol: 'kilojoule', name: 'Kilojoule' },
|
||||
{ symbol: 'gramcalorie', name: 'Gram Calorie' },
|
||||
{ symbol: 'kilocalorie', name: 'Kilo Calorie' },
|
||||
{ symbol: 'Wh', name: 'Watt Hour' },
|
||||
{ symbol: 'erg', name: 'Erg' },
|
||||
{ symbol: 'BTU', name: 'BTU' },
|
||||
{ symbol: 'electronvolt', name: 'Electronvolt' },
|
||||
{ symbol: 'footpound', name: 'Foot Pound'},
|
||||
{ symbol: 'decielectronvolt', name: 'Decielectron volt'},
|
||||
{ symbol: 'centielectronvolt', name: 'Centielectron volt'},
|
||||
{ symbol: 'millielectronvolt', name: 'Millielectron volt'},
|
||||
{ symbol: 'microelectronvolt', name: 'Microelectron volt'},
|
||||
{ symbol: 'nanoelectronvolt', name: 'Nanoelectron volt'},
|
||||
{ symbol: 'picoelectronvolt', name: 'Picoelectron volt'},
|
||||
{ symbol: 'femtoelectronvolt', name: 'Femtoelectron volt'},
|
||||
{ symbol: 'attoelectronvolt', name: 'Attoelectron volt'},
|
||||
{ symbol: 'zeptoelectronvolt', name: 'Zeptoelectron volt'},
|
||||
{ symbol: 'yoctoelectronvolt', name: 'Yoctoelectron volt'},
|
||||
{ symbol: 'decaelectronvolt', name: 'Decaelectron volt'},
|
||||
{ symbol: 'hectoelectronvolt', name: 'Hectoelectron volt'},
|
||||
{ symbol: 'kiloelectronvolt', name: 'Kiloelectron volt'},
|
||||
{ symbol: 'megaelectronvolt', name: 'Megaelectron volt'},
|
||||
{ symbol: 'gigaelectronvolt', name: 'Gigaelectron volt'},
|
||||
{ symbol: 'teraelectronvolt', name: 'Teraelectron volt'},
|
||||
{ symbol: 'petaelectronvolt', name: 'Petaelectron volt'},
|
||||
{ symbol: 'exaelectronvolt', name: 'Exaelectron volt'},
|
||||
{ symbol: 'zettaelectronvolt', name: 'Zettaelectron volt'},
|
||||
{ symbol: 'yottaelectronvolt', name: 'Yottaelectron volt'},
|
||||
],
|
||||
defaults: ['joule', 'Wh']
|
||||
},
|
||||
|
|
|
@ -982,6 +982,15 @@ aliases:
|
|||
type: energy
|
||||
unit: erg
|
||||
---
|
||||
aliases:
|
||||
- fp
|
||||
- footpound
|
||||
- footpounds
|
||||
- foot pound
|
||||
- foot pounds
|
||||
type: energy
|
||||
unit: footpound
|
||||
---
|
||||
aliases:
|
||||
- electronvolt
|
||||
- electronvolts
|
||||
|
@ -993,6 +1002,166 @@ type: energy
|
|||
unit: electronvolt
|
||||
symbols: [eV]
|
||||
---
|
||||
aliases:
|
||||
- decielectron volt
|
||||
- decielectronvolt
|
||||
- decielectronvolts
|
||||
- decielectron volts
|
||||
type: energy
|
||||
unit: decielectronvolt
|
||||
---
|
||||
aliases:
|
||||
- microelectron volt
|
||||
- microelectronvolt
|
||||
- microelectronvolts
|
||||
- microelectron volts
|
||||
type: energy
|
||||
unit: microelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- millielectron volt
|
||||
- millielectronvolt
|
||||
- millielectronvolts
|
||||
- millielectron volts
|
||||
type: energy
|
||||
unit: millielectronvolt
|
||||
---
|
||||
aliases:
|
||||
- centielectron volt
|
||||
- centielectronvolt
|
||||
- centielectronvolts
|
||||
- centielectron volts
|
||||
type: energy
|
||||
unit: centielectronvolt
|
||||
---
|
||||
aliases:
|
||||
- nanoelectron volt
|
||||
- nanoelectronvolt
|
||||
- nanoelectronvolts
|
||||
- nanoelectron volts
|
||||
type: energy
|
||||
unit: nanoelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- picoelectron volt
|
||||
- picoelectronvolt
|
||||
- picoelectronvolts
|
||||
- picoelectron volts
|
||||
type: energy
|
||||
unit: picoelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- femtoelectron volt
|
||||
- femtoelectronvolt
|
||||
- femtoelectronvolts
|
||||
- femtoelectron volts
|
||||
type: energy
|
||||
unit: femtoelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- attoelectron volt
|
||||
- attoelectronvolt
|
||||
- attoelectronvolts
|
||||
- attoelectron volts
|
||||
type: energy
|
||||
unit: attoelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- zeptoelectron volt
|
||||
- zeptoelectronvolt
|
||||
- zeptoelectronvolts
|
||||
- zeptoelectron volts
|
||||
type: energy
|
||||
unit: zeptoelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- yoctoelectron volt
|
||||
- yoctoelectronvolt
|
||||
- yoctoelectronvolts
|
||||
- yoctoelectron volts
|
||||
type: energy
|
||||
unit: yoctoelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- decaelectron volt
|
||||
- decaelectronvolt
|
||||
- decaelectronvolts
|
||||
- decaelectron volts
|
||||
type: energy
|
||||
unit: decaelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- hectoelectron volt
|
||||
- hectoelectronvolt
|
||||
- hectoelectronvolts
|
||||
- hectoelectron volts
|
||||
type: energy
|
||||
unit: hectoelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- kiloelectron volt
|
||||
- kiloelectronvolt
|
||||
- kiloelectronvolts
|
||||
- kiloelectron volts
|
||||
type: energy
|
||||
unit: kiloelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- megaelectron volt
|
||||
- megaelectronvolt
|
||||
- megaelectronvolts
|
||||
- megaelectron volts
|
||||
type: energy
|
||||
unit: megaelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- gigaelectron volt
|
||||
- gigaelectronvolt
|
||||
- gigaelectronvolts
|
||||
- gigaelectron volts
|
||||
type: energy
|
||||
unit: gigaelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- teraelectron volt
|
||||
- teraelectronvolt
|
||||
- teraelectronvolts
|
||||
- teraelectron volts
|
||||
type: energy
|
||||
unit: teraelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- petaelectron volt
|
||||
- petaelectronvolt
|
||||
- petaelectronvolts
|
||||
- petaelectron volts
|
||||
type: energy
|
||||
unit: petaelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- exaelectron volt
|
||||
- exaelectronvolt
|
||||
- exaelectronvolts
|
||||
- exaelectron volts
|
||||
type: energy
|
||||
unit: exaelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- zettaelectron volt
|
||||
- zettaelectronvolt
|
||||
- zettaelectronvolts
|
||||
- zettaelectron volts
|
||||
type: energy
|
||||
unit: zettaelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- yottaelectron volt
|
||||
- yottaelectronvolt
|
||||
- yottaelectronvolts
|
||||
- yottaelectron volts
|
||||
type: energy
|
||||
unit: yottaelectronvolt
|
||||
---
|
||||
aliases:
|
||||
- btus
|
||||
- BTU
|
||||
|
|
|
@ -302,4 +302,57 @@ describe("Conversion of Custom Units", function() {
|
|||
expect(conversion).toEqual("50000");
|
||||
});
|
||||
|
||||
/*
|
||||
* CUSTOM ENERGY UNITS
|
||||
*/
|
||||
it("should convert decielectronvolt to centielectronvolt", function() {
|
||||
var conversion = stripUnit(math.eval("50decielectronvolt to centielectronvolt"));
|
||||
expect(conversion).toEqual("500.00000000000006");
|
||||
});
|
||||
|
||||
it("should convert millielectronvolt to microelectronvolt", function() {
|
||||
var conversion = stripUnit(math.eval("5millielectronvolt to microelectronvolt"));
|
||||
expect(conversion).toEqual("5000");
|
||||
});
|
||||
|
||||
it("should convert nanoelectronvolt to picoelectronvolt", function() {
|
||||
var conversion = stripUnit(math.eval("5nanoelectronvolt to picoelectronvolt"));
|
||||
expect(conversion).toEqual("5000.000000000001");
|
||||
});
|
||||
|
||||
it("should convert femtoelectronvolt to attoelectronvolt", function() {
|
||||
var conversion = stripUnit(math.eval("5femtoelectronvolt to attoelectronvolt"));
|
||||
expect(conversion).toEqual("5000");
|
||||
});
|
||||
|
||||
it("should convert zeptoelectronvolt to yoctoelectronvolt", function() {
|
||||
var conversion = stripUnit(math.eval("5zeptoelectronvolt to yoctoelectronvolt"));
|
||||
expect(conversion).toEqual("5000.000000000001");
|
||||
});
|
||||
|
||||
it("should convert decaelectronvolt to hectoelectronvolt", function() {
|
||||
var conversion = stripUnit(math.eval("5decaelectronvolt to hectoelectronvolt"));
|
||||
expect(conversion).toEqual("0.5");
|
||||
});
|
||||
|
||||
it("should convert kiloelectronvolt to megaelectronvolt", function() {
|
||||
var conversion = stripUnit(math.eval("5kiloelectronvolt to megaelectronvolt"));
|
||||
expect(conversion).toEqual("0.005");
|
||||
});
|
||||
|
||||
it("should convert gigaelectronvolt to teraelectronvolt", function() {
|
||||
var conversion = stripUnit(math.eval("5gigaelectronvolt to teraelectronvolt"));
|
||||
expect(conversion).toEqual("0.004999999999999999");
|
||||
});
|
||||
|
||||
it("should convert petaelectronvolt to exaelectronvolt", function() {
|
||||
var conversion = stripUnit(math.eval("5petaelectronvolt to exaelectronvolt"));
|
||||
expect(conversion).toEqual("0.004999999999999999");
|
||||
});
|
||||
|
||||
it("should convert zettaelectronvolt to yottaelectronvolt", function() {
|
||||
var conversion = stripUnit(math.eval("5zettaelectronvolt to yottaelectronvolt"));
|
||||
expect(conversion).toEqual("0.005");
|
||||
});
|
||||
|
||||
});
|
|
@ -1696,8 +1696,97 @@ ddg_goodie_test(
|
|||
from_unit => 'hertz',
|
||||
to_unit => 'hertz',
|
||||
physical_quantity => 'frequency'
|
||||
})
|
||||
})
|
||||
),
|
||||
# energe tests
|
||||
'10 electronvolts to foot pounds' => test_zci(
|
||||
'', structured_answer => make_answer({
|
||||
raw_input => '10',
|
||||
from_unit => 'electronvolt',
|
||||
to_unit => 'footpound',
|
||||
physical_quantity => 'energy'
|
||||
})
|
||||
),
|
||||
'10 decielectronvolt to centielectronvolts' => test_zci(
|
||||
'', structured_answer => make_answer({
|
||||
raw_input => '10',
|
||||
from_unit => 'decielectronvolt',
|
||||
to_unit => 'centielectronvolt',
|
||||
physical_quantity => 'energy'
|
||||
})
|
||||
),
|
||||
'10 millielectronvolts to microelectronvolts' => test_zci(
|
||||
'', structured_answer => make_answer({
|
||||
raw_input => '10',
|
||||
from_unit => 'millielectronvolt',
|
||||
to_unit => 'microelectronvolt',
|
||||
physical_quantity => 'energy'
|
||||
})
|
||||
),
|
||||
'10 nanoelectronvolts to picoelectronvolts' => test_zci(
|
||||
'', structured_answer => make_answer({
|
||||
raw_input => '10',
|
||||
from_unit => 'nanoelectronvolt',
|
||||
to_unit => 'picoelectronvolt',
|
||||
physical_quantity => 'energy'
|
||||
})
|
||||
),
|
||||
'10 femtoelectronvolts to attoelectronvolts' => test_zci(
|
||||
'', structured_answer => make_answer({
|
||||
raw_input => '10',
|
||||
from_unit => 'femtoelectronvolt',
|
||||
to_unit => 'attoelectronvolt',
|
||||
physical_quantity => 'energy'
|
||||
})
|
||||
),
|
||||
'10 zeptoelectronvolts to yoctoelectronvolts' => test_zci(
|
||||
'', structured_answer => make_answer({
|
||||
raw_input => '10',
|
||||
from_unit => 'zeptoelectronvolt',
|
||||
to_unit => 'yoctoelectronvolt',
|
||||
physical_quantity => 'energy'
|
||||
})
|
||||
),
|
||||
'10 decaelectronvolt to hectoelectronvolt' => test_zci(
|
||||
'', structured_answer => make_answer({
|
||||
raw_input => '10',
|
||||
from_unit => 'decaelectronvolt',
|
||||
to_unit => 'hectoelectronvolt',
|
||||
physical_quantity => 'energy'
|
||||
})
|
||||
),
|
||||
'10 kiloelectronvolt to megaelectronvolt' => test_zci(
|
||||
'', structured_answer => make_answer({
|
||||
raw_input => '10',
|
||||
from_unit => 'kiloelectronvolt',
|
||||
to_unit => 'megaelectronvolt',
|
||||
physical_quantity => 'energy'
|
||||
})
|
||||
),
|
||||
'10 gigaelectronvolt to teraelectronvolt' => test_zci(
|
||||
'', structured_answer => make_answer({
|
||||
raw_input => '10',
|
||||
from_unit => 'gigaelectronvolt',
|
||||
to_unit => 'teraelectronvolt',
|
||||
physical_quantity => 'energy'
|
||||
})
|
||||
),
|
||||
'10 petaelectronvolts to exaelectronvolts' => test_zci(
|
||||
'', structured_answer => make_answer({
|
||||
raw_input => '10',
|
||||
from_unit => 'petaelectronvolt',
|
||||
to_unit => 'exaelectronvolt',
|
||||
physical_quantity => 'energy'
|
||||
})
|
||||
),
|
||||
'10 zettaelectronvolt to yottaelectronvolt' => test_zci(
|
||||
'', structured_answer => make_answer({
|
||||
raw_input => '10',
|
||||
from_unit => 'zettaelectronvolt',
|
||||
to_unit => 'yottaelectronvolt',
|
||||
physical_quantity => 'energy'
|
||||
})
|
||||
),
|
||||
|
||||
# natural language queries
|
||||
'unit converter' => test_zci(
|
||||
|
|
Loading…
Reference in New Issue