From 33048ac0d7d0041cdac3fd7891b7109f867e2b5f Mon Sep 17 00:00:00 2001 From: Boyd Duffee Date: Sat, 4 Jun 2022 14:06:11 +0100 Subject: [PATCH] Correct value for electron volt in Units.pm Correct exponential for factor of eV fixes #677 Adds definitions for kev, MeV and GeV Remove t/README because it has been superseded by t/README.md --- lib/Units.pm | 31 ++++++++++++++++++++++++++----- t/README | 14 -------------- 2 files changed, 26 insertions(+), 19 deletions(-) delete mode 100644 t/README diff --git a/lib/Units.pm b/lib/Units.pm index 50830b868f..a2dc07505f 100644 --- a/lib/Units.pm +++ b/lib/Units.pm @@ -475,9 +475,12 @@ our %known_units = ('m' => { # cal -- calorie # kcal -- kilocalorie # eV -- electron volt +# keV -- kilo electron volt +# MeV -- mega electron volt +# GeV -- giga electron volt # kWh -- kilo Watt hour # - 'J' => { + 'J' => { 'factor' => 1, 'm' => 2, 'kg' => 1, @@ -501,13 +504,13 @@ our %known_units = ('m' => { 'kg' => 1, 's' => -2 }, - 'kt' => { + 'kt' => { 'factor' => 4.184E12, 'm' => 2, 'kg' => 1, 's' => -2 }, - 'Mt' => { + 'Mt' => { 'factor' => 4.184E15, 'm' => 2, 'kg' => 1, @@ -525,8 +528,26 @@ our %known_units = ('m' => { 'kg' => 1, 's' => -2 }, - 'eV' => { - 'factor' => 1.60E-9, + 'eV' => { + 'factor' => 1.6022E-19, + 'm' => 2, + 'kg' => 1, + 's' => -2 + }, + 'keV' => { + 'factor' => 1.6022E-16, + 'm' => 2, + 'kg' => 1, + 's' => -2 + }, + 'MeV' => { + 'factor' => 1.6022E-13, + 'm' => 2, + 'kg' => 1, + 's' => -2 + }, + 'GeV' => { + 'factor' => 1.6022E-10, 'm' => 2, 'kg' => 1, 's' => -2 diff --git a/t/README b/t/README deleted file mode 100644 index 77ca89b829..0000000000 --- a/t/README +++ /dev/null @@ -1,14 +0,0 @@ -These files, contributed by Boyd Duffe, are an example of writing unit tests -for PG modules so that we can determine (a) that they work, and (b) that they continue -to work when some seemingly innocuous change elsewhere in the system causes troubles -in this module. - -Of course this is not supposed to happen when modular programming practices are followed -but it happens anyway. :-) - -We need more "unit tests" like this. (The unit does not refer to Unit.pm but to testing -a small piece or unit of the WeBWorK/PG code.) I would also like to wire these -in so that administrators can perform these tests from the admin page on the web -to reassure themselves that the new version of PG they are using is functioning correctly. - -