Search Unity

Question Molecule simulation produces cyclone

Discussion in 'Physics' started by devPatrick, May 3, 2023.

  1. devPatrick

    devPatrick

    Joined:
    Sep 28, 2018
    Posts:
    22
    Hello, I'm working on a molecular simulation of gasses with monatomic and diatomic molecules. It's nothing fancy- just molecules bouncing around in a glass container. I use a script to maintain a constant velocity on the molecules. My setup works fine for both the monatomic and diatomic molecules in a cube shaped container, but when I put the molecules in a cylindrical container, the diatomic molecules develop an odd behavior (the monatomic molecules behave as expected).

    Specifically, the diatomic molecules spread out from the center towards the side walls of the cylinder while rotating around the centerline (world up) of the cylindrical container in a kind of cyclone behavior. Before long, they've all condensed around the side walls (still moving and bouncing, but sticking close to the walls) leaving a cylindrical void in the center of the container which the molecules rarely pass through. As interesting as this behavior is, I expect the diatomic molecules to bounce around throughout the volume (relatively uniform distribution as opposed to this weird consolidation around the side walls).

    So that's the story. Anyone have any ideas on what could be causing this cyclone behavior and possible solutions?
     
    Last edited: May 9, 2023
  2. devPatrick

    devPatrick

    Joined:
    Sep 28, 2018
    Posts:
    22
    Here are some other things I've tried:
    - Different molecular configurations (just simple ones like triatomic for water).
    - Replacing the capsule colliders which encompass a pair of bonded atoms with a sphere per atom.
    - Changing the collision detection method.
    - Only adding a force once the molecule's speed gets close to zero (to prevent the molecules from stopping and going to sleep).

    None of these changes prevented the cyclone behavior. Additionally, I used debug line renders to better visualize the direction of the linear velocity of the molecules. As expected, the direction of the linear velocity of the molecules seems to maintain a shallow angle with respect to the planes of the walls.

    Only adding the force once the molecule's speed gets close to zero did help. I got noticeably more molecules passing through the void area in the center, but I alluded to before, the cyclone behavior continues.

    Anyone have any ideas?
     
  3. devPatrick

    devPatrick

    Joined:
    Sep 28, 2018
    Posts:
    22
    I've settled for the time being on a work around (hack) of using a sphere for collisions with the container and a capsule (per pair of bonded atoms) for collisions with other molecules. Obviously, this isn't great, though. I'd still like to figure out how to make capsule collisions with a cylindrical container work correctly.

    Anyone have any ideas?