chemistry_paradise 1.4.2

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