void LocalBrownianMotionWalker::generate(size_t timepos) { if (m_init) init(); size_t oldtimepos = translations.size(); if (timepos<oldtimepos) return; // don't generate anything if we already have it CartesianCoor3D oldtranslation(0,0,0); if (oldtimepos>0) { oldtranslation = translations[oldtimepos-1]; } for(size_t ti = oldtimepos; ti <= timepos; ++ti) { CartesianCoor3D newtrans; while(true) { double normran = (*p_mynormaldistribution)(); vector<double> sphereran = (*p_myspheredistribution)(); for(size_t i = 0; i < (m_sampling-1); ++i) { (*p_mynormaldistribution)(); (*p_myspheredistribution)(); } double displacement = m_displace * normran; newtrans = oldtranslation + displacement*CartesianCoor3D(sphereran[0],sphereran[1],sphereran[2]) ; if (newtrans.length()>m_radius) continue; else break; } translations[ti] = newtrans; oldtranslation = newtrans; } }
double ScatterFactors::compute_background(CartesianCoor3D q) { double efactor_sum = 0; double sf_sum=0; double ql = q.length(); for(size_t i = 0; i < p_selection->size(); ++i) { size_t atomID = p_sample->atoms[(*p_selection)[i]]; double sf = Database::Inst()->sfactors.get(atomID,ql); double k = m_kappas[(*p_selection)[i]]; double v = Database::Inst()->volumes.get(atomID); double efactor = Database::Inst()->exclusionfactors.get(atomID,k*v,ql); efactor_sum+=efactor; sf_sum+=sf; } return sf_sum/efactor_sum; }
void ScatterFactors::update(CartesianCoor3D q) { double background_sl = Params::Inst()->scattering.background.factor; for(size_t i = 0; i < p_selection->size(); ++i) { size_t atomID = p_sample->atoms[(*p_selection)[i]]; double ql = q.length(); double sf = Database::Inst()->sfactors.get(atomID,ql); // calculate effective scattering length: if (m_background) { double k = m_kappas[(*p_selection)[i]]; double v = Database::Inst()->volumes.get(atomID); double efactor = Database::Inst()->exclusionfactors.get(atomID,k*v,ql); sf = sf - background_sl*efactor; } factors[i] = sf; } }
FixedMotionWalker::FixedMotionWalker(double displace,CartesianCoor3D direction) { m_translate = displace*direction/direction.length(); }
LinearMotionWalker::LinearMotionWalker(double displace,long sampling, CartesianCoor3D direction) { m_translate = displace*sampling*direction/direction.length(); }
OscillationMotionWalker::OscillationMotionWalker(double displace,double frequency,long sampling, CartesianCoor3D direction) { m_translate = displace*direction/direction.length(); m_frequency = frequency; m_sampling = sampling; }