Sciencemadness Discussion Board
Not logged in [Login - Register]
Go To Bottom

Printable Version  
Author: Subject: The Stoichiometer
MrHomeScientist
International Hazard
*****




Posts: 1419
Registered: 24-10-2010
Location: Flerovium
Member Is Online


[*] posted on 24-12-2017 at 20:27
The Stoichiometer


I like to think one of my specialties is writing small software tools to help in various tasks. At my day job, this is mostly for data analysis. For quite a while now I've wanted to write a tool to help with stoichiometry, and I've finally gotten around to doing it. I call it the Stoichiometer.

To use: simply enter in a chemical equation in the box, and click Calculate. (Make sure it's a balanced equation! The program won't do it for you.) The molecular weights of each piece will be displayed. Choose a molecule and type in your desired mass in grams in the box below it and press Enter, and the rest of the boxes will be filled with the stoichiometrically-calculated values!

I wrote this mainly for myself, so there are a few conventions that must be followed for it to work that you might not necessarily use. I left in a sample equation as an example of the required format.

Quote:
1) The program does not accept decimal coefficients. So no H2 + 0.5O2 = H2O ! I've never liked decimal coefficients, so I don't use them, and didn't want to take the effort to code it in. Just multiply your equations! :D
2) Equations must be entered in the format A + B = C + D. Plus signs, a single equals sign, and spaces. Spaces aren't critical (if you omit them, the display gets weird but the calculations still work), but the format of the + and = does matter.
3) Capitalization matters. Otherwise your nitric oxide (NO) might be interpreted as nobelium (No). Write your formulas properly!


The program is to the point where I believe it works, and has passed several test cases. Now I'd like to recruit you all as beta testers :) Try it out, and let me know if any particular equation breaks the program or gives a wrong answer. If it works for you, great! Feel free to use it as much as you like.

I'll also include the source code if anyone wants to modify it. And so you can see there aren't any viruses built in! I'm sure there are more elegant ways to write the program, but these sort of tools are usually meant for just myself and the point is to write them quickly so that they save more time than they take. Hope it's useful to people!

Improvements that could be made:
- Add an equation balancing module!
- Convert it to a web-based app so you can more easily access it from your phone!

Attachment: Stoichiometer.exe (16kB)
This file has been downloaded 29 times

Attachment: Stoichiometer.zip (61kB)
This file has been downloaded 18 times

[Edited on 12-25-2017 by MrHomeScientist]
View user's profile Visit user's homepage View All Posts By User
j_sum1
International Hazard
*****




Posts: 3389
Registered: 4-10-2014
Location: Oz
Member Is Offline

Mood: Undergoing decantation and leaving all the crap behind.

[*] posted on 24-12-2017 at 21:20


Sounds good. I'll take a look when I am on the laptop.



A little shameless self-promotion: You are welcome to tour my newly-completed lab.
View user's profile View All Posts By User
j_sum1
International Hazard
*****




Posts: 3389
Registered: 4-10-2014
Location: Oz
Member Is Offline

Mood: Undergoing decantation and leaving all the crap behind.

[*] posted on 1-1-2018 at 18:36


I like it.
You are right -- it would be good to have an equation balancer as well but that is a whole other task.
What would be really cool is a phone version. I would find that really practical.

Some suggestions.
1. I know why you did it but in practice it would be better without the sample equation in the input box. I don't realy want to delete it every time.
2. It would be cool if it remembered the last few compounds that were used. No need for a complex library or anything but a drop down list of the most recent 20 would be great. After all, when you are doing this stuff you are usually on a cycle of related compounds until the next project. I'd rather not type in ferric ammonium sulfate 18 hydrate more often than I need to.




A little shameless self-promotion: You are welcome to tour my newly-completed lab.
View user's profile View All Posts By User
ninhydric1
Hazard to Others
***




Posts: 194
Registered: 21-4-2017
Location: Western US
Member Is Offline

Mood: extreme heating needed

[*] posted on 1-1-2018 at 19:51


