Example #1
0
int roulette(ANT * ant){
  WAY * way = ant->way;
  int nextNode;
  int num = ant->way->num;
  int S[N - num];
  int sizeOfS = N - num;
  double sum;

  for(int i = 0; i < sizeOfS; i++){
    int column = getColumn(ant, i);
    sum += pow(way->tau[i], alpha) * pow(eta(ant, num + 1, column), beta);
  }

  double ball = sum * Rand01();

  sum = 0;
  for(itn i = 0; i < sizeOfS; i++){
    sum += pow(way->tau[i], alpha) * pow(eta(ant, num + 1, column), beta);
    if(sum > ball){
      nextNode = i;
      break;
    }
  }
  return nextNode;
}
Example #2
0
bool Jet::isGood() const {
    // bool passesPt = pt() > 30; // Bristol original value
    bool passesPt = pt() > 35;  // 19.07.11 Chris's value
    bool passesEta = fabs(eta()) < 2.4;
    bool jetID = false;
    //if (usedAlgorithm == JetAlgorithm::ParticleFlow || usedAlgorithm == JetAlgorithm::PF2PAT) {
    if (usedAlgorithm == JetAlgorithm::CA08PF || usedAlgorithm == JetAlgorithm::PF2PAT) {
        bool passNOD = NOD() > 1;
        bool passCEF = CEF() < 0.99;
        bool passNHF = NHF() < 0.99;
        bool passNEF = NEF() < 0.99;
        bool passCHF = true;
        bool passNCH = true;
        if (fabs(eta()) < 2.4) {
            passCHF = CHF() > 0;
            passNCH = NCH() > 0;
        }
        jetID = passNOD && passCEF && passNHF && passNEF && passCHF && passNCH;
    }
    else{
        bool passesEMF = emf() > 0.01;
        bool passesN90Hits = n90Hits() > 1;
        bool passesFHPD = fHPD() < 0.98;
        jetID = passesEMF && passesN90Hits && passesFHPD;
    }
    return passesPt && passesEta && jetID;
}
Example #3
0
int roulette(ANT * ant){
  int nextNode;
  int S[N*N];//next nodes this ant can choose
  int sizeOfS;//sizeof S
  double sum;
  double *currentTau = tau[ant->x][ant->y*N + ant->z];
  double ball;//roulette ball
  sizeOfS = 0;
  for(int i = 0; i < N*N; i++){
    if(!ant->BD[i / N][i % N]){
      S[sizeOfS] = i;
      sizeOfS++;
    }
  }

  sum = 0;
  for(int i = 0; i < sizeOfS; i++){
    sum += pow(currentTau[S[i]] , alpha) + pow(eta(ant, S[i]) , beta);
  }

  ball = sum * Rand01();

  sum = 0;
  for(int i = 0; i < sizeOfS; i++){
    sum += pow(currentTau[S[i]] , alpha) + pow(eta(ant, S[i]) , beta);
    if(sum > ball) {
      nextNode = S[i];
      break;
    }
  }
  
  return nextNode;
}
Example #4
0
Vector adams()
{
  size_t numof_xs = get_numof_xs(h);
  Vector runge_ys = runge();
  Vector adams_ys;
  initVector(&adams_ys, numof_xs);
  for (size_t i = 0; i < adams_acc; ++i)
    append(&adams_ys, runge_ys.values[i]);
  disposeVector(&runge_ys);

  Vector etas;
  initVector(&etas, numof_xs);
  for (size_t i = 0; i < adams_acc; ++i)
    append(&etas, eta(i, adams_ys.values[i]));
  FiniteDiffTable table = createFiniteDiffTable(&etas);

  for (size_t k = 5; k < numof_xs; ++k) {
    double yk = adams_next_yk(adams_ys.values[k - 1], &table);
    append(&adams_ys, yk);
    append(&etas, eta(k, yk));
    disposeFiniteDiffTable(&table);
    table = createFiniteDiffTable(&etas);
  }

  printTable(&table, &adams_ys, stdout);
  disposeVector(&etas);
  disposeFiniteDiffTable(&table);
  return adams_ys;
}
Example #5
0
int main() {
  // _mm_setcsr (_mm_getcsr () | 0x8040);    // on Intel, treat denormals as zero for full speed
  
  {
    std::pair<double, double> res = fastmath::atan2r(-3.,4.);
    std::cout << res.first << " " << res.second << std::endl;
    std::cout << atan2(-3.,4.) << std::endl;
  }
  {
    std::pair<double, double> res = fastmath::etaphi(-3.,4.,5.);
    std::cout << res.first << " " << res.second << std::endl;
    std::cout << eta(-3.,4.,5.)  << " " << std::atan2(4.,-3.) << std::endl;
  }
  
  
  {
    std::pair<float, float> res = fastmath::atan2r(3.f,-4.f);
    std::cout << res.first << " " << res.second << std::endl;
    std::cout << atan2f(3.f,-4.f) << std::endl;
    
  }
  {
    std::pair<double, double> res = fastmath::etaphi(3.f,-4.f,-5.f);
    std::cout << res.first << " " << res.second << std::endl;
    std::cout << eta(3.f,-4.f,-5.f)   << " " << std::atan2(-4.f,3.f) << std::endl;
  }

 
 
  sampleSquare<float>();
  sampleSquare<double>();
  return 0;

}
Example #6
0
Type objective_function<Type>::operator() ()
{
  
  DATA_FACTOR(y); //categorical response vector
  DATA_INTEGER(S); //number of response categories
  DATA_MATRIX(X); // Fixed effects design matrix
  DATA_FACTOR(group);
  PARAMETER_VECTOR(b); // Fixed effects
  PARAMETER(logsigma);
  PARAMETER_VECTOR(tmpk); // kappa ( category thresholds)
  PARAMETER_VECTOR(u);    // Random effects
  Type sigma = exp(logsigma);
  vector<Type> alpha = tmpk;
  for(int s=1;s<tmpk.size();s++)
    alpha(s) = alpha(s-1) + exp(tmpk(s));
  Type ans=0;
  ans -= sum(dnorm(u,Type(0),Type(1),true));
  vector<Type> eta = X*b;
  for(int i=0; i<y.size(); i++){
    eta(i) += sigma*u(group(i));
    Type P;
    if(y(i)==(S-1)) P = 1.0; else P = Type(1)/(Type(1)+exp(-(alpha(y(i))-eta(i))));
    if(y(i)>0) P -= Type(1)/(Type(1)+exp(-(alpha(y(i)-1)-eta(i))));
    ans -= log(1.e-20+P);
  }
  
  return ans;
}
Example #7
0
void eval_T(double Tmin, double Tmax) 
{ alf_run=1; g = 1.; double res1, res2, res3, res4;

       if (!HTL) sprintf(fname, "out/data/eta(T), kappa=%.2f, Nf=%d.csv", kappa, Nf     );
  else if  (HTL) sprintf(fname, "out/data/eta(T), HTL, Nf=%d.csv", Nf                   );

  file = fopen(fname,"w+");

  fprintf(file,   "# GJ, eta w/ only 2->2 processes\n"                                            );
  fprintf(file,   "# Nf = %d, Lambda/Tc=%.3f\n",Nf,lambda                                         );

       if (!HTL) fprintf(file, "# screening: M_eff, kappa = %.3f\n", kappa                        );
  else if  (HTL) fprintf(file, "# screening: htl\n"                                               );

  fprintf(file,   "# 1-fnc basis (Legendre)\n"                                                    );
  fprintf(file,   "# MC samples, %d\n",(int) calls                                                );
  fprintf(file,   "#\n"                                                                           );
  fprintf(file,   "# T,       eta/T^3\n"                                                          );

  printf("\n [ Nf = %d ] \n", Nf );
  printf("  -------------------------------------------------------\n" );
  printf("  : T/lambda :    rel err    :   chisq/dof  :  eta/T^3  :\n" );
  printf("  -------------------------------------------------------\n" );
  for(int i=0; i<points; i++) {
    Temp = Tmin + (Tmax-Tmin)*( ((double) i)/((double) points) );
    printf("  :  %-1.4f  :", Temp/lambda);                       fprintf(file, "%.8f", Temp/lambda);
    J = .0;  res4 = eta()/pow(Temp,3);
    J = .5;  res3 = eta()/pow(Temp,3);
    J = 2.;  res2 = eta()/pow(Temp,3);
    J = 1.;  res1 = eta()/pow(Temp,3);
    printf("  %-1.3e  :\n",res1);            fprintf(file, ", %g, %g, %g, %g\n", res1, res2, res3, res4);
  }
  printf("  -------------------------------------------------------\n" );
  fclose(file);
}
Example #8
0
void eval_g(double gmin, double gmax) 
{ alf_run=0; Temp = 1.; double res1, res2, res3, res4;

       if (!HTL) sprintf(fname, "out/data/eta(g), M_eff, (kappa=%.2f) Nf=%d.csv", kappa, Nf    );
  else if  (HTL) sprintf(fname, "out/data/eta(g), HTL, Nf=%d.csv", Nf                           );

  file = fopen(fname,"w+");

  fprintf(file,   "# GJ, eta w/ only 2->2 processes\n"                                            );
  fprintf(file,   "# Nf = %d, Lambda/Tc=%.3f\n",Nf,lambda                                         );

       if (!HTL) fprintf(file, "# screening: M_eff, kappa = %.3f\n", kappa                        );
  else if  (HTL) fprintf(file, "# screening: htl\n"                                               );

  fprintf(file,   "# 1-fnc basis (Legendre)\n"                                                    );
  fprintf(file,   "# MC samples, %d\n",(int) calls                                                );
  fprintf(file,   "#\n"                                                                           );
  fprintf(file,   "# g,      eta/T^3, lower, upper, omni \n"                                            );

  printf("\n [ Nf = %d ] \n", Nf );
  printf("  ---------------------------------------------------------\n" );
  printf("  :    g       :    rel err    :   chisq/dof  :  eta/T^3  :\n" );
  printf("  ---------------------------------------------------------\n" );
  for(int i=0; i<points; i++) {
    g = gmax*pow(10., -(points -1 - i)*( log(gmax/gmin)/log(10.))/((double) points - 1));
    printf("  :  %03.5f   :", g);                                           fprintf(file, "%.8f",g);
    J = .0;  res4 = eta()/pow(Temp,3);
    J = .5;  res3 = eta()/pow(Temp,3);
    J = 2.;  res2 = eta()/pow(Temp,3);
    J = 1.;  res1 = eta()/pow(Temp,3);
    printf("  %-1.1e  :\n",res1);            fprintf(file, ", %g, %g, %g, %g\n", res1, res2, res3, res4);
  }
  printf("  ---------------------------------------------------------\n" );
  fclose(file);
}
Example #9
0
  void NgammaT::scaleSimBox(){
    Mat3x3d scaleMat;

    scaleMat(0, 0) = exp(dt*eta(0, 0));
    scaleMat(1, 1) = exp(dt*eta(1, 1));    
    scaleMat(2, 2) = exp(dt*eta(2, 2));
    Mat3x3d hmat = snap->getHmat();
    hmat = hmat *scaleMat;
    snap->setHmat(hmat);

  }
