chemistry_paradise 1.3.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of chemistry_paradise might be problematic. Click here for more details.

Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +522 -0
  3. data/bin/chemistry_paradise +7 -0
  4. data/bin/wetter +7 -0
  5. data/chemistry_paradise.gemspec +46 -0
  6. data/doc/README.gen +518 -0
  7. data/doc/bugs/BUGS.md +16 -0
  8. data/doc/formulas/biochemical_calculations.md +5 -0
  9. data/doc/todo/todo_for_the_chemistry_paradise_project.md +33 -0
  10. data/doc/todo/todo_for_the_wetter_project.md +7 -0
  11. data/lib/chemistry_paradise/base/base.rb +215 -0
  12. data/lib/chemistry_paradise/base/colours.rb +93 -0
  13. data/lib/chemistry_paradise/commandline/help.rb +40 -0
  14. data/lib/chemistry_paradise/commandline/menu.rb +88 -0
  15. data/lib/chemistry_paradise/commandline/parse_commandline.rb +94 -0
  16. data/lib/chemistry_paradise/constants/constants.rb +77 -0
  17. data/lib/chemistry_paradise/constants/file_constants.rb +33 -0
  18. data/lib/chemistry_paradise/constants/german_names_of_elements_to_element_symbol.rb +157 -0
  19. data/lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb +143 -0
  20. data/lib/chemistry_paradise/converters/celsius_to_kelvin.rb +125 -0
  21. data/lib/chemistry_paradise/converters/fahrenheit_to_celsius.rb +132 -0
  22. data/lib/chemistry_paradise/converters/shared.rb +21 -0
  23. data/lib/chemistry_paradise/gui/gtk3/calculate_molecular_weight/calculate_molecular_weight.rb +34 -0
  24. data/lib/chemistry_paradise/gui/gtk3/show_periodic_table/show_periodic_table.rb +34 -0
  25. data/lib/chemistry_paradise/gui/gtk3/temperature_converter/temperature_converter.rb +112 -0
  26. data/lib/chemistry_paradise/gui/gtk3/wetter/wetter.rb +119 -0
  27. data/lib/chemistry_paradise/gui/libui/temperature_converter/temperature_converter.rb +100 -0
  28. data/lib/chemistry_paradise/gui/libui/wetter/wetter.rb +47 -0
  29. data/lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb +171 -0
  30. data/lib/chemistry_paradise/gui/shared_code/show_periodic_table/show_periodic_table_module.rb +318 -0
  31. data/lib/chemistry_paradise/gui/shared_code/temperature_converter/temperature_converter_module.rb +192 -0
  32. data/lib/chemistry_paradise/gui/shared_code/wetter/wetter_module.rb +349 -0
  33. data/lib/chemistry_paradise/gui/swing/TemperatureConverter$1.class +0 -0
  34. data/lib/chemistry_paradise/gui/swing/TemperatureConverter.class +0 -0
  35. data/lib/chemistry_paradise/gui/swing/TemperatureConverter.java +133 -0
  36. data/lib/chemistry_paradise/gui/unified_widgets/wetter/wetter.rb +62 -0
  37. data/lib/chemistry_paradise/images/show_periodic_table.png +0 -0
  38. data/lib/chemistry_paradise/images/vienna_map.png +0 -0
  39. data/lib/chemistry_paradise/interactive_chemistry_shell.rb +246 -0
  40. data/lib/chemistry_paradise/project/project.rb +24 -0
  41. data/lib/chemistry_paradise/requires/common_external_requires.rb +17 -0
  42. data/lib/chemistry_paradise/requires/require_the_project.rb +21 -0
  43. data/lib/chemistry_paradise/requires/require_the_project_including_the_graphical_user_interface.rb +7 -0
  44. data/lib/chemistry_paradise/requires/require_the_project_including_the_web_interface.rb +4 -0
  45. data/lib/chemistry_paradise/shared.rb +130 -0
  46. data/lib/chemistry_paradise/show_electron_configuration.rb +250 -0
  47. data/lib/chemistry_paradise/show_element.rb +145 -0
  48. data/lib/chemistry_paradise/sinatra/sinatra.rb +131 -0
  49. data/lib/chemistry_paradise/sinatra/wetter/app.rb +68 -0
  50. data/lib/chemistry_paradise/sinatra/wetter/start_sinatra_interface.rb +31 -0
  51. data/lib/chemistry_paradise/split_molecule_names.rb +228 -0
  52. data/lib/chemistry_paradise/toplevel_methods/atomgewichte.rb +31 -0
  53. data/lib/chemistry_paradise/toplevel_methods/convert_parens.rb +64 -0
  54. data/lib/chemistry_paradise/toplevel_methods/display_where_the_molmasses_are_kept.rb +24 -0
  55. data/lib/chemistry_paradise/toplevel_methods/e.rb +16 -0
  56. data/lib/chemistry_paradise/toplevel_methods/kelvin.rb +34 -0
  57. data/lib/chemistry_paradise/toplevel_methods/language.rb +50 -0
  58. data/lib/chemistry_paradise/toplevel_methods/misc.rb +147 -0
  59. data/lib/chemistry_paradise/toplevel_methods/periodic_table.rb +16 -0
  60. data/lib/chemistry_paradise/toplevel_methods/remove_this_molecule_from.rb +63 -0
  61. data/lib/chemistry_paradise/toplevel_methods/roebe.rb +16 -0
  62. data/lib/chemistry_paradise/toplevel_methods/show_electron_negativity_chart.rb +26 -0
  63. data/lib/chemistry_paradise/utility_scripts/calculate_atomic_mass.rb +559 -0
  64. data/lib/chemistry_paradise/utility_scripts/combustion_analysis.rb +207 -0
  65. data/lib/chemistry_paradise/utility_scripts/electron_negativity_chart.rb +78 -0
  66. data/lib/chemistry_paradise/utility_scripts/equalize_chemical_formula.rb +84 -0
  67. data/lib/chemistry_paradise/utility_scripts/equation_solver.rb +130 -0
  68. data/lib/chemistry_paradise/utility_scripts/orbitals.rb +70 -0
  69. data/lib/chemistry_paradise/utility_scripts/show_electron_negativity_of_this_element.rb +103 -0
  70. data/lib/chemistry_paradise/verbose_chemical_calculation.rb +21 -0
  71. data/lib/chemistry_paradise/version/version.rb +19 -0
  72. data/lib/chemistry_paradise/wetter/wetter.rb +539 -0
  73. data/lib/chemistry_paradise/www/wetter/embeddable_interface.rb +78 -0
  74. data/lib/chemistry_paradise/www/wetter/wetter.cgi +28 -0
  75. data/lib/chemistry_paradise/yaml/atomgewichte.yml +113 -0
  76. data/lib/chemistry_paradise/yaml/colours_for_the_elements.yml +13 -0
  77. data/lib/chemistry_paradise/yaml/dichte.yml +21 -0
  78. data/lib/chemistry_paradise/yaml/electron_negativity_chart.yml +111 -0
  79. data/lib/chemistry_paradise/yaml/molecular_formula_of_different_molecules.yml +13 -0
  80. data/lib/chemistry_paradise/yaml/periodic_table_of_the_elements.yml +125 -0
  81. data/lib/chemistry_paradise.rb +1 -0
  82. data/test/testing_chemistry_paradise.rb +49 -0
  83. metadata +173 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5277958b4b4bc41837609a82dda266000f3fd4a44df12672236ffe1cac9c5c90
4
+ data.tar.gz: 49f2ebb30279b2fe7679be0fd1bfc31de412d186faff2dff0c3085b37ed2ed7d
5
+ SHA512:
6
+ metadata.gz: 5953efdfd6792b8864256f619872f681983d857750e38d526313e88497277542a472d2eb95410029eff5d3b2dfb28f3acdff88120306ff46a94338deef43f954
7
+ data.tar.gz: c91a98c8ed33cf791a2ff3b64a88ad0705f77180785f10ec33b617d06336110e11fbaf346f89c16ba38898ed5399e4955fff33974d81e54fc0767372fbce56fd
data/README.md ADDED
@@ -0,0 +1,522 @@
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">17.03.2023</span> (dd.mm.yyyy notation), at <span style="color: steelblue; font-weight: bold">18:49:59</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
+ ## Potential useful links related to chemistry
516
+
517
+ This is another good <b>ruby-library</b> for handling
518
+ chemistry-related aspects:
519
+
520
+ https://github.com/fogonthedowns/rubychem/
521
+
522
+ CONTACT_INFORMATION
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'chemistry_paradise/commandline/parse_commandline.rb'
6
+
7
+ ChemistryParadise::ParseCommandline.new(ARGV)
data/bin/wetter ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'chemistry_paradise'
6
+
7
+ ChemistryParadise::Wetter.menu(ARGV)
@@ -0,0 +1,46 @@
1
+ # =========================================================================== #
2
+ # Gemspec for Project Chemistry.
3
+ # =========================================================================== #
4
+ require 'chemistry_paradise'
5
+ require 'roebe/toplevel_methods/misc.rb'
6
+
7
+ Gem::Specification.new { |s|
8
+
9
+ s.name = 'chemistry_paradise'
10
+ s.version = ChemistryParadise::VERSION
11
+ s.date = Time.now.strftime('%Y-%m-%d')
12
+
13
+ DESCRIPTION = <<-EOF
14
+
15
+ Chemistry-related tasks are gathered in this project.
16
+
17
+ The classes in this project may allow you to translate
18
+ between celsius and fahrenheit (and vice versa), show the
19
+ mass of elements or compounds and several similar things
20
+ somewhat related to chemistry.
21
+
22
+ For more extensive documentation, see the link at the
23
+ bottom right side of this webpage, called "Documentation".
24
+
25
+ EOF
26
+
27
+ s.summary = DESCRIPTION
28
+ s.description = DESCRIPTION
29
+
30
+ s.extra_rdoc_files = %w()
31
+
32
+ s.authors = ['Robert A. Heiler']
33
+ s.email = Roebe.email?
34
+ s.files = Dir['**/*']
35
+ s.license = 'MIT'
36
+ s.homepage = 'https://rubygems.org/gems/chemistry_paradise'
37
+
38
+ s.required_ruby_version = '>= '+Roebe.third_most_stable_version_of_ruby
39
+ s.required_rubygems_version = '>= '+Gem::VERSION
40
+ s.rubygems_version = '>= '+Gem::VERSION
41
+
42
+ s.add_dependency 'opn'
43
+ s.add_dependency 'cliner'
44
+ s.add_dependency 'colours'
45
+
46
+ }