You are browsing as a guest. Sign up (or log in) to start making projects!

VSEPR Predictor

  • 5 Devlogs
  • 18 Total hours

The project uses Valence Shell Electron-Pair Repulsion Theory (VSEPR) to predict the molecular and electron-group shapes of simple molecules and compounds.

Open comments for this post

6h 9m 33s logged

Hello, World.

It’s been a while.

Welcome to the 5th devlog centralized around a (mainly python) project that uses VSEPR Theory– aka Valence Shell Electron Pair Repulsion Theory– to predict the shapes/geometries of given molecules. For more info on the project’s main aims, please read my previous devlog. Nevertheless, a bulleted summary of what the project can do (structured in a way similar to my other devlogs for simplicity) is shown below.

Capabilities of the Project

This project, at its state at the moment of writing:

  • Counts Valence Electrons of the inputted molecule (mendeleev assist).
  • Accounts for charges on molecules and taking that into consideration while calculating Valence Electrons.
  • Error checks / parses the user’s input to only allow valid molecules. * NEW/ADDED
  • Calculates electronegativities of constituent elements (using mendeleev) and determining the central atom of the molecule.
  • Parses the molecule to find its elements and subscripts.
  • Calculates electron groups / steric number.
  • Calculates lone pairs around the central atom.
  • Reforms the molecule in VSEPR form: AX_mE_n.
  • Searches through a dictionary/table of all of the permutations of VSEPR form in order to fetch appropriate data.
  • Interacts with the user in order to act as an educational tool. * NEW
  • Allows the user freedom in the questions asked: they can ask for a hint, can skip 1 questions, and can skip all questions at once.

The Radical Problem (literally. (solved))

A major mistake on my part was that I forgot to account for radical molecules; in fact, I didn’t even know they were a thing. It turns out that, some molecules are allowed to have a lone electron surrounding the central atom, since they have an odd number of total valence electrons, hence yielding them an inevitable 1 leftover electron. Thankfully, the problem is solved now, perhaps in an admittingly unfortunate way: the program is now designed to simply reject radical molecules. There is a good reason for this, and that’s because these molecules’ shapes cannot reliably be predicted with VSEPR theory.

The Clean Up

In the time in between my 4th and 5th devlog, I have spent a lot of time capturing bugs in my code, and cleaning the code along the way. For a simple example, I would lazily copy-and-paste the same code into each constituent if, elif, and else statement when I could just call that code after them. As it’s been a relatively long time, I cannot remember a lot of the specific clean-ups I had done, which is probably included in the **cons of pushing devlogs late . . . **

I apologize for the late devlog (although I know not many care). The reason for this, and the low amount of hours and effort given in these past 13 days, is mostly because of school. As well as there was a problem with my hackatime or rather my VSCode wherein multiple hours of work were not logged for whatever reason– however, I worked with quality during those times so I consider it a win.

Addressing the Functionality (the interactivity)

For now, my project asks questions to the reader terminal style, being arguably not engaging and probably very indescriptive as well– which is important to take note of, as this is indeed supposed to be an educational tool. In my future plans, I hope to pick up on some JavaScript or TypeScript, HTML, and CSS, in order to create a website or application that actually renders the models of these molecules, as well as to provide models for constituent steps like creating the Lewis/Dot structure. I firmly believe that if we are building the Dot Structures and are predicting shapes of molecules, the users should be able to see these things so they can then understand.

Conclusions

Thank you for reading!
This was the 5th devlog, on the project based around VSEPR Theory, and I’ll see you, next time.

0
0
7
Open comments for this post

4h 41m 36s logged

Welcome, reader.

This is my 4th devlog on a project (primarily built in python), that takes a molecule with a single defined central atom and predicts the electron geometries, molecular geometries (bond hybridization as well) using VSEPR Theory, and other quantitative data like total valence electrons, lone pairs, etc., that were collected along the calculations. If you are interested in my motivations and overall more information about the project, you can read my previous devlogs as well. However, the near-following bulleted-list will hopefully provide decent context.
I would usually write a devlog earlier than this; however, I worked on my README.MD, yielding not a full 4h 37m on functional programming necessarily.

