Coder Social home page Coder Social logo

ekuester / periodic-table-molecular-formula Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 844 KB

Periodic Table of the elements ( PTE ) combined with information about elements and calculation of molecular formulas and their molecular weight, the amount of the contained elements in percent is given. ( C++ / Linux / Gnome / GTK / gtkmm / chemistry / PTE / PSE )

License: GNU General Public License v3.0

Makefile 14.14% Shell 0.94% M4 0.87% C++ 84.06%
science chemistry periodic-table-of-elements elements calculations molecular-formulas programming gnome gtkmm c-plus-plus

periodic-table-molecular-formula's Introduction

GTK-Periodic-Table-Molecular-Formula

Periodic Table of the elements ( PTE ) combined with information about elements and calculation of molecular formulas and their molecular weight (also named molar mass), the amount of the contained elements in percent is given. ( C++ / Linux / Gnome / GTK / gtkmm / chemistry / PTE / PSE )

The program itself consists of three parts: The table of the periodic system of the elements ( PTE resp. PSE ), information about the elements and a calculator for molecular formulas and molecular weights. The first and second part was written the last months, since I thought it would harmonize with the third.
For further explanations look at
  https://nl.wikipedia.org/wiki/Periodiek_systeem in dutch
  https://en.wikipedia.org/wiki/Periodic_table in english
  https://fr.wikipedia.org/wiki/Tableau_p%C3%A9riodique_des_%C3%A9l%C3%A9ments in french
  https://de.wikipedia.org/wiki/Periodensystem in german
  https://it.wikipedia.org/wiki/Tavola_periodica_degli_elementi in italian

The third part is accompanying my life since years, I wrote it first in BASIC, followed by versions in Borland Turbo C and Microsoft Visual C# 2005 (both for Windows), switched to Objective C and Swift on Apple Macs and now finally in C++ with use of gtkmm wrapper for Gnome GTK environment of Linux.

While working under Fedora Linux I choose C++ as the programming language in combination with GTK and the gtkmm wrapper. With these you have excellent tools for developing own programs.

The normal procedure for building the program is using the standard autotools. The following sequence

./autogen.sh --prefix=$HOME/.local
make
make install
periodictable.sh

will build and run the program for the current user. The Linux way of localization for the dutch/french/german/italian translation files is adapted. For rpm packaging use the SPEC file in directorypackage.

Alternatively (for all supported languages) you can easily compile and run the program in Terminal with the added shell script:

sh ./GTKPeriodicTable.sh

I wrote this program to become familiar with the C++ language, especially the GTK-API under the gtkmm wrapper and to get a feeling how to display different widgets on the screen. Take it as example for handling of windows, menus, buttons, labels, entries and textviews. Nowadays you have to consider features regarding hiDPI displays and when using dark themes.
Very interesting in GTK 3.0 is the mode of setting colors in widgets: First place to go is
  https://developer.gnome.org/gtk3/stable/chap-css-overview.html
It is essential to generate the necessary CSS data in the right syntax.
Printing of the table is possible, you will learn to use aGtk::OffscreenWindow for that.

Usage:
You will find the program mostly self explaining. On start you are confronted with the actual table of elements according with IUPAC (International Union of Pure and Applied Chemistry). Divergent from their nomenclature I choose the latinized element names, which clearly explain the origin of the chemical element symbols, mainly from
  https://la.wikipedia.org/wiki/Systema_periodicum in latin as lingua franca ...
By clicking on an element a window with further information about the element is shown. At the end of the list you will find a link to the relevant article in Wikipedia.

Click in the menubar on "Calc" and "Open" and you will see the little calculator for formulas, molecular masses and percent of elements. Input your formula into the topmost field, what you can do in a relatively comfortable way by grouping the formula into formula elements. Formula elements means the combination of an element symbol with an index. The only restriction is that indices can only be set behind the formula element which shall be counted. Then let the program do the necessary calculations for you.

  • use the normal element symbols
  • use arabic numerals as indices
  • use bonds:  - : = . · (only illustrative, not controlled on correctness)
  • use paired brackets and/or parenthesis for more complex formulas:  [ ] ( )

examples:

organic:
CH2=CH-CO-ONa              2-Propenoic acid, sodium salt (Sodium acrylate)
(CH2=CH-CO)2O              2-Propenoic acid, anhydride (Acrylic anhydride)
CH2=C(CH3)-CO-NH2          2-Methyl-2-propenamide (Methacrylamide)
HO-CO-CH(OH)-CH(OH)-CO-OH  2,3-Dihydroxybutanedioic acid (Tartaric acid)
HOCH2-CO-(CHOH)3-CH2OH     Pentahydroxyhexan-2-one (Fructose)
C6H6                       Benzene
C10H8                      Naphthalene
C4H4C(CH2)CC4H4            Bicyclo[4.4.1]undeca-1,3,5,7,9-pentaene (1,6-Methano[10]annulene)
CH3-CO-O-C6H4-CO-OH        2-(Acetyloxy)benzoesäure (Acetylsalicylic acid, Aspirin)
HO-C17H22(CH3)2-CH(CH3)-(CH2)3-CH(CH3)2
                           (3ß)-cholest-5-en-3-ol (Cholesterol)
inorganic:
[Cu(NH3)4(H2O)]SO4         Tetraamminecopper(II)sulfate, monohydrate
FeSO4·[H2O]7               Iron(II)sulfate, heptahydrate (containing crystallisation water)
 note: FeSO4·7[H2O] is not recognized correctly

Pressing the ENTER key will output the overall molecular formula strictly sorted in alphabetical order, the overall molecular mass and the amount of each element in the molecule in percent.
For further explanations look at
  https://en.wikipedia.org/wiki/Chemical_formula#Molecular_formula
  https://en.wikipedia.org/wiki/Molecular_mass

Annotation: For homology I changed the name of the halogens to end with -inum to match more the official names of IUPAC.

Acknowledgements: Special thanks go to the people in the developer community at StackOverflow. Without their help and answered questions at https://stackoverflow.com/ this work would not be possible.

Disclaimer: Use the program for what purpose you like, but hold in mind, that I will not be responsible for any harm it will cause to your hard- or software. It was your decision to use this piece of software.

periodic-table-molecular-formula's People

Contributors

ekuester avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.