Adding a new contact history Array to the liggghts code

Submitted by ldelcid on Sat, 09/13/2014 - 23:13

I have been trying to add a new plasticity contact model to the LIGGGHTS code. I have the formulation down but this model requires I keep track of the plastic deformation between particle-particle and particle-wall contacts. It should work similarly to the shearing array that is present in the code. However, I have been unable to add the array properly.

My first attempt was to add it to the contacthistory list of arrays but I was unsure how to append one more parameter to it. In my second attempt, I tried to create a plasticity array similarly to how contacthistory is created but I run into segmentation faults. Has anyone added a history parameter to any of the history contact models? What would be the best approach to tracking a parameter that needs to be set and cleared similarly to the shearing history?

Thank you for any suggestions,

-Liz

richti83's picture

richti83 | Mon, 09/15/2014 - 12:40

Have a look in normal_model_hooke_hysteresis.h, there is the "magic"

double * const shear = &cdata.contact_history[history_offset]; //pointer to dnum+1 element
double deltaMax = shear[0]; // the 4th value of the history array is deltaMax

in line 113,114ff
after that you can acces the dnum+1 shear-parameter with shear[0]

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

rberger's picture

rberger | Mon, 09/15/2014 - 18:15

In addition to what richti83 said:

It's important to first register the additional value in the constructor of your model. As can be seen in normal_model_hooke_hysteresis.h.
The function add_history_value will give you an offset which you can then use to access the additional double value as cdata.contact_history[offset].

offset = hsetup->add_history_value("VALUE_NAME", "1");

But you also need to make sure that the touch bitfield is set if you want to keep the values of the current contact. History values will be discarded if none of the models (normal, tangential, rolling, etc.) sets the touch flag of the current contact. So a normal model might do this:

if(cdata.touch) *cdata.touch |= TOUCH_NORMAL_MODEL;

When you no longer need the values you can remove them by unsetting the touch bit. E.g. in the noCollision method you could see this:

if(cdata.touch) *cdata.touch &= ~TOUCH_NORMAL_MODEL;

Final note: contact history values only exist while two contact partners are neighbors. Therefore the touch flag only controls how values are persisted during noCollission and collision events.

Cheers,
Richard

vinaym | Mon, 12/19/2016 - 14:29

Hello all,

I want to do something similar to what Liz asked. However, I just need one value of a particular attribute from the past contact. Based on what richi83 and richard said, I added following lines to tangential_model_history.h

history_offset_new = hsetup->add_history_value("shearnew", "1");

double * const shear_n = &sidata.contact_history[history_offset_new];

then i access old value via shear_n[0] and set the new one shear_n[0] = sidata.newvalue.

Is this all to be done to access/store old value?

Any help is highly appreciated. Thank you.

regards,

Vinay

aaigner's picture

aaigner | Mon, 01/16/2017 - 17:41

Hello Vinay,

from your code snippet, I would say: "Yes, that's all".

Just to mention it: Always be aware of that newton_flag in the function add_history_value(name, newton_flag). If it is enabled the value will change the sign in case of swapped neighbor order. (e.g. for contact particle i with j it will be +1; for j with i it will be -1)

Best regards,
Andreas