Example #10
0
 void NgammaT::evolveEtaB() {
   Mat3x3d hmat = snap->getHmat();
   RealType hz = hmat(2, 2);
   RealType Axy = hmat(0,0) * hmat(1, 1);
   prevEta = eta;
   RealType sx = -hz * (press(0, 0) - targetPressure/PhysicalConstants::pressureConvert);
   RealType sy = -hz * (press(1, 1) - targetPressure/PhysicalConstants::pressureConvert);
   eta(0,0) = oldEta(0, 0) - dt2 * Axy * (sx -surfaceTension) / (NkBT*tb2);
   eta(1,1) = oldEta(1, 1) - dt2 * Axy * (sy -surfaceTension) / (NkBT*tb2);
   eta(2,2) = 0.0;
 }
Example #11
0
int main() {
	int i;
	int n = 5;
	ez::ezETAProgressBar eta(n);

	eta.start();
	for(i=0; i <= n; ++i, ++eta) {
	#ifdef WIN32
		Sleep(1000);
	#else
		usleep(500000);
	#endif
	}

	n = 99999;
	//eta.n = n;
	eta.reset(n);
	eta.start();
	for(i=0; i <= 15; ++i, ++eta) {
	#ifdef WIN32
		Sleep(1000);
	#else
		sleep(1);
	#endif
	}

	return 0;
}
Example #12
0
void CurrentElem<real_num_mov>::PrintOrientation() const {
  
      const uint mesh_dim = _mesh.get_dim();
      const uint el_nnodes   = _el_conn.size();

       std::vector<double>   xi(mesh_dim,0.);
       std::vector<double>  eta(mesh_dim,0.);
       std::vector<double> zeta(mesh_dim,0.);  //TODO this should only be instantiated  in the 3D case, in any case we avoid USING IT 

      for (uint idim=0; idim< mesh_dim; idim++) {
                              xi[idim] = _xx_nds[1+idim*el_nnodes]-_xx_nds[0+idim*el_nnodes]; //1-0 xi axis
                             eta[idim] = _xx_nds[3+idim*el_nnodes]-_xx_nds[0+idim*el_nnodes]; //3-0 eta axis
        if ( mesh_dim == 3 )   zeta[idim] = _xx_nds[4+idim*el_nnodes]-_xx_nds[0+idim*el_nnodes]; //4-0 zeta axis

     }

     std::cout << "asse xi   ";
       for (uint idim=0; idim< mesh_dim; idim++)  std::cout << xi[idim] << " ";
      std::cout <<std::endl;
     std::cout << "asse eta  ";
       for (uint idim=0; idim< mesh_dim; idim++)  std::cout << eta[idim] << " ";
      std::cout <<std::endl;
      if ( mesh_dim == 3 )  {
     std::cout << "asse zeta ";
       for (uint idim=0; idim< mesh_dim; idim++)  std::cout << zeta[idim] << " ";
      std::cout <<std::endl;
      }

      
      
      return; 
    }
