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.
- checksums.yaml +7 -0
- data/README.md +522 -0
- data/bin/chemistry_paradise +7 -0
- data/bin/wetter +7 -0
- data/chemistry_paradise.gemspec +46 -0
- data/doc/README.gen +518 -0
- data/doc/bugs/BUGS.md +16 -0
- data/doc/formulas/biochemical_calculations.md +5 -0
- data/doc/todo/todo_for_the_chemistry_paradise_project.md +33 -0
- data/doc/todo/todo_for_the_wetter_project.md +7 -0
- data/lib/chemistry_paradise/base/base.rb +215 -0
- data/lib/chemistry_paradise/base/colours.rb +93 -0
- data/lib/chemistry_paradise/commandline/help.rb +40 -0
- data/lib/chemistry_paradise/commandline/menu.rb +88 -0
- data/lib/chemistry_paradise/commandline/parse_commandline.rb +94 -0
- data/lib/chemistry_paradise/constants/constants.rb +77 -0
- data/lib/chemistry_paradise/constants/file_constants.rb +33 -0
- data/lib/chemistry_paradise/constants/german_names_of_elements_to_element_symbol.rb +157 -0
- data/lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb +143 -0
- data/lib/chemistry_paradise/converters/celsius_to_kelvin.rb +125 -0
- data/lib/chemistry_paradise/converters/fahrenheit_to_celsius.rb +132 -0
- data/lib/chemistry_paradise/converters/shared.rb +21 -0
- data/lib/chemistry_paradise/gui/gtk3/calculate_molecular_weight/calculate_molecular_weight.rb +34 -0
- data/lib/chemistry_paradise/gui/gtk3/show_periodic_table/show_periodic_table.rb +34 -0
- data/lib/chemistry_paradise/gui/gtk3/temperature_converter/temperature_converter.rb +112 -0
- data/lib/chemistry_paradise/gui/gtk3/wetter/wetter.rb +119 -0
- data/lib/chemistry_paradise/gui/libui/temperature_converter/temperature_converter.rb +100 -0
- data/lib/chemistry_paradise/gui/libui/wetter/wetter.rb +47 -0
- data/lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb +171 -0
- data/lib/chemistry_paradise/gui/shared_code/show_periodic_table/show_periodic_table_module.rb +318 -0
- data/lib/chemistry_paradise/gui/shared_code/temperature_converter/temperature_converter_module.rb +192 -0
- data/lib/chemistry_paradise/gui/shared_code/wetter/wetter_module.rb +349 -0
- data/lib/chemistry_paradise/gui/swing/TemperatureConverter$1.class +0 -0
- data/lib/chemistry_paradise/gui/swing/TemperatureConverter.class +0 -0
- data/lib/chemistry_paradise/gui/swing/TemperatureConverter.java +133 -0
- data/lib/chemistry_paradise/gui/unified_widgets/wetter/wetter.rb +62 -0
- data/lib/chemistry_paradise/images/show_periodic_table.png +0 -0
- data/lib/chemistry_paradise/images/vienna_map.png +0 -0
- data/lib/chemistry_paradise/interactive_chemistry_shell.rb +246 -0
- data/lib/chemistry_paradise/project/project.rb +24 -0
- data/lib/chemistry_paradise/requires/common_external_requires.rb +17 -0
- data/lib/chemistry_paradise/requires/require_the_project.rb +21 -0
- data/lib/chemistry_paradise/requires/require_the_project_including_the_graphical_user_interface.rb +7 -0
- data/lib/chemistry_paradise/requires/require_the_project_including_the_web_interface.rb +4 -0
- data/lib/chemistry_paradise/shared.rb +130 -0
- data/lib/chemistry_paradise/show_electron_configuration.rb +250 -0
- data/lib/chemistry_paradise/show_element.rb +145 -0
- data/lib/chemistry_paradise/sinatra/sinatra.rb +131 -0
- data/lib/chemistry_paradise/sinatra/wetter/app.rb +68 -0
- data/lib/chemistry_paradise/sinatra/wetter/start_sinatra_interface.rb +31 -0
- data/lib/chemistry_paradise/split_molecule_names.rb +228 -0
- data/lib/chemistry_paradise/toplevel_methods/atomgewichte.rb +31 -0
- data/lib/chemistry_paradise/toplevel_methods/convert_parens.rb +64 -0
- data/lib/chemistry_paradise/toplevel_methods/display_where_the_molmasses_are_kept.rb +24 -0
- data/lib/chemistry_paradise/toplevel_methods/e.rb +16 -0
- data/lib/chemistry_paradise/toplevel_methods/kelvin.rb +34 -0
- data/lib/chemistry_paradise/toplevel_methods/language.rb +50 -0
- data/lib/chemistry_paradise/toplevel_methods/misc.rb +147 -0
- data/lib/chemistry_paradise/toplevel_methods/periodic_table.rb +16 -0
- data/lib/chemistry_paradise/toplevel_methods/remove_this_molecule_from.rb +63 -0
- data/lib/chemistry_paradise/toplevel_methods/roebe.rb +16 -0
- data/lib/chemistry_paradise/toplevel_methods/show_electron_negativity_chart.rb +26 -0
- data/lib/chemistry_paradise/utility_scripts/calculate_atomic_mass.rb +559 -0
- data/lib/chemistry_paradise/utility_scripts/combustion_analysis.rb +207 -0
- data/lib/chemistry_paradise/utility_scripts/electron_negativity_chart.rb +78 -0
- data/lib/chemistry_paradise/utility_scripts/equalize_chemical_formula.rb +84 -0
- data/lib/chemistry_paradise/utility_scripts/equation_solver.rb +130 -0
- data/lib/chemistry_paradise/utility_scripts/orbitals.rb +70 -0
- data/lib/chemistry_paradise/utility_scripts/show_electron_negativity_of_this_element.rb +103 -0
- data/lib/chemistry_paradise/verbose_chemical_calculation.rb +21 -0
- data/lib/chemistry_paradise/version/version.rb +19 -0
- data/lib/chemistry_paradise/wetter/wetter.rb +539 -0
- data/lib/chemistry_paradise/www/wetter/embeddable_interface.rb +78 -0
- data/lib/chemistry_paradise/www/wetter/wetter.cgi +28 -0
- data/lib/chemistry_paradise/yaml/atomgewichte.yml +113 -0
- data/lib/chemistry_paradise/yaml/colours_for_the_elements.yml +13 -0
- data/lib/chemistry_paradise/yaml/dichte.yml +21 -0
- data/lib/chemistry_paradise/yaml/electron_negativity_chart.yml +111 -0
- data/lib/chemistry_paradise/yaml/molecular_formula_of_different_molecules.yml +13 -0
- data/lib/chemistry_paradise/yaml/periodic_table_of_the_elements.yml +125 -0
- data/lib/chemistry_paradise.rb +1 -0
- data/test/testing_chemistry_paradise.rb +49 -0
- metadata +173 -0
@@ -0,0 +1,246 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === ChemistryParadise::InteractiveChemistryShell
|
6
|
+
#
|
7
|
+
# Usage examples:
|
8
|
+
#
|
9
|
+
# ChemistryParadise::InteractiveChemistryShell.new
|
10
|
+
#
|
11
|
+
# =========================================================================== #
|
12
|
+
# require 'chemistry/interactive_chemistry_shell'
|
13
|
+
# =========================================================================== #
|
14
|
+
require 'chemistry_paradise/base/base.rb'
|
15
|
+
|
16
|
+
begin
|
17
|
+
require 'readline'
|
18
|
+
rescue LoadError; end
|
19
|
+
|
20
|
+
module ChemistryParadise
|
21
|
+
|
22
|
+
class InteractiveChemistryShell < Base # === ChemistryParadise::InteractiveChemistryShell
|
23
|
+
|
24
|
+
require 'chemistry_paradise/utility_scripts/calculate_atomic_mass.rb'
|
25
|
+
|
26
|
+
# ========================================================================= #
|
27
|
+
# === PROMPT
|
28
|
+
# ========================================================================= #
|
29
|
+
PROMPT = '> '
|
30
|
+
if File.exist? Shared.periodic_table?
|
31
|
+
PERIODIC_TABLE = YAML.load_file(Shared.periodic_table?)
|
32
|
+
else
|
33
|
+
PERIODIC_TABLE = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
# ========================================================================= #
|
37
|
+
# === initialize
|
38
|
+
# ========================================================================= #
|
39
|
+
def initialize(run_already = true)
|
40
|
+
reset
|
41
|
+
run if run_already
|
42
|
+
end
|
43
|
+
|
44
|
+
# ========================================================================= #
|
45
|
+
# === reset
|
46
|
+
# ========================================================================= #
|
47
|
+
def reset
|
48
|
+
@lpad = ' '
|
49
|
+
end
|
50
|
+
|
51
|
+
# ========================================================================= #
|
52
|
+
# === show_welcome_message
|
53
|
+
# ========================================================================= #
|
54
|
+
def show_welcome_message
|
55
|
+
e 'Welcome to the InteractiveChemistryShell.'
|
56
|
+
e 'Input "help" to get a list of options, otherwise'
|
57
|
+
e 'just type in your input now.'
|
58
|
+
print PROMPT
|
59
|
+
end
|
60
|
+
|
61
|
+
# ========================================================================= #
|
62
|
+
# === report_input
|
63
|
+
# ========================================================================= #
|
64
|
+
def report_input(i)
|
65
|
+
ewarn 'Input was: `'+sfancy(i)+'`'
|
66
|
+
end
|
67
|
+
|
68
|
+
# ========================================================================= #
|
69
|
+
# === show_welcome_message_and_help
|
70
|
+
# ========================================================================= #
|
71
|
+
def show_welcome_message_and_help
|
72
|
+
show_welcome_message
|
73
|
+
show_help
|
74
|
+
end
|
75
|
+
|
76
|
+
# ========================================================================= #
|
77
|
+
# === calculate
|
78
|
+
#
|
79
|
+
# To test this, do:
|
80
|
+
# calc C3H5
|
81
|
+
# ========================================================================= #
|
82
|
+
def calculate(i)
|
83
|
+
if i.nil?
|
84
|
+
e 'Please provide proper input to this method now, for instance, `C12H12N2`:'
|
85
|
+
i = $stdin.gets.chomp
|
86
|
+
end
|
87
|
+
CalculateAtomicMass.new(i)
|
88
|
+
end; alias calc calculate # === calc
|
89
|
+
|
90
|
+
# ========================================================================= #
|
91
|
+
# === check_against_menu
|
92
|
+
# ========================================================================= #
|
93
|
+
def check_against_menu
|
94
|
+
_ = @user_input # We can use this now.
|
95
|
+
arguments = nil # Default to denote that we have no arguments.
|
96
|
+
if _.include? ' '
|
97
|
+
splitted = _.split(' ')
|
98
|
+
_ = splitted[0] # Reassign here to the first entry.
|
99
|
+
arguments = splitted[1..-1]
|
100
|
+
end
|
101
|
+
case _ # case tag
|
102
|
+
# ======================================================================= #
|
103
|
+
# === quit
|
104
|
+
# ======================================================================= #
|
105
|
+
when 'quit','exit','q'
|
106
|
+
e 'Bye from the InteractiveChemistryShell.'
|
107
|
+
exit
|
108
|
+
# ======================================================================= #
|
109
|
+
# === show_electron_negativity_chart
|
110
|
+
# ======================================================================= #
|
111
|
+
when '4','show_electron_negativity_chart'
|
112
|
+
ChemistryParadise.show_electron_negativity_chart
|
113
|
+
# ======================================================================= #
|
114
|
+
# === periodic_table?
|
115
|
+
# ======================================================================= #
|
116
|
+
when '3','periodic_table?','show_periodic_table','top','top?',
|
117
|
+
'periodic?','periodic','showperiodictable'
|
118
|
+
show_periodic_table
|
119
|
+
# ======================================================================= #
|
120
|
+
# === help
|
121
|
+
# ======================================================================= #
|
122
|
+
when /-?-?help/,'hel','he','h','?'
|
123
|
+
show_help
|
124
|
+
when '1','calc','calculate'
|
125
|
+
calculate(arguments)
|
126
|
+
when '2','show'
|
127
|
+
e 'Input your element symbol now:'
|
128
|
+
element_symbol = $stdin.gets.chomp
|
129
|
+
ShowElectronConfiguration.new(element_symbol)
|
130
|
+
when '' # pass through
|
131
|
+
else
|
132
|
+
# To test the following, try:
|
133
|
+
# 454 g NH4NO3
|
134
|
+
if @user_input.include?('g') and @user_input =~ /\d+/
|
135
|
+
splitted = @user_input.strip.split('g').map(&:strip)
|
136
|
+
atomic_mass = ChemistryParadise::CalculateAtomicMass[splitted.last].to_f
|
137
|
+
n_times = splitted.first.strip.to_i
|
138
|
+
mass = n_times / atomic_mass
|
139
|
+
e (mass.round(2)).to_s+' mol'
|
140
|
+
else
|
141
|
+
report_input(_)
|
142
|
+
show_help
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# ========================================================================= #
|
148
|
+
# === ecomment
|
149
|
+
# ========================================================================= #
|
150
|
+
def ecomment(i)
|
151
|
+
Colours.ecomment(i)
|
152
|
+
end
|
153
|
+
|
154
|
+
# ========================================================================= #
|
155
|
+
# === run_loop
|
156
|
+
# ========================================================================= #
|
157
|
+
def run_loop
|
158
|
+
loop {
|
159
|
+
fetch_user_input # Get user input first.
|
160
|
+
check_against_menu
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
# ========================================================================= #
|
165
|
+
# === run (run tag)
|
166
|
+
# ========================================================================= #
|
167
|
+
def run
|
168
|
+
show_welcome_message_and_help # Show the help section on startup.
|
169
|
+
run_loop
|
170
|
+
end
|
171
|
+
|
172
|
+
# ========================================================================= #
|
173
|
+
# === show_help
|
174
|
+
# ========================================================================= #
|
175
|
+
def show_help # help tag
|
176
|
+
e 'Available options:'
|
177
|
+
e
|
178
|
+
# ======================================================================= #
|
179
|
+
# Add more documented help-options to this Array here.
|
180
|
+
# ======================================================================= #
|
181
|
+
array = [
|
182
|
+
'calculate the atomic mass',
|
183
|
+
'show the electron configuration of an Element',
|
184
|
+
'show the periodic table',
|
185
|
+
'show electron negativity chart'
|
186
|
+
]
|
187
|
+
array.each_with_index {|entry, index|
|
188
|
+
index += 1
|
189
|
+
ecomment @lpad+index.to_s+' # '+entry
|
190
|
+
}
|
191
|
+
end
|
192
|
+
|
193
|
+
# ========================================================================= #
|
194
|
+
# === has_readline?
|
195
|
+
# ========================================================================= #
|
196
|
+
def has_readline?
|
197
|
+
Object.const_defined? :Readline
|
198
|
+
end
|
199
|
+
|
200
|
+
# ========================================================================= #
|
201
|
+
# === fetch_user_input
|
202
|
+
# ========================================================================= #
|
203
|
+
def fetch_user_input
|
204
|
+
if has_readline?
|
205
|
+
@user_input = Readline.readline('', true)
|
206
|
+
else
|
207
|
+
@user_input = $stdin.gets.chomp
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
# ========================================================================= #
|
212
|
+
# === show_periodic_table
|
213
|
+
# ========================================================================= #
|
214
|
+
def show_periodic_table
|
215
|
+
e # Add a newline.
|
216
|
+
inverted = PERIODIC_TABLE.invert
|
217
|
+
1.upto(7).each {|periode|
|
218
|
+
range = return_range_for_this_period(periode)
|
219
|
+
# ===================================================================== #
|
220
|
+
# Now we have a proper range.
|
221
|
+
# ===================================================================== #
|
222
|
+
matches = inverted.select {|index_position, value|
|
223
|
+
range.include? index_position
|
224
|
+
}
|
225
|
+
ee colourize_via_kde_konsole(periode.to_s)+': ' # Display the periode here.
|
226
|
+
matches.each_pair {|key, value|
|
227
|
+
ee simp(value)+' ('+key.to_s+') '
|
228
|
+
}; e
|
229
|
+
}
|
230
|
+
end
|
231
|
+
|
232
|
+
# ========================================================================= #
|
233
|
+
# === colourize_via_kde_konsole
|
234
|
+
# ========================================================================= #
|
235
|
+
def colourize_via_kde_konsole(i)
|
236
|
+
if Object.const_defined? :Colours
|
237
|
+
i = ::Colours.lightgreen(i)
|
238
|
+
end
|
239
|
+
return i
|
240
|
+
end
|
241
|
+
|
242
|
+
end; end
|
243
|
+
|
244
|
+
if __FILE__ == $PROGRAM_NAME
|
245
|
+
ChemistryParadise::InteractiveChemistryShell.new
|
246
|
+
end # ichem
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'chemistry_paradise/project/project.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module ChemistryParadise
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === PROJECT_BASE_DIRECTORY
|
11
|
+
#
|
12
|
+
# The constant must have a trailing '/' character.
|
13
|
+
# ========================================================================= #
|
14
|
+
PROJECT_BASE_DIRECTORY =
|
15
|
+
File.absolute_path("#{__dir__}/..")+'/'
|
16
|
+
|
17
|
+
# ========================================================================= #
|
18
|
+
# === ChemistryParadise.project_base_directory?
|
19
|
+
# ========================================================================= #
|
20
|
+
def self.project_base_directory?
|
21
|
+
PROJECT_BASE_DIRECTORY
|
22
|
+
end; self.instance_eval { alias project_base_dir? project_base_directory? } # === ChemistryParadise.project_base_dir?
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'chemistry_paradise/requires/common_external_requires.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'yaml'
|
8
|
+
begin
|
9
|
+
require 'colours'
|
10
|
+
rescue LoadError; end
|
11
|
+
begin
|
12
|
+
require 'opn'
|
13
|
+
rescue LoadError; end
|
14
|
+
|
15
|
+
begin
|
16
|
+
require 'cliner'
|
17
|
+
rescue LoadError; end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'chemistry_paradise/requires/require_the_project.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'chemistry_paradise/show_electron_configuration.rb'
|
8
|
+
require 'chemistry_paradise/commandline/parse_commandline.rb'
|
9
|
+
require 'chemistry_paradise/utility_scripts/calculate_atomic_mass.rb'
|
10
|
+
require 'chemistry_paradise/utility_scripts/combustion_analysis.rb'
|
11
|
+
require 'chemistry_paradise/utility_scripts/equation_solver.rb'
|
12
|
+
require 'chemistry_paradise/utility_scripts/equalize_chemical_formula.rb'
|
13
|
+
require 'chemistry_paradise/utility_scripts/orbitals.rb'
|
14
|
+
require 'chemistry_paradise/utility_scripts/show_electron_negativity_of_this_element.rb'
|
15
|
+
|
16
|
+
require 'chemistry_paradise/toplevel_methods/atomgewichte.rb'
|
17
|
+
require 'chemistry_paradise/toplevel_methods/misc.rb'
|
18
|
+
require 'chemistry_paradise/toplevel_methods/remove_this_molecule_from.rb'
|
19
|
+
require 'chemistry_paradise/toplevel_methods/show_electron_negativity_chart.rb'
|
20
|
+
|
21
|
+
require 'chemistry_paradise/wetter/wetter.rb'
|
data/lib/chemistry_paradise/requires/require_the_project_including_the_graphical_user_interface.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'chemistry_paradise/requires/require_the_project_including_the_graphical_user_interface.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'chemistry_paradise/gui/gtk3/wetter/wetter.rb'
|
@@ -0,0 +1,4 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# require 'chemistry_paradise/requires/require_the_project_including_the_web_interface.rb'
|
3
|
+
# =========================================================================== #
|
4
|
+
require 'chemistry_paradise/www/wetter/embeddable_interface.rb'
|
@@ -0,0 +1,130 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === ChemistryParadise::Shared
|
6
|
+
#
|
7
|
+
# To load this file, do:
|
8
|
+
#
|
9
|
+
# require 'chemistry_paradise/shared.rb'
|
10
|
+
#
|
11
|
+
# =========================================================================== #
|
12
|
+
require 'chemistry_paradise/requires/common_external_requires.rb'
|
13
|
+
|
14
|
+
module ChemistryParadise # include ChemistryParadise::Shared
|
15
|
+
|
16
|
+
module Shared # === ChemistryParadise::Shared
|
17
|
+
|
18
|
+
require 'chemistry_paradise/constants/constants.rb'
|
19
|
+
require 'chemistry_paradise/version/version.rb'
|
20
|
+
require 'chemistry_paradise/toplevel_methods/convert_parens.rb'
|
21
|
+
require 'chemistry_paradise/toplevel_methods/periodic_table.rb'
|
22
|
+
|
23
|
+
include ChemistryParadise::Constants
|
24
|
+
|
25
|
+
# ========================================================================= #
|
26
|
+
# === ARRAY_TEST_THESE_MOLECULES
|
27
|
+
#
|
28
|
+
# Test these molecules. Default values.
|
29
|
+
# ========================================================================= #
|
30
|
+
ARRAY_TEST_THESE_MOLECULES = %w(
|
31
|
+
NH3
|
32
|
+
NH4
|
33
|
+
MnO2
|
34
|
+
P2O5
|
35
|
+
H2O
|
36
|
+
Pb3O4
|
37
|
+
H2SO4
|
38
|
+
C12H12N2
|
39
|
+
BaCO3
|
40
|
+
PbCrO4
|
41
|
+
Al2(SO4)3
|
42
|
+
Ca(OH)2
|
43
|
+
CH3COOH
|
44
|
+
C12H22O11
|
45
|
+
)
|
46
|
+
|
47
|
+
# ========================================================================= #
|
48
|
+
# === is_number?
|
49
|
+
#
|
50
|
+
# This method will return true if is a number, else false. For this it
|
51
|
+
# uses the .to_i method trick, which returns 0 for non-numbers.
|
52
|
+
# ========================================================================= #
|
53
|
+
def is_number?(i)
|
54
|
+
result = (i.to_i.to_s == i)
|
55
|
+
return result
|
56
|
+
end
|
57
|
+
|
58
|
+
# ========================================================================= #
|
59
|
+
# === square
|
60
|
+
#
|
61
|
+
# Die Wurzel aus 2 ist 1.414
|
62
|
+
#
|
63
|
+
# chem; square 2; sqr 3; sqr 4; sqr 5; sqr 6; sqr 7; sqr 8; sqr 9
|
64
|
+
#
|
65
|
+
# ========================================================================= #
|
66
|
+
def square(of)
|
67
|
+
Math.sqrt of
|
68
|
+
end; alias sqr square # === sqr
|
69
|
+
|
70
|
+
# ========================================================================= #
|
71
|
+
# === periodic_table?
|
72
|
+
# ========================================================================= #
|
73
|
+
def periodic_table?
|
74
|
+
return Shared.periodic_table?
|
75
|
+
end
|
76
|
+
|
77
|
+
# ========================================================================= #
|
78
|
+
# === ChemistryParadise::Shared.periodic_table?
|
79
|
+
# ========================================================================= #
|
80
|
+
def self.periodic_table?
|
81
|
+
::ChemistryParadise.periodic_table?
|
82
|
+
end
|
83
|
+
|
84
|
+
# ========================================================================= #
|
85
|
+
# === return_range_for_this_period
|
86
|
+
#
|
87
|
+
# This method will tell us the legal range of elements for any given
|
88
|
+
# period.
|
89
|
+
#
|
90
|
+
# The formula would be:
|
91
|
+
#
|
92
|
+
# 2+4n
|
93
|
+
#
|
94
|
+
# For instance:
|
95
|
+
# period 1 will return (1..2).
|
96
|
+
# period 2 will return (3..8).
|
97
|
+
# ========================================================================= #
|
98
|
+
def return_range_for_this_period(this_period = 1)
|
99
|
+
case this_period
|
100
|
+
when 1
|
101
|
+
(1..2)
|
102
|
+
when 2
|
103
|
+
(3..10)
|
104
|
+
when 3
|
105
|
+
(11..18)
|
106
|
+
when 4
|
107
|
+
(19..36)
|
108
|
+
when 5
|
109
|
+
(37..54)
|
110
|
+
when 6
|
111
|
+
(55..86)
|
112
|
+
when 7
|
113
|
+
(87..118)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# ========================================================================= #
|
118
|
+
# === convert_parens
|
119
|
+
# ========================================================================= #
|
120
|
+
def convert_parens(i)
|
121
|
+
ChemistryParadise.convert_parens(i)
|
122
|
+
end; alias parse convert_parens # === parse
|
123
|
+
|
124
|
+
end; end
|
125
|
+
|
126
|
+
if __FILE__ == $PROGRAM_NAME
|
127
|
+
include ChemistryParadise::Shared
|
128
|
+
pp convert_parens 'Al2(SO4)3'
|
129
|
+
pp convert_parens 'Fe(OH)3 + H2SO4 -> Fe2(SO4)3 + H2O'
|
130
|
+
end # rb shared.rb
|