Why use "+=" rather than "+" to change delta value of customer property
Dear guys
I have a question about getDelta when using getDelta() in the API. When I follow the "EDEM API Tutorial 5 - Relative Wear" and "Tutorial 7 - HM with Pressure Calculation", the doucment told me if I want to change the value of customer property I should assign the Delta a value. Then Delta is added to the Custom Property Value at the end of the time-step. But I don't understand why use "+=" rather than "=" to assign the Delta value. When use "+=", the New Delta is the sum of the current Delta and the historical Delta instead of the current Delta. Then the New Property Value = History Property Value + Current Delta +Historical Delta rather than New Property Value = History Property Value + Current Delta . I feel confussed. Please help me!
Best wishes
Zhou
Answers
-
Hi Zhou,
With Custom Properties it is always Value(t+1) = Value(t) + Delta(t)
Regardless of how it is summed the Value at the next time-step is always the result of the current value + the resultant Delta.
For Operators this is a useful link - https://cplusplus.com/doc/tutorial/operators/
The confusion potentially comes in that the Delta(t) can come from different sources, you can add a delta from a Body Force as well as a Contact Model, or from multiple sources inside 1 model.
It's up to how you write the code if you want to use += or = but this only affects the resultant Delta at time t, it doesn't influence how the calculation for the final Value is done. For example:
//code delta[0] += 10.0; //more code delta[0] = 1.0;
In the above the resultant Delta would be 1.0 as the second time we add to the delta we are overwriting any previous additions. However with:
//code delta[0] += 10.0; //more code delta[0] += 1.0;
We're adding 11 to the Value at this time-step.
I hope this helps.
Regards
Stephen
0