I can finally spend more time in the lab instead of doing these goddamn tedious calculations! Very nice MrHomeScientist; the interface looks great and it works smoothly.



The philosophy of one century is the common sense of the next.
View user's profile View All Posts By User
MrHomeScientist
International Hazard
*****




Posts: 1419
Registered: 24-10-2010
Location: Flerovium
Member Is Online


[*] posted on 2-1-2018 at 19:49


Ask and ye shall receive!

Version 1.1
- Replaced main text box with combobox, to remember previously entered equations
- Initial sample equation disappears when box is clicked the first time
- Added ability to press Enter in the combobox instead of clicking the run button
- Added save functionality to remember equations entered in previous sessions
- Equations are saved to Stoichiometer.dat, in the same directory as the executable
- Added Delete button to remove equations from the list and save file

Attachment: Stoichiometer.exe (18kB)
This file has been downloaded 9 times

Attachment: Stoichiometer.zip (66kB)
This file has been downloaded 9 times


If this takes off and becomes popular, I'd love to add an equation balancer. Would be an interesting challenge to write one.
A phone app would be perfect, if I knew how to code phone apps! Would be something cool to learn for sure. Thanks for the feedback!
View user's profile Visit user's homepage View All Posts By User
j_sum1
International Hazard
*****




Posts: 3389
Registered: 4-10-2014
Location: Oz
Member Is Offline

Mood: Undergoing decantation and leaving all the crap behind.

[*] posted on 2-1-2018 at 20:02


Wow! that was fast.

Do I need everything in the zip file -- I just ran the exe and it seems ok by itself.
One further thing... and maybe this is my machine. The window does not resize well. When the equation runs too wide for the window a horizontal scroll bar appears. That's fine but when I widen the window, the window gets bigger but the content dows not change -- the scroll vbar remains and the amount of visible equation is unchanged.


Edit
If it helps there are numerous equation balancers around online which you might hack or fish for ideas. I confess that I don't use them much but I reckon I would use it a lot if incorporated into the stoichiometer.
Anyway, this is the one I have bookmarked -- seems above average.
https://www.webqc.org/balance.php

[Edited on 3-1-2018 by j_sum1]




A little shameless self-promotion: You are welcome to tour my newly-completed lab.
View user's profile View All Posts By User
MrHomeScientist
International Hazard
*****




Posts: 1419
Registered: 24-10-2010
Location: Flerovium
Member Is Online


[*] posted on 3-1-2018 at 07:33


No, the zip file is just the source code in case people want to edit it themselves. If you just want to run the program, all you need is the exe.

Protip: If it's easier for you, you can skip the GUI and edit the Stoichiometer.dat file directly to enter in your equations. Just open it with notepad and put each equation on its own separate line. The program imports that file every time it starts up. You can also delete equations directly from there, or delete the file entirely if you want to wipe the slate clean. The program will re-create it if it doesn't exist.

Resizing isn't something I really considered when writing it; I'll look into it. Should be a simple change.


Edit: Well damn, the site you linked already does everything my program does and more. :mad: Here I thought I was being innovative.

[Edited on 1-3-2018 by MrHomeScientist]
View user's profile Visit user's homepage View All Posts By User
j_sum1
International Hazard
*****




Posts: 3389
Registered: 4-10-2014
Location: Oz
Member Is Offline

Mood: Undergoing decantation and leaving all the crap behind.

[*] posted on 3-1-2018 at 21:13


Well, TBH, I had forgotten that that particular site did the stoichiometry bit. I haven't looked at it for over a year. I found it while looking for teaching resources but it was not a whole lot of help. I want my students to be able to balance equations and do stoichiometry calculations for themselves. Once they know the theory and can do it for themselves, that is when they can take some calculation short-cuts.

I still like what you have done. And I am not always online (despite what my post-frequency suggests.)




A little shameless self-promotion: You are welcome to tour my newly-completed lab.
View user's profile View All Posts By User

  Go To Top