chemistry_paradise 1.1.26
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 +419 -0
- data/bin/chemistry_paradise +7 -0
- data/chemistry_paradise.gemspec +46 -0
- data/doc/BUGS.md +16 -0
- data/doc/README.gen +391 -0
- data/doc/todo/TODO.md +26 -0
- data/lib/chemistry_paradise/base/base.rb +101 -0
- data/lib/chemistry_paradise/base/colours.rb +65 -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 +52 -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/fahrenheit_to_celsius.rb +132 -0
- data/lib/chemistry_paradise/converters/shared.rb +15 -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 +249 -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/images/show_periodic_table.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 +19 -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/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 +128 -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/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/www/chemistry/chemistry.cgi +7 -0
- data/lib/chemistry_paradise/www/chemistry/chemistry.rb +1526 -0
- data/lib/chemistry_paradise/www/chemistry/chemistry.sinatra +56 -0
- data/lib/chemistry_paradise/www/organic_chemistry/organic_chemistry.md +16 -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 +155 -0
data/doc/README.gen
ADDED
@@ -0,0 +1,391 @@
|
|
1
|
+
ADD_RUBY_BADGES
|
2
|
+
ADD_LAST_UPDATE
|
3
|
+
|
4
|
+
## Introduction
|
5
|
+
|
6
|
+
This project bundles together some commonly used methods and classes
|
7
|
+
related to **chemistry**.
|
8
|
+
|
9
|
+
Use cases may include when you want to quickly know the molecular
|
10
|
+
weight of a compound (via the commandline) or when you want to
|
11
|
+
want to perform a simple **combustion analysis**, so mostly
|
12
|
+
homework, school, college or simple university-related use cases.
|
13
|
+
|
14
|
+
Please keep in mind that this is just a hobby project. It will
|
15
|
+
never compete with professional or commercial-grade projects,
|
16
|
+
simply because that is not its main use case or goal. It's also
|
17
|
+
not my primary project related to science - I am more of a molecular
|
18
|
+
biology person, so the code in this project is mostly just
|
19
|
+
"helper"-related code. Perhaps you may find some interesting
|
20
|
+
ideas in the long run, though, and other chemistry-related
|
21
|
+
projects in ruby could benefit from it. See also <b>sciruby</b>.
|
22
|
+
|
23
|
+
For more information, have a look at the other documentation
|
24
|
+
in this file (respectively at
|
25
|
+
https://www.rubydoc.info/gems/chemistry_paradise/
|
26
|
+
).
|
27
|
+
|
28
|
+
## The individual classes in this project
|
29
|
+
|
30
|
+
The individual classes of this project may have their own
|
31
|
+
subsection here, starting with class **CalculateAtomicMass**,
|
32
|
+
which was one of the first classes originally written - I
|
33
|
+
had to calculate the mass of compounds via a pocket
|
34
|
+
calculator. Since I kept doing mistakes doing so, I decided
|
35
|
+
to write some code that will show whether I calculated
|
36
|
+
correctly.
|
37
|
+
|
38
|
+
## class ChemistryParadise::CalculateAtomicMass
|
39
|
+
|
40
|
+
class ChemistryParadise::CalculateAtomicMass will calculate the
|
41
|
+
mass of compounds.
|
42
|
+
|
43
|
+
Argument to this class should be something such as
|
44
|
+
<b>C16H12N2</b>, but you can also use Unicode numbers
|
45
|
+
such as ₃ rather than 3.
|
46
|
+
|
47
|
+
So the following shows valid arguments to the class:
|
48
|
+
|
49
|
+
ChemistryParadise::CalculateAtomicMass.new('C16H12N2')
|
50
|
+
ChemistryParadise::CalculateAtomicMass.new('CH3Cl')
|
51
|
+
ChemistryParadise::CalculateAtomicMass.new('CH₃Cl') # ← This variant also works since as of December 2019.
|
52
|
+
ChemistryParadise::CalculateAtomicMass.new('CO₂') # ← As does this, too, since as of December 2019.
|
53
|
+
|
54
|
+
If you need **english output**, look at the entry default language
|
55
|
+
to use within the project, in this file.
|
56
|
+
|
57
|
+
- **ChemistryParadise::Orbitals** will simply show how many
|
58
|
+
electrons fit into an orbital.
|
59
|
+
|
60
|
+
- The class **ChemistryParadise::ShowElectronConfiguration**
|
61
|
+
will report the electron configuration for the given element.
|
62
|
+
|
63
|
+
For example, if you pass 'Fe' as element (iron), then the
|
64
|
+
class will report something like this:
|
65
|
+
|
66
|
+
Found element Fe. It has 26 electrons.
|
67
|
+
[Ar] 4s2 3d6
|
68
|
+
|
69
|
+
Specific example in pure ruby:
|
70
|
+
|
71
|
+
require 'chemistry_paradise'
|
72
|
+
ChemistryParadise::ShowElectronConfiguration.new('Fe')
|
73
|
+
|
74
|
+
Note that this may not work as well for heavy atoms, but for
|
75
|
+
the more common ~smaller atoms, it should work fine.
|
76
|
+
|
77
|
+
Do note that since as of March 2020 a few chemical substances
|
78
|
+
can be quickly queried by their trivial name, including a
|
79
|
+
few german names.
|
80
|
+
|
81
|
+
Example:
|
82
|
+
|
83
|
+
molmasse harnstoff
|
84
|
+
|
85
|
+
This would be the very same as:
|
86
|
+
|
87
|
+
molmasse CH₄N₂O
|
88
|
+
molmasse CH4N2O
|
89
|
+
|
90
|
+
To output this in english, try:
|
91
|
+
|
92
|
+
molmasse "(NH₄)₂SO₄" --english
|
93
|
+
|
94
|
+
So basically use the **--english** commandline flag.
|
95
|
+
|
96
|
+
## Default language to use within the project
|
97
|
+
|
98
|
+
The project initially showed output mostly in the german language.
|
99
|
+
|
100
|
+
However had - most people may prefer the english language, so a
|
101
|
+
switch exists that allows you to toggle the behaviour of the
|
102
|
+
ChemistryParadise project, in regards to the language at hand.
|
103
|
+
|
104
|
+
If you wish to **use the english language**, you can use the following
|
105
|
+
method call:
|
106
|
+
|
107
|
+
ChemistryParadise.do_use_english
|
108
|
+
|
109
|
+
Also, the Base class allows one to switch between the english
|
110
|
+
and the german language.
|
111
|
+
|
112
|
+
Either way, past this point, if you invoke **class CalculateAtomicMass**,
|
113
|
+
it will then report the result in english. Internally the
|
114
|
+
module-method instance variable called <b>@language</b> will
|
115
|
+
keep track of the language at hand.
|
116
|
+
|
117
|
+
See also the test/ subdirectory to look at this in action.
|
118
|
+
|
119
|
+
## German names of atoms/elements
|
120
|
+
|
121
|
+
In the german language, we can find names such as <b>Quecksilber</b>
|
122
|
+
for the element <b>Hg</b> (mercury, aka <b>hydrargyrum</b>).
|
123
|
+
|
124
|
+
The file <b>german_names_of_elements_to_element_symbol.rb</b>
|
125
|
+
handles this conversion, but you can also query the translated
|
126
|
+
symbol-name from the commandliny, by using a pseudo-regex such
|
127
|
+
as:
|
128
|
+
|
129
|
+
chemistry_paradise /Quecksilber/
|
130
|
+
|
131
|
+
So in other words, the german name of the element at hand is
|
132
|
+
to be put between the two **/** characters.
|
133
|
+
|
134
|
+
The default pseudo-regex may change one day, in which case
|
135
|
+
the change would be properly documented here as well.
|
136
|
+
|
137
|
+
## class ChemistryParadise::ShowElectronNegativityOfThisElement
|
138
|
+
|
139
|
+
<b>class ChemistryParadise::ShowElectronNegativityOfThisElement</b>
|
140
|
+
can be used to show, on the commandline, the **electronegativity**
|
141
|
+
of the given elements.
|
142
|
+
|
143
|
+
So for example, if you'd want to know to know the electron negativity
|
144
|
+
of Fluor and Iron, you'd pass in this:
|
145
|
+
|
146
|
+
ChemistryParadise::ShowElectronNegativityOfThisElement.new(['F','Fe'])
|
147
|
+
|
148
|
+
From the commandline, if you aliased towards the .rb file, simply pass
|
149
|
+
in F and Fe, without any ' quotes.
|
150
|
+
|
151
|
+
If you want another accessor, also from the commandline, then do:
|
152
|
+
|
153
|
+
chemistry_paradise --electronegativity-of=F/Fe
|
154
|
+
|
155
|
+
In that case, <b>/</b> acts as the separator between several elements.
|
156
|
+
|
157
|
+
<b>Always input the element symbol, NOT the long name of the
|
158
|
+
element.</b>
|
159
|
+
|
160
|
+
See **wikipedia** for a complete list of elements.
|
161
|
+
|
162
|
+
If you intent to use this part of the chemistry_paradise project
|
163
|
+
to predict whether two elements form an ionic bond, as a rule of
|
164
|
+
thumb, the difference should be at the very least <b>1.5</b> between
|
165
|
+
the two elements; ideally <b>1.8</b>. Past that point it can
|
166
|
+
be concluded, that two different elements with such a large
|
167
|
+
discrepancy in their electron negativity values, would form
|
168
|
+
<b>ionic bonds</b> (if they would bind to one another in the
|
169
|
+
first place, that is).
|
170
|
+
|
171
|
+
## Showing the individual steps
|
172
|
+
|
173
|
+
If you wish to display the molecular mass of some compound, on
|
174
|
+
the commandline, and would also like to display the individual
|
175
|
+
steps done, you can use the following commandline flag:
|
176
|
+
|
177
|
+
mmasse CaCO3 --show-steps
|
178
|
+
|
179
|
+
Note that this will probably be extended in the future, so
|
180
|
+
that this also works a bit like a **debug-flag**. The idea
|
181
|
+
here is to be able to verify what is going on in a simple
|
182
|
+
manner, rather than to merely rely on the output **assumed**
|
183
|
+
to be correct.
|
184
|
+
|
185
|
+
## class ChemistryParadise::CombustionAnalysis
|
186
|
+
|
187
|
+
**class ChemistryParadise::CombustionAnalysis** can be used
|
188
|
+
to analyse the combustion of a compound.
|
189
|
+
|
190
|
+
Say that you know these values:
|
191
|
+
|
192
|
+
K 28,93%
|
193
|
+
S 23,72%
|
194
|
+
O 47.35%
|
195
|
+
|
196
|
+
K means Kalium aka Sodium (correction in November 2020: Sodium
|
197
|
+
is, of course, Na aka Natrium; not sure why the german name
|
198
|
+
matches, whereas the english one does not, but evidently I
|
199
|
+
made the mistake in assuming that Kalium would be Sodium,
|
200
|
+
which was **evidently** incorrect).
|
201
|
+
|
202
|
+
Note that 28,93% refers to 28.93% of **100%**
|
203
|
+
of the given substance is stored in Kalium.
|
204
|
+
|
205
|
+
Next, we invoke the class from the commandline; I aliased
|
206
|
+
it to **combustionanalysis**.
|
207
|
+
|
208
|
+
combustionanalysis "K 28,93% S 23,72% O 47.35%"
|
209
|
+
|
210
|
+
The output will be:
|
211
|
+
|
212
|
+
**KSO₄**
|
213
|
+
|
214
|
+
combustionanalysis "Al 15,77% O 56,12% S 28,11%" # => Al₂O12S₃
|
215
|
+
|
216
|
+
Note that this may have a few bugs left, for larger compounds
|
217
|
+
or any combustion analysis that is not very correct. But for
|
218
|
+
simple compounds, such as the examples shown above, it should
|
219
|
+
work very well.
|
220
|
+
|
221
|
+
You can use this from ruby code via:
|
222
|
+
|
223
|
+
require 'chemistry_paradise/combustion_analysis.rb'
|
224
|
+
ChemistryParadise::CombustionAnalysis.new(ARGV)
|
225
|
+
|
226
|
+
# To use the example above:
|
227
|
+
ChemistryParadise::CombustionAnalysis.new('Al 15,77% O 56,12% S 28,11%') # => Al₂O₁₂S₃
|
228
|
+
|
229
|
+
## Disclaimer
|
230
|
+
|
231
|
+
Keep in mind that this is merely **a hobby project**, not a
|
232
|
+
"fully fledged professional" suite of code.
|
233
|
+
|
234
|
+
I use it primarily to help me in little things, such as **querying
|
235
|
+
the electron configuration of an atom on the commandline**, or
|
236
|
+
**calculating the molar mass of a compound**. I could do the latter
|
237
|
+
manually, but computers are a lot faster and a lot less work
|
238
|
+
than manual calculations - and more reliable, too. I tend to
|
239
|
+
do errors when typing anything into a calculator.
|
240
|
+
|
241
|
+
As this is not professional chemistry-software, please do not
|
242
|
+
expect that this project could ever really help calculating
|
243
|
+
the **Schroedinger equation** or anything similar to that.
|
244
|
+
|
245
|
+
## Www-related documentation in german and english
|
246
|
+
|
247
|
+
Since as of **January 2021** I have decided to slowly put my
|
248
|
+
local knowledge base about chemistry online. These were
|
249
|
+
mostly stored in .cgi files. I may put them into sinatra
|
250
|
+
as interface eventually; we'll see. Anyway, this is a
|
251
|
+
low priority, ongoing effort, and the german parts will
|
252
|
+
not be too useful for other people - but still, I wanted
|
253
|
+
to publish it, simply because it seems to be more useful
|
254
|
+
when available in combination with ruby code as well..
|
255
|
+
|
256
|
+
Since as of May 2021 there is also a tiny sinatra API
|
257
|
+
available.
|
258
|
+
|
259
|
+
For example, if you start sinatra.rb, and then visit a page
|
260
|
+
such as:
|
261
|
+
|
262
|
+
http://localhost:4567/compound/H2SO4
|
263
|
+
|
264
|
+
The atomic mass of H2SO4 will be calculated and then
|
265
|
+
shown via that web-interface.
|
266
|
+
|
267
|
+
## GUI
|
268
|
+
|
269
|
+
I may in the long run add GUIs similar to this one here:
|
270
|
+
|
271
|
+
http://www.gamgi.org/images/screenshot13_5b.png
|
272
|
+
|
273
|
+
But this is a hobby project, so don't expect too much
|
274
|
+
work going into it. See the image below for how that GUI part
|
275
|
+
currently looks like, in regards to the chemistry_paradise
|
276
|
+
project. This depends on the ruby-gtk3 bindings. Once you
|
277
|
+
have the necessary C-files (glib, atk, pango, cairo, gtk),
|
278
|
+
doing "**gem install gtk3**" should work just fine. On
|
279
|
+
windows this is a bit more tedious though.
|
280
|
+
|
281
|
+
For now have a look at the **gtk3/** subdirectory in this
|
282
|
+
gem. But there isn't that much there. Just buttons with
|
283
|
+
different colours really ... this needs more functionality,
|
284
|
+
evidently! ;-)
|
285
|
+
|
286
|
+
Since as of **February 2021**, if you need to calculate
|
287
|
+
the molecular weight of a compound and want to use a
|
288
|
+
GUI, try:
|
289
|
+
|
290
|
+
require 'chemistry_paradise/gui/gtk3/calculate_molecular_weight/calculate_molecular_weight.rb'
|
291
|
+
|
292
|
+
ChemistryParadise::GUI::Gtk::CalculateMolecularWeight.run
|
293
|
+
|
294
|
+
This depends on the ruby-gtk3 bindings.
|
295
|
+
|
296
|
+
Or, from the commandline, try:
|
297
|
+
|
298
|
+
chemistry_paradise --gtk-calculate-molecular-weight
|
299
|
+
|
300
|
+
You can also view the periodic table via a ruby-gtk3 wrapper.
|
301
|
+
This currently (**May 2021**) looks like this:
|
302
|
+
|
303
|
+
<img src="https://i.imgur.com/kY95n2d.png">
|
304
|
+
|
305
|
+
The two lower entries can be used to calculate the atomic weight. The
|
306
|
+
example shows H2O aka water. Note that this has a few bugs here and
|
307
|
+
there - it's not quite polished. I only wanted to showcase the prototype
|
308
|
+
really.
|
309
|
+
|
310
|
+
## YAML files (.yml) distributed with this gem
|
311
|
+
|
312
|
+
This subsection will briefly mention the .yml files that
|
313
|
+
are currently (**May 2021**) part of this project.
|
314
|
+
|
315
|
+
**electron_negativity_chart.yml**: This file keeps track of
|
316
|
+
the "Pauling electronegativity scale". In theory this
|
317
|
+
could be used for distance-calculation as well, but
|
318
|
+
it really is just a simple (stupid) file that keeps
|
319
|
+
track of the old Pauling scores.
|
320
|
+
|
321
|
+
**atomgewichte.yml**: This file keeps track of the molecular
|
322
|
+
weight of the individual atoms. The name is still german;
|
323
|
+
not sure if I will change it to english, but for now
|
324
|
+
it'll remain in german, due to historic reasons mostly
|
325
|
+
(this project was started with german output on the
|
326
|
+
commandline, many years ago).
|
327
|
+
|
328
|
+
**colours_for_the_elements.yml**: Here you can specify
|
329
|
+
which colours to use for the ruby-gtk3 widget. This
|
330
|
+
is probably not very important for many people though.
|
331
|
+
|
332
|
+
**molecular_formula_of_different_molecules.yml**: This file
|
333
|
+
may be used to keep track of some common substances,
|
334
|
+
in regards to their formula. Note that not every
|
335
|
+
molecule can be found there, logically; it just showcases
|
336
|
+
a few examples and may then be re-used in different
|
337
|
+
parts, such as the GUI elements.
|
338
|
+
|
339
|
+
## Licence:
|
340
|
+
|
341
|
+
Since as of **June 2021** the licence is now MIT. I encourage folks
|
342
|
+
to contribute code or documentation, but ultimately the project
|
343
|
+
is mostly a "I needed these things done, so I wrote the code,
|
344
|
+
then I moved on to do other things".
|
345
|
+
|
346
|
+
You can see the MIT licence here:
|
347
|
+
|
348
|
+
https://opensource.org/licenses/MIT
|
349
|
+
|
350
|
+
The individual .rb files do not contain that licence header,
|
351
|
+
simply because I can not want to be bothered to read through
|
352
|
+
legalese that doesn't add anything to code or documentation -
|
353
|
+
but if you ever need an "official" licence, it is here stated
|
354
|
+
that the project is now under the MIT licence, and this is
|
355
|
+
also specified in the .gemspec file that is used to create
|
356
|
+
this project - see the .gem file that you can download
|
357
|
+
from **rubygems.org**.
|
358
|
+
|
359
|
+
## Todo list:
|
360
|
+
|
361
|
+
This is just a generic todo list.
|
362
|
+
|
363
|
+
- Add sinatra-bindings so that the above can be used
|
364
|
+
on the www as well.
|
365
|
+
|
366
|
+
- Add fxruby and tk bindings as well.
|
367
|
+
|
368
|
+
- Extend the ruby-gtk3 widgets while retaining support
|
369
|
+
for ruby-gtk2.
|
370
|
+
|
371
|
+
## Calculating the atomic mass of an element
|
372
|
+
|
373
|
+
Let's take the example of the element <b>Mg</b>. It has different
|
374
|
+
isotopes:
|
375
|
+
|
376
|
+
²⁴Mg 78,99% 23,985
|
377
|
+
²⁵Mg 10,00% 24,985
|
378
|
+
²⁶Mg 11,01% 25,983
|
379
|
+
|
380
|
+
To calculate the atomic mass here use the following toplevel API:
|
381
|
+
|
382
|
+
ChemistryParadise.calculate_atomic_mass_based_on_isotope_percentage(78.99, 23.985, 10.00, 24.985, 11.01, 25.983)
|
383
|
+
|
384
|
+
## Potential useful links related to chemistry
|
385
|
+
|
386
|
+
This is another good ruby-library for handling
|
387
|
+
chemistry-related aspects:
|
388
|
+
|
389
|
+
https://github.com/fogonthedowns/rubychem/
|
390
|
+
|
391
|
+
ADD_CONTACT_INFORMATION
|
data/doc/todo/TODO.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
- 1.32 * (10 ** -3) # => 0.00132
|
2
|
+
x = 0.00132 # => 0.00132
|
3
|
+
log x # => -2.87942606879415
|
4
|
+
-(log x)
|
5
|
+
# => 2.87942606879415
|
6
|
+
|
7
|
+
^^^ chemparadise sollte diese steps angeben.
|
8
|
+
|
9
|
+
|
10
|
+
- we should ahve an interactive periodensystem
|
11
|
+
that tells us which periods we have. not sure
|
12
|
+
if this shall be integrated into the shell
|
13
|
+
or be separate.
|
14
|
+
|
15
|
+
- add sinatra parts at the least for calculating
|
16
|
+
the weight of the compoudd directly.
|
17
|
+
|
18
|
+
(4) In the ruby-gtk3, add a small number on the bottom
|
19
|
+
left area, to indicate the atomic number of that
|
20
|
+
element at hand. This should be subscript or so,
|
21
|
+
perhaps via pango? hmm.
|
22
|
+
|
23
|
+
(5) Integrate:
|
24
|
+
|
25
|
+
https://github.com/fogonthedowns/rubychem/
|
26
|
+
|
@@ -0,0 +1,101 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'chemistry_paradise/base/base.rb'; < ::ChemistryParadise::Base
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'chemistry_paradise/toplevel_methods/language.rb'
|
8
|
+
require 'chemistry_paradise/shared.rb'
|
9
|
+
require 'chemistry_paradise/constants/german_names_of_elements_to_element_symbol.rb'
|
10
|
+
require 'chemistry_paradise/base/colours.rb'
|
11
|
+
|
12
|
+
module ChemistryParadise
|
13
|
+
|
14
|
+
class Base # === ChemistryParadise::Base
|
15
|
+
|
16
|
+
include ChemistryParadise::Constants
|
17
|
+
include ChemistryParadise::Shared
|
18
|
+
|
19
|
+
alias ee print
|
20
|
+
|
21
|
+
# ========================================================================= #
|
22
|
+
# === NAMESPACE
|
23
|
+
# ========================================================================= #
|
24
|
+
NAMESPACE = inspect
|
25
|
+
|
26
|
+
# ========================================================================= #
|
27
|
+
# === FILE_MOLECULAR_FORMULA_OF_DIFFERENT_MOLECULES
|
28
|
+
# ========================================================================= #
|
29
|
+
FILE_MOLECULAR_FORMULA_OF_DIFFERENT_MOLECULES =
|
30
|
+
"#{PROJECT_BASE_DIRECTORY}yaml/molecular_formula_of_different_molecules.yml"
|
31
|
+
|
32
|
+
# ========================================================================= #
|
33
|
+
# === reset
|
34
|
+
# ========================================================================= #
|
35
|
+
def reset
|
36
|
+
end
|
37
|
+
|
38
|
+
# ========================================================================= #
|
39
|
+
# === opnn
|
40
|
+
# ========================================================================= #
|
41
|
+
def opnn(i)
|
42
|
+
if i.is_a? String
|
43
|
+
i = { namespace: i }
|
44
|
+
end
|
45
|
+
Opn.opn(i) # Delegate to module Opn here.
|
46
|
+
end
|
47
|
+
|
48
|
+
# ========================================================================= #
|
49
|
+
# === use_which_language?
|
50
|
+
# ========================================================================= #
|
51
|
+
def use_which_language?
|
52
|
+
::ChemistryParadise.use_which_language?
|
53
|
+
end
|
54
|
+
|
55
|
+
# ========================================================================= #
|
56
|
+
# === do_we_use_english?
|
57
|
+
#
|
58
|
+
# Query method to determine whether we will use english or whether
|
59
|
+
# we will use another language, for a project-wide setting.
|
60
|
+
# ========================================================================= #
|
61
|
+
def do_we_use_english?
|
62
|
+
(use_which_language? == :english)
|
63
|
+
end
|
64
|
+
|
65
|
+
# ========================================================================= #
|
66
|
+
# === set_commandline_arguments
|
67
|
+
# ========================================================================= #
|
68
|
+
def set_commandline_arguments(i = '')
|
69
|
+
i = [i].flatten.compact
|
70
|
+
@commandline_arguments = i
|
71
|
+
end
|
72
|
+
|
73
|
+
# ========================================================================= #
|
74
|
+
# === commandline_arguments?
|
75
|
+
# ========================================================================= #
|
76
|
+
def commandline_arguments?
|
77
|
+
@commandline_arguments
|
78
|
+
end
|
79
|
+
|
80
|
+
# ========================================================================= #
|
81
|
+
# === first_argument?
|
82
|
+
# ========================================================================= #
|
83
|
+
def first_argument?
|
84
|
+
@commandline_arguments.first
|
85
|
+
end; alias first? first_argument? # === first?
|
86
|
+
|
87
|
+
# ========================================================================= #
|
88
|
+
# === do_use_the_german_language
|
89
|
+
# ========================================================================= #
|
90
|
+
def do_use_the_german_language
|
91
|
+
::ChemistryParadise.do_use_german
|
92
|
+
end
|
93
|
+
|
94
|
+
# ========================================================================= #
|
95
|
+
# === do_use_the_english_language
|
96
|
+
# ========================================================================= #
|
97
|
+
def do_use_the_english_language
|
98
|
+
::ChemistryParadise.do_use_english
|
99
|
+
end
|
100
|
+
|
101
|
+
end; end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'chemistry_paradise/base/colours.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module ChemistryParadise
|
8
|
+
|
9
|
+
class Base # === ChemistryParadise::Base
|
10
|
+
|
11
|
+
begin
|
12
|
+
require 'colours'
|
13
|
+
include Colours
|
14
|
+
rescue LoadError; end
|
15
|
+
|
16
|
+
# ========================================================================= #
|
17
|
+
# === rev
|
18
|
+
# ========================================================================= #
|
19
|
+
def rev
|
20
|
+
::Colours.rev
|
21
|
+
end
|
22
|
+
|
23
|
+
# ========================================================================= #
|
24
|
+
# === grey
|
25
|
+
# ========================================================================= #
|
26
|
+
def grey(i)
|
27
|
+
"#{Colours::GREY}#{i}#{Colours}#{rev}"
|
28
|
+
end
|
29
|
+
|
30
|
+
# ========================================================================= #
|
31
|
+
# === royalblue
|
32
|
+
# ========================================================================= #
|
33
|
+
def royalblue(i)
|
34
|
+
::Colours.royalblue(i)
|
35
|
+
end
|
36
|
+
|
37
|
+
# ========================================================================= #
|
38
|
+
# === steelblue
|
39
|
+
# ========================================================================= #
|
40
|
+
def steelblue(i)
|
41
|
+
::Colours.steelblue(i)
|
42
|
+
end
|
43
|
+
|
44
|
+
# ========================================================================= #
|
45
|
+
# === yellow
|
46
|
+
# ========================================================================= #
|
47
|
+
def yellow(i)
|
48
|
+
::Colours.yellow(i)
|
49
|
+
end
|
50
|
+
|
51
|
+
# ========================================================================= #
|
52
|
+
# === teal
|
53
|
+
# ========================================================================= #
|
54
|
+
def teal(i)
|
55
|
+
Colours.teal(i)
|
56
|
+
end
|
57
|
+
|
58
|
+
# ========================================================================= #
|
59
|
+
# === sfancy
|
60
|
+
# ========================================================================= #
|
61
|
+
def sfancy(i)
|
62
|
+
::Colours.sfancy(i)
|
63
|
+
end
|
64
|
+
|
65
|
+
end; end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'chemistry_paradise/commandline/help.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module ChemistryParadise
|
8
|
+
|
9
|
+
class ParseCommandline < ::ChemistryParadise::Base
|
10
|
+
|
11
|
+
# ========================================================================= #
|
12
|
+
# === show_help
|
13
|
+
#
|
14
|
+
# The help options can be queried via:
|
15
|
+
#
|
16
|
+
# chemistry_paradise --help
|
17
|
+
#
|
18
|
+
# ========================================================================= #
|
19
|
+
def show_help
|
20
|
+
e 'The following options are documented:'
|
21
|
+
e
|
22
|
+
e ' --molmassen? # show '\
|
23
|
+
'where the molmasses are kept (a file)'
|
24
|
+
e ' --electronegativity-of=F/Fe # report '\
|
25
|
+
'the electronegativitiy of the elements F '\
|
26
|
+
'and Fe (Fluor and Iron)'
|
27
|
+
e ' --show_electron_negativity_chart # show '\
|
28
|
+
'the electron negativity chart of the atoms'
|
29
|
+
e ' --gtk-calculate-molecular-weight # to start '\
|
30
|
+
'the ruby-gtk3 wrapper for calculating the '\
|
31
|
+
'weight of compounds'
|
32
|
+
e ' /Quecksilber/ # use '\
|
33
|
+
'a pseudo-regex to obtain the element-symbol '\
|
34
|
+
'from a german name'
|
35
|
+
e ' ^^^ the above // is called a pseudo-regex; pseudo '\
|
36
|
+
'because it is actually a String and not a regex'
|
37
|
+
e
|
38
|
+
end
|
39
|
+
|
40
|
+
end; end
|