void set_parameter (string_ref name, double value) { if (! (value > 0.)) rt_error ("Invalid " + name + " value"); if (name == "temperature") inv_temperature = 1./value; else if (name == "inv_temperature") inv_temperature = value; else if (name == "cutoff") cutoff = value; else if (name == "gauss_epsilon") gauss_epsilon = value; else if (name == "gauss_r0") gauss_r0 = value; else if (name == "gauss_sigma_sq") gauss_sigma_sq = value; else rt_error ("Invalid parameter: " + name); if (gauss_r0 < LJ_MINIMUM || cutoff < gauss_r0) std::cerr << "Code is not correct in this regime" << ABORT; // precompute some interesting quantities lj_at_cutoff = evaluate_lj (sq (cutoff)); pref_g = -.5 / gauss_sigma_sq; g_at_cutoff = evaluate_g (sq (cutoff)); g_at_origin = evaluate_g (sq (0.)); }
double random_attractive_lift_g (double rsq, RandomContext *random) { rsq = fmax (rsq, sq (gauss_r0)); // add thermal energy increase on current interaction energy double e_now = evaluate_g (rsq); double e_star = random->exponential (inv_temperature); double e_evt = e_now + e_star; if (e_evt >= g_at_cutoff) { // thermal energy too large, particle escapes to infinity return ESCAPES_TO_INFINITY (); } else { // invert the Gauss, picking the solution in attractive region double r_evt = gauss_r0 + sqrt (log (e_evt / (-gauss_epsilon)) / pref_g); return sq (r_evt); } }
double random_repulsive_lift_g (double rsq, RandomContext *random) { rsq = fmin (rsq, sq (gauss_r0)); // add thermal energy increase on current interaction energy double e_now = evaluate_g (rsq); double e_star = random->exponential (inv_temperature); double e_evt = e_now + e_star; if (e_evt >= g_at_origin) { // no event (thermal energy large enough) return -rsq; } else { // invert the Gauss, picking the solution in repulsive region double r_evt = gauss_r0 - sqrt (log (e_evt / (-gauss_epsilon)) / pref_g); assert (r_evt > 0.); return sq (r_evt); } }
DBL Superellipsoid::evaluate_superellipsoid(const Vector3d& P) const { return evaluate_g(evaluate_g(fabs(P[X]), fabs(P[Y]), Power[X]), fabs(P[Z]), Power[Z]) - 1; }