coin flip simulation

Submitted by mschramm on Sat, 02/03/2018 - 06:42

Hello,
I am wanting to get familiar with the new atom style and thought it would be fun to try and
simulate flipping coins. This is what I have so far.

Dimensions of a quarter (approx)
variable r1 equal 0.5*${coin_diam}
variable r2 equal 0.5*${coin_thik}
fix pts1 all particletemplate/superquadric 86028157 density constant 2500 shape constant ${r1} ${r1} ${r2} blockiness constant 10. 2.

I believe this creates a "coin" that is "face up" with a diameter of coin_diam and a thickness of coin_thik

My real question is how can I easily tell if the coin has landed "face up", "face down", or something else (a coin does have a thickness.......)?

I am printing the quaternions but I do not know enough to easily say what the coins end position was.

Any help would be appreciated.

mschramm | Sun, 02/04/2018 - 22:21

I am trying things and I am currently converting the quats to euler angles and checking the R33 entry to see if it is close to 1 or -1.
I then try to count the 1s by using the following after my run is finished.

# Calculate num heads, num tails, and num sides
variable Q2 atom quat2
variable Q3 atom quat3
variable R33 atom 1-2*(v_Q2^2+v_Q3^2)
variable R33gr09 atom v_R33>0.9
compute num_heads all reduce sum update_on_run_end yes v_R33gr09
variable num_heads equal c_num_heads
print num_heads=${num_heads}

This gives me an illegal compute.

Any help would be appreciated.

medvedeg | Tue, 02/06/2018 - 13:10

Hallo mschramm,

I am afraid but quaternion components most probably cannot be called from the input script file like positions (x), velocity (vx vy vz) or forces (fx fy fz). You can write a "compute" that does it.

Alexander Podlozhnyuk

mschramm | Tue, 02/06/2018 - 15:27

Hello,
Looking at the cpp file, it seems that quat can be printed if using ellipsoid particles.
I think I can modify it using what is in the dump custom cpp file.

As for everything else, am I using the quats correctly and creating the "coins" correctly?

Thank you

medvedeg | Wed, 02/07/2018 - 11:17

Hi,

superquadrics are implemented separately from ellipsoids (however you ca model ellipsoids as superquadrics).
In order to check if the coin is face up face down, you must calculate the rotation of the z-axis of the particle (0, 0, 1) and check if the z-component after rotation is close to 1 (face up) or close to -1 (face down). Quaternion components are available for writing in dump files. But, as I said, there is no access to this per atom structure inside the input script. You can extend variable.cpp file for this, look how it is implemented for velocities and forces. Quaternions can be accessed in the code by atom->quaternion[iAtom][iComponent]. Maybe it will become available in the future release.

Alexander Podlozhnyuk