std::pair<bool, double> DynCompression::getOffcentreSpheresCollision(const double offset1, const double diameter1, const double offset2, const double diameter2, const Particle& p1, const Particle& p2, double t_max, double maxdist) const { #ifdef DYNAMO_DEBUG if (!hasOrientationData()) M_throw() << "Cannot use this function without orientational data"; if (!isUpToDate(p1)) M_throw() << "Particle1 " << p1.getID() << " is not up to date"; if (!isUpToDate(p2)) M_throw() << "Particle2 " << p2.getID() << " is not up to date"; #endif Vector r12 = p1.getPosition() - p2.getPosition(); Vector v12 = p1.getVelocity() - p2.getVelocity(); Sim->BCs->applyBC(r12, v12); const double limit_time_window = 1 / growthRate; std::pair<bool, double> retval = magnet::intersection::offcentre_growing_spheres(r12, v12, orientationData[p1.getID()].angularVelocity, orientationData[p2.getID()].angularVelocity, orientationData[p1.getID()].orientation * Quaternion::initialDirector() * offset1, orientationData[p2.getID()].orientation * Quaternion::initialDirector() * offset2, diameter1, diameter2, maxdist, std::min(limit_time_window, t_max), Sim->systemTime, growthRate); //Check if there's no collision reported but we've limited the interval if ((retval.second == HUGE_VAL) && (t_max > limit_time_window)) return std::pair<bool, double>(false, limit_time_window); //Otherwise return what was calculated return retval; }
double DynCompression::getPBCSentinelTime(const Particle& part, const double& lMax) const { #ifdef DYNAMO_DEBUG if (!isUpToDate(part)) M_throw() << "Particle is not up to date"; #endif Vector pos(part.getPosition()), vel(part.getVelocity()); Sim->BCs->applyBC(pos, vel); double retval = (0.5 * Sim->primaryCellSize[0] - lMax) / (fabs(vel[0]) + lMax * growthRate); for (size_t i(1); i < NDIM; ++i) { double tmp = (0.5 * Sim->primaryCellSize[i] - lMax) / (fabs(vel[0]) + lMax * growthRate); if (tmp < retval) retval = tmp; } return retval; }
QList<AutoUpdater::UpdateFileMeta> AutoUpdater::genUpdateDiff(QList<UpdateFileMeta> updateFlist) { QList<UpdateFileMeta> diff; for (UpdateFileMeta file : updateFlist) if (!isUpToDate(file)) diff += file; return diff; }
QList<UpdateFileMeta> genUpdateDiff(QList<UpdateFileMeta> updateFlist, Widget* w) { QList<UpdateFileMeta> diff; float progressDiff = 45; float progress = 5; for (UpdateFileMeta file : updateFlist) { if (!isUpToDate(file)) diff += file; progress += progressDiff / updateFlist.size(); w->setProgress(progress); } return diff; }
double DynGravity::getCylinderWallCollision(const Particle& part, const Vector& wallLoc, const Vector& wallNorm, const double& diameter) const { #ifdef DYNAMO_DEBUG if (!isUpToDate(part)) M_throw() << "Particle is not up to date"; #endif Vector rij = part.getPosition() - wallLoc, vij = part.getVelocity(); Sim->BCs->applyBC(rij, vij); return magnet::intersection::parabola_cylinder(rij, vij, g * part.testState(Particle::DYNAMIC), wallNorm, diameter); }
double DynGravity::getPBCSentinelTime(const Particle& part, const double& lMax) const { #ifdef DYNAMO_DEBUG if (!isUpToDate(part)) M_throw() << "Particle is not up to date"; #endif if (!part.testState(Particle::DYNAMIC)) return DynNewtonian::getPBCSentinelTime(part, lMax); Vector pos(part.getPosition()), vel(part.getVelocity()); Sim->BCs->applyBC(pos, vel); double retval = std::numeric_limits<float>::infinity(); for (size_t i(0); i < NDIM; ++i) if (g[i] == 0) { if (vel[i] != 0) { double tmp = (0.5 * Sim->primaryCellSize[i] - lMax) / fabs(vel[i]); if (tmp < retval) retval = tmp; } } else { try { std::pair<double, double> roots = magnet::math::quadraticEquation(0.5 * g[i], vel[i], 0.5 * Sim->primaryCellSize[i] - lMax); if (roots.first > 0) retval = std::min(retval, roots.first); if (roots.second > 0) retval = std::min(retval, roots.second); } catch (magnet::math::NoQuadraticRoots&) {} try { std::pair<double, double> roots = magnet::math::quadraticEquation(0.5 * g[i], vel[i], -(0.5 * Sim->primaryCellSize[i] - lMax)); if (roots.first > 0) retval = std::min(retval, roots.first); if (roots.second > 0) retval = std::min(retval, roots.second); } catch (magnet::math::NoQuadraticRoots&) {} } return retval; }
double DynGravity::getParabolaSentinelTime(const Particle& part) const { #ifdef DYNAMO_DEBUG if (!isUpToDate(part)) M_throw() << "Particle is not up to date"; #endif if (!part.testState(Particle::DYNAMIC)) return std::numeric_limits<float>::infinity(); //Particle is not dynamic (does not feel gravity) Vector pos(part.getPosition()), vel(part.getVelocity()); Sim->BCs->applyBC(pos, vel); //We return the time of the next turning point, per dimension double time = std::numeric_limits<float>::infinity(); for (size_t iDim(0); iDim < NDIM; ++iDim) if (g[iDim] != 0) { double tmpTime = - vel[iDim] / g[iDim]; if ((tmpTime > 0) && (tmpTime < time)) time = tmpTime; } return time; }