physics_plus 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e649015dbe928f7849b8bd13d0c4a3659e64439a35cccfdc27350c548ff5d8c
4
- data.tar.gz: e78e605022870a0d6c93e707659d7ef952d9f914b37465ddaf5974a4952290a6
3
+ metadata.gz: 68f215f8775f979e0034ceb43d376dd9b3c2de884e8b2b91e585aa5f6f844002
4
+ data.tar.gz: ee1abe52951e3eab86e6fb07c3ebe57f3ae297629d4d883d16a14a73d1085ed9
5
5
  SHA512:
6
- metadata.gz: b984bac8ca85f5e209da9488cc73a06388e0dcac8d126a46e76fdc1ef02ba757007e9a44df7330886e799519692adc22e19bcaefe09b6193617c4c747df0f658
7
- data.tar.gz: cc027d1988dd1e9f63a175f8d58784369577b33618e74294af15dc000eebdf521546efc2d9e7291efa924216a99ca14467203166187d3ef13baad9694914b11f
6
+ metadata.gz: 151d6de5367201c1e305080b51ce93d447aecfd2b5269545a53df228f009bc5c46986da9aa437dea55ea52c1fe3ef9b5aa803715d5d868db53ada666511cdd56
7
+ data.tar.gz: 03fad634f23e53c5ef67cf21d7bc330849c27d90f2b64d174e227d882af9be1d0462da3a36e824a804794b42b49296c9f58631b5595e61514c8cae85e2bf5403
data/README.md CHANGED
@@ -3,14 +3,13 @@
3
3
 
4
4
  I will try every week to add new gem functionality.
5
5
 
6
- ### features already implemented
7
- - Fundamental Constants
8
6
 
9
7
  ### plans to implement functions
10
8
  - Mechanics
11
9
  - Thermodynamics
12
10
  - Optics
13
11
  - Electrodynamics
12
+ - and others
14
13
 
15
14
  ### Installation
16
15
  GEMFILE:
@@ -23,15 +22,36 @@ INSTALL:
23
22
  gem install physics_plus
24
23
  ```
25
24
 
26
- EXAMPLE (Fundamental Constants):
25
+ EXAMPLE (List fundamental constants):
27
26
  ```
28
27
  require 'physics_plus' => true
29
28
 
30
- puts PhysicsPlus.list_fundamental_constants
31
- puts PhysicsPlus.list_planck_quantities
29
+ puts PhysicsPlus::Constants.List_fundamental_constants
32
30
 