Functions of the Predictor

This project, at its state at the moment of writing:

  • Counts Valence Electrons of the inputted molecule (mendeleev assist).
  • Accounts for charges on molecules and taking that into consideration while calculating Valence Electrons.
  • Error checks / parses the user’s input to only allow valid molecules. * NEW/ADDED
  • Calculates electronegativities of constituent elements (using mendeleev) and determining the central atom of the molecule.
  • Parses the molecule to find its elements and subscripts.
  • Calculates electron groups / steric number.
  • Calculates lone pairs around the central atom.
  • Reforms the molecule in VSEPR form: AX_mE_n. * NEW
  • Searches through a dictionary/table of all of the permutations of VSEPR form in order to fetch appropriate data. * NEW

New Changes

I rewrote some of the code in order to remove redundancy and to improve efficiency. I also created designated functions for some of the code I recently wrote. These parts were quite annoying, as it was frustrating to have to rewrite code to reach the same goal again; a lot of errors kept appearing. Nevertheless, I finished in the end. It takes a lot of patience to read through all your code line by line and go through the functions of each, and then seeing where efficiency could be improved. Nevertheless, it is satisfying to realize and improve on code, and to produce a more concise and readable product in the end. Since I can’t write extensively in this devlog, I will touch on topics like bond hybridization and more later. I also worked on my README.MD as aforementioned, which I encourage you to read or look at.

Future Plans

As you can see in the screenshot I included below (using H3O+/hydronium as the example), my project is simply printing out all of the data– though the calculations are arguably demanding. In essence, the output is underwhelming compared to the immense backend logic. I would certainly like to make this into a web or application, and at the same time I would be learning HTML, CSS, and JavaScript.

Conclusion / Goodbyes

Thank you for reading, reader. I imagine that you learned or found something in my devlog interesting. If you have any suggestions, comment below and I will be sure to ponder over them. By the way, I really don’t know which molecules to pick for my examples in my screenshots, so you can comment some that you might want me to use (make sure it has one central atom). My name is Lucky, and I thank you, once again, Goodbye.

for H3O+ (Hydronium) below

0
0
21
Open comments for this post

2h 21m 6s logged

Good day, reader. I’m Lucky.

This is a third devlog on my project: VSEPR Predictor. If you aren’t sure of the project aims to do, feel free to read my first devlog; however, I will give you a brief summary. The project takes input a molecule, and then predicts the molecular geometry / shape of the molecule, as well as the electron-group geometry overall. It is built in python.

Pytest

As stated in my earlier log, I was tired of manually testing my project all of the time, and I wanted to use pytest. Therefore, I created 4 functions that have specific roles in my code. These four functions are the following: get_atoms_subscripts, get_central_atom, get_total_valence, and validate_formula– all of which take a molecule as input.
*Before I state the advancements I have made, I’d like to disclaim that the electron-group calculations are not yet finalized, as I have yet to account for double and single bonds. To target this problem, I have calculated formal charges, and I plan to tackle it next. I will not explain what formal charges are– for the sake of words– but if you want, you can search it up.

Functional Changes

  • Calculated electron groups note ^^^
  • Calculated formal charge before adding double or triple bonds
    -Listed terminal atoms (every atom but the central one)
  • Calculated Lone pairs note ^^^

Overall Function

This project, at its state at the moment of writing:

  • Counts Valence Electrons of the inputted molecule (mendeleev assist).
  • Accounts for charges on molecules and taking that into consideration while calculating Valence Electrons.
  • Error checks / parses the user’s input to only allow valid molecules.
  • Calculates electronegativities of constituent elements (using mendeleev) and determining the central atom of the molecule.
  • Parses the molecule to find its elements and subscripts.
  • And does the aforementioned (functional changes).
Struggles

I admit that the hardest part of this session was transforming my code to create functions instead of just a blob of code. As you can imagine, it became very frustrating when– when I started to convert the code into constituent functions– my code started to have errors: some that have come of before and some new. At one point, I told myself, “My old code works, why can’t I just use that!” Of course, this was just out of a fit of discouragement, but I went on. I included I screenshot of what the project does at this moment, below– using NH3 (ammonia) as an example.
Goodbye, thank you for reading. I hope you gained something, whether it be entertainment or knowledge.