Example #13
0
double get_einstein_rotational_diffusion_coefficient(double r) {
  MillipascalSecond e=eta(IMP::internal::DEFAULT_TEMPERATURE);
  //double kt= get_kt(IMP::internal::DEFAULT_TEMPERATURE);
  unit::PerFemtosecond ret=kt(IMP::internal::DEFAULT_TEMPERATURE)
      /(8*PI*e*square(unit::Angstrom(r))*unit::Angstrom(r));
  return ret.get_value();
}
Example #14
0
    arma::mat CartesianDMPLearner::computeFitY(arma::vec& time, arma::mat &y, arma::mat &dy, arma::mat &ddy, arma::vec& vec_g) {

        // position
        mat retMat(y.n_cols - 1, y.n_rows);

        for(int i = 0; i < y.n_rows; ++i) {

            for(int j = 0; j < 3; ++j) {

                double yVal = y(i, j);
                double dyVal = dy(i, j);
                double ddyVal = ddy(i, j);
                retMat(j, i) = /*1 / (vec_g(j) - y(0, j)) */ tau * tau * ddyVal - az * (bz * (vec_g(j) - yVal) - tau * dyVal);

            }

        }

        // orientation
        arma::mat omega(y.n_rows, 3);
        arma::mat domega;
        arma::mat eta;
        arma::mat deta;

        for (int j = 0; j < y.n_rows - 1; ++j) {

            vec logL= log(tf::Quaternion(y(j + 1, 3), y(j + 1,  4), y(j + 1, 5), y(j + 1, 6)) * tf::Quaternion(y(j, 3), y(j, 4), y(j, 5), y(j, 6)).inverse());

            for (int i = 0; i < 3; i++)
                omega(j, i) = 2 * logL(i) / (time(1)-time(0));

            if (j == y.n_rows - 2)
                for (int i = 0; i < 3; i++)
                    omega(y.n_rows - 1, i) = 2 * logL(i) / (time(1)-time(0));

        }

        for(int i = 0; i < 3 ; ++i) {

            vec trajectory = omega.col(i);
            vec domegaV = computeDiscreteDerivatives(time, trajectory);
            domega = join_rows(domega, domegaV);

        }


        eta = tau * omega;
        deta = tau * domega;

        for (int i = 0; i < y.n_rows; ++i) {

            vec logL = log(tf::Quaternion(vec_g(3), vec_g(4), vec_g(5), vec_g(6)) * tf::Quaternion(y(i, 3), y(i, 4), y(i, 5), y(i, 6)).inverse());
            for (int j = 3; j < retMat.n_rows; ++j)
                retMat(j, i) = tau * deta (i, j - 3) - az * (bz * 2 * logL(j - 3) - eta(i, j - 3));

        }

        return retMat;

    }
