Closed adhishm closed 11 years ago
The dislocation-defect interactions are to take place when a dislocation and another defect find each other within a radius defined as the interaction distance. The following interactions are possible:
What happens when a dislocation disappears? This concern is valid for any other defect, but let's focus on dislocations for now.
It is an easy matter to simply remove it from the std::vector<Defect*> SlipPlane::defects
using std::vector::erase
, but how to take care of the corresponding entries in the std::vector<Dislocation*> SlipPlane::dislocations
? The pointers in the vector defects
point to the memory locations of the dislocations and other defects, but how do we find the corresponding dislocation in the vector dislocations
?
Perhaps there is no need to remove them from the other vectors. They can be removed from the vector defects
and then once in a hundred iterations or so, the other vectors can be browsed to check for entities that do not exist in the main list defects
, and then they can be removed.
Even so, there is a problem. The list defects
is browsed using iterators in the function SlipPlane::checkLocalReactions
. Removing items from it will definitely mess up the iterator positions.
There is, however, the function SlipPlane::updateDefects
. If we use this, we could remove the dislocations from the vector dislocations
and simply call updateDefects
afterwards. But this still does not solve the problem of the iterator in checkLocalReactions
In order to solve the problem of the iterator, consider the following code as part of SlipPlane::checkLocalReactions
:
std::vector<Defect*>::iterator dit;
dit = this->defects.begin();
while ( dit != this.defects.end() ) {
d0 = *dit; p0 = d0->getPosition();
d1 = *(dit+1); p1 = d1->getPosition();
if ( (p1-p0).magnitude() <= reactionRadius ) {
dit = this->identifyLocalReaction(dit, dit+1);
}
else {
dit++;
}
}
Then the function identifyLocalReaction
should return one of the following:
dit
which was sent into it if there are no local reactions (no dislocations got annihilated)defects
.This iterator should be updated within the function according to the number of dislocations removed. The integrity of all vectors must be maintained.
So returning the iterator to the next defect to be considered seems to be a reasonable fix.
// Check for neighbouring defects that lie too close
dit = this->defects.begin();
while (dit != this->defects.end()) {
d0 = *dit;
d1 = *(dit + 1);
p0 = d0->getPosition();
p1 = d1->getPosition();
if ( (p1-p0).magnitude() <= reactionRadius ) {
// The two defects are close to each other - a local reaction is imminent
dit = this->identifyLocalReaction(dit, dit+1);
}
else {
// Nothing happens - defects too far away
dit++;
}
}
The trouble is elsewhere now. When there is an imminent reaction between two dislocations, we must check for their Burgers vectors being opposite before the annihilation event. But, with pointers of the type Defect*
, we obviously cannot call the function Dislocation::getBurgers()
. How to resolve this problem without having to search for the corresponding dislocation in SlipPlane::dislocations
?
The local interactions have been coded into the functions. The annihilation takes place when an appropriate reactionRadius
is used.
There is a bug now. The program enters an infinite loop when the dislocations are annihilated and there is nothing left to do.
The infinite loop problem has been solved. There were a couple of issues regarding re-ordering of the vectors (see #46 ) but these have been resolved as well.
Graph showing annihilation and pile-up of dislocations.
Interactions between dislocations and other defects need to be defined. For example: