void OPOrientationalOrder::ticker() { size_t count(0); ComplexNum sum(0,0); BOOST_FOREACH(const Particle& part, Sim->particleList) { Neighbours nbs; static_cast<const GNeighbourList*> (Sim->dynamics.getGlobals()[_nblistID].get()) ->getParticleNeighbourhood (part, magnet::function::MakeDelegate (&nbs, &Neighbours::addNeighbour)); if (nbs._neighbours.size() >= 6) { std::vector<MagVec> bonds; BOOST_FOREACH(const size_t& id2, nbs._neighbours) { Vector bond = Sim->particleList[id2].getPosition() - part.getPosition(); Sim->dynamics.BCs().applyBC(bond); bonds.push_back(bond); } std::sort(bonds.begin(), bonds.end()); if (bonds.size() > 6) bonds.erase(bonds.begin()+6, bonds.end()); //Normalise the vectors. BOOST_FOREACH(MagVec& vec, bonds) { vec /= vec.nrm(); double angle; if (vec[0] != 0) angle = atan(vec[1]/vec[0]); else if (vec[1] > 0) angle = M_PI / 2; else angle = - M_PI / 2; if (vec[0] < 0) angle += M_PI; sum += std::exp(ComplexNum(0, 6 * angle)); } ++count; }
ComplexNum operator/ (ComplexNum a, ComplexNum b) { ComplexNum temp = a * ComplexNumUtils::Conjugate(b); float bNormSq = b.GetReal() * b.GetReal() + b.GetImaginary() * b.GetImaginary(); return ComplexNum(temp.GetReal() / bNormSq, temp.GetImaginary() / bNormSq); }
ComplexNum operator* (ComplexNum a, ComplexNum b) { return ComplexNum((a.GetReal() * b.GetReal() - a.GetImaginary() * b.GetImaginary()), (a.GetReal() * b.GetImaginary() + a.GetImaginary() * b.GetReal())); }