Example #15
0
void IsoMuonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup){
  auto mu_pt = make_auto(new std::vector<float>);
  auto mu_phi = make_auto(new std::vector<float>);
  auto mu_eta = make_auto(new std::vector<float>);
  auto mu_iso = make_auto(new std::vector<float>);
  
  edm::Handle<edm::ValueMap<double> > iso_handle;
  edm::Handle<std::vector<reco::RecoChargedCandidate> > muon_handle;
  iEvent.getByToken(iso_token_, iso_handle);
  iEvent.getByToken(cand_token_, muon_handle);
  
  for(auto it = iso_handle->begin(); it != iso_handle->end(); ++it){
    for(auto ite = it.begin(); ite != it.end(); ++ite){
      mu_iso->push_back(*ite);
    }
  }
  
  for(auto it = muon_handle->begin(); it != muon_handle->end(); ++it){
    mu_pt->push_back(it->pt());
    mu_phi->push_back(it->phi());
    mu_eta->push_back(it->eta());
  }

  iEvent.put(mu_pt, "mupt");
  iEvent.put(mu_phi, "muphi");
  iEvent.put(mu_eta, "mueta");
  iEvent.put(mu_iso, "muiso");
}
Example #16
0
// computes Btransposed*eta for the given Gauss point
// (where eta is the derivative of cum. plastic strain wrt final strain)
void
RankineMatNl :: giveRemoteNonlocalStiffnessContribution(GaussPoint *gp, IntArray &rloc, const UnknownNumberingScheme &s,
                                                        FloatArray &rcontrib, TimeStep *atTime)
{
    RankineMatNlStatus *status = ( RankineMatNlStatus * ) this->giveStatus(gp);
    StructuralElement *elem = ( StructuralElement * )( gp->giveElement() );
    elem->giveLocationArray(rloc, EID_MomentumBalance, s);
    FloatMatrix b;
    elem->computeBmatrixAt(gp, b);
    int ncols = b.giveNumberOfColumns();
    rcontrib.resize(ncols);

    double kappa = status->giveCumulativePlasticStrain();
    double tempKappa = status->giveTempCumulativePlasticStrain();
    if ( tempKappa <= kappa ) {
        rcontrib.zero();
        return;
    }

    int i, j;
    double sum;
    int nsize = 3;
    FloatArray eta(3);
    computeEta(eta, status);
    for ( i = 1; i <= ncols; i++ ) {
        sum = 0.;
        for ( j = 1; j <= nsize; j++ ) {
            sum += eta.at(j) * b.at(j, i);
        }

        rcontrib.at(i) = sum;
    }
}
Example #17
0
double get_einstein_diffusion_coefficient(double r) {
  MillipascalSecond e = eta(IMP::internal::DEFAULT_TEMPERATURE);
  unit::SquareAngstromPerFemtosecond ret(
      kt(IMP::internal::DEFAULT_TEMPERATURE) /
      (6.0 * PI * e * unit::Angstrom(r)));
  return ret.get_value();
}
TEST_F(OverlapGTest, testHashingOverlapperForCorrectness) {
	count n = 4;
	Graph G(n);

	Partition zeta(n);
	Partition eta(n);

	zeta.setUpperBound(2);
	zeta[0] = 0;
	zeta[1] = 0;
	zeta[2] = 1;
	zeta[3] = 1;

	eta.setUpperBound(2);
	eta[0] = 0;
	eta[1] = 1;
	eta[2] = 0;
	eta[3] = 1;

	std::vector<Partition> clusterings = {zeta, eta};
	HashingOverlapper overlapper;
	Partition overlap = overlapper.run(G, clusterings);

	INFO("overlap clustering number of clusters: ", overlap.numberOfSubsets());
	INFO("overlap clustering: ", overlap.getVector());
}
Example #19
0
    void write_transformed_weak_form(EquationArray const & weak_form,
                                    latex_logger<InterfaceType> & log)
    {
      // Restriction to the discrete space
      log << "\\section{Discrete Approximation by Finite Elements}\n";
      log << "The discrete approximation to the continuous problem is obtained by a Galerkin approach:\n";
      log << "\\begin{align}\n";
      log << " u_h = \\sum_j \\alpha_j \\varphi_j  \n";
      log << "\\end{align}\n";
      log << "with trial functions $\\varphi_j$.\n";
      //log << "Thus, instead of solving for the continuous function $u$, only the coefficients $\\alpha_i$ need to be computed.\n";
      log << "In a Galerkin approach, test functions $v$ are also chosen from a finite-dimensional space:\n";
      log << "\\begin{align}\n";
      log << " v_h = \\sum_i \\beta_i \\psi_i  \n";
      log << "\\end{align}\n";
      log << "Due to integral transformations, it is sufficient to define the trial and test functions on the reference cell.\n";
      log << "After transformation to the reference cell, the weak form on a cell reads\n";

      // give new name to local variables:
      viennamath::variable xi(0);
      viennamath::variable eta(1);
      viennamath::variable nu(2);

      log.translator().customize(xi, "\\xi");
      log.translator().customize(eta, "\\eta");
      log.translator().customize(nu, "\\nu");

      viennamath::function_symbol u0(0, viennamath::unknown_tag<>());
      viennamath::function_symbol u1(1, viennamath::unknown_tag<>());
      viennamath::function_symbol u2(2, viennamath::unknown_tag<>());

      viennamath::function_symbol v0(0, viennamath::test_tag<>());
      viennamath::function_symbol v1(1, viennamath::test_tag<>());
      viennamath::function_symbol v2(2, viennamath::test_tag<>());

      log.translator().customize(u0, "\\tilde{u}_0");
      log.translator().customize(u1, "\\tilde{u}_1");
      log.translator().customize(u2, "\\tilde{u}_2");

      log.translator().customize(v0, "\\tilde{v}_0");
      log.translator().customize(v1, "\\tilde{v}_1");
      log.translator().customize(v2, "\\tilde{v}_2");

      // [JW] switched to $ math expressions, otherwise the equation is cut
      // off at the right page border ...
      //
      //log << "\\begin{align}\n";
      log << "\\newline\\newline$\n";
      for (typename EquationArray::const_iterator it = weak_form.begin();
                                                  it != weak_form.end();
                                                ++it)
        log << log.translator()(*it) << " \\  . \n";
      //log << "\\end{align}\n";
      log << "$\\newline\\newline\n";


      //
      //log << "write transformed weak form\n";
    }
