Skip to content

Commit 5b80070

Browse files
committed
energy
1 parent 5eda964 commit 5b80070

File tree

8 files changed

+68
-4
lines changed

8 files changed

+68
-4
lines changed

lab/test_physics_electron.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
print "De Broglie wavelength of electron is $λdB \n";
2323
$λdB = Electron::getDeBroglieWavelength(Physics::q(1, Planck::length)/Physics::q(1, NonStandard::year));
2424
print "De Broglie wavelength of electron is $λdB \n";
25+
$λdB = Electron::getDeBroglieWavelength(10);
26+
print "\n\n De Broglie wavelength of electron is $λdB \n";
27+
$λdB = Electron::getDeBroglieWavelength(20);
28+
print "De Broglie wavelength of electron is $λdB \n";
2529
?>
2630

2731
<?php

vendor/irrevion/science/Physics/Unit/Categories.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ class Categories {
3636
// btu
3737
// calorie
3838
// coal_ton
39-
// electron_volt
40-
// eV
39+
'electron_volt' => 'Entities\ElectronVolt',
40+
'eV' => 'Entities\ElectronVolt',
4141
// erg
4242
// exajoule
4343
// foot_poundal
4444
// gigajoule
4545
// hartree
46-
// joule
46+
'joule' => 'Entities\Joule',
4747
// kilocalorie
4848
// kcal
4949
// kilojoule
@@ -55,7 +55,7 @@ class Categories {
5555
// rydberg
5656
// terawatt_year
5757
// therm
58-
// watt_hour
58+
'watt_second' => 'Entities\Joule',
5959
],
6060
'length' => [
6161
// Angstrom
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
namespace irrevion\science\Physics\Unit\Entities;
3+
4+
class ElectronVolt implements Energy, NonStandard {
5+
const name = 'electronvolt';
6+
const short_name = 'eV';
7+
// const category = 'energy'; // defined by interface
8+
// const unit_system = 'NonStandart'; // defined by interface
9+
const measure = 'eV';
10+
const reference = 1;
11+
const reference_measure = 'J';
12+
const alias = 'E';
13+
const descr = 'In physics, an electronvolt (symbol eV, also written electron-volt and electron volt) is the measure of an amount of kinetic energy gained by a single electron accelerating from rest through an electric potential difference of one volt in vacuum. When used as a unit of energy, the numerical value of 1 eV in joules (symbol J) is equivalent to the numerical value of the charge of an electron in coulombs (symbol C). Under the 2019 redefinition of the SI base units, this sets 1 eV equal to the exact value 1.602176634×10−19 J.';
14+
const base = 'J';
15+
}
16+
?>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
namespace irrevion\science\Physics\Unit\Entities;
3+
4+
interface Energy extends UnitInterface {
5+
final const category = 'energy';
6+
}
7+
?>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
namespace irrevion\science\Physics\Unit\Entities;
3+
4+
class Joule implements Energy, SI {
5+
const name = 'joule';
6+
const short_name = 'J';
7+
// const category = 'energy'; // defined by interface
8+
// const unit_system = 'SI'; // defined by interface
9+
const measure = 'J';
10+
const reference = 1;
11+
const reference_measure = 'J';
12+
const alias = 'E';
13+
const descr = 'The joule is the unit of energy in the International System of Units (SI). It is equal to the amount of work done when a force of 1 newton displaces a mass through a distance of 1 metre in the direction of the force applied. It is also the energy dissipated as heat when an electric current of one ampere passes through a resistance of one ohm for one second.';
14+
const base = 'J';
15+
}
16+
?>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
namespace irrevion\science\Physics\Unit;
3+
4+
// Hartree units
5+
enum Natural: string implements SystemInterface {
6+
case electron_mass = 'mass.electron_mass';
7+
case electronvolt = 'energy.electronvolt';
8+
case planck_length = 'length.planck_length';
9+
10+
public function i($const='') {
11+
$reflection = Categories::get($this->value);
12+
if (empty($const)) {
13+
return $reflection;
14+
}
15+
return $reflection->getConstant($const);
16+
}
17+
}
18+
?>

vendor/irrevion/science/Physics/Unit/NonStandard.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
enum NonStandard: string implements SystemInterface {
55
case celsius = 'temperature.celsius';
66
case electron_mass = 'mass.electron_mass';
7+
case electronvolt = 'energy.electronvolt';
78
case planck_length = 'length.planck_length';
89
case rankine = 'temperature.rankine';
910
case year = 'time.year';

vendor/irrevion/science/Physics/Unit/SI.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ enum SI: string implements SystemInterface {
1616
// Derived units
1717
case candela_per_square_metre = 'brightness.candela_per_square_metre';
1818
// case celsius = 'temperature.celsius'; // disabled so autocasting still work
19+
case joule = 'energy.joule';
1920
case nit = 'brightness.nit';
2021
case radian = 'angle.radian';
2122
case volt = 'electric_tension.volt';
23+
case watt_second = 'energy.watt_second';
2224

2325
public function i($const='') {
2426
$reflection = Categories::get($this->value);

0 commit comments

Comments
 (0)