Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Algorithm for Calculating Angles in sp3d2 Hybridization #3

Open
TharunKumarrA opened this issue Dec 24, 2024 · 22 comments · May be fixed by #12
Open

Implement Algorithm for Calculating Angles in sp3d2 Hybridization #3

TharunKumarrA opened this issue Dec 24, 2024 · 22 comments · May be fixed by #12

Comments

@TharunKumarrA
Copy link
Owner

TharunKumarrA commented Dec 24, 2024

Description

Develop and implement an algorithm to calculate bond angles for sp3d2 (octahedral) hybridization. This is essential for the accurate representation of molecular geometries like SF₆.

Acceptance Criteria

  • The algorithm calculates bond angles for sp3d2 hybridization correctly (90°).
  • Results align with standard octahedral geometry.
  • The implementation is efficient for real-time molecular visualization.

Suggested Approach

  1. Use mathematical models (e.g., vectors and rotation matrices) to derive bond angles for sp3d2 hybridization.
  2. Ensure compatibility with existing getCoordinates() logic in Molecule.js.
  3. Integrate the new functionality within the molecule construction logic to maintain modularity and scalability.

File Locations for Implementation

File: /src/components/Molecule.js

  • Update Functionality:
    • Modify the getCoordinates(molecule) function to handle sp3d2 hybridization bond angles.
    • Add a specific case for sp3d2 in the existing angles mapping object.
  • Additional Logic:
    • Create helper methods to calculate bond directions for sp3d2 hybridization based on octahedral geometry.

File: /src/components/GraphADT.js

  • Enhancements:
    • Add properties or methods in the Molecule class (if required) to store and retrieve calculated bond angles.

File: /src/components/EditMolecule.jsx

  • Frontend Integration:
    • Update UI logic if user interaction for sp3d2 molecules (e.g., dropdowns or selectors) is required.

Code Changes

In Molecule.js

Update the bond angle logic:

const angles = {
  sp: { angleX: Math.PI, angleY: 0, angleZ: 0 },
  sp2: { angleX: -Math.PI / 6, angleY: Math.PI / 3, angleZ: 0 },
  sp3: { angleX: 0.615 * Math.PI, angleY: 0.955 * Math.PI, angleZ: 0.615 * Math.PI },
  sp3d2: // Octahedral geometry
};

In getCoordinates() (Molecule.js)

Add specific logic for sp3d2 hybridization:

if (currentAtom.hybridisation === "sp3d2") {
  // Calculate coordinates for octahedral geometry bonds
}
@priyansh-narang2308
Copy link

HI I WOULD LIKE TO WORK ON THIS ISSUE @TharunKumarrA

@TharunKumarrA
Copy link
Owner Author

yes, please. Assigned to @priyansh-narang2308

@TharunKumarrA
Copy link
Owner Author

TharunKumarrA commented Dec 26, 2024

can you first propose an algorithm for this by referencing to the methods used in sp, sp2 and sp3?
We can discuss on this first before going into implementation. any queries just ping me

@priyansh-narang2308
Copy link

priyansh-narang2308 commented Dec 26, 2024

Yeahh Sorry for the Delay,
So if we take a reference from sp,sp2, and sp3 these were taking 2,3,4 electron domains but the sp3d2 needs 6 electron which are arranged in octahedral geometey. So as sp3 uses tetrahedral base we can use the three axes x y and z for octahedral ,we can take these 3 as our base vectors and these vectiors can be normalized . by this we can calc the bond angle . and as adjacent bonds make 90 degree and opposite 180 degree we can keep in mind that also. we can also cmpare with the SF6 as a test case .
So this was my view anything to add or if smthing is out of the box pls let me knoww..

@TharunKumarrA
Copy link
Owner Author

Yeah sorry for the delayed reply. I'm kinda not well, so I'll discuss it tomorrow if it works

@priyansh-narang2308
Copy link

So like should i start working on it ? or is there any deadline to submit?

@TharunKumarrA
Copy link
Owner Author

so the main issue is how you find the coordinates for the atoms - from the previous atoms coordinate position. So, you can think its as easy as finding the unit vector directions and then just multipying the bond length. That would work only for a standalone structure. If we have sp3d2 in a larger molecule or with double or triple bonds we need more than the unit vector directions, so do you have clarity of it?

@TharunKumarrA
Copy link
Owner Author

i partially agree with you proposed solution, yes we need 3 as our base, but the hard part is to find which atoms to go as base atoms