Example #20
0
float controller(const struct Robot *r, const struct Step steps[],
                 int numOfSteps,        float t)
{
  float _c1d = c1d(steps, numOfSteps, r, t);
  float _eta = eta(steps, numOfSteps, r, t);
  float p = _c1d + _eta;
  return p;
}
Example #21
0
File: ex15.c Project: Kun-Qu/petsc
/*
   FormFunctionLocal - Evaluates nonlinear function, F(x).
 */
static PetscErrorCode FormFunctionLocal(DMDALocalInfo *info,PetscScalar **x,PetscScalar **f,AppCtx *user)
{
  PetscReal      hx,hy,dhx,dhy,sc,source;
  PetscInt       i,j;

  PetscFunctionBegin;
  hx     = 1.0/(PetscReal)(info->mx-1);
  hy     = 1.0/(PetscReal)(info->my-1);
  sc     = hx*hy*user->lambda;
  source = hx*hy*user->source;
  dhx    = 1/hx;
  dhy    = 1/hy;
  /*
     Compute function over the locally owned part of the grid
  */
  for (j=info->ys; j<info->ys+info->ym; j++) {
    for (i=info->xs; i<info->xs+info->xm; i++) {
      if (i == 0 || j == 0 || i == info->mx-1 || j == info->my-1) {
        f[j][i] = x[j][i];
      } else {
        const PetscScalar
          u = x[j][i],
          ux_E = dhx*(x[j][i+1]-x[j][i]),
          uy_E = 0.25*dhy*(x[j+1][i]+x[j+1][i+1]-x[j-1][i]-x[j-1][i+1]),
          ux_W = dhx*(x[j][i]-x[j][i-1]),
          uy_W = 0.25*dhy*(x[j+1][i-1]+x[j+1][i]-x[j-1][i-1]-x[j-1][i]),
          ux_N = 0.25*dhx*(x[j][i+1]+x[j+1][i+1]-x[j][i-1]-x[j+1][i-1]),
          uy_N = dhy*(x[j+1][i]-x[j][i]),
          ux_S = 0.25*dhx*(x[j-1][i+1]+x[j][i+1]-x[j-1][i-1]-x[j][i-1]),
          uy_S = dhy*(x[j][i]-x[j-1][i]),
          e_E = eta(user,ux_E,uy_E),
          e_W = eta(user,ux_W,uy_W),
          e_N = eta(user,ux_N,uy_N),
          e_S = eta(user,ux_S,uy_S),
          uxx = -hy * (e_E*ux_E - e_W*ux_W),
          uyy = -hx * (e_N*uy_N - e_S*uy_S);
        /** For p=2, these terms decay to:
        * uxx = (2.0*u - x[j][i-1] - x[j][i+1])*hydhx
        * uyy = (2.0*u - x[j-1][i] - x[j+1][i])*hxdhy
        **/
        f[j][i] = uxx + uyy - sc*PetscExpScalar(u) - source;
      }
    }
  }
  PetscFunctionReturn(0);
}
Example #22
0
TArrayD MinimalEvent::Eta() const {
  TArrayD eta(particles);
  for (size_t i = 0; i != particles; ++i){
    double P = sqrt(pow(px[i],2) + pow(py[i],2) + pow(pz[i],2));
    eta.AddAt(0.5*log( (P+pz[i])/(P-pz[i])), i);
  }
  return eta;
}
Example #23
0
  void NgammaT::calcVelScale(){

    for (int i = 0; i < 3; i++ ) {
      for (int j = 0; j < 3; j++ ) {
	vScale(i, j) = eta(i, j);

	if (i == j) {
	  vScale(i, j) += thermostat.first;
	}
      }
    }
  }
