chemistry_paradise 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +657 -0
- data/bin/chemistry_paradise +7 -0
- data/bin/wetter +7 -0
- data/chemistry_paradise.gemspec +46 -0
- data/doc/README.gen +595 -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/constants_for_chemical_formulas.rb +16 -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 +228 -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/utility_scripts/show_periodic_table.rb +996 -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 +139 -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 +175 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '09d67d6c93e330fd4a3ce6c2c6bd9f2a447aa5786f02d1616bf7fac105a0190f'
|
4
|
+
data.tar.gz: 2a52a6df6e6f370eb195cc53923b4ca13d60b1b81ffbd7849471dec27737ac53
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8185dee13f281b5d81b5dd4250c14b7dd32b974f6cd837d1751bbad6feeba29567ac51c86eb9754a988c71948bbc61e2b821854e408527b38abe900bd355cfa4
|
7
|
+
data.tar.gz: 41cd8627982c38e82f62cab3a18394a994a629c242c667745b22ce4361ed95fc71739493ee213eddc33220cc737b8d1b12709f6a2ecf1bc11953bc1a2134554b
|
data/README.md
ADDED
@@ -0,0 +1,657 @@
|
|
1
|
+
[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
|
2
|
+
[![forthebadge](https://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/chemistry_paradise.svg)](https://badge.fury.io/rb/chemistry_paradise)
|
4
|
+
|
5
|
+
This gem was <b>last updated</b> on the <span style="color: darkblue; font-weight: bold">10.11.2023</span> (dd.mm.yyyy notation), at <span style="color: steelblue; font-weight: bold">16:25:50</span> o'clock.
|
6
|
+
|
7
|
+
## Introduction
|
8
|
+
|
9
|
+
This project bundles together some commonly used methods and classes
|
10
|
+
related to **chemistry**.
|
11
|
+
|
12
|
+
Use cases may include when you want to quickly know the molecular
|
13
|
+
weight of a compound (via the commandline) or when you want to
|
14
|
+
want to perform a simple **combustion analysis**, so mostly
|
15
|
+
homework, school, college or simple university-related use cases.
|
16
|
+
|
17
|
+
Please keep in mind that this is just a hobby project. It will
|
18
|
+
never compete with professional or commercial-grade projects,
|
19
|
+
simply because that is not its main use case or goal. It's also
|
20
|
+
not my primary project related to science - I am more of a molecular
|
21
|
+
biology person, so the code in this project is mostly just
|
22
|
+
"helper"-related code. Perhaps you may find some interesting
|
23
|
+
ideas in the long run, though, and other chemistry-related
|
24
|
+
projects in ruby could benefit from it. See also <b>sciruby</b>.
|
25
|
+
|
26
|
+
For more information, have a look at the other documentation
|
27
|
+
in this file (respectively at
|
28
|
+
https://www.rubydoc.info/gems/chemistry_paradise/
|
29
|
+
).
|
30
|
+
|
31
|
+
## The individual classes in this project
|
32
|
+
|
33
|
+
The individual classes of this project may have their own
|
34
|
+
subsection here, starting with class **CalculateAtomicMass**,
|
35
|
+
which was one of the first classes originally written - I
|
36
|
+
had to calculate the mass of compounds via a pocket
|
37
|
+
calculator. Since I kept doing mistakes doing so, I decided
|
38
|
+
to write some code that will show whether I calculated
|
39
|
+
correctly.
|
40
|
+
|
41
|
+
## class ChemistryParadise::CalculateAtomicMass
|
42
|
+
|
43
|
+
class ChemistryParadise::CalculateAtomicMass will calculate the
|
44
|
+
mass of compounds.
|
45
|
+
|
46
|
+
Argument to this class should be something such as
|
47
|
+
<b>C16H12N2</b>, but you can also use Unicode numbers
|
48
|
+
such as ₃ rather than 3.
|
49
|
+
|
50
|
+
So the following shows valid arguments to the class:
|
51
|
+
|
52
|
+
ChemistryParadise::CalculateAtomicMass.new('C16H12N2')
|
53
|
+
ChemistryParadise::CalculateAtomicMass.new('CH3Cl')
|
54
|
+
ChemistryParadise::CalculateAtomicMass.new('CH₃Cl') # ← This variant also works since as of December 2019.
|
55
|
+
ChemistryParadise::CalculateAtomicMass.new('CO₂') # ← As does this, too, since as of December 2019.
|
56
|
+
|
57
|
+
If you need **english output**, look at the entry default language
|
58
|
+
to use within the project, in this file.
|
59
|
+
|
60
|
+
- **ChemistryParadise::Orbitals** will simply show how many
|
61
|
+
electrons fit into an orbital.
|
62
|
+
|
63
|
+
- The class **ChemistryParadise::ShowElectronConfiguration**
|
64
|
+
will report the electron configuration for the given element.
|
65
|
+
|
66
|
+
For example, if you pass 'Fe' as element (iron), then the
|
67
|
+
class will report something like this:
|
68
|
+
|
69
|
+
Found element Fe. It has 26 electrons.
|
70
|
+
[Ar] 4s2 3d6
|
71
|
+
|
72
|
+
Specific example in pure ruby:
|
73
|
+
|
74
|
+
require 'chemistry_paradise'
|
75
|
+
ChemistryParadise::ShowElectronConfiguration.new('Fe')
|
76
|
+
|
77
|
+
Note that this may not work as well for heavy atoms, but for
|
78
|
+
the more common ~smaller atoms, it should work fine.
|
79
|
+
|
80
|
+
Do note that since as of March 2020 a few chemical substances
|
81
|
+
can be quickly queried by their trivial name, including a
|
82
|
+
few german names.
|
83
|
+
|
84
|
+
Example:
|
85
|
+
|
86
|
+
molmasse harnstoff
|
87
|
+
|
88
|
+
This would be the very same as:
|
89
|
+
|
90
|
+
molmasse CH₄N₂O
|
91
|
+
molmasse CH4N2O
|
92
|
+
|
93
|
+
To output this in english, try:
|
94
|
+
|
95
|
+
molmasse "(NH₄)₂SO₄" --english
|
96
|
+
|
97
|
+
So basically use the **--english** commandline flag.
|
98
|
+
|
99
|
+
## Default language to use within the project
|
100
|
+
|
101
|
+
The project initially showed output mostly in the german language.
|
102
|
+
|
103
|
+
However had - most people may prefer the english language, so a
|
104
|
+
switch exists that allows you to toggle the behaviour of the
|
105
|
+
ChemistryParadise project, in regards to the language at hand.
|
106
|
+
|
107
|
+
If you wish to **use the english language**, you can use the following
|
108
|
+
method call:
|
109
|
+
|
110
|
+
ChemistryParadise.do_use_english
|
111
|
+
|
112
|
+
Also, the Base class allows one to switch between the english
|
113
|
+
and the german language.
|
114
|
+
|
115
|
+
Either way, past this point, if you invoke **class CalculateAtomicMass**,
|
116
|
+
it will then report the result in english. Internally the
|
117
|
+
module-method instance variable called <b>@language</b> will
|
118
|
+
keep track of the language at hand.
|
119
|
+
|
120
|
+
See also the test/ subdirectory to look at this in action.
|
121
|
+
|
122
|
+
## German names of atoms/elements
|
123
|
+
|
124
|
+
In the german language, we can find names such as <b>Quecksilber</b>
|
125
|
+
for the element <b>Hg</b> (mercury, aka <b>hydrargyrum</b>).
|
126
|
+
|
127
|
+
The file <b>german_names_of_elements_to_element_symbol.rb</b>
|
128
|
+
handles this conversion, but you can also query the translated
|
129
|
+
symbol-name from the commandliny, by using a pseudo-regex such
|
130
|
+
as:
|
131
|
+
|
132
|
+
chemistry_paradise /Quecksilber/
|
133
|
+
|
134
|
+
So in other words, the german name of the element at hand is
|
135
|
+
to be put between the two **/** characters.
|
136
|
+
|
137
|
+
The default pseudo-regex may change one day, in which case
|
138
|
+
the change would be properly documented here as well.
|
139
|
+
|
140
|
+
## class ChemistryParadise::ShowElectronNegativityOfThisElement
|
141
|
+
|
142
|
+
<b>class ChemistryParadise::ShowElectronNegativityOfThisElement</b>
|
143
|
+
can be used to show, on the commandline, the **electronegativity**
|
144
|
+
of the given elements.
|
145
|
+
|
146
|
+
So for example, if you'd want to know to know the electron negativity
|
147
|
+
of Fluor and Iron, you'd pass in this:
|
148
|
+
|
149
|
+
ChemistryParadise::ShowElectronNegativityOfThisElement.new(['F','Fe'])
|
150
|
+
|
151
|
+
From the commandline, if you aliased towards the .rb file, simply pass
|
152
|
+
in F and Fe, without any ' quotes.
|
153
|
+
|
154
|
+
If you want another accessor, also from the commandline, then do:
|
155
|
+
|
156
|
+
chemistry_paradise --electronegativity-of=F/Fe
|
157
|
+
|
158
|
+
In that case, <b>/</b> acts as the separator between several elements.
|
159
|
+
|
160
|
+
<b>Always input the element symbol, NOT the long name of the
|
161
|
+
element.</b>
|
162
|
+
|
163
|
+
See **wikipedia** for a complete list of elements.
|
164
|
+
|
165
|
+
If you intent to use this part of the chemistry_paradise project
|
166
|
+
to predict whether two elements form an ionic bond, as a rule of
|
167
|
+
thumb, the difference should be at the very least <b>1.5</b> between
|
168
|
+
the two elements; ideally <b>1.8</b>. Past that point it can
|
169
|
+
be concluded, that two different elements with such a large
|
170
|
+
discrepancy in their electron negativity values, would form
|
171
|
+
<b>ionic bonds</b> (if they would bind to one another in the
|
172
|
+
first place, that is).
|
173
|
+
|
174
|
+
## Showing the individual steps
|
175
|
+
|
176
|
+
If you wish to display the molecular mass of some compound, on
|
177
|
+
the commandline, and would also like to display the individual
|
178
|
+
steps done, you can use the following commandline flag:
|
179
|
+
|
180
|
+
mmasse CaCO3 --show-steps
|
181
|
+
|
182
|
+
Note that this will probably be extended in the future, so
|
183
|
+
that this also works a bit like a **debug-flag**. The idea
|
184
|
+
here is to be able to verify what is going on in a simple
|
185
|
+
manner, rather than to merely rely on the output **assumed**
|
186
|
+
to be correct.
|
187
|
+
|
188
|
+
## class ChemistryParadise::CombustionAnalysis
|
189
|
+
|
190
|
+
**class ChemistryParadise::CombustionAnalysis** can be used
|
191
|
+
to analyse the combustion of a compound.
|
192
|
+
|
193
|
+
Say that you know these values:
|
194
|
+
|
195
|
+
K 28,93%
|
196
|
+
S 23,72%
|
197
|
+
O 47.35%
|
198
|
+
|
199
|
+
K means Kalium aka Sodium (correction in November 2020: Sodium
|
200
|
+
is, of course, Na aka Natrium; not sure why the german name
|
201
|
+
matches, whereas the english one does not, but evidently I
|
202
|
+
made the mistake in assuming that Kalium would be Sodium,
|
203
|
+
which was **evidently** incorrect).
|
204
|
+
|
205
|
+
Note that 28,93% refers to 28.93% of **100%**
|
206
|
+
of the given substance is stored in Kalium.
|
207
|
+
|
208
|
+
Next, we invoke the class from the commandline; I aliased
|
209
|
+
it to **combustionanalysis**.
|
210
|
+
|
211
|
+
combustionanalysis "K 28,93% S 23,72% O 47.35%"
|
212
|
+
|
213
|
+
The output will be:
|
214
|
+
|
215
|
+
**KSO₄**
|
216
|
+
|
217
|
+
combustionanalysis "Al 15,77% O 56,12% S 28,11%" # => Al₂O12S₃
|
218
|
+
|
219
|
+
Note that this may have a few bugs left, for larger compounds
|
220
|
+
or any combustion analysis that is not very correct. But for
|
221
|
+
simple compounds, such as the examples shown above, it should
|
222
|
+
work very well.
|
223
|
+
|
224
|
+
You can use this from ruby code via:
|
225
|
+
|
226
|
+
require 'chemistry_paradise/combustion_analysis.rb'
|
227
|
+
ChemistryParadise::CombustionAnalysis.new(ARGV)
|
228
|
+
|
229
|
+
# To use the example above:
|
230
|
+
ChemistryParadise::CombustionAnalysis.new('Al 15,77% O 56,12% S 28,11%') # => Al₂O₁₂S₃
|
231
|
+
|
232
|
+
## Disclaimer
|
233
|
+
|
234
|
+
Keep in mind that this is merely **a hobby project**, not a
|
235
|
+
"fully fledged professional" suite of code.
|
236
|
+
|
237
|
+
I use it primarily to help me in little things, such as **querying
|
238
|
+
the electron configuration of an atom on the commandline**, or
|
239
|
+
**calculating the molar mass of a compound**. I could do the latter
|
240
|
+
manually, but computers are a lot faster and a lot less work
|
241
|
+
than manual calculations - and more reliable, too. I tend to
|
242
|
+
do errors when typing anything into a calculator.
|
243
|
+
|
244
|
+
As this is not professional chemistry-software, please do not
|
245
|
+
expect that this project could ever really help calculating
|
246
|
+
the **Schroedinger equation** or anything similar to that.
|
247
|
+
|
248
|
+
## Www-related documentation in german and english
|
249
|
+
|
250
|
+
Since as of **January 2021** I have decided to slowly put my
|
251
|
+
local knowledge base about chemistry online. These were
|
252
|
+
mostly stored in .cgi files. I may put them into sinatra
|
253
|
+
as interface eventually; we'll see. Anyway, this is a
|
254
|
+
low priority, ongoing effort, and the german parts will
|
255
|
+
not be too useful for other people - but still, I wanted
|
256
|
+
to publish it, simply because it seems to be more useful
|
257
|
+
when available in combination with ruby code as well..
|
258
|
+
|
259
|
+
Since as of May 2021 there is also a tiny sinatra API
|
260
|
+
available.
|
261
|
+
|
262
|
+
For example, if you start sinatra.rb, and then visit a page
|
263
|
+
such as:
|
264
|
+
|
265
|
+
http://localhost:4567/compound/H2SO4
|
266
|
+
|
267
|
+
The atomic mass of H2SO4 will be calculated and then
|
268
|
+
shown via that web-interface.
|
269
|
+
|
270
|
+
## GUI
|
271
|
+
|
272
|
+
I may in the long run add GUIs similar to this one here:
|
273
|
+
|
274
|
+
http://www.gamgi.org/images/screenshot13_5b.png
|
275
|
+
|
276
|
+
But this is a hobby project, so don't expect too much
|
277
|
+
work going into it. See the image below for how that GUI part
|
278
|
+
currently looks like, in regards to the chemistry_paradise
|
279
|
+
project. This depends on the ruby-gtk3 bindings. Once you
|
280
|
+
have the necessary C-files (glib, atk, pango, cairo, gtk),
|
281
|
+
doing "**gem install gtk3**" should work just fine. On
|
282
|
+
windows this is a bit more tedious though.
|
283
|
+
|
284
|
+
For now have a look at the **gtk3/** subdirectory in this
|
285
|
+
gem. But there isn't that much there. Just buttons with
|
286
|
+
different colours really ... this needs more functionality,
|
287
|
+
evidently! ;-)
|
288
|
+
|
289
|
+
Since as of **February 2021**, if you need to calculate
|
290
|
+
the molecular weight of a compound and want to use a
|
291
|
+
GUI, try:
|
292
|
+
|
293
|
+
require 'chemistry_paradise/gui/gtk3/calculate_molecular_weight/calculate_molecular_weight.rb'
|
294
|
+
|
295
|
+
ChemistryParadise::GUI::Gtk::CalculateMolecularWeight.run
|
296
|
+
|
297
|
+
This depends on the ruby-gtk3 bindings.
|
298
|
+
|
299
|
+
Or, from the commandline, try:
|
300
|
+
|
301
|
+
chemistry_paradise --gtk-calculate-molecular-weight
|
302
|
+
|
303
|
+
You can also view the periodic table via a ruby-gtk3 wrapper.
|
304
|
+
This currently (**May 2021**) looks like this:
|
305
|
+
|
306
|
+
<img src="https://i.imgur.com/kY95n2d.png">
|
307
|
+
|
308
|
+
The two lower entries can be used to calculate the atomic weight. The
|
309
|
+
example shows H2O aka water. Note that this has a few bugs here and
|
310
|
+
there - it's not quite polished. I only wanted to showcase the prototype
|
311
|
+
really.
|
312
|
+
|
313
|
+
In <b>August 2022</b> the <b>temperature calculator</b> has been
|
314
|
+
improved a bit in ruby-gtk3. It now looks like this:
|
315
|
+
|
316
|
+
<img src="https://i.imgur.com/1CeRd5z.png" style="margin: 1em">
|
317
|
+
|
318
|
+
Furthermore, if a number is inputted into the first entry then
|
319
|
+
the other entries are <b>automatically</b> calculated. A libui
|
320
|
+
variant was added as well, thus allowing you to use this on
|
321
|
+
windows more easily, and I also added a java-swing variant,
|
322
|
+
to make it even simpler on windows to work with it (even
|
323
|
+
if ruby is not available there).
|
324
|
+
|
325
|
+
## YAML files (.yml) distributed with this gem
|
326
|
+
|
327
|
+
This subsection will briefly mention the .yml files that
|
328
|
+
are currently (**May 2021**) part of this project.
|
329
|
+
|
330
|
+
**electron_negativity_chart.yml**: This file keeps track of
|
331
|
+
the "Pauling electronegativity scale". In theory this
|
332
|
+
could be used for distance-calculation as well, but
|
333
|
+
it really is just a simple (stupid) file that keeps
|
334
|
+
track of the old Pauling scores.
|
335
|
+
|
336
|
+
**atomgewichte.yml**: This file keeps track of the molecular
|
337
|
+
weight of the individual atoms. The name is still german;
|
338
|
+
not sure if I will change it to english, but for now
|
339
|
+
it'll remain in german, due to historic reasons mostly
|
340
|
+
(this project was started with german output on the
|
341
|
+
commandline, many years ago).
|
342
|
+
|
343
|
+
**colours_for_the_elements.yml**: Here you can specify
|
344
|
+
which colours to use for the ruby-gtk3 widget. This
|
345
|
+
is probably not very important for many people though.
|
346
|
+
|
347
|
+
**molecular_formula_of_different_molecules.yml**: This file
|
348
|
+
may be used to keep track of some common substances,
|
349
|
+
in regards to their formula. Note that not every
|
350
|
+
molecule can be found there, logically; it just showcases
|
351
|
+
a few examples and may then be re-used in different
|
352
|
+
parts, such as the GUI elements.
|
353
|
+
|
354
|
+
## Licence
|
355
|
+
|
356
|
+
Since as of **June 2021** the licence for the chemistry_paradise
|
357
|
+
project is now MIT. I encourage folks to contribute code or
|
358
|
+
documentation, but ultimately the project is mostly a "I needed
|
359
|
+
these things done, so I wrote the code, then I moved on to do
|
360
|
+
other things".
|
361
|
+
|
362
|
+
You can see the MIT licence here:
|
363
|
+
|
364
|
+
https://opensource.org/licenses/MIT
|
365
|
+
|
366
|
+
The individual .rb files that are part of the chemistry_paradise
|
367
|
+
project do not contain that licence header, simply because I can
|
368
|
+
not want to be bothered to read through legalese that doesn't add
|
369
|
+
anything to code or documentation - but if you ever need an "official"
|
370
|
+
licence, it is here stated that the project is now under the MIT
|
371
|
+
licence, and this is also specified in the .gemspec file that is
|
372
|
+
used to create this gem - see the .gem file that you can
|
373
|
+
download from **rubygems.org**.
|
374
|
+
|
375
|
+
## Todo list
|
376
|
+
|
377
|
+
This is just a generic todo list.
|
378
|
+
|
379
|
+
- Add sinatra-bindings so that the above can be used
|
380
|
+
on the www as well.
|
381
|
+
|
382
|
+
- Add fxruby and tk bindings as well.
|
383
|
+
|
384
|
+
- Extend the ruby-gtk3 widgets while retaining support
|
385
|
+
for ruby-gtk2.
|
386
|
+
|
387
|
+
## Calculating the atomic mass of an element
|
388
|
+
|
389
|
+
Let's take the example of the element <b>Mg</b>. It has different
|
390
|
+
isotopes:
|
391
|
+
|
392
|
+
²⁴Mg 78,99% 23,985
|
393
|
+
²⁵Mg 10,00% 24,985
|
394
|
+
²⁶Mg 11,01% 25,983
|
395
|
+
|
396
|
+
To calculate the atomic mass here use the following toplevel API:
|
397
|
+
|
398
|
+
ChemistryParadise.calculate_atomic_mass_based_on_isotope_percentage(78.99, 23.985, 10.00, 24.985, 11.01, 25.983)
|
399
|
+
|
400
|
+
It's a bit cumbersome API, but this is mostly owing to the fact
|
401
|
+
that I wanted to add this quickly, to solve an existing
|
402
|
+
problem.
|
403
|
+
|
404
|
+
## Sanitizing a chemical formula
|
405
|
+
|
406
|
+
Say that you have citrulline, an aminoacid, with the following
|
407
|
+
chemical formula:
|
408
|
+
|
409
|
+
C6H13N3O3
|
410
|
+
|
411
|
+
The more correct way to write this down is:
|
412
|
+
|
413
|
+
C₆H₁₃N₃O₃
|
414
|
+
|
415
|
+
So, simply use numbers via subscript.
|
416
|
+
|
417
|
+
There is a method that can help with this conversion, called
|
418
|
+
<b>ChemistryParadise.sanitize()</b>. This may not be extremely
|
419
|
+
useful, but is just a tiny helper method; may be interesting
|
420
|
+
to integrate it in a webpage or a GUI.
|
421
|
+
|
422
|
+
Usage example:
|
423
|
+
|
424
|
+
ChemistryParadise.sanitize('C6H13N3O3') # => "C₆H₁₃N₃O₃"
|
425
|
+
|
426
|
+
## The Wetter submodule
|
427
|
+
|
428
|
+
## Introduction
|
429
|
+
|
430
|
+
The name <b>wetter</b> is german for <b>weather</b>.
|
431
|
+
|
432
|
+
Code residing in the <b>module Wetter</b> namespace will
|
433
|
+
relate to the weather in general. For instance, calculating
|
434
|
+
pressure of air at a specific altitude. No such code has been
|
435
|
+
added for this yet, but it may happen in the future.
|
436
|
+
|
437
|
+
Until then, the Wetter submodule contains a bit of helper-code
|
438
|
+
for querying wetter-related information. In February 2023
|
439
|
+
functionality and code was also added to allow this to
|
440
|
+
happen when openssl is unavailable - in such an event
|
441
|
+
ruby's open-uri would normally not work and instead print
|
442
|
+
out a specific OpenSSL related error.
|
443
|
+
|
444
|
+
### The Sinatra interface of the Wetter module
|
445
|
+
|
446
|
+
To start the sinatra interface, do:
|
447
|
+
|
448
|
+
wetter --sinatra
|
449
|
+
|
450
|
+
### Graphical User Interface (GUI) of the Wetter module
|
451
|
+
|
452
|
+
To start the ruby-gtk3 wrapper, try:
|
453
|
+
|
454
|
+
wetter --gtk # ← This now defaults to ruby-gtk3
|
455
|
+
wetter --gtk3
|
456
|
+
|
457
|
+
Note that you have to have the two gems **gtk3** and **gtk_paradise**
|
458
|
+
installed in order for this to work. This is not terribly
|
459
|
+
useful anyway; it was mostly done just for quick demo purposes,
|
460
|
+
what is possible. Anyone wanting to improve on this is
|
461
|
+
welcome to give it a try. :)
|
462
|
+
|
463
|
+
As of **30.08.2021** (August 2021) a widget in libui also
|
464
|
+
exists now. This has the advantage that it works on
|
465
|
+
windows out of the box, if you did install the libui
|
466
|
+
gem on windows.
|
467
|
+
|
468
|
+
Commandline invocation goes via:
|
469
|
+
|
470
|
+
wetter --libui
|
471
|
+
|
472
|
+
Incomplete "unified widgets" bindings also exist; I may
|
473
|
+
eventually add support for ruby-tk, fxruby as well as
|
474
|
+
gosu - but we'll see.
|
475
|
+
|
476
|
+
The ruby-gtk3 wrapper looks like this on my system:
|
477
|
+
|
478
|
+
<img src="https://i.imgur.com/uZGAQrJ.png" style="margin: 1em">
|
479
|
+
|
480
|
+
This is not extremely pretty, but I wanted to keep it
|
481
|
+
simple; if others want modifications then drop me an
|
482
|
+
email. Otherwise I'll just keep it as it is for now.
|
483
|
+
|
484
|
+
### Fahrenheit to Celsius table as a reminder
|
485
|
+
|
486
|
+
32 °F 0 °C freezing/melting point of water
|
487
|
+
40 °F 4.44 °C
|
488
|
+
50 °F 10.00 °C
|
489
|
+
60 °F 15.56 °C
|
490
|
+
70 °F 21.11 °C room temperature
|
491
|
+
80 °F 26.67 °C
|
492
|
+
90 °F 32.22 °C
|
493
|
+
98.6 °F 37 °C average body temperature
|
494
|
+
100 °F 37.78 °C
|
495
|
+
110 °F 43.33 °C
|
496
|
+
120 °F 48.89 °C
|
497
|
+
130 °F 54.44 °C
|
498
|
+
140 °F 60.00 °C
|
499
|
+
150 °F 65.56 °C
|
500
|
+
160 °F 71.11 °C
|
501
|
+
170 °F 76.67 °C
|
502
|
+
180 °F 82.22 °C
|
503
|
+
190 °F 87.78 °C
|
504
|
+
200 °F 93.33 °C
|
505
|
+
|
506
|
+
### Deprecations of the Wetter submodule
|
507
|
+
|
508
|
+
In <b>November 2021</b> (02.11.2021) support for ruby-gtk2 was
|
509
|
+
removed as far as the **wetter** gem is concerned. I am
|
510
|
+
not completely abandoning ruby-gtk2 in general, but for
|
511
|
+
the small wetter app it is simply easier to use
|
512
|
+
ruby-gtk3 instead - and ruby-gtk3 looks better as well,
|
513
|
+
via CSS rules.
|
514
|
+
|
515
|
+
### Convenience methods for obtaining individual rows of the periodic table
|
516
|
+
|
517
|
+
The periodic table of elements has seven rows.
|
518
|
+
|
519
|
+
The first row has only two elements: <b>H</b> and <b>He</b>.
|
520
|
+
|
521
|
+
The second row has <b>Li</b>, <b>Be</b> and so forth.
|
522
|
+
|
523
|
+
In <b>April 2023</b> I noticed a small shell script that will print out
|
524
|
+
the periodic table on the commandline. The project can be found here:
|
525
|
+
|
526
|
+
https://github.com/monsieurmoneybags/periodic_table
|
527
|
+
|
528
|
+
The image it will yield on the commandline may look like this:
|
529
|
+
|
530
|
+
<img src="https://github.com/monsieurmoneybags/periodic_table/raw/main/periodic_table.png" style="margin: 1em">
|
531
|
+
|
532
|
+
I found this feature neat, so I wanted to add it to the chemistry_paradise
|
533
|
+
gem.
|
534
|
+
|
535
|
+
In order to do this, I decided to first add seven helper methods: one for
|
536
|
+
each row.
|
537
|
+
|
538
|
+
So, the following toplevel methods were added:
|
539
|
+
|
540
|
+
ChemistryParadise.row1
|
541
|
+
ChemistryParadise.period1 # simply an alias to the ^^^ above
|
542
|
+
ChemistryParadise.row2
|
543
|
+
ChemistryParadise.period2 # simply an alias to the ^^^ above
|
544
|
+
ChemistryParadise.row3
|
545
|
+
ChemistryParadise.period3 # simply an alias to the ^^^ above
|
546
|
+
ChemistryParadise.row4
|
547
|
+
ChemistryParadise.period4 # simply an alias to the ^^^ above
|
548
|
+
ChemistryParadise.row5
|
549
|
+
ChemistryParadise.period5 # simply an alias to the ^^^ above
|
550
|
+
ChemistryParadise.row6
|
551
|
+
ChemistryParadise.period6 # simply an alias to the ^^^ above
|
552
|
+
ChemistryParadise.row7
|
553
|
+
ChemistryParadise.period7 # simply an alias to the ^^^ above
|
554
|
+
|
555
|
+
These methods will return all elements in that given row.
|
556
|
+
|
557
|
+
For instance:
|
558
|
+
|
559
|
+
ChemistryParadise.row1 # => ["H", "He"]
|
560
|
+
|
561
|
+
Will return an Array showing <b>H</b> and He (Hydrogen and Helium).
|
562
|
+
|
563
|
+
Whereas:
|
564
|
+
|
565
|
+
ChemistryParadise.row2 # => ["Li", "Be", "B", "C", "N", "O", "F", "Ne"]
|
566
|
+
|
567
|
+
Would return the elements Li, Be, B and so forth.
|
568
|
+
|
569
|
+
This was a necessary first step, before adding support for
|
570
|
+
displaying the elements on the commandline.
|
571
|
+
|
572
|
+
See the next subsection for more information pertaining this feature.
|
573
|
+
|
574
|
+
### Showing the periodic table on the commandline
|
575
|
+
|
576
|
+
As mentioned elsewhere in this document, it is possible, since as of
|
577
|
+
April 2023, to quickly display the periodic table on the commandline.
|
578
|
+
|
579
|
+
This functionality was inspired by a shell script written by someone
|
580
|
+
else. class <b>ChemistryParadise::ShowPeriodicTable</b> handles
|
581
|
+
this step.
|
582
|
+
|
583
|
+
It looks like this:
|
584
|
+
|
585
|
+
<img src="https://i.imgur.com/3BF4AYj.png" style="margin: 1em">
|
586
|
+
|
587
|
+
Unfortunately it is also significantly longer in code than the
|
588
|
+
shell script. On the plus side, though, feature-wise, it is
|
589
|
+
trivial to change the colours, whereas the shell script
|
590
|
+
uses some hardcoded values as-is.
|
591
|
+
|
592
|
+
## Potential useful links related to chemistry
|
593
|
+
|
594
|
+
This is another good <b>ruby-library</b> for handling
|
595
|
+
chemistry-related aspects:
|
596
|
+
|
597
|
+
https://github.com/fogonthedowns/rubychem/
|
598
|
+
|
599
|
+
|
600
|
+
## Contact information and mandatory 2FA coming up in 2022
|
601
|
+
|
602
|
+
If your creative mind has ideas and specific suggestions to make this gem
|
603
|
+
more useful in general, feel free to drop me an email at any time, via:
|
604
|
+
|
605
|
+
shevy@inbox.lt
|
606
|
+
|
607
|
+
Before that email I used an email account at Google gmail, but in **2021** I
|
608
|
+
decided to slowly abandon gmail, for various reasons. In order to limit the
|
609
|
+
explanation here, allow me to just briefly state that I do not feel as if I
|
610
|
+
want to promote any Google service anymore when the user becomes the end
|
611
|
+
product (such as via data collection by upstream services, including other
|
612
|
+
proxy-services). My feeling is that this is a hugely flawed business model
|
613
|
+
to begin with, and I no longer wish to support this in any way, even if
|
614
|
+
only indirectly so, such as by using services of companies that try to
|
615
|
+
promote this flawed model.
|
616
|
+
|
617
|
+
In regards to responding to emails: please keep in mind that responding
|
618
|
+
may take some time, depending on the amount of work I may have at that
|
619
|
+
moment. So it is not that emails are ignored; it is more that I have not
|
620
|
+
(yet) found the time to read and reply. This means there may be a delay
|
621
|
+
of days, weeks and in some instances also months. There is, unfortunately,
|
622
|
+
not much I can do when I need to prioritise my time investment, but I try
|
623
|
+
to consider <b>all</b> feedback as an opportunity to improve my projects
|
624
|
+
nonetheless.
|
625
|
+
|
626
|
+
In <b>2022</b> rubygems.org decided to make 2FA mandatory for every
|
627
|
+
gem owner eventually:
|
628
|
+
|
629
|
+
see
|
630
|
+
https://blog.rubygems.org/2022/06/13/making-packages-more-secure.html
|
631
|
+
|
632
|
+
Mandatory 2FA will eventually be extended to all rubygems.org developers and
|
633
|
+
maintainers. As I can not use 2FA, for reasons I will skip explaining here,
|
634
|
+
this means that my projects will eventually be removed, as I no longer
|
635
|
+
have any control over my projects hosted on rubygems.org (because I
|
636
|
+
can not use 2FA).
|
637
|
+
|
638
|
+
At that point, I no longer have any control what is done to my projects
|
639
|
+
since whoever is controlling the gems ecosystem took away our control
|
640
|
+
here. I am not sure at which point ruby became corporate-controlled -
|
641
|
+
that was not the case several years ago, so something has
|
642
|
+
changed.
|
643
|
+
|
644
|
+
Ruby also only allows 2FA users to participate on the issue tracker these
|
645
|
+
days:
|
646
|
+
|
647
|
+
https://bugs.ruby-lang.org/issues/18800
|
648
|
+
|
649
|
+
But this has been reverted some months ago, so it is no longer applicable.
|
650
|
+
Suffice to say that I do not think that we should only be allowed to
|
651
|
+
interact on the world wide web when some 'authority' authenticated us,
|
652
|
+
such as via mandatory 2FA, so I hope this won't come back again.
|
653
|
+
|
654
|
+
Fighting spam is a noble goal, but when it also means you lock out
|
655
|
+
real human people then this is definitely NOT a good situation
|
656
|
+
to be had.
|
657
|
+
|