@priyansh-narang2308
Copy link

So for complex molecules we can use the vector algebra to like find the position of all six atoms which are relatove to the center atom .this will use the bond orders and steric effects . we can calculate by finding the ligand positions by determining the unit vecttors

@TharunKumarrA
Copy link
Owner Author

Okay so I think you can start with the implementation 🫡

@priyansh-narang2308
Copy link

Can u pls tell the deadline to submit a PR for this issue🫡

@TharunKumarrA
Copy link
Owner Author

It's Jan 2nd

@priyansh-narang2308
Copy link

HEY @TharunKumarrA
I HAVE MADE THE CHANGES SO SHOULD I MAKE A PR?
BUT I HAVE A DOUBT . AS I TOLD U ABOUT THE COMPLEX MOLCULES WE CAN USE THE VECTOR ALGEBRA BUT AS SOON AS I AM APPLYING THE FORMULA THE CODE'S NOT RUNNING AND SHOWING AN UNEXPECTED ERRIR
I USED THE DOT PRODUCT FOR IT.
BUT THE FILES THAT WERE TO BE IMPLEMENTED THE CHANGES HAVE BEEN MADE..

@priyansh-narang2308
Copy link

image
WHEN I AM CLICKING THE RADIO BUTTONS ITS WORKING

@priyansh-narang2308
Copy link

THE ONLY ISSUE IS THE COMPLEX MOLECULES
I HAVE DONE FOR SF6
image

@TharunKumarrA
Copy link
Owner Author

HEY @TharunKumarrA
I HAVE MADE THE CHANGES SO SHOULD I MAKE A PR?
BUT I HAVE A DOUBT . AS I TOLD U ABOUT THE COMPLEX MOLCULES WE CAN USE THE VECTOR ALGEBRA BUT AS SOON AS I AM APPLYING THE FORMULA THE CODE'S NOT RUNNING AND SHOWING AN UNEXPECTED ERRIR
I USED THE DOT PRODUCT FOR IT.
BUT THE FILES THAT WERE TO BE IMPLEMENTED THE CHANGES HAVE BEEN MADE..

Can you show what exactly the issue is?

@TharunKumarrA
Copy link
Owner Author

Also can you just walk me through how you went about the logic? To find the positions in the 3d space. If you can attach a sample output in screen it would be nice.
Sorry for the late reply I was not in college
@priyansh-narang2308

@priyansh-narang2308
Copy link

Yeahh so the i used a 3d cartesian system in the sp3d2 system. and the unit vectors along the six octahedral directions
The ligand postion is found by multiplying the unit vectors with the bond length and adding the central atom coordiatnates.
So by this we can find the position in 3d space
AND ABOUT THE ERROR
The errir in the sense its not showing in the screen the for like molecules like [Fe(Cl)6]3- where should it show thats the confusion

@TharunKumarrA
Copy link
Owner Author

ohh okay I see, try to simplify the dimensionality for the functions.
We can see that 4 are in the same plane, so consider (any standard plane like XY or YZ or ZX if its standalone) or a plane that is perpendicular to the last bond connected to the central atom and place the 4 atoms (using the unit vectors) then since we can find the normal of the plane place 2 remaining atoms in the opp directions of the normal vector.
This way we can modularize the functions and make it easy to both understand and implement.

And regarding the error, for now the code base doesn't support ionic structures as they vary both in angle and shape from classical one.
The application focuses more on Carbon based molecular structures (organic) for now

[Fe(Cl)6]3- this is a really complex molecule to implement with the current functions, so maybe try going for simpler ones.

Hope I answered you queries! Sorry for responding late, I was not having my laptop yesterday @priyansh-narang2308

@TharunKumarrA
Copy link
Owner Author

I would encourage you to use already available functions if needed such as the findcentralatoms() wherein there is logic to find the central atom of an hybridization using the hybridization of each atom in the molecule. And similar other helper functions too, if needed create any helper functions that you need such as finding normal to a plane or normalizing a direction vector to be a unit vector etc ...
@priyansh-narang2308

@priyansh-narang2308
Copy link

yeah so i used the helper functions

  • normalizeVector: makes the vector length = 1 while keeping its direction
  • getPerpendicularVector: gets a vector at 90° angle
  • crossProduct: finds a vector perpendicular to the other two
    So should i Make a PR

@TharunKumarrA
Copy link
Owner Author

If it's working well make a pr ... sure, but in the pr I need you to add output screenshots (very helpful for my side)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants