module ChemistryParadise
#¶ ↑
require 'chemistry_paradise/base/colours.rb'
#¶ ↑
#¶ ↑
require 'chemistry_paradise/commandline/help.rb'
#¶ ↑
#¶ ↑
require 'chemistry_paradise/constants/german_names_of_elements_to_element_symbol.rb'
#¶ ↑
This .rb file will translate from the german name of an element towards the element symbol, if applicable. So, “Quecksilber” will become “Hg”.
See: de.wikipedia.org/wiki/Liste_der_chemischen_Elemente
#¶ ↑
#¶ ↑
require 'chemistry_paradise/project/project_base_directory.rb'
#¶ ↑
#¶ ↑
require 'chemistry_paradise/toplevel_methods/e.rb'
#¶ ↑
#¶ ↑
require 'chemistry_paradise/toplevel_methods/kelvin.rb'
#¶ ↑
#¶ ↑
This class can help set a different language for the project. By default, the german language is used, but you can call the module-method below, called ChemistryParadise.use_english, to enable english instead.
#¶ ↑
require 'chemistry_paradise/toplevel_methods/language.rb'
#¶ ↑
#¶ ↑
require 'chemistry_paradise/toplevel_methods/periodic_table.rb'
#¶ ↑
#¶ ↑
Purpose of this class is to explain what we are doing in a step-by-step wise fashion.
Right now this is a stub.
#¶ ↑
#¶ ↑
require 'chemistry_paradise/version/version.rb'
#¶ ↑
Constants
- GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL
#¶ ↑
ChemistryParadise::GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL
¶ ↑#¶ ↑
- LAST_UPDATE
#¶ ↑
LAST_UPDATE
¶ ↑#¶ ↑
- PROJECT_BASE_DIRECTORY
#¶ ↑
ChemistryParadise::PROJECT_BASE_DIRECTORY
¶ ↑The constant must have a trailing '/' character.
#¶ ↑
- VERSION
#¶ ↑
ChemistryParadise::VERSION
¶ ↑#¶ ↑
Public Class Methods
#¶ ↑
ChemistryParadise.atomic_mass_of
¶ ↑
This method is a shortcut, to quickly calculate the molecular mass of a compound. See the usage example that follows.
Usage example:
ChemistryParadise.atomic_mass_of 'C10H13N5O3' # => "251.245"
#¶ ↑
# File lib/chemistry_paradise/calculate_atomic_mass.rb, line 439 def self.atomic_mass_of(i) ChemistryParadise::CalculateAtomicMass.parse(i) end
#¶ ↑
ChemistryParadise.kelvin
¶ ↑
This method will output how many Kelvin n Celsius are.
The temperature T in Kelvin (K) is equal to the temperature T in degrees Celsius (°C) plus 273.1.
The formula thus is:
T(K) = T(°C) + 273.15
#¶ ↑
# File lib/chemistry_paradise/toplevel_methods/kelvin.rb, line 22 def self.kelvin(n_celsius) if n_celsius.is_a? Array n_celsius = n_celsius.first end n_kelvin = n_celsius.to_f + 273.15 return n_kelvin end
#¶ ↑
ChemistryParadise.remove_this_molecule_from
¶ ↑
The first argument is the molecule that should be deducted from the formula.
#¶ ↑
# File lib/chemistry_paradise/toplevel_methods/remove_this_molecule_from.rb, line 17 def self.remove_this_molecule_from( this_molecule = 'OH', from = 'C2H5NO2' ) array_big_molecule = ::ChemistryParadise.split_this_molecular_formula_into_a_hash(from) array_this_molecule = ::ChemistryParadise.split_this_molecular_formula_into_a_hash(this_molecule) # ======================================================================= # # Next, iterate over the small molecule. # ======================================================================= # array_this_molecule.each {|this_compound| unless this_compound =~ /\d+/ this_compound << '1' # Must be at the least one. end # ===================================================================== # # Select the entry that is the correct one. # ===================================================================== # this_entry = array_big_molecule.find {|entry| entry[0,1] == this_compound[0,1] } begin n_times_in_the_big_molecule = /(\d{1,3})/.match(this_entry)[1].to_i n_times_in_the_small_molecule = /(\d{1,3})/.match(this_compound)[1].to_i new_n_times = n_times_in_the_big_molecule - n_times_in_the_small_molecule new_entry = this_compound[0,1]+new_n_times.to_s # ===================================================================== # # Now we have the new entry; we need to re-insert it into the big # original Array. # ===================================================================== # proper_index = array_big_molecule.index {|entry| entry[0,1] == this_compound[0,1] } array_big_molecule[proper_index] = new_entry rescue NoMethodError => error pp error end } return array_big_molecule.join # Join it up again. end
#¶ ↑
ChemistryParadise.return_element_symbol_from_this_german_name
¶ ↑
#¶ ↑
# File lib/chemistry_paradise/constants/german_names_of_elements_to_element_symbol.rb, line 142 def self.return_element_symbol_from_this_german_name(i) i = i.dup if i.frozen? i.capitalize! if GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL.has_key? i GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL[i] else nil end end
#¶ ↑
ChemistryParadise.show_electron_negativity_chart
¶ ↑
#¶ ↑
# File lib/chemistry_paradise/toplevel_methods/show_electron_negativity_chart.rb, line 14 def self.show_electron_negativity_chart Constants::ELECTRON_NEGATIVITY_CHART.each_pair {|key, value| value = value.to_f value = '%.2f' % value puts key.ljust(2)+' -> '+value.to_s.rjust(2) } end