Exemplo n.º 1
0
void CollisionD2Q9LNP::collide() {
  updateNi();
  // cout<<"D2Q9 LNP collision"<<endl;
  // cout<<"pe:"<<Pe<<endl;
  double pref = (PHYS_E_CHARGE * z) / (PHYS_KB * T * Pe);
//    cout<<"pref: "<<pref<<endl;
//    cout<<"dPsiY: "<<dPsiy[1][lm->n.x/2]<<endl;
//    cout<<"dPsiX: "<<dPsix[1][lm->n.x/2]<<endl;
//    cout<<"RHS: "<<rhs[1][lm->n.x/2]<<endl;
//    cout<<"F_2: "<<f[0][1][lm->n.x/2][2]<<endl;
//    cout<<"d2psi = "<<dPsiy[2][lm->n.x/2] - dPsiy[1][lm->n.x/2]<<" = "<<
//            (rhs[1][lm->n.x/2] + rhs[2][lm->n.x/2])*0.5<<endl;
//    cout<<"pref*dpsiy: "<<-dPsiy[1][lm->n.x/2]*pref<<endl;
  for (int j = 0; j < n.y; j++) {
    for (int i = 0; i < n.x; i++) {
      // cout<<"i: "<<i<<endl;
      // cout<<"j: "<<j<<endl;
      // if(skip != NULL && skip[j][i]){continue;}
      for (int d = 0; d < 9; d++) {
        f[0][j][i][d] += w
            * (fEq(d, ux[j][i] - pref * dPsix[j][i],
                uy[j][i] - pref * dPsiy[j][i], ni[j][i]) - f[0][j][i][d])
            + W[d] * colPrefactor * ni[j][i] * rhs[j][i];
        // cout<<"orig f: "<<w*( fEq(d, ux[j][i] - pref*dPsix[j][i],
        //          uy[j][i] - pref*dPsiy[j][i],
        //          ni[j][i]) - f[0][j][i][d] )<<endl;
        //  cout<<"extra f: "<<W[d] * colPrefactor *ni[j][i] * rhs[j][i]<<endl;
        //   cout<<"RHS: "<<rhs[j][i]<<endl;
      }
    }
  }
  updateNi();

  double sum = 0;
  double sumCol = 0;
  for (int j = 0; j < lm->n.y; j++) {
    sumCol += ni[j][lm->n.x / 2];
    for (int i = 0; i < lm->n.x; i++) {
      sum += ni[j][1];
    }
  }

  cout << "SUM: " << sum << ", SUMCOL: " << sumCol << ", SUM/3: " << sum / 3.0
      << endl;

}
void CollisionD2Q9LNPSource::collide(){
    cout<<"D2Q9 LNP with source collision"<<endl;
    cout<<"pe:"<<Pe<<endl;
    for(int j = 0; j < n.y; j++){
        for(int i = 0; i < n.x; i++){
            for(int d = 0; d < 9; d++){
                f[0][j][i][d] += w*( fEq(d, ux[j][i], uy[j][i], ni[j][i]) - f[0][j][i][d] ) +
                                 W[d] * colPrefactor * rhs[j][i];
            }
        }
    }

    updateNi();
}
void CollisionD2Q9LNPSource::init(){
    cout<<"init LNP with source..."<<endl;
    double initConc = 0.0;
    ni = allocate2DArray(lm->n.y, lm->n.x);
    rhs = allocate2DArray(lm->n.y, lm->n.x);
    for(int j = 0; j < lm->n.y; j++){
        for(int i = 0; i < lm->n.x; i++){
            for(int d = 0; d < lm->UDIRS; d++){
                f[0][j][i][d] = fEq(d, 0, 0, j*j);
            }
        }
    }

    double colPrefactor = ( 1 - 0.5 * w );

    updateNi();
}