33
- PhysicsPlus.C => 299792458
34
- PhysicsPlus.Na => 6.02214076e+23
31
+ Speed_light_vacuum => 299792458 (Speed of light)
32
+ Gravitational_constant => 6.674484e-11 (Gravitational constant)
33
+ Planck_constant => 6.62607015e-34 (Constant Plank)
34
+ Reduced_Planck_constant => 1.0545717999999998e-34 (Dirac constant)
35
+ Elementary_charge => 1.6021766340000001e-19 (Elementary charge)
36
+ Boltzmanns_constant => 1.380649e-23 (Boltzmann's constant)
37
+
38
+ to others
39
+
40
+ puts PhysicsPlus::Constants.List_planck_quantities
41
+ puts PhysicsPlus::Constants.List_different_systems_quantities
42
+ puts PhysicsPlus::Constants.List_electromagnetic_constants
43
+
44
+ PhysicsPlus::Constants::C => 299792458
45
+ PhysicsPlus::Constants::Speed_light_vacuum => 299792458
46
+
47
+ PhysicsPlus::Constants::G => 6.02214076e+23
48
+ PhysicsPlus::Constants::Gravitational_constant => 6.02214076e+23
49
+
50
+ PhysicsPlus::Optics.absolute_refractive_index(200_000_000) => 1.49896229
51
+ PhysicsPlus::Optics.power_lens(2) => 0.5
52
+
53
+ PhysicsPlus::ElementsTheoryRelativity.inertial_system_length(1.5, 200_000_000) => 1.1174144036800955
54
+ PhysicsPlus::ElementsTheoryRelativity.inertial_system_time(60, 200_000_000) => 80.54308205048527
35
55
  ```
36
56
 
37
57
 
@@ -40,3 +60,4 @@ PhysicsPlus.Na => 6.02214076e+23
40
60
  MIT
41
61
 
42
62
  **Free Software, Hell Yeah!**
63
+
@@ -0,0 +1,113 @@
1
+ # This module contains physical constants
2
+ module PhysicsPlus
3
+ # This module contains physical constants
4
+ class Constants
5
+
6
+ # @return [String] List fundamental constants
7
+ def self.List_fundamental_constants
8
+ constants = <<~CONSTANTS
9
+ Speed_light_vacuum => 299792458 (Speed of light)
10
+ Gravitational_constant => 6.674484e-11 (Gravitational constant)
11
+ Planck_constant => 6.62607015e-34 (Constant Plank)
12
+ Reduced_Planck_constant => 1.0545717999999998e-34 (Dirac constant)
13
+ Elementary_charge => 1.6021766340000001e-19 (Elementary charge)
14
+ Boltzmanns_constant => 1.380649e-23 (Boltzmann's constant)
15
+ CONSTANTS
16
+ end
17
+
18
+ # @return [Integer]
19
+ Speed_light_vacuum = C = 299792458.freeze
20
+
21
+ # @return [Float]
22
+ Gravitational_constant = G = (6.674484 * ( 10 ** (11 * -1.0 ) )).freeze
23
+
24
+ # @return [Float]
25
+ Planck_constant = (6.62607015 * ( 10 ** (34 * -1.0 ) )).freeze
26
+
27
+ # @return [Float]
28
+ Reduced_Planck_constant = (1.0545718 * ( 10 ** (34 * -1.0 ) )).freeze
29
+
30
+ # @return [Float]
31
+ Elementary_charge = (1.602176634 * ( 10 ** (19 * -1.0 ) )).freeze
32
+
33
+ # @return [Float]
34
+ Boltzmanns_constant = (1.380649 * ( 10 ** (23 * -1.0 ) )).freeze
35
+
36
+
37
+ # @return [String] List of planck quantities
38
+ def self.List_planck_quantities
39
+ constants = <<~CONSTANTS
40
+ Planck_mass => 2.176434e-08 (Planck mass)
41
+ Planck_length => 1.616255e-35 (Planck length)
42
+ Planck_time => 5.391246999999999e-44 (Planck time)
43
+ Planck_temperature => 1.4167840000000002e+32 (Planck temperature)
44
+ CONSTANTS
45
+ end
46
+
47
+ # @return [Float]
48
+ Planck_mass = (2.176434 * ( 10 ** (8 * -1.0 ) )).freeze
49
+
50
+ # @return [Float]
51
+ Planck_length = (1.616255 * ( 10 ** (35 * -1.0 ) )).freeze
52
+
53
+ # @return [Float]
54
+ Planck_time = (5.391247 * ( 10 ** (44 * -1.0 ) )).freeze
55
+
56
+ # @return [Float]
57
+ Planck_temperature = (1.416784 * ( 10 ** (32 * 1.0 ) )).freeze
58
+
59
+ # @return [String] List Constants linking different systems of units and conversion factors
60
+ def self.List_different_systems_quantities
61
+ constants = <<~CONSTANTS
62
+ Fine_structure_constant => 0.0072973525693 (Fine structure constant)
63
+ Electrical_constant => 8.854187812799999e-12 (Electrical constant)
64
+ Atomic_mass_unit => 4.1868 (Atomic mass unit)
65
+ Avogadros_constant => 6.02214076e+23 (Avogadro's constant)
66
+ Electron_volt => 1.6021766340000001e-19 (Electron volt)
67
+ Calorie => 4.1868 (Calorie)
68
+ Liter_atmosphere => 101325 (Liter * atmosphere)
69
+ CONSTANTS
70
+ end
71
+
72
+ # @return [Float]
73
+ Fine_structure_constant = (7.2973525693 * ( 10 ** (3 * -1.0 ) )).freeze
74
+
75
+ # @return [Float]
76
+ Electrical_constant = (8.8541878128 * ( 10 ** (12 * -1.0 ) )).freeze
77
+
78
+ # @return [Float]
79
+ Atomic_mass_unit = (1.66053906660 * ( 10 ** (27 * -1.0 ) )).freeze
80
+
81
+ # @return [Float]
82
+ Avogadros_constant = (6.02214076 * ( 10 ** (23 * 1.0 ) )).freeze
83
+
84
+ # @return [Float]
85
+ Electron_volt = (1.602176634 * ( 10 ** (19 * -1.0 ) )).freeze
86
+
87
+ # @return [Float]
88
+ Calorie = 4.1868.freeze
89
+
90
+ # @return [Integer]
91
+ Liter_atmosphere = (101325).freeze
92
+
93
+ # @return [String] List electromagnetic constants
94
+ def self.List_electromagnetic_constants
95
+ constants = <<~CONSTANTS
96
+ Magnetic_constant => 1.25663706212e-06 (Magnetic constant)
97
+ Vacuum_impedance => 376.73 (Vacuum impedance)
98
+ Electrical_constant => 8.854187812799999e-12 (Electrical constant)
99
+ Coulombs_constant => 8987550000.0 (Coulombs constant)
100
+ CONSTANTS
101
+ end
102
+
103
+ # @return [Float]
104
+ Magnetic_constant = (1.25663706212 * ( 10 ** (6 * -1.0 ) )).freeze
105
+
106
+ # @return [Float]
107
+ Vacuum_impedance = 376.73
108
+
109
+ # @return [Float]
110
+ Coulombs_constant = (8.98755 * ( 10 ** (9 * 1.0 ) )).freeze
111
+
112
+ end
113
+ end
@@ -0,0 +1,26 @@
1
+ # This module elements theory relativity
2
+ module PhysicsPlus
3
+ # This class elements theory relativity formulas
4
+ class ElementsTheoryRelativity
5
+ def self.relativistic_velocity_addition(speed_1, speed_2)
6
+ (speed_1 + speed_2)/(1 + (speed_1 * speed_2.to_f)/Constants::C ** 2 )
7
+ end
8
+
9
+ def self.inertial_system_length(length_0, speed)
10
+ length_0 * Math.sqrt(1-(speed.to_f ** 2)/(Constants::C ** 2))
11
+ end
12
+
13
+ def self.inertial_system_time(time_0, speed)
14
+ time_0 / Math.sqrt(1 - (speed.to_f ** 2)/(Constants::C ** 2))
15
+ end
16
+
17
+ def self.inertial_system_weight(weight_0, speed)
18
+ weight_0 / Math.sqrt(1 - (speed.to_f ** 2)/(Constants::C ** 2))
19
+ end
20
+
21
+ def self.relationship_mass_energy(weight)
22
+ weight.to_f * (Constants::C ** 2)
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,49 @@
1
+ # This module optics
2
+ module PhysicsPlus
3
+ # This class optics formulas
4
+ class Optics
5
+ def self.absolute_refractive_index(speed)
6
+ raise 'speed must not exceed the speed of light' if Constants::C < speed
7
+ raise 'speed must be positive' if speed.negative?
8
+
9
+ (Constants::C / speed.to_f)
10
+ end
11
+
12
+ def self.power_lens(focal_length)
13
+ raise 'optical distance must be positive' if focal_length.negative?
14
+ raise 'optical distance must not be zero' if focal_length.zero?
15
+
16
+ 1/focal_length.to_f
17
+ end
18
+
19
+
20
+ def self.thin_lens_formula(f, d)
21
+ raise 'distance from object to lens must be positive' if d.negative?
22
+ raise 'distance from image to lens must be positive' if f.negative?
23
+
24
+ raise 'distance from object to lens must not be zero' if d.zero?
25
+ raise 'distance from image to lens must not be zero' if f.zero?
26
+
27
+ (f + d)/(f.to_f * d)
28
+ end
29
+
30
+ def self.linear_magnification_lens(image_size, item_size)
31
+ raise 'image size must be positive' if image_size.negative?
32
+ raise 'item size must be positive' if item_size.negative?
33
+
34
+ raise 'image_size not be zero' if image_size.zero?
35
+ raise 'item_size not be zero' if item_size.zero?
36
+
37
+ image_size.to_f/item_size
38
+ end
39
+
40
+ def self.interference_minimum_condition(k, lambda)
41
+ (2*k+1)*lambda.to_f/2
42
+ end
43
+
44
+ def self.interference_maximum_condition(k, lambda)
45
+ k * lambda.to_f
46
+ end
47
+
48
+ end
49
+ end
@@ -1,5 +1,5 @@
1
1
  # This module VERSION gem
2
2
  module PhysicsPlus
3
3
  # @return VERSION
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.6'
5
5
  end
data/lib/physics_plus.rb CHANGED
@@ -1,12 +1,9 @@
1
- require_relative 'physics_plus/main/constants'
1
+ require_relative 'physics_plus/constants'
2
+ require_relative 'physics_plus/optics'
3
+ require_relative 'physics_plus/version'
4
+ require_relative 'physics_plus/elements_theory_relativity'
2
5
 
3
6
  # This module is the main one for the gem
4
7
 
5
8
  module PhysicsPlus
6
- # Main module
7
- extend Main::Constants
8
- include Main::Constants
9
9
  end
10
-
11
-
12
- puts PhysicsPlus.list_fundamental_constants
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: physics_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - AlexVikPast
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-28 00:00:00.000000000 Z
11
+ date: 2023-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.6'
27
- description: physics_plus
27
+ description: physics_plus - basic formulas in physics
28
28
  email: steplerpav@gmail.com
29
29
  executables: []
30
30
  extensions: []
@@ -34,7 +34,9 @@ files:
34
34
  - Gemfile
35
35
  - README.md
36
36
  - lib/physics_plus.rb
37
- - lib/physics_plus/main/constants.rb
37
+ - lib/physics_plus/constants.rb
38
+ - lib/physics_plus/elements_theory_relativity.rb
39
+ - lib/physics_plus/optics.rb
38
40
  - lib/physics_plus/version.rb
39
41
  homepage: https://github.com/AlexVikPast/physics_plus
40
42
  licenses:
@@ -1,146 +0,0 @@
1
- # This module contains physical constants
2
- module Main
3
- # This module contains physical constants
4
- module Constants
5
-
6
- # @return [String] List fundamental constants
7
- def list_fundamental_constants
8
- constants = <<~CONSTANTS
9
- Const_C => 299792458 (speed of light)
10
- Const_G => 6.674484e-11 (gravitational constant)
11
- Const_h => 6.62607015e-34 (constant Plank)
12
- Const_h_line => 1.0545717999999998e-34 (Dirac constant)
13
- Const_e => 1.6021766340000001e-19 (elementary charge)
14
- Const_k => 1.380649e-23 (Boltzmann's constant)
15
- CONSTANTS
16
- end
17
-
18
- # @return [Integer]
19
- Const_C = 299792458.freeze
20
- # def C
21
- # 299792458
22
- # end
23
-
24
- # @return [Float]
25
- Const_G = (6.674484 * ( 10 ** (11 * -1.0 ) )).freeze
26
- # def G
27
- # 6.674484 * ( 10 ** (11 * -1.0 ) )
28
- # end
29
-
30
- # @return [Float]
31
- Const_h = (6.62607015 * ( 10 ** (34 * -1.0 ) )).freeze
32
- # def h
33
- # 6.62607015 * ( 10 ** (34 * -1.0 ) )
34
- # end
35
-
36
- # @return [Float]
37
- Const_h_line = (1.0545718 * ( 10 ** (34 * -1.0 ) )).freeze
38
- # def h_line
39
- # 1.0545718 * ( 10 ** (34 * -1.0 ) )
40
- # end
41
-
42
- # @return [Float]
43
- Const_e = (1.602176634 * ( 10 ** (19 * -1.0 ) )).freeze
44
- # def e
45
- # 1.602176634 * ( 10 ** (19 * -1.0 ) )
46
- # end
47
-
48
- # @return [Float]
49
- Const_k = (1.380649 * ( 10 ** (23 * -1.0 ) )).freeze
50
- # def k
51
- # 1.380649 * ( 10 ** (23 * -1.0 ) )
52
- # end
53
-
54
-
55
- # @return [String] List of planck quantities
56
- def list_planck_quantities
57
- constants = <<~CONSTANTS
58
- Const_m_p => 2.176434e-08 (Planck mass)
59
- Const_l_p => 1.616255e-35 (Planck length)
60
- Const_t_p => 5.391246999999999e-44 (Planck time)
61
- Const_T_p => 1.4167840000000002e+32 (Planck temperature)
62
- CONSTANTS
63
- end
64
-
65
- # @return [Float]
66
- Const_m_p = (2.176434 * ( 10 ** (8 * -1.0 ) )).freeze
67
- # def m_p
68
- # 2.176434 * ( 10 ** (8 * -1.0 ) )
69
- # end
70
-
71
- # @return [Float]
72
- Const_l_p = (1.616255 * ( 10 ** (35 * -1.0 ) )).freeze
73
- # def l_p
74
- # 1.616255 * ( 10 ** (35 * -1.0 ) )
75
- # end
76
-
77
- # @return [Float]
78
- Const_t_p = (5.391247 * ( 10 ** (44 * -1.0 ) )).freeze
79
- # def t_p
80
- # 5.391247 * ( 10 ** (44 * -1.0 ) )
81
- # end
82
-
83
- # @return [Integer]
84
- Const_T_p = (1.416784 * ( 10 ** (32 * 1.0 ) )).freeze
85
- # def T_p
86
- # 1.416784 * ( 10 ** (32 * 1.0 ) )
87
- # end
88
-
89
-
90
- # @return [String] List Constants linking different systems of units and conversion factors
91
- def list_planck_quantities
92
- constants = <<~CONSTANTS
93
- Const_alpha => 0.0072973525693 (fine structure constant)
94
- Const_epsilon_0 => 8.854187812799999e-12 (electrical constant)
95
- Const_a_e_m => 4.1868 (atomic mass unit)
96
- Const_Na => 6.02214076e+23 (Avogadro's constant)
97
- Const_eV => 1.6021766340000001e-19 (electron volt)
98
- Const_Calorie => 4.1868 (calorie)
99
- Const_liter_atmosphere => 101325 (liter * atmosphere)
100
- CONSTANTS
101
- end
102
-
103
- # @return [Float]
104
- Const_alpha = (7.2973525693 * ( 10 ** (3 * -1.0 ) )).freeze
105
- # def alpha
106
- # 7.2973525693 * ( 10 ** (3 * -1.0 ) )
107
- # end
108
-
109
- # @return [Float]
110
- Const_epsilon_0 = (8.8541878128 * ( 10 ** (12 * -1.0 ) )).freeze
111
- # def epsilon_0
112
- # 8.8541878128 * ( 10 ** (12 * -1.0 ) )
113
- # end
114
-
115
- # @return [Float]
116
- Const_a_e_m = (1.66053906660 * ( 10 ** (27 * -1.0 ) )).freeze
117
- # def a_e_m
118
- # 1.66053906660 * ( 10 ** (27 * -1.0 ) )
119
- # end
120
-
121
- # @return [Integer]
122
- Const_Na = (6.02214076 * ( 10 ** (23 * 1.0 ) )).freeze
123
- # def Na
124
- # 6.02214076 * ( 10 ** (23 * 1.0 ) )
125
- # end
126
-
127
- # @return [Float]
128
- Const_eV = (1.602176634 * ( 10 ** (19 * -1.0 ) )).freeze
129
- # def eV
130
- # 1.602176634 * ( 10 ** (19 * -1.0 ) )
131
- # end
132
-
133
- # @return [Float]
134
- Const_Calorie = 4.1868.freeze
135
- # def calorie
136
- # 4.1868
137
- # end
138
-
139
- # @return [Integer]
140
- Const_liter_atmosphere = (101325).freeze
141
- # def liter_atmosphere
142
- # 101325
143
- # end
144
-
145
- end
146
- end