Nested if statement

Submitted by SHUBHAM AGARWAL on Wed, 12/30/2020 - 12:56

Hello
I am a new user of LIGGGHTS-flexible fiber version. My problem is similar to the shear tutorial. Its different in a sense that in my case I intend to make cross-linked fiber bonds. In order to avoid 'bond loss error', I am using a kinetic energy (KE) based logic, i.e if KE of all atoms is less than a certain thresold, we form the cross-links, otherwise NOT.
Following is the logical statement I am using:

%%
run ${relax_step} upto #post no
variable ke_tol2 equal 0.01*${ke_tol}*atoms
variable ke_tol3 equal 0.00000001*${ke_tol}*atoms
variable force_tol equal 0.95*${shear_force}
label begin_set_loop # Start of the loop
variable old_height equal ${zdisp}
run ${relax_step} #pre no post no # Run so many steps until we check the KE again
variable res equal abs(${old_height}-${zdisp})
if "${my_ke}<${ke_tol2} && ${res}<${res_tol} && ${zforc}>${force_tol}" then &
if "${my_ke}>${ke_tol3}" then "fix_modify bondcr2 every 0" &
"jump in.settle_particles end_set_loop" &
else &
if "${my_ke}<${ke_tol3}" then & "fix bondcr2 all bond/create/gran 1 1 1 ${bond_skin2} 2 50 #every itype jtype cutoff btype newperts" &
"jump in.settle_particles begin_set_loop" &
label end_set_loop # End of the loop
%%

It shows the error of "Illegal if command".
Can we write the nested if statements? Can you please suggest better logic in case we can't.

Thank you very much

AttachmentSize
Plain text icon in.settle_particles10.84 KB
Plain text icon in.insert_particles8.25 KB

SHUBHAM AGARWAL | Fri, 01/01/2021 - 01:03

Hi
Thanks for the link.
I have temporarily fixed the 'if' problem, however, I am still not able to form the cross link bonds. I am getting the error: Bond atoms 9670 5351 missing on proc 3 at step 100039

I have attached 2 codes in this thread. Please run "in.insert_particles" first, following with "in.settle_particles".
I have tried KE minimization and increase damping the system, but it is not helping. Can you please suggest something

Thanks
Shubham

mschramm | Fri, 01/01/2021 - 20:10

Hello,
Which commit are you using for the bond code?
The new version of the code does automatic bond formation when creating a multiplesphere template and setting bonded to yes. (Just something to look out for.)

The error you are getting about not finding particles is often due to either the time step being too large or a particle crossed the simulation domain, was deleted, but the bond was not deleted. For the later problem, the best I can say is try building a box around your particles so they cannot leave the system or modify neigh_bond.cpp and remove the error (I can't remember which line it is but LIGGGHTS will tell you where). I have done this in the past for some simulations but you cannot you any results that are near the simulation boarders. Ideally, the particle would not be deleted until all atoms are outside of the domain but I have not been able to find this part of the code.

If time step is the issue, try using non-linear damping (again, check your commit). check the enums in bond_gran.cpp (at the top), you should see either two options (linear or non-linear) or you should see more options with one of them being non-linear-rel (or something similar {I am away from my computer at the moment}). YuGuo/linear damping is version 1 while the others will just go up in number (so 2 or 5???). This is a highly experimental damping style but allows users to have large damping while maintaining a high time step.
With this option there are 3 damping values that will need to be given. For 99% of the cases, users will be able to give values as following
bond_coeff 1 ${bond_out_per} ${bond_in_per} ${bond_youngs_modulus} ${bond_shear_modulus} {2 or 5 please double check} 0.0 ${bond_damp_val} 0.0 1 1.0e32 1.0e32
where a value of 0.001 should do well in damping for ${bond_damp_val}.
This style can be very close to Yu Guo's original critical time step calculation. I would say to swap your time step calculation line to
variable dt equal 0.8/((1.2+3.0*${bond_damp_val})*$w)
and you should be fine.