chemistry_paradise 1.3.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 (83) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +522 -0
  3. data/bin/chemistry_paradise +7 -0
  4. data/bin/wetter +7 -0
  5. data/chemistry_paradise.gemspec +46 -0
  6. data/doc/README.gen +518 -0
  7. data/doc/bugs/BUGS.md +16 -0
  8. data/doc/formulas/biochemical_calculations.md +5 -0
  9. data/doc/todo/todo_for_the_chemistry_paradise_project.md +33 -0
  10. data/doc/todo/todo_for_the_wetter_project.md +7 -0
  11. data/lib/chemistry_paradise/base/base.rb +215 -0
  12. data/lib/chemistry_paradise/base/colours.rb +93 -0
  13. data/lib/chemistry_paradise/commandline/help.rb +40 -0
  14. data/lib/chemistry_paradise/commandline/menu.rb +88 -0
  15. data/lib/chemistry_paradise/commandline/parse_commandline.rb +94 -0
  16. data/lib/chemistry_paradise/constants/constants.rb +77 -0
  17. data/lib/chemistry_paradise/constants/file_constants.rb +33 -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 +143 -0
  20. data/lib/chemistry_paradise/converters/celsius_to_kelvin.rb +125 -0
  21. data/lib/chemistry_paradise/converters/fahrenheit_to_celsius.rb +132 -0
  22. data/lib/chemistry_paradise/converters/shared.rb +21 -0
  23. data/lib/chemistry_paradise/gui/gtk3/calculate_molecular_weight/calculate_molecular_weight.rb +34 -0
  24. data/lib/chemistry_paradise/gui/gtk3/show_periodic_table/show_periodic_table.rb +34 -0
  25. data/lib/chemistry_paradise/gui/gtk3/temperature_converter/temperature_converter.rb +112 -0
  26. data/lib/chemistry_paradise/gui/gtk3/wetter/wetter.rb +119 -0
  27. data/lib/chemistry_paradise/gui/libui/temperature_converter/temperature_converter.rb +100 -0
  28. data/lib/chemistry_paradise/gui/libui/wetter/wetter.rb +47 -0
  29. data/lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb +171 -0
  30. data/lib/chemistry_paradise/gui/shared_code/show_periodic_table/show_periodic_table_module.rb +318 -0
  31. data/lib/chemistry_paradise/gui/shared_code/temperature_converter/temperature_converter_module.rb +192 -0
  32. data/lib/chemistry_paradise/gui/shared_code/wetter/wetter_module.rb +349 -0
  33. data/lib/chemistry_paradise/gui/swing/TemperatureConverter$1.class +0 -0
  34. data/lib/chemistry_paradise/gui/swing/TemperatureConverter.class +0 -0
  35. data/lib/chemistry_paradise/gui/swing/TemperatureConverter.java +133 -0
  36. data/lib/chemistry_paradise/gui/unified_widgets/wetter/wetter.rb +62 -0
  37. data/lib/chemistry_paradise/images/show_periodic_table.png +0 -0
  38. data/lib/chemistry_paradise/images/vienna_map.png +0 -0
  39. data/lib/chemistry_paradise/interactive_chemistry_shell.rb +246 -0
  40. data/lib/chemistry_paradise/project/project.rb +24 -0
  41. data/lib/chemistry_paradise/requires/common_external_requires.rb +17 -0
  42. data/lib/chemistry_paradise/requires/require_the_project.rb +21 -0
  43. data/lib/chemistry_paradise/requires/require_the_project_including_the_graphical_user_interface.rb +7 -0
  44. data/lib/chemistry_paradise/requires/require_the_project_including_the_web_interface.rb +4 -0
  45. data/lib/chemistry_paradise/shared.rb +130 -0
  46. data/lib/chemistry_paradise/show_electron_configuration.rb +250 -0
  47. data/lib/chemistry_paradise/show_element.rb +145 -0
  48. data/lib/chemistry_paradise/sinatra/sinatra.rb +131 -0
  49. data/lib/chemistry_paradise/sinatra/wetter/app.rb +68 -0
  50. data/lib/chemistry_paradise/sinatra/wetter/start_sinatra_interface.rb +31 -0
  51. data/lib/chemistry_paradise/split_molecule_names.rb +228 -0
  52. data/lib/chemistry_paradise/toplevel_methods/atomgewichte.rb +31 -0
  53. data/lib/chemistry_paradise/toplevel_methods/convert_parens.rb +64 -0
  54. data/lib/chemistry_paradise/toplevel_methods/display_where_the_molmasses_are_kept.rb +24 -0
  55. data/lib/chemistry_paradise/toplevel_methods/e.rb +16 -0
  56. data/lib/chemistry_paradise/toplevel_methods/kelvin.rb +34 -0
  57. data/lib/chemistry_paradise/toplevel_methods/language.rb +50 -0
  58. data/lib/chemistry_paradise/toplevel_methods/misc.rb +147 -0
  59. data/lib/chemistry_paradise/toplevel_methods/periodic_table.rb +16 -0
  60. data/lib/chemistry_paradise/toplevel_methods/remove_this_molecule_from.rb +63 -0
  61. data/lib/chemistry_paradise/toplevel_methods/roebe.rb +16 -0
  62. data/lib/chemistry_paradise/toplevel_methods/show_electron_negativity_chart.rb +26 -0
  63. data/lib/chemistry_paradise/utility_scripts/calculate_atomic_mass.rb +559 -0
  64. data/lib/chemistry_paradise/utility_scripts/combustion_analysis.rb +207 -0
  65. data/lib/chemistry_paradise/utility_scripts/electron_negativity_chart.rb +78 -0
  66. data/lib/chemistry_paradise/utility_scripts/equalize_chemical_formula.rb +84 -0
  67. data/lib/chemistry_paradise/utility_scripts/equation_solver.rb +130 -0
  68. data/lib/chemistry_paradise/utility_scripts/orbitals.rb +70 -0
  69. data/lib/chemistry_paradise/utility_scripts/show_electron_negativity_of_this_element.rb +103 -0
  70. data/lib/chemistry_paradise/verbose_chemical_calculation.rb +21 -0
  71. data/lib/chemistry_paradise/version/version.rb +19 -0
  72. data/lib/chemistry_paradise/wetter/wetter.rb +539 -0
  73. data/lib/chemistry_paradise/www/wetter/embeddable_interface.rb +78 -0
  74. data/lib/chemistry_paradise/www/wetter/wetter.cgi +28 -0
  75. data/lib/chemistry_paradise/yaml/atomgewichte.yml +113 -0
  76. data/lib/chemistry_paradise/yaml/colours_for_the_elements.yml +13 -0
  77. data/lib/chemistry_paradise/yaml/dichte.yml +21 -0
  78. data/lib/chemistry_paradise/yaml/electron_negativity_chart.yml +111 -0
  79. data/lib/chemistry_paradise/yaml/molecular_formula_of_different_molecules.yml +13 -0
  80. data/lib/chemistry_paradise/yaml/periodic_table_of_the_elements.yml +125 -0
  81. data/lib/chemistry_paradise.rb +1 -0
  82. data/test/testing_chemistry_paradise.rb +49 -0
  83. metadata +173 -0
@@ -0,0 +1,207 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === ChemistryParadise::CombustionAnalysis
6
+ #
7
+ # This class can be used to calculate the molar coefficients of
8
+ # a compound that has been analysed through a combustion analysis.
9
+ #
10
+ # Usage example:
11
+ #
12
+ # ChemistryParadise::CombustionAnalysis.new(ARGV)
13
+ #
14
+ # =========================================================================== #
15
+ # require 'chemistry_paradise/combustion_analysis.rb'
16
+ # ChemistryParadise::CombustionAnalysis.new(ARGV)
17
+ # =========================================================================== #
18
+ require 'chemistry_paradise/base/base.rb'
19
+
20
+ module ChemistryParadise
21
+
22
+ class CombustionAnalysis < Base # === ChemistryParadise::CombustionAnalysis
23
+
24
+ # ========================================================================= #
25
+ # === initialize
26
+ # ========================================================================= #
27
+ def initialize(
28
+ commandline_arguments = nil,
29
+ run_already = true
30
+ )
31
+ reset
32
+ set_commandline_arguments(
33
+ commandline_arguments
34
+ )
35
+ run if run_already
36
+ end
37
+
38
+ # ========================================================================= #
39
+ # === reset (reset tag)
40
+ # ========================================================================= #
41
+ def reset
42
+ super()
43
+ # ======================================================================= #
44
+ # === @hash_ratio
45
+ # ======================================================================= #
46
+ @hash_ratio = {}
47
+ end
48
+
49
+ # ========================================================================= #
50
+ # === parse_the_main_input
51
+ # ========================================================================= #
52
+ def parse_the_main_input(i)
53
+ dataset = YAML.load_file(FILE_ATOMGEWICHTE)
54
+ # ======================================================================= #
55
+ # Currently we require that the String has '%' inserted appropriately.
56
+ # ======================================================================= #
57
+ if i.is_a?(String) and i.include?('%')
58
+ splitted = i.split('%').map(&:strip)
59
+ # ===================================================================== #
60
+ # splitted is now:
61
+ #
62
+ # ["K 28,93", "S 23,72", "O 47.35"]
63
+ #
64
+ # ===================================================================== #
65
+ splitted.each {|entry|
66
+ entry.tr!(',','.')
67
+ inner_splitted = entry.split(' ')
68
+ first = inner_splitted.first
69
+ last = inner_splitted.last.to_f
70
+ @hash_ratio[first] = last / dataset[first]
71
+ }
72
+ end
73
+ end
74
+
75
+ # ========================================================================= #
76
+ # === work_on_the_hash_ratio
77
+ # ========================================================================= #
78
+ def work_on_the_hash_ratio
79
+ # ======================================================================= #
80
+ # The Hash may look like this:
81
+ #
82
+ # { "K"=>0.7399355465752724,
83
+ # "S"=>0.7397473881178855,
84
+ # "O"=>2.959559972498281}
85
+ #
86
+ # ======================================================================= #
87
+ min_element = @hash_ratio.min
88
+ ratio = 1.0 / min_element.last
89
+ @hash_ratio.transform_values! {|values|
90
+ (values * ratio).round(1)
91
+ }
92
+ if does_the_main_hash_have_an_uneven_value?
93
+ further_process_the_main_hash
94
+ end
95
+ end
96
+
97
+ # ========================================================================= #
98
+ # === further_process_the_main_hash
99
+ #
100
+ # This method is specifically to turn e. g. a 1.5 into a 3.0.
101
+ # ========================================================================= #
102
+ def further_process_the_main_hash
103
+ first_zero_point_result = @hash_ratio.select {|key, value|
104
+ value - value.floor == 0.5
105
+ }
106
+ if first_zero_point_result
107
+ # ===================================================================== #
108
+ # This may be:
109
+ #
110
+ # {"S"=>1.5}
111
+ #
112
+ # ===================================================================== #
113
+ @hash_ratio.transform_values! {|value|
114
+ value * 2.0
115
+ }
116
+ end
117
+ end
118
+
119
+ # ========================================================================= #
120
+ # === does_the_main_hash_have_an_uneven_value?
121
+ #
122
+ # This method will return true if we have an uneven value in the
123
+ # main Hash, such as 1.5.
124
+ # ========================================================================= #
125
+ def does_the_main_hash_have_an_uneven_value?
126
+ @hash_ratio.values.any? {|entry|
127
+ (entry - entry.floor) > 0
128
+ }
129
+ end
130
+
131
+ # ========================================================================= #
132
+ # === hash_ratio?
133
+ # ========================================================================= #
134
+ def hash_ratio?
135
+ @hash_ratio
136
+ end; alias hash? hash_ratio? # === hash?
137
+
138
+ # ========================================================================= #
139
+ # === report
140
+ # ========================================================================= #
141
+ def report
142
+ e @result
143
+ end
144
+
145
+ # ========================================================================= #
146
+ # === determine_the_result
147
+ # ========================================================================= #
148
+ def determine_the_result
149
+ @result = @hash_ratio.map {|k, v|
150
+ v = v.to_i
151
+ case v
152
+ when 1
153
+ v = '₁'
154
+ when 2
155
+ v = '₂'
156
+ when 3
157
+ v = '₃'
158
+ when 4
159
+ v = '₄'
160
+ when 5
161
+ v = '₅'
162
+ when 6
163
+ v = '₆'
164
+ when 7
165
+ v = '₇'
166
+ when 8
167
+ v = '₈'
168
+ when 9
169
+ v = '₉'
170
+ when 12
171
+ v = '₁₂'
172
+ end
173
+ "#{k}#{v}"
174
+ }.join
175
+ end
176
+
177
+ # ========================================================================= #
178
+ # === result?
179
+ # ========================================================================= #
180
+ def result?
181
+ @result
182
+ end
183
+
184
+ # ========================================================================= #
185
+ # === run (run tag)
186
+ # ========================================================================= #
187
+ def run
188
+ _ = first?
189
+ parse_the_main_input(_)
190
+ work_on_the_hash_ratio
191
+ determine_the_result
192
+ report
193
+ end
194
+
195
+ # ========================================================================= #
196
+ # === CombustionAnalysis[]
197
+ # ========================================================================= #
198
+ def self.[](i = '')
199
+ new(i)
200
+ end
201
+
202
+ end; end
203
+
204
+ if __FILE__ == $PROGRAM_NAME
205
+ ChemistryParadise::CombustionAnalysis.new(ARGV)
206
+ end # combustionanalysis "K 28,93% S 23,72% O 47.35%"
207
+ # combustionanalysis "Al 15,77% O 56,12% S 28,11%"
@@ -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 < ::ChemistryParadise::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
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === ChemistryParadise::EqualizeChemicalFormula
6
+ #
7
+ # This class will fill in the missing stoichiometric numbers.
8
+ #
9
+ # Usage examples:
10
+ #
11
+ # ChemistryParadise::EqualizeChemicalFormula.new(ARGV)
12
+ #
13
+ # =========================================================================== #
14
+ # require 'chemistry_paradise/utility_scripts/equalize_chemical_formula'
15
+ # =========================================================================== #
16
+ require 'chemistry_paradise/base/base.rb'
17
+
18
+ module ChemistryParadise
19
+
20
+ class EqualizeChemicalFormula < ::ChemistryParadise::Base # === EqualizeChemicalFormula
21
+
22
+ # ========================================================================= #
23
+ # === DEFAULT_FORMULA
24
+ # ========================================================================= #
25
+ DEFAULT_FORMULA = 'Fe(OH)3 + H2SO4 -> Fe2(SO4)3 + H2O'
26
+
27
+ # ========================================================================= #
28
+ # === initialize
29
+ # ========================================================================= #
30
+ def initialize(
31
+ i = nil,
32
+ run_already = true
33
+ )
34
+ set_test_this_formula(i)
35
+ run if run_already
36
+ end
37
+
38
+ # ========================================================================= #
39
+ # === set_original_input
40
+ # ========================================================================= #
41
+ def set_original_input(i)
42
+ @original_input = i
43
+ end
44
+
45
+ # ========================================================================= #
46
+ # === set_test_this_formula
47
+ # ========================================================================= #
48
+ def set_test_this_formula(
49
+ i = DEFAULT_FORMULA
50
+ )
51
+ i = DEFAULT_FORMULA if i.nil?
52
+ i = DEFAULT_FORMULA if i.empty?
53
+ set_original_input(i) # Call this before parse().
54
+ i = parse(i)
55
+ @test_this_formula = i
56
+ end
57
+
58
+ # ========================================================================= #
59
+ # === analyze_dataset
60
+ # ========================================================================= #
61
+ def analyze_dataset
62
+ splitted = @test_this_formula.split('->')
63
+ links = splitted[0]
64
+ rechts = splitted[1]
65
+ opn; e 'Auf der '+RED+'linken Seite '+WHITE+'finden wir: '+links
66
+ opn; e 'Auf der '+RED+'rechten Seite '+WHITE+'finden wir: '+rechts
67
+ pp 'TODO: WIR MÜSSEN NOCH BERECHNEN WIE VIELE'
68
+ pp 'ELEMENTE DORT VORKOMMEN'
69
+ pp splitted
70
+ end
71
+
72
+ # ========================================================================= #
73
+ # === run (run tag)
74
+ # ========================================================================= #
75
+ def run
76
+ analyze_dataset
77
+ pp self
78
+ end
79
+
80
+ end; end
81
+
82
+ if __FILE__ == $PROGRAM_NAME
83
+ ChemistryParadise::EqualizeChemicalFormula.new(ARGV)
84
+ end # $RUBY_CHEMISTRY/equalize_chemical_formula.rb
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # =========================================================================== #
4
+ # === ChemistryParadise::EquationSolver
5
+ #
6
+ # Usage example:
7
+ # ChemistryParadise::EquationSolver.new
8
+ # =========================================================================== #
9
+ require 'chemistry_paradise/base/base.rb'
10
+ require 'chemistry_paradise/split_molecule_names.rb'
11
+
12
+ module ChemistryParadise
13
+
14
+ class EquationSolver < ::ChemistryParadise::Base # require 'equation_solver'; EquationSolver.new
15
+
16
+ # ========================================================================= #
17
+ # === THIS_FORMULA
18
+ # ========================================================================= #
19
+ THIS_FORMULA = 'NH3HHH + O2 -> N2 + H2O'
20
+
21
+ # ========================================================================= #
22
+ # === TOKEN_TO_SPLIT_AT
23
+ # ========================================================================= #
24
+ TOKEN_TO_SPLIT_AT = '->'
25
+
26
+ # ========================================================================= #
27
+ # === initialize
28
+ # ========================================================================= #
29
+ def initialize(
30
+ i = nil,
31
+ run_already = true
32
+ )
33
+ reset
34
+ set_input(i)
35
+ run if run_already
36
+ end
37
+
38
+ # ========================================================================= #
39
+ # === reset
40
+ # ========================================================================= #
41
+ def reset # (reset tag)
42
+ @token_to_split_at = TOKEN_TO_SPLIT_AT
43
+ end
44
+
45
+ # ========================================================================= #
46
+ # === set_input
47
+ # ========================================================================= #
48
+ def set_input(i = '')
49
+ i = i.first if i.is_a? Array
50
+ i = THIS_FORMULA if i.nil?
51
+ i = i.to_s.dup
52
+ i.strip!
53
+ # ======================================================================= #
54
+ # Next, we will get rid of all ' '.
55
+ # ======================================================================= #
56
+ i.tr!(' ','')
57
+ @input = i
58
+ end
59
+
60
+ # ========================================================================= #
61
+ # === left?
62
+ # ========================================================================= #
63
+ def left?
64
+ @left_hand_side
65
+ end
66
+
67
+ # ========================================================================= #
68
+ # === right?
69
+ # ========================================================================= #
70
+ def right?
71
+ @right_hand_side
72
+ end
73
+
74
+ # ========================================================================= #
75
+ # === ensure_that_the_token_is_correct
76
+ # ========================================================================= #
77
+ def ensure_that_the_token_is_correct
78
+ if @input.include? '=' # In this case we overrule the token.
79
+ @token_to_split_at = '='
80
+ end
81
+ end
82
+
83
+ # ========================================================================= #
84
+ # === split_into_components
85
+ # ========================================================================= #
86
+ def split_into_components
87
+ @left_hand_side, @right_hand_side = @input.
88
+ split(@token_to_split_at).map(&:strip)
89
+ # ======================================================================= #
90
+ # Ok, we now have our left side, and we have our right side.
91
+ # We will next get the total content of Elements at the left
92
+ # and at the right side.
93
+ # ======================================================================= #
94
+ p SplitMoleculeNames.new left?
95
+ p SplitMoleculeNames.new right?
96
+ if are_both_sides_equal?
97
+ opn; e 'Both sides are now equal.'
98
+ else
99
+ opn; e 'Both sides are not equal.'
100
+ end
101
+ end
102
+
103
+ # ========================================================================= #
104
+ # === are_both_sides_equal?
105
+ # ========================================================================= #
106
+ def are_both_sides_equal?
107
+ result = false
108
+ # ======================================================================= #
109
+ # We have to eliminate the '+' characters.
110
+ # ======================================================================= #
111
+ left = SplitMoleculeNames.new(left?.delete('+')).total?
112
+ right = SplitMoleculeNames.new(right?.delete('+')).total?
113
+ result = ( left == right )
114
+ return result
115
+ end
116
+
117
+ # ========================================================================= #
118
+ # === run
119
+ # ========================================================================= #
120
+ def run # (run tag)
121
+ ensure_that_the_token_is_correct
122
+ split_into_components
123
+ end
124
+
125
+ end; end
126
+
127
+ if __FILE__ == $PROGRAM_NAME
128
+ ChemistryParadise::EquationSolver.new(ARGV)
129
+ end # equation_solver
130
+ # equation_solver '2 Fe + 3 Cl2 = FeCl3'
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === ChemistryParadise::Orbitals
6
+ #
7
+ # This class will just output the amount of electrons residing in a
8
+ # specific orbital.
9
+ # =========================================================================== #
10
+ # require 'chemistry_paradise/utility_scripts/orbitals.rb'
11
+ # =========================================================================== #
12
+ require 'chemistry_paradise/base/base.rb'
13
+
14
+ module ChemistryParadise
15
+
16
+ class Orbitals < Base # === ChemistryParadise::Orbitals
17
+
18
+ # ========================================================================= #
19
+ # === initialize
20
+ # ========================================================================= #
21
+ def initialize(
22
+ upto_n = 10,
23
+ run_already = true
24
+ )
25
+ reset
26
+ set_upto(upto_n)
27
+ run if run_already
28
+ end
29
+
30
+ # ========================================================================= #
31
+ # === set_upto
32
+ # ========================================================================= #
33
+ def set_upto(i = 10) # 10 is default.
34
+ @upto = i
35
+ end
36
+
37
+ # ========================================================================= #
38
+ # === reset
39
+ # ========================================================================= #
40
+ def reset
41
+ set_upto
42
+ end
43
+
44
+ # ========================================================================= #
45
+ # === calculate_for_this_orbital
46
+ # ========================================================================= #
47
+ def calculate_for_this_orbital(n)
48
+ 2 * (n ** 2)
49
+ end
50
+
51
+ # ========================================================================= #
52
+ # === run
53
+ # ========================================================================= #
54
+ def run
55
+ e
56
+ 1.upto(@upto).each {|entry|
57
+ e rev+
58
+ ' '+entry.to_s.rjust(3)+' → '+
59
+ sfancy(
60
+ calculate_for_this_orbital(entry).to_s.rjust(3)
61
+ )+' Orbitals.'
62
+ }
63
+ e
64
+ end
65
+
66
+ end; end
67
+
68
+ if __FILE__ == $PROGRAM_NAME
69
+ ChemistryParadise::Orbitals.new(10)
70
+ end # orbitals
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === ChemistryParadise::ShowElectronNegativityOfThisElement
6
+ #
7
+ # This class will report the electron negativity of the input-element,
8
+ # such as "S" or "Fe" and so forth (chemical elements).
9
+ #
10
+ # Usage example in ruby:
11
+ #
12
+ # Chemistry::ShowElectronNegativityOfThisElement.new(ARGV)
13
+ #
14
+ # =========================================================================== #
15
+ # require 'chemistry_paradise/utility_scripts/show_electron_negativity_of_this_element.rb'
16
+ # =========================================================================== #
17
+ require 'chemistry_paradise/base/base.rb'
18
+
19
+ module ChemistryParadise
20
+
21
+ class ShowElectronNegativityOfThisElement < Base # === ChemistryParadise::ShowElectronNegativityOfThisElement
22
+
23
+ # ========================================================================= #
24
+ # === NAMESPACE
25
+ # ========================================================================= #
26
+ NAMESPACE = inspect
27
+
28
+ # ========================================================================= #
29
+ # === initialize
30
+ # ========================================================================= #
31
+ def initialize(
32
+ i = nil,
33
+ run_already = true
34
+ )
35
+ reset
36
+ set_input(i)
37
+ run if run_already
38
+ end
39
+
40
+ # ========================================================================= #
41
+ # === reset (reset tag)
42
+ # ========================================================================= #
43
+ def reset
44
+ super()
45
+ @dataset = Constants::ELECTRON_NEGATIVITY_CHART
46
+ end
47
+
48
+ # ========================================================================= #
49
+ # === set_input
50
+ # ========================================================================= #
51
+ def set_input(i = '')
52
+ i = [i] unless i.is_a? Array
53
+ @input = i
54
+ end
55
+
56
+ # ========================================================================= #
57
+ # === input?
58
+ # ========================================================================= #
59
+ def input?
60
+ @input
61
+ end
62
+
63
+ # ========================================================================= #
64
+ # === run (run tag)
65
+ # ========================================================================= #
66
+ def run
67
+ try_to_detect_the_electron_negativity_of_the_passed_elements
68
+ end
69
+
70
+ # ========================================================================= #
71
+ # === try_to_detect_the_electron_negativity_of_the_passed_elements
72
+ # ========================================================================= #
73
+ def try_to_detect_the_electron_negativity_of_the_passed_elements
74
+ dataset = @dataset
75
+ input?.each {|this_element|
76
+ if dataset.has_key? this_element
77
+ electron_negativity_value = dataset[this_element]
78
+ e "#{simp(this_element.ljust(2))} has an electron negativity of "\
79
+ "#{sfancy(electron_negativity_value)}"\
80
+ " (in this Pauling electronegativity scale)"
81
+ end
82
+ }
83
+ end
84
+
85
+ # ========================================================================= #
86
+ # === opnn
87
+ # ========================================================================= #
88
+ def opnn
89
+ super(NAMESPACE)
90
+ end
91
+
92
+ # ========================================================================= #
93
+ # === []
94
+ # ========================================================================= #
95
+ def self.[](i = '')
96
+ self.new(i)
97
+ end
98
+
99
+ end; end
100
+
101
+ if __FILE__ == $PROGRAM_NAME
102
+ ChemistryParadise::ShowElectronNegativityOfThisElement.new(ARGV)
103
+ end # showelectronnegativityofthiselement S
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # Purpose of this class is to explain what we are doing in a
6
+ # step-by-step wise fashion.
7
+ #
8
+ # Right now this is a stub.
9
+ # =========================================================================== #
10
+ module ChemistryParadise
11
+
12
+ class VerboseChemicalCalculation
13
+
14
+ # ========================================================================= #
15
+ # === initialize
16
+ # ========================================================================= #
17
+ def initialize
18
+ e 'This is currently a stub.'
19
+ end
20
+
21
+ end; end