Example #24
0
scalar irregular::eta
(
    const point& x,
    const scalar& time
) const
{
    scalar eta(0);

    forAll (amp_, index)
    {
        scalar arg = omega_[index]*time - (k_[index] & x) + phi_[index];
        eta += amp_[index]*Foam::cos(arg);
    }
Example #25
0
  bool NgammaT::etaConverged() {
    int i;
    RealType diffEta, sumEta;

    sumEta = 0;
    for(i = 0; i < 3; i++) {
      sumEta += pow(prevEta(i, i) - eta(i, i), 2);
    }
    
    diffEta = sqrt( sumEta / 3.0 );

    return ( diffEta <= etaTolerance );
  }
Example #26
0
    inline Vec3f eval(const SurfaceScatterEvent &event, bool adjoint) const
    {
        Vec3f f = eval(event);

        if (adjoint)
            f *= std::abs(
                 (event.frame.toGlobal(event.wo).dot(event.info->Ng)*event.wi.z())/
                 (event.frame.toGlobal(event.wi).dot(event.info->Ng)*event.wo.z())); // TODO: Optimize
        else
            f *= sqr(eta(event));

        return f;
    }
Example #27
0
static ex eta_series(const ex & x, const ex & y,
                     const relational & rel,
                     int order,
                     unsigned options)
{
	const ex x_pt = x.subs(rel, subs_options::no_pattern);
	const ex y_pt = y.subs(rel, subs_options::no_pattern);
	if ((x_pt.info(info_flags::numeric) && x_pt.info(info_flags::negative)) ||
	    (y_pt.info(info_flags::numeric) && y_pt.info(info_flags::negative)) ||
	    ((x_pt*y_pt).info(info_flags::numeric) && (x_pt*y_pt).info(info_flags::negative)))
			throw (std::domain_error("eta_series(): on discontinuity"));
	epvector seq { expair(eta(x_pt,y_pt), _ex0) };
	return pseries(rel, std::move(seq));
}
Example #28
0
    inline bool sample(SurfaceScatterEvent &event, bool adjoint) const
    {
        if (!sample(event))
            return false;

        if (adjoint)
            event.weight *= std::abs(
                (event.frame.toGlobal(event.wo).dot(event.info->Ng)*event.wi.z())/
                (event.frame.toGlobal(event.wi).dot(event.info->Ng)*event.wo.z())); // TODO: Optimize
        else
            event.weight *= sqr(eta(event));

        return true;
    }
Example #29
0
string Particle::toString() const {
	stringstream out;
	out << "Particle information" << "\n";
	out << setw(30) << "energy" << setw(30) << "px" << setw(30) << "py" << setw(30) << "pz" << "\n";
	out << setw(30) << energy() << setw(30) << px() << setw(30) << py() << setw(30) << pz() << "\n";
	out << setw(30) << "phi" << setw(30) << "eta" << setw(30) << "theta" << setw(30) << "  " << "\n";
	out << setw(30) << phi() << setw(30) << eta()  << setw(30) << theta() << setw(30) << " " << "\n";
	out << setw(30) << "momentum" << setw(30) << "E_T" << setw(30) << "p_T" << setw(30) << "  " << "\n";
	out << setw(30) << momentum() << setw(30) << et() << setw(30) << pt() << setw(30) << "  " << "\n";
	out << setw(30) << "m_dyn" << setw(30) << "m_fix" << setw(30) << "charge" << setw(30) << "  " << "\n";
	out << setw(30) << massFromEnergyAndMomentum() << setw(30) <<  mass() << setw(30) << charge() << setw(30) << "  " << "\n";
	out << setw(30) << "d0 =" << setw(30) << "d0_bs" << setw(30) << "  " << setw(30) << "  " << "\n";
	out << setw(30) << d0() << setw(30) << d0_wrtBeamSpot() << setw(30) << "  " << setw(30) << "  " << "\n";
	return out.str();
}
Foam::backwardDiffusionFvPatchScalarField::backwardDiffusionFvPatchScalarField
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF
)
:
    mixedUserDefinedFvPatchScalarField(p, iF)
{
	alfa()    = 0.0;
	beta()    = 0.0;
        eta()     = 0.0;
	omega0()  = 0.0;
	rho0()    = 0.0;
        epsilon() = 0.0;
        nameInternal_ = dimensionedInternalField().name();
}