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,24 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'chemistry_paradise/toplevel_methods/display_where_the_molmasses_are_kept.rb'
6
+ # =========================================================================== #
7
+ require 'chemistry_paradise/toplevel_methods/e.rb'
8
+ require 'chemistry_paradise/requires/common_external_requires.rb'
9
+ require 'chemistry_paradise/constants/file_constants.rb'
10
+
11
+ module ChemistryParadise
12
+
13
+ # ========================================================================= #
14
+ # === ChemistryParadise.display_where_the_molmasses_are_kept
15
+ # ========================================================================= #
16
+ def self.display_where_the_molmasses_are_kept
17
+ Colours.e(Constants::FILE_ATOMGEWICHTE)
18
+ end
19
+
20
+ end
21
+
22
+ if __FILE__ == $PROGRAM_NAME
23
+ ChemistryParadise.display_where_the_molmasses_are_kept
24
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'chemistry_paradise/toplevel_methods/e.rb'
6
+ # =========================================================================== #
7
+ module ChemistryParadise
8
+
9
+ # ========================================================================= #
10
+ # === ChemistryParadise.e
11
+ # ========================================================================= #
12
+ def self.e(i = '')
13
+ puts i
14
+ end
15
+
16
+ end
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'chemistry_paradise/toplevel_methods/kelvin.rb'
6
+ # =========================================================================== #
7
+ module ChemistryParadise
8
+
9
+ # ========================================================================= #
10
+ # === ChemistryParadise.kelvin
11
+ #
12
+ # This method will output how many Kelvin n Celsius are.
13
+ #
14
+ # The temperature T in Kelvin (K) is equal to the temperature T in
15
+ # degrees Celsius (°C) plus 273.1.
16
+ #
17
+ # The formula thus is:
18
+ #
19
+ # T(K) = T(°C) + 273.15
20
+ #
21
+ # ========================================================================= #
22
+ def self.kelvin(n_celsius)
23
+ if n_celsius.is_a? Array
24
+ n_celsius = n_celsius.first
25
+ end
26
+ n_kelvin = n_celsius.to_f + 273.15
27
+ return n_kelvin
28
+ end; self.instance_eval { alias celsius_to_kelvin kelvin } # === ChemistryParadise.celsius_to_kelvin
29
+
30
+ end
31
+
32
+ if __FILE__ == $PROGRAM_NAME
33
+ puts ChemistryParadise.kelvin(ARGV)
34
+ end # kelvin 37
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This class can help set a different language for the project. By default,
6
+ # the german language is used, but you can call the module-method below,
7
+ # called ChemistryParadise.use_english, to enable english instead.
8
+ # =========================================================================== #
9
+ # require 'chemistry_paradise/toplevel_methods/language.rb'
10
+ # =========================================================================== #
11
+ module ChemistryParadise
12
+
13
+ # ========================================================================= #
14
+ # === @use_this_language
15
+ # ========================================================================= #
16
+ @use_this_language = :german
17
+
18
+ # ========================================================================= #
19
+ # === ChemistryParadise.set_use_this_language
20
+ # ========================================================================= #
21
+ def self.set_use_this_language(i = :german)
22
+ @use_this_language = i
23
+ end
24
+
25
+ # ========================================================================= #
26
+ # === ChemistryParadise.use_which_language?
27
+ # ========================================================================= #
28
+ def self.use_which_language?
29
+ @use_this_language
30
+ end
31
+
32
+ # ========================================================================= #
33
+ # === ChemistryParadise.do_use_english
34
+ #
35
+ # Use this method if you want to use the english language.
36
+ # ========================================================================= #
37
+ def self.do_use_english
38
+ set_use_this_language(:english)
39
+ end; self.instance_eval { alias use_english do_use_english } # === ChemistryParadise.use_english
40
+
41
+ # ========================================================================= #
42
+ # === ChemistryParadise.do_use_german
43
+ #
44
+ # Use this method if you want to use the german language.
45
+ # ========================================================================= #
46
+ def self.do_use_german
47
+ set_use_this_language(:german)
48
+ end; self.instance_eval { alias use_german do_use_german } # === ChemistryParadise.use_german
49
+
50
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'chemistry_paradise/toplevel_methods/periodic_table.rb'
6
+ # =========================================================================== #
7
+ module ChemistryParadise
8
+
9
+ # ========================================================================= #
10
+ # === ChemistryParadise.periodic_table?
11
+ # ========================================================================= #
12
+ def self.periodic_table?
13
+ '/Users/x/DATA/SCIENCE/YAML/periodic_table.yml'
14
+ end
15
+
16
+ end
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'chemistry_paradise/toplevel_methods/remove_this_molecule_from.rb'
6
+ # =========================================================================== #
7
+ require 'chemistry_paradise/split_molecule_names.rb'
8
+
9
+ module ChemistryParadise
10
+
11
+ # ========================================================================= #
12
+ # === ChemistryParadise.remove_this_molecule_from
13
+ #
14
+ # The first argument is the molecule that should be deducted from
15
+ # the formula.
16
+ # ========================================================================= #
17
+ def self.remove_this_molecule_from(
18
+ this_molecule = 'OH',
19
+ from = 'C2H5NO2'
20
+ )
21
+ array_big_molecule = ::ChemistryParadise.split_this_molecular_formula_into_a_hash(from)
22
+ array_this_molecule = ::ChemistryParadise.split_this_molecular_formula_into_a_hash(this_molecule)
23
+ # ======================================================================= #
24
+ # Next, iterate over the small molecule.
25
+ # ======================================================================= #
26
+ array_this_molecule.each {|this_compound|
27
+ unless this_compound =~ /\d+/
28
+ this_compound << '1' # Must be at the least one.
29
+ end
30
+ # ===================================================================== #
31
+ # Select the entry that is the correct one.
32
+ # ===================================================================== #
33
+ this_entry = array_big_molecule.find {|entry|
34
+ entry[0,1] == this_compound[0,1]
35
+ }
36
+ begin
37
+ n_times_in_the_big_molecule = /(\d{1,3})/.match(this_entry)[1].to_i
38
+ n_times_in_the_small_molecule = /(\d{1,3})/.match(this_compound)[1].to_i
39
+ new_n_times = n_times_in_the_big_molecule - n_times_in_the_small_molecule
40
+ new_entry = this_compound[0,1]+new_n_times.to_s
41
+ # ===================================================================== #
42
+ # Now we have the new entry; we need to re-insert it into the big
43
+ # original Array.
44
+ # ===================================================================== #
45
+ proper_index = array_big_molecule.index {|entry|
46
+ entry[0,1] == this_compound[0,1]
47
+ }
48
+ array_big_molecule[proper_index] = new_entry
49
+ rescue NoMethodError => error
50
+ pp error
51
+ end
52
+ }
53
+ return array_big_molecule.join # Join it up again.
54
+ end
55
+
56
+ end
57
+
58
+ if __FILE__ == $PROGRAM_NAME
59
+ puts 'Deducting OH from C2H5NO2 next:'
60
+ puts ::ChemistryParadise.remove_this_molecule_from('OH', 'C2H5NO2')
61
+ puts 'Deducting H2O from C2H5NO2 next:'
62
+ puts ::ChemistryParadise.remove_this_molecule_from('H2O', 'C2H5NO2')
63
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'chemistry_paradise/toplevel_methods/show_electron_negativity_chart.rb'
6
+ # =========================================================================== #
7
+ require 'chemistry_paradise/constants/constants.rb'
8
+
9
+ module ChemistryParadise
10
+
11
+ # ========================================================================= #
12
+ # === ChemistryParadise.show_electron_negativity_chart
13
+ # ========================================================================= #
14
+ def self.show_electron_negativity_chart
15
+ Constants::ELECTRON_NEGATIVITY_CHART.each_pair {|key, value|
16
+ value = value.to_f
17
+ value = '%.2f' % value
18
+ puts key.ljust(2)+' -> '+value.to_s.rjust(2)
19
+ }
20
+ end
21
+
22
+ end
23
+
24
+ if __FILE__ == $PROGRAM_NAME
25
+ ChemistryParadise.show_electron_negativity_chart
26
+ end
@@ -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
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'chemistry_paradise/version/version.rb'
6
+ # =========================================================================== #
7
+ module ChemistryParadise
8
+
9
+ # ========================================================================= #
10
+ # === ChemistryParadise::VERSION
11
+ # ========================================================================= #
12
+ VERSION = '1.1.1'
13
+
14
+ # ========================================================================= #
15
+ # === LAST_UPDATE
16
+ # ========================================================================= #
17
+ LAST_UPDATE = '22.11.2020'
18
+
19
+ end
@@ -0,0 +1,109 @@
1
+ # =========================================================================== #
2
+ # Die Atommasse (frueher Atomgewicht) ist die Masse eines Atoms. In dieser
3
+ # Yaml Datei hier beziehen wir uns auf 12 C.
4
+ #
5
+ # Folgende URL wurde herangezogen um die Information zu speichern:
6
+ #
7
+ # http://old.iupac.org/reports/periodic_table/
8
+ #
9
+ # Genauere Information erhalten wir aber von hier:
10
+ # http://www.ciaaw.org/
11
+ # =========================================================================== #
12
+ # x = load_yaml(ChemistryParadise.file_atomgewichte)
13
+ # =========================================================================== #
14
+
15
+ # =========================================================================== #
16
+ # 1. Reihe:
17
+ # =========================================================================== #
18
+ H: 1.0079 # In normalen Kalkulationen ist dies 1.008
19
+ He: 4.0026
20
+
21
+ # =========================================================================== #
22
+ # 2. Reihe:
23
+ # =========================================================================== #
24
+ Li: 6.941
25
+ Be: 9.0122
26
+ B: 10.811
27
+ C: 12.011
28
+ N: 14.007
29
+ O: 15.999
30
+ F: 18.998
31
+ Ne: 20.180
32
+
33
+ # =========================================================================== #
34
+ # 3. Reihe:
35
+ # =========================================================================== #
36
+ Na: 22.990
37
+ Mg: 24.305
38
+ Al: 26.982
39
+ Si: 28.086
40
+ P: 30.974
41
+ S: 32.065
42
+ Cl: 35.453
43
+ Ar: 39.948
44
+
45
+ # =========================================================================== #
46
+ # 4. Reihe:
47
+ # =========================================================================== #
48
+ K: 39.098
49
+ Ca: 40.078
50
+ Sc: 44.956
51
+ Ti: 47.867
52
+ V: 50.942
53
+ Cr: 51.996
54
+ Mn: 54.938
55
+ Fe: 55.845
56
+ Co: 58.933
57
+ Ni: 58.693
58
+ Cu: 63.546
59
+ Zn: 65.38 # This is Zink. This is valid in 2007, see: http://www.ciaaw.org/zinc.htm
60
+ Ga: 69.723
61
+ Ge: 72.64
62
+ As: 74.922
63
+ Se: 78.96
64
+ Br: 79.904
65
+ Kr: 83.798
66
+
67
+ # =========================================================================== #
68
+ # 5. Reihe:
69
+ # =========================================================================== #
70
+ Rb: 85.468
71
+ Sr: 87.62
72
+ Y: 88.906
73
+ Zr: 91.224
74
+ Nb: 92.906
75
+ Mo: 95.96
76
+ Tc: 97.907 # Why doesn't this have anything in the IUPAC version?
77
+ Ru: 101.07
78
+ Rh: 102.91
79
+ Pd: 106.42
80
+ Ag: 107.87
81
+ Cd: 112.41
82
+ In: 114.82
83
+ Sn: 118.71
84
+ Sb: 121.76
85
+ Te: 127.60
86
+ I: 126.90
87
+ Xe: 131.29
88
+
89
+ # =========================================================================== #
90
+ # 6. Reihe:
91
+ # =========================================================================== #
92
+ Cs: 132.91
93
+ Ba: 137.33
94
+ Hf: 178.49
95
+ Ta: 180.95
96
+ W: 183.84
97
+ Re: 186.21
98
+ Os: 190.23
99
+ Ir: 192.22
100
+ Pt: 195.08
101
+ Au: 196.97
102
+ Hg: 200.59
103
+ Tl: 204.38
104
+ Pb: 207.2
105
+ Bi: 208.98
106
+ # Po:
107
+ # At:
108
+ # Rn:
109
+ # ^^^ Da steht nix bei diesen 3 Elementen, wahrscheinlich weil sie instabil sind.
@@ -0,0 +1,109 @@
1
+ # =========================================================================== #
2
+ # This here is the Pauling electronegativity scale.
3
+ #
4
+ # There are other ways of measuring electronegativity, such as the
5
+ # Mulliken scale and the Allred-Rochow scale.
6
+ #
7
+ # Linus Pauling's electronegativity scale is the most common though.
8
+ #
9
+ # Taken from:
10
+ #
11
+ # http://www.tutor-homework.com/Chemistry_Help/electronegativity_table/electronegativity.html
12
+ #
13
+ # =========================================================================== #
14
+
15
+ # =========================================================================== #
16
+ # 1. Periode
17
+ # =========================================================================== #
18
+ H: 2.1
19
+ He: 0
20
+
21
+ # =========================================================================== #
22
+ # 2. Periode
23
+ # =========================================================================== #
24
+ Li: 0.98
25
+ Be: 1.57
26
+ B: 2.04
27
+ C: 2.55
28
+ N: 3.04
29
+ O: 3.44
30
+ F: 3.98
31
+ Ne: 0
32
+
33
+ # =========================================================================== #
34
+ # 3. Periode
35
+ # =========================================================================== #
36
+ Na: 0.93
37
+ Mg: 1.31
38
+ Al: 1.61
39
+ Si: 1.9
40
+ P: 2.19
41
+ S: 2.58
42
+ Cl: 3.16
43
+ Ar: 0
44
+
45
+ # =========================================================================== #
46
+ # 4. Periode
47
+ # =========================================================================== #
48
+ K: 0.82
49
+ Ca: 1
50
+ Sc: 1.36
51
+ Ti: 1.54
52
+ V: 1.63
53
+ Cr: 1.66
54
+ Mn: 1.55
55
+ Fe: 1.83
56
+ Co: 1.88
57
+ Ni: 1.91
58
+ Cu: 1.9
59
+ Zn: 1.65
60
+ Ga: 1.81
61
+ Ge: 2.01
62
+ As: 2.18
63
+ Se: 2.55
64
+ Br: 2.96
65
+ Kr: 0
66
+
67
+ # =========================================================================== #
68
+ # 5. Periode
69
+ # =========================================================================== #
70
+ Rb: 0.82
71
+ Sr: 0.95
72
+ Y: 1.22
73
+ Zr: 1.33
74
+ Nb: 1.6
75
+ Mo: 2.16
76
+ Tc: 1.9
77
+ Ru: 2.2
78
+ Rh: 2.28
79
+ Pd: 2.2
80
+ Ag: 1.93
81
+ Cd: 1.69
82
+ In: 1.78
83
+ Sn: 1.96
84
+ Sb: 2.05
85
+ Te: 2.1
86
+ I: 2.66
87
+ Xe: 2.6
88
+
89
+ # =========================================================================== #
90
+ # 6. Periode
91
+ # =========================================================================== #
92
+ Cs: 0.79
93
+ Ba: 0.89
94
+ La: 1.1
95
+ Hf: 1.3
96
+ Ta: 1.5
97
+ W: 2.36
98
+ Re: 1.9
99
+ Os: 2.2
100
+ Ir: 2.2
101
+ Pt: 2.28
102
+ Au: 2.54
103
+ Hg: 2
104
+ Tl: 2.04
105
+ Pb: 2.33
106
+ Bi: 2.02
107
+ Po: 2
108
+ At: 2.2
109
+ Rn: 0