Thread: Water molecule simulation

  1. #1

    Join Date
    May 2005
    Posts
    1,042

    Water molecule simulation

    I wrote this program as a visual aid for my engineering chemistry professor.

    It is 3 water molecules which bonds to a central +3 aluminum. I implemented it by integrating the force and torque from the coloumb forces of Hydrogen and Oxygen. It is 'correct,' except that I modified the variables such that the reaction would not happen instantaneously.

    The molecule that emerges is similar to the real thing, e.g. a central aluminum with 3 water molecules evenly spaced around it (equal angles). I didn't specifically tell it to do this, it emerges from the physics. This model limits it to a single plane.

    I plan on implementing more complex molecules/compounds.

    ihatenature.thejefffiles.com/tonadeau.zip
    Last edited by BobMcGee123; 04-29-2007 at 09:10 PM.
    I'm not immature, I'm refined in the opposite direction.

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Cool stuff. How are you doing it? Are you solving directly for the minimum points in the potential function? Or are you doing some kind of annealing technique to search for the lowest energy? Or are you letting the molecule oscillate under the influence of a frictional force?

  3. #3

    Join Date
    May 2005
    Posts
    1,042
    I've taken all of the information I could find about a water molecule, e.g. the bond length bond angle, etc and made sure that these quantities remained proportional. I loop through each molecule and solve for their new positions and orientations based on the coloumbic forces.

    I add very slight dampening factors to their positions and orientations.
    I'm not immature, I'm refined in the opposite direction.

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by BobMcGee123 View Post
    I've taken all of the information I could find about a water molecule, e.g. the bond length bond angle, etc and made sure that these quantities remained proportional. I loop through each molecule and solve for their new positions and orientations based on the coloumbic forces.

    I add very slight dampening factors to their positions and orientations.
    So it sounds like the third option I mentioned. If I'm not mistaken, you are integrating the coulomb force through some finite difference method? And then applying friction so that instead of oscillating around the stable state forever it slowly settles into it.

    How do you deal with false minima? Are there any other stable configurations of this complex which have a higher energy than the one you found?

    Very cool.

  5. #5
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    That's really cool

    *Goes back to simulating orbiting shiny spheres*

    I have a long ways to go.

  6. #6
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by indigo0086 View Post
    That's really cool

    *Goes back to simulating orbiting shiny spheres*
    If you can simulate gravity, you can simulate the coulomb force They are both inverse square laws. Simulating magnetism is quite a bit harder.

  7. #7
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    orbiting sans gravity, more simple rotation.

  8. #8
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Those are pretty comments, Bob
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  9. #9

    Join Date
    May 2005
    Posts
    1,042
    If you can simulate gravity, you can simulate the coulomb force They are both inverse square laws. Simulating magnetism is quite a bit harder.
    Yeah, the basics aren't too hard, although integrating it numerically isn't particularly easy. I've got an RK4 solver doing the work on this one, which isn't best suited for this particular application, but it works with no catastropic anomalies.
    I'm not immature, I'm refined in the opposite direction.

  10. #10
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Wow, this is actually what I'm doing right now. I'm writing molecular dynamics and I am trying to use adaptive numerical methods, which isn't trivial. The difference between simulating gravity and simulating molecular dynamics is surprisingly small.

    Perhaps I'll post more here later.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  11. #11
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,071
    I hate chemistry, but this still looks pretty cool (even though I really don't know what it is exactly ).
    M.Eng Computer Engineering Candidate
    B.Sc Computer Science

    Robotics and graphics enthusiast.

  12. #12

    Join Date
    May 2005
    Posts
    1,042
    Quote Originally Posted by Sang-drax View Post
    Wow, this is actually what I'm doing right now. I'm writing molecular dynamics and I am trying to use adaptive numerical methods, which isn't trivial. The difference between simulating gravity and simulating molecular dynamics is surprisingly small.

    Perhaps I'll post more here later.
    The equations for forces and gravitational/electric fields are identical in form.

    What type of adaptive numerical solver are you using? Nothing about mine is 'adaptive,' e.g. I use the same timestep throughout.


    I hate chemistry too, for some reason it just doesn't make sense to me. But this little project is going to boost my grade, so I'm all set.
    I'm not immature, I'm refined in the opposite direction.

  13. #13
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    We're trying to implement the adaptive step size controller described in this paper: http://www.maths.lth.se/na/staff/gustaf/revstep2.pdf. The author has implemented the method for planetary orbits, but the equations are very similar. We have had some success and it turns out that the adaptive method pays off if there is much happening, i.e. before the system has reached an equilibrium configuration.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  14. #14
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    I don't understand chemistry to hate it

    Nice inverted colours though *cough*, how the hell do you work with a windows coloured (or not-coloured ) like that.

  15. #15
    Registered User IdioticCreation's Avatar
    Join Date
    Nov 2006
    Location
    Lurking about
    Posts
    229
    broke my brain.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fluid Mechanics program help
    By Hajjo in forum C Programming
    Replies: 15
    Last Post: 03-10-2008, 02:09 PM
  2. Molecule interaction simulation program
    By AdamLAN in forum C++ Programming
    Replies: 3
    Last Post: 05-12-2005, 03:09 PM
  3. water is flooding my room what should I do??
    By GanglyLamb in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 09-08-2004, 06:53 PM
  4. Water and Electricity: Common Misconception
    By Liger86 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 12-05-2003, 10:03 PM
  5. addiction to water
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 07-19-2002, 10:19 AM