chemistry_paradise 1.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of chemistry_paradise might be problematic. Click here for more details.

Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +222 -0
  3. data/bin/chemistry_paradise +7 -0
  4. data/chemistry_paradise.gemspec +45 -0
  5. data/doc/BUGS.md +16 -0
  6. data/doc/README.gen +205 -0
  7. data/doc/TODO.md +13 -0
  8. data/lib/chemistry_paradise.rb +6 -0
  9. data/lib/chemistry_paradise/base/base.rb +101 -0
  10. data/lib/chemistry_paradise/base/colours.rb +65 -0
  11. data/lib/chemistry_paradise/calculate_atomic_mass.rb +487 -0
  12. data/lib/chemistry_paradise/combustion_analysis.rb +181 -0
  13. data/lib/chemistry_paradise/commandline/help.rb +35 -0
  14. data/lib/chemistry_paradise/commandline/menu.rb +80 -0
  15. data/lib/chemistry_paradise/commandline/parse_commandline.rb +94 -0
  16. data/lib/chemistry_paradise/constants/constants.rb +52 -0
  17. data/lib/chemistry_paradise/constants/file_constants.rb +27 -0
  18. data/lib/chemistry_paradise/constants/german_names_of_elements_to_element_symbol.rb +157 -0
  19. data/lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb +134 -0
  20. data/lib/chemistry_paradise/converters/fahrenheit_to_celsius.rb +122 -0
  21. data/lib/chemistry_paradise/converters/shared.rb +15 -0
  22. data/lib/chemistry_paradise/electron_negativity_chart.rb +78 -0
  23. data/lib/chemistry_paradise/equalize_chemical_formula.rb +82 -0
  24. data/lib/chemistry_paradise/equation_solver.rb +130 -0
  25. data/lib/chemistry_paradise/interactive_chemistry_shell.rb +241 -0
  26. data/lib/chemistry_paradise/orbitals.rb +65 -0
  27. data/lib/chemistry_paradise/project/project_base_directory.rb +24 -0
  28. data/lib/chemistry_paradise/requires/common_external_requires.rb +17 -0
  29. data/lib/chemistry_paradise/shared.rb +162 -0
  30. data/lib/chemistry_paradise/show_electron_configuration.rb +243 -0
  31. data/lib/chemistry_paradise/show_electron_negativity_of_this_element.rb +101 -0
  32. data/lib/chemistry_paradise/show_element.rb +141 -0
  33. data/lib/chemistry_paradise/split_molecule_names.rb +185 -0
  34. data/lib/chemistry_paradise/toplevel_methods/atomgewichte.rb +31 -0
  35. data/lib/chemistry_paradise/toplevel_methods/display_where_the_molmasses_are_kept.rb +24 -0
  36. data/lib/chemistry_paradise/toplevel_methods/e.rb +16 -0
  37. data/lib/chemistry_paradise/toplevel_methods/kelvin.rb +34 -0
  38. data/lib/chemistry_paradise/toplevel_methods/language.rb +50 -0
  39. data/lib/chemistry_paradise/toplevel_methods/periodic_table.rb +16 -0
  40. data/lib/chemistry_paradise/toplevel_methods/remove_this_molecule_from.rb +63 -0
  41. data/lib/chemistry_paradise/toplevel_methods/show_electron_negativity_chart.rb +26 -0
  42. data/lib/chemistry_paradise/verbose_chemical_calculation.rb +21 -0
  43. data/lib/chemistry_paradise/version/version.rb +19 -0
  44. data/lib/chemistry_paradise/yaml/atomgewichte.yml +109 -0
  45. data/lib/chemistry_paradise/yaml/electron_negativity_chart.yml +109 -0
  46. data/lib/chemistry_paradise/yaml/molecular_formula_of_different_molecules.yml +12 -0
  47. data/test/testing_chemistry_paradise.rb +49 -0
  48. metadata +138 -0
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'chemistry_paradise/constants/german_names_of_elements_to_element_symbol.rb'
6
+ # =========================================================================== #
7
+ # This .rb file will translate from the german name of an element towards
8
+ # the element symbol, if applicable. So, "Quecksilber" will become
9
+ # "Hg".
10
+ #
11
+ # See: https://de.wikipedia.org/wiki/Liste_der_chemischen_Elemente
12
+ # =========================================================================== #
13
+ module ChemistryParadise
14
+
15
+ # ========================================================================= #
16
+ # === ChemistryParadise::GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL
17
+ # ========================================================================= #
18
+ GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL = {
19
+ 'Actinium' => 'Ac',
20
+ 'Aluminium' => 'Al',
21
+ 'Americium' => 'Am',
22
+ 'Antimon' => 'Sb',
23
+ 'Argon' => 'Ar',
24
+ 'Arsen' => 'As',
25
+ 'Astat' => 'At',
26
+ 'Barium' => 'Ba',
27
+ 'Berkelium' => 'Bk',
28
+ 'Beryllium' => 'Be',
29
+ 'Bismut' => 'Bi',
30
+ 'Blei' => 'Pb',
31
+ 'Bohrium' => 'Bh',
32
+ 'Bor' => 'B',
33
+ 'Brom' => 'Br',
34
+ 'Cadmium' => 'Cd',
35
+ 'Caesium' => 'Cs',
36
+ 'Calcium' => 'Ca',
37
+ 'Californium' => 'Cf',
38
+ 'Cer' => 'Ce',
39
+ 'Chlor' => 'Cl',
40
+ 'Chrom' => 'Cr',
41
+ 'Cobalt' => 'Co',
42
+ 'Copernicium' => 'Cn',
43
+ 'Curium' => 'Cm',
44
+ 'Darmstadtium' => 'Ds',
45
+ 'Dubnium' => 'Db',
46
+ 'Dysprosium' => 'Dy',
47
+ 'Einsteinium' => 'Es',
48
+ 'Eisen' => 'Fe',
49
+ 'Erbium' => 'Er',
50
+ 'Europium' => 'Eu',
51
+ 'Fermium' => 'Fm',
52
+ 'Flerovium' => 'Fl',
53
+ 'Fluor' => 'F',
54
+ 'Francium' => 'Fr',
55
+ 'Gadolinium' => 'Gd',
56
+ 'Gallium' => 'Ga',
57
+ 'Germanium' => 'Ge',
58
+ 'Gold' => 'Au',
59
+ 'Hafnium' => 'Hf',
60
+ 'Hassium' => 'Hs',
61
+ 'Helium' => 'He',
62
+ 'Holmium' => 'Ho',
63
+ 'Indium' => 'In',
64
+ 'Iod' => 'I',
65
+ 'Iridium' => 'Ir ',
66
+ 'Kalium' => 'K',
67
+ 'Kohlenstoff' => 'C',
68
+ 'Krypton' => 'Kr',
69
+ 'Kupfer' => 'Cu',
70
+ 'Lanthan' => 'La',
71
+ 'Lawrencium' => 'Lr',
72
+ 'Lithium' => 'Li',
73
+ 'Livermorium' => 'Lv',
74
+ 'Lutetium' => 'Lu',
75
+ 'Magnesium' => 'Mg',
76
+ 'Mangan' => 'Mn',
77
+ 'Meitnerium' => 'Mt',
78
+ 'Mendelevium' => 'Md',
79
+ 'Molybdän' => 'Mo',
80
+ 'Moscovium' => 'Mc',
81
+ 'Natrium' => 'Na',
82
+ 'Neodym' => 'Nd',
83
+ 'Neon' => 'Ne',
84
+ 'Neptunium' => 'Np',
85
+ 'Nickel' => 'Ni',
86
+ 'Nihonium' => 'Nh',
87
+ 'Niob' => 'Nb',
88
+ 'Nobelium' => 'No',
89
+ 'Oganesson' => 'Og',
90
+ 'Osmium' => 'Os',
91
+ 'Palladium' => 'Pd',
92
+ 'Phosphor' => 'P',
93
+ 'Platin' => 'Pt',
94
+ 'Plutonium' => 'Pu',
95
+ 'Polonium' => 'Po',
96
+ 'Praseodym' => 'Pr',
97
+ 'Promethium' => 'Pm',
98
+ 'Protactinium' => 'Pa',
99
+ 'Quecksilber' => 'Hg',
100
+ 'Radium' => 'Ra',
101
+ 'Radon' => 'Rn',
102
+ 'Rhenium' => 'Re',
103
+ 'Rhodium' => 'Rh',
104
+ 'Roentgenium' => 'Rg',
105
+ 'Rubidium' => 'Rb',
106
+ 'Ruthenium' => 'Ru',
107
+ 'Rutherfordium' => 'Rf',
108
+ 'Samarium' => 'Sm',
109
+ 'Sauerstoff' => 'O',
110
+ 'Scandium' => 'Sc',
111
+ 'Schwefel' => 'S',
112
+ 'Seaborgium' => 'Sg',
113
+ 'Selen' => 'Se',
114
+ 'Silber' => 'Ag',
115
+ 'Silicium' => 'Si',
116
+ 'Stickstoff' => 'N',
117
+ 'Strontium' => 'Sr',
118
+ 'Tantal' => 'Ta',
119
+ 'Technetium' => 'Tc',
120
+ 'Tellur' => 'Te',
121
+ 'Tenness' => 'Ts',
122
+ 'Terbium' => 'Tb',
123
+ 'Thallium' => 'Tl',
124
+ 'Thorium' => 'Th',
125
+ 'Thulium' => 'Tm',
126
+ 'Titan' => 'Ti',
127
+ 'Uran' => 'U',
128
+ 'Vanadium' => 'V',
129
+ 'Wasserstoff' => 'H',
130
+ 'Wolfram' => 'W',
131
+ 'Xenon' => 'Xe',
132
+ 'Ytterbium' => 'Yb',
133
+ 'Yttrium' => 'Y',
134
+ 'Zink' => 'Zn',
135
+ 'Zinn' => 'Sn',
136
+ 'Zirconium' => 'Zr'
137
+ }
138
+
139
+ # ========================================================================= #
140
+ # === ChemistryParadise.return_element_symbol_from_this_german_name
141
+ # ========================================================================= #
142
+ def self.return_element_symbol_from_this_german_name(i)
143
+ i = i.dup if i.frozen?
144
+ i.capitalize!
145
+ if GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL.has_key? i
146
+ GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL[i]
147
+ else
148
+ nil
149
+ end
150
+ end
151
+
152
+ end
153
+
154
+ if __FILE__ == $PROGRAM_NAME
155
+ puts ChemistryParadise::GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL['Quecksilber']
156
+ puts ChemistryParadise.return_element_symbol_from_this_german_name('quecksilber')
157
+ end
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === CelsiusToFahrenheit
6
+ #
7
+ # Celsius was defined by the freezing point of water (and later the melting
8
+ # point of ice). Nowadays, the Celsius scale is a derived scale, defined in
9
+ # relation to the Kelvin temperature scale.
10
+ #
11
+ # Zero on the Celsius scale (0�C) is defined as the equivalent to 273.15 K.
12
+ #
13
+ # The Celsius scale is an interval system but not a ratio system, meaning
14
+ # it follows a relative scale but not an absolute scale.
15
+ #
16
+ # A temperature difference of 1 deg C is the equivalent of a temperature
17
+ # difference 1.8�F (which is 9/5).
18
+ #
19
+ # Usage example:
20
+ # CelsiusToFahrenheit.new
21
+ # =========================================================================== #
22
+ require 'colours'
23
+ require 'opn'
24
+ require 'chemistry_paradise/converters/shared.rb'
25
+
26
+ module ChemistryParadise
27
+
28
+ class CelsiusToFahrenheit # require 'celsius_to_fahrenheit'; CelsiusToFahrenheit.new
29
+
30
+ include Colours
31
+ include ChemistryParadise::Converters
32
+
33
+ # ========================================================================= #
34
+ # === NAMESPACE
35
+ # ========================================================================= #
36
+ NAMESPACE = 'ChemistryParadise::CelsiusToFahrenheit'
37
+
38
+ # ========================================================================= #
39
+ # === initialize
40
+ # ========================================================================= #
41
+ def initialize(
42
+ celsius = 0,
43
+ run_already = true
44
+ )
45
+ reset
46
+ set_celsius(celsius)
47
+ run if run_already
48
+ end
49
+
50
+ # ========================================================================= #
51
+ # === reset (reset tag)
52
+ # ========================================================================= #
53
+ def reset
54
+ set_celsius
55
+ end
56
+
57
+ # ========================================================================= #
58
+ # === set_celsius
59
+ # ========================================================================= #
60
+ def set_celsius(i = 0)
61
+ i = i.first if i.is_a? Array
62
+ i = i.to_s.dup
63
+ i = i.to_f
64
+ @celsius = i
65
+ end
66
+
67
+ # ========================================================================= #
68
+ # === do_the_calculation
69
+ #
70
+ # We determine how many Fahrenheit we have here, by using the
71
+ # specific formula.
72
+ # ========================================================================= #
73
+ def do_the_calculation
74
+ @fahrenheit = (@celsius * CELSIUS_TO_FAHRENHEIT_CONVERSION_FACTOR)+32.00
75
+ end
76
+
77
+ # ========================================================================= #
78
+ # === fahrenheit?
79
+ # ========================================================================= #
80
+ def fahrenheit?
81
+ @fahrenheit
82
+ end; alias n_fahrenheit fahrenheit? # === fahrenheit?
83
+
84
+ # ========================================================================= #
85
+ # === input?
86
+ # ========================================================================= #
87
+ def celsius?
88
+ @celsius
89
+ end; alias n_celsius celsius? # === n_celsius
90
+
91
+ # ========================================================================= #
92
+ # === run (run tag)
93
+ # ========================================================================= #
94
+ def run
95
+ do_the_calculation
96
+ end
97
+
98
+ # ========================================================================= #
99
+ # === report_result
100
+ # ========================================================================= #
101
+ def report_result
102
+ opnn if use_opn?
103
+ e n_celsius.to_s+'� '+simp('Celsius')+' are '+n_fahrenheit.to_s+
104
+ '� '+simp('Fahrenheit')+'.'
105
+ end; alias report report_result # === report
106
+
107
+ # ========================================================================= #
108
+ # === use_opn?
109
+ # ========================================================================= #
110
+ def use_opn?
111
+ false
112
+ end
113
+
114
+ # ========================================================================= #
115
+ # === opnn
116
+ # ========================================================================= #
117
+ def opnn
118
+ Opn.opn(use_this_as_namespace: NAMESPACE)
119
+ end
120
+
121
+ # ========================================================================= #
122
+ # === CelsiusToFahrenheit[]
123
+ # ========================================================================= #
124
+ def self.[](i)
125
+ _ = CelsiusToFahrenheit.new(i)
126
+ _.report
127
+ end
128
+
129
+ end; end
130
+
131
+ if __FILE__ == $PROGRAM_NAME
132
+ _ = ChemistryParadise::CelsiusToFahrenheit.new(ARGV)
133
+ _.report_result
134
+ end # celsius_to_fahrenheit2 50
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === ChemistryParadise::FahrenheitToCelsius
6
+ #
7
+ # Usage example:
8
+ # ChemistryParadise::FahrenheitToCelsius.new
9
+ # =========================================================================== #
10
+ require 'colours'
11
+ require 'opn'
12
+ require 'chemistry_paradise/converters/shared.rb'
13
+
14
+ module ChemistryParadise
15
+
16
+ class FahrenheitToCelsius
17
+
18
+ include Colours
19
+ include ChemistryParadise::Converters
20
+
21
+ # ========================================================================= #
22
+ # === NAMESPACE
23
+ # ========================================================================= #
24
+ NAMESPACE = 'ChemistryParadise::FahrenheitToCelsius'
25
+
26
+ # ========================================================================= #
27
+ # === initialize
28
+ # ========================================================================= #
29
+ def initialize(
30
+ fahrenheit = 0,
31
+ run_already = true
32
+ )
33
+ reset
34
+ set_fahrenheit(fahrenheit)
35
+ run if run_already
36
+ end
37
+
38
+ # ========================================================================= #
39
+ # === reset (reset tag)
40
+ # ========================================================================= #
41
+ def reset
42
+ set_fahrenheit
43
+ end
44
+
45
+ # ========================================================================= #
46
+ # === set_fahrenheit
47
+ # ========================================================================= #
48
+ def set_fahrenheit(i = 0)
49
+ i = i.first if i.is_a? Array
50
+ i = i.to_s.dup
51
+ i = i.to_f
52
+ @fahrenheit = i
53
+ end
54
+
55
+ # ========================================================================= #
56
+ # === do_the_calculation
57
+ #
58
+ # We determine how many Fahrenheit we have here, by using the
59
+ # specific formula.
60
+ # ========================================================================= #
61
+ def do_the_calculation
62
+ @celsius = (@fahrenheit - 32) / FAHRENHEIT_TO_CELSIUS_CONVERSION_FACTOR
63
+ end
64
+
65
+ # ========================================================================= #
66
+ # === fahrenheit?
67
+ # ========================================================================= #
68
+ def fahrenheit?
69
+ @fahrenheit
70
+ end; alias n_fahrenheit fahrenheit? # === fahrenheit?
71
+
72
+ # ========================================================================= #
73
+ # === input?
74
+ # ========================================================================= #
75
+ def celsius?
76
+ @celsius
77
+ end; alias n_celsius celsius? # === n_celsius
78
+
79
+ # ========================================================================= #
80
+ # === run (run tag)
81
+ # ========================================================================= #
82
+ def run
83
+ do_the_calculation
84
+ end
85
+
86
+ # ========================================================================= #
87
+ # === report_result
88
+ # ========================================================================= #
89
+ def report_result
90
+ opnn if use_opn?
91
+ e n_fahrenheit.to_s+'� '+simp('Fahrenheit')+' are '+n_celsius.round(2).to_s+
92
+ '� '+simp('Celsius')+'.'
93
+ end; alias report report_result # === report
94
+
95
+ # ========================================================================= #
96
+ # === use_opn?
97
+ # ========================================================================= #
98
+ def use_opn?
99
+ false
100
+ end
101
+
102
+ # ========================================================================= #
103
+ # === opnn
104
+ # ========================================================================= #
105
+ def opnn
106
+ Opn.opn(use_this_as_namespace: NAMESPACE)
107
+ end
108
+
109
+ # ========================================================================= #
110
+ # === FahrenheitToCelsius[]
111
+ # ========================================================================= #
112
+ def self.[](i)
113
+ _ = FahrenheitToCelsius.new(i)
114
+ _.report
115
+ end
116
+
117
+ end; end
118
+
119
+ if __FILE__ == $PROGRAM_NAME
120
+ _ = ChemistryParadise::FahrenheitToCelsius.new(ARGV)
121
+ _.report_result
122
+ end # fahrenheit_to_celsius2 50
@@ -0,0 +1,15 @@
1
+ module ChemistryParadise # require 'chemistry_paradise/converters/shared.rb'
2
+
3
+ module Converters # === include ChemistryParadise::Converters
4
+
5
+ # ========================================================================= #
6
+ # === CELSIUS_TO_FAHRENHEIT_CONVERSION_FACTOR
7
+ # ========================================================================= #
8
+ CELSIUS_TO_FAHRENHEIT_CONVERSION_FACTOR = 1.8000
9
+
10
+ # ========================================================================= #
11
+ # === FAHRENHEIT_TO_CELSIUS_CONVERSION_FACTOR
12
+ # ========================================================================= #
13
+ FAHRENHEIT_TO_CELSIUS_CONVERSION_FACTOR = 1 / ( 5.0 / 9)
14
+
15
+ end; end
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === ChemistryParadise::ElectronNegativityChart
6
+ #
7
+ # This class will tell us about the individual electron negativity of a
8
+ # given element at hand.
9
+ # =========================================================================== #
10
+ require 'chemistry_paradise/base/base.rb'
11
+
12
+ module ChemistryParadise
13
+
14
+ class ElectronNegativityChart < Base
15
+
16
+ # ========================================================================= #
17
+ # === initialize
18
+ # ========================================================================= #
19
+ def initialize(
20
+ optional_input = nil,
21
+ run_already = true
22
+ )
23
+ set_input(optional_input)
24
+ run if run_already
25
+ end
26
+
27
+ # ========================================================================= #
28
+ # === set_input
29
+ # ========================================================================= #
30
+ def set_input(i)
31
+ @input = i
32
+ end
33
+
34
+ # ========================================================================= #
35
+ # === show_chart
36
+ #
37
+ # Show the particular electronegativy chart for that element.
38
+ # ========================================================================= #
39
+ def show_chart
40
+ # ======================================================================= #
41
+ # Tap into the elctron negativity chart next.
42
+ # ======================================================================= #
43
+ electron_negativity_chart?.each_pair {|key, value|
44
+ e "#{key.ljust(2)} -> #{value.to_s}"
45
+ }
46
+ end
47
+
48
+ # ========================================================================= #
49
+ # === entry?
50
+ # ========================================================================= #
51
+ def entry?
52
+ @input.first
53
+ end
54
+
55
+ # ========================================================================= #
56
+ # === ElectronNegativityChart.show_chart
57
+ # ========================================================================= #
58
+ def self.show
59
+ ElectronNegativityChart.new.show_chart
60
+ end
61
+
62
+ # ========================================================================= #
63
+ # === run
64
+ # ========================================================================= #
65
+ def run
66
+ if @input.nil?
67
+ show_chart
68
+ else
69
+ e electron_negativity_chart?[entry?]
70
+ end
71
+ end
72
+
73
+ end; end
74
+
75
+ if __FILE__ == $PROGRAM_NAME
76
+ include ChemistryParadise
77
+ ElectronNegativityChart.new(ARGV)
78
+ end # echart P