0
0
23
Open comments for this post

2h 59m 27s logged

Welcome. My name is Lucky
This is my second devlog, based around a project (my first personal one) in python that predicts molecular and overall shape geometries using Valence Shell Electron-Pair Repulsion Theory– VSEPR (check my first devlog if you seek more information). The following is what I have done, in simple terms. I have:

  • Counted the Valence Electrons of the inputted molecule using mendeleev.
  • Accounted for charges on molecules and taking that into consideration while calculating Valence Electrons.
  • Error checked / parsed the user’s input to only allow valid molecules.
  • Calculated electronegativities of constituent elements (using mendeleev) and determining the central atom of the molecule.
    Challenges:
    It was hard to parse the user’s input, and organizing code in respect to the type of the user’s molecule (e.g., if it has a charge that isn’t 0 or not). This way, it was hard to check whether my code was breaking other code. I remember accounting charges for my valence electron total– I was so happy and I felt very accomplished. However, I realized that I couldn’t input zero-charge molecules anymore– simple ones like H20 or CO2 . . .
    This is why I am going to decide to make a test file using pytest. (I may even have errors in my code I haven’t found yet.) I won’t have to go through this struggle again: testing and testing and testing. Rather, I can just run a single line in my terminal and test my whole file easily. That said, I will still need to change some things in order for that to happen– which leads me on to what I hope to achieve in the near future in terms of this project.
    Goals for next sessions:
  • Create actual functions with respective function (obviously, haha), so I can use pytest.
  • Overall clean up code
  • Start abstractly creating a lewis structure– I don’t know yet if I will actually draw it on the screen.
  • Calculate the amount of covalent bonds needed from the central atom to terminal atoms, and account 2 electrons for each bond.
    Thanks for reading, I hope you learned something or found my post interesting. I included a screenshot below of my project’s output for now.
0
0
1
Open comments for this post

1h 31m 27s logged

Welcome, reader. My name is Lucky, and this is my first personal project; and it's made using python. 

The modules I decided to use for now was just one: re. For context: my overall project is a cmd-line project that revolves around taking input from the user, a molecule, and predicting the molecular and electron-pair geometries of it. In other words, predicting the overall shape of the molecule. My first step is to count the valence electrons of the full molecule, and my first step in that is shown here. I was inspired by a bit of chemistry and I thought it would be an interesting first project to build my skills, although the concept is admittedly of low practicality or use. Little did I know, the overall idea requires a lot of parsing and error checking than I initially thought!
At first, I used for-loop logic to find subscripts and trace them back to their respective elements. The logic was personally overwhelming: while programming, the ideas were too much to hold: I had to think about this list and that list, this dictionary and that dictionary, this index and that index, lining up everything perfectly. I'm glad I pseudo-coded a bit as of before, as I'm afraid my head would have exploded. Even after building the for-logic, there was still too much to parse. It all felt arbitrarily too much for a relatively simple function. I had to take into account of the implicit subscripts of 1, the implicit coefficient as well . . . 

However, after the struggle, I realized that I could use re.findall to do such as the aforementioned. Plug in a simple pattern, and boom– no more parsing needed, no more messiness. Nonetheless, I am glad and I went through the struggle, as I learned a lot specifically, and I also learned about the reality of programming: it seems easier in your head– it’s certainly easier said than done. As Lao Tzu had said: “A journey of a thousand miles begins with a single step.” Although, admittedly, and ironically, I can’t say my journey is of a thousand miles haha. As you can see, I included I screenshot / small demo below, of what the project’s function is.
Next up, I plan to use the information granted by my code to count the number of valence electrons in the full molecule, possibly creating and using a dictionary of valence electron information for constituent atoms.
Reader, thanks for coming along and listening to my experience coding my first personal project! I am determined to keep going and ultimately reach my final goal. Again, my name is Lucky, and I thank you for reading.

0
0
1

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…