Syrocco / Graphical-EDMD

Event Driven Molecular Dynamics Simulation
MIT License
5 stars 4 forks source link

Charged particles #2

Open Ceres90 opened 7 months ago

Ceres90 commented 7 months ago

Do you think this code could be modifed to include particles with different properties like charge, ie positive particles would stick if they touched negative particles , but repel or not stick to other positive particles?

Syrocco commented 7 months ago

Yes surely. But the interaction would need to be discontinuous. In EDMD.h, you can had a property to the type particle that would be the charge. Then, you could use the already implemented algorithm for square shoulder (U>0) and square well potential (U<0) to behave differently according to the type of the two particles colliding. If both particles have the same charge, you’d want to use the interaction with U > 0, otherwise, you’d use the interaction with U < 0.

Syrocco commented 7 months ago

I added a minimal charged particle example. You can look at the (before) last commit change to see what I did. You can also compile the new code. You have a new button: image alongside the % of charged particle (with the same charge, there're only + and - charges, with same absolute value of charge). You can control the attraction/repulsion strenght between different/same charges using U (-U and U are the same, only the absolute value of U matters). You can also display different charge in different color with the dropdown: image

This will create crystal like structures of alternating charge: image

Syrocco commented 7 months ago

That was a cool idea. At large interaction distance, you can obtain very nice patterns: image

In physics, this is called Frustration. You have geometrical constraint (here the volume and the number of particle are fixed) and the system tries to minimize its energy. Off course, every particles cannot have only the neighbors it would like to have, so it has to do some compromise. On top of that, these kind of systems are known to have a very slow dynamics (we call them Glasses) and do not manage to find the minimal energy state easily, so for a very very very long time, you only see a system that is in a local minimum of energy and not a global one.

Ceres90 commented 7 months ago

wow thanks for the quick response and change in code!!! this program could have really interesting biology applications with just a couple more additions . I work in a lab where we study nanoparticle interactions with various pathogens (viruses and bacteria) and we use zeta potential (which is the measure of the particles charge ) to predict interactions but we currently only perform wetlab experiements I saw your comment on youtube , what makes the neutral particle more difficult(just curious not trying to be a jerk) ? Would it be possible to have certain particles that follow the old interaction equation that didn;t include the charge rule? (i have no coding experience so maybe thats a dumb suggestion)

Ceres90 commented 7 months ago
idea

I attached a silly drawing to illustrate what would be a dream program , essentially each color has a denoted charge amount(-20,15, 4 ,-2 etc. or 0) and then you could see how the particles interact as time progresses. No idea if this is possible within the framework of your program or if this is a huge undertaking but figured I would put it out there since the program seems to be pretty powerful already. Thanks for all of this already!!!

Syrocco commented 7 months ago

image

I added neutral particles (see (before)last commit), grey-blue particles are neutral and free fly between the others. By hard I meant that to be done "nicely" it requires a bit of work. These types of simulations (event driven) really really like that all particles follow the same rules. Here, I made a particle neutral by simply asking for it to ignore a large chunk of code (or rule), but a lot of computations are still lost for "nothing"...

Yes, the drawing you show is more or less possible to simulate up to some issues:

Other than that, this should be pretty straightforward to do. Instead of relying on a global potential energy U, we could rely, for each interaction on a particle-particle one. That would for example be U_12 = charge particle 1 charge particle 2 mass particle 1 * mass particle 2 with a radius of interaction that depends on the radius of the particle for example (The interactions here, are square well and square shoulders, if you want to look it up, it might not be what you have in mind when you talk about an usual attractive or repulsive potential). If you have in mind a simple initial condition (that can be simply algorithmically described), I can give it a shot!

But for these kind of things, you would be better with LAMMPS (not "event driven" and slower (in single processor), but way more powerful and versatile) or DYNAMO if you want to stay close to the "event driven molecular dynamics" paradigm (that I think Bio people like a lot for proteins and stuff like that). Both of them give you total control over the program through a scripting language (well the scripting language of LAMMPS is a total absurdity, but it is the price to pay for such versatility). You don't really have a real time interface with these programs but they output files containing the positions of the particles, that you can then read with Ovito for example


Edit: I looked up at the Zeta potential and, according to the picture I saw, you indeed need a huge scale difference between the different particles. My program would really perform badly here (well less than 500 particles should be fine but you completely lost advantage of the blaziingly fast speed of the monodisperse algorithm)! Again, for this kind of things, LAMMPS would be the way to go!!

Ceres90 commented 7 months ago

I tried updating but im not seeing the neutral particles? does git fetch work?

Syrocco commented 7 months ago

Strange You don't see these two sliders (% of + particles and % of neutral particles) when clicking on charged? image

In addition to: image coloring by "charge"?

The commits seem to have worked well: image

Ceres90 commented 7 months ago
image
Ceres90 commented 7 months ago

i see color by charge , whats the right way to update the program? im using "git fetch", "git pull origin main" and it doesn't give me an error but something isn't working

Ceres90 commented 7 months ago
image
Syrocco commented 7 months ago

Ah that's very strange... you can try to do git stash and then pull again. Or create a new directory and do a new git clone in it. To start fresh?

Ceres90 commented 7 months ago

oh didn't realize I had to run "make" after updating!

Ceres90 commented 7 months ago

its working now

Syrocco commented 7 months ago

Cool

Ceres90 commented 7 months ago

To your earlier comments I may eventually try LAAMP but the learning curve is prohibitively high the fact that I can already play around with your program and that I can watch the results live is pretty nice, even if the results aren't going to be as accurate as LAAMP . If you are still willing to make changes (whenever you have the time to) I would probably still try this instead.