void Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
updateCoeffs()
{
    if (updated())
    {
        return;
    }

    flowRate() = timeSeries_(this->db().time().timeOutputValue());
    flowRateInletVelocityFvPatchVectorField::updateCoeffs();
}
double ChromoConditions::dV() const
{
    if (mDV == 0.0)
    {
        return flowRate() / 20.0;
    }
    else
    {
        return mDV;
    }
}
Exemplo n.º 3
0
void ViscosityFO<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  double a = 1.0;  
  switch (visc_type) {
    case CONSTANT: 
      for (std::size_t cell=0; cell < workset.numCells; ++cell) {
        for (std::size_t qp=0; qp < numQPs; ++qp) 
          mu(cell,qp) = 1.0; 
      }
      break; 
    case EXPTRIG:  
      for (std::size_t cell=0; cell < workset.numCells; ++cell) {
        for (std::size_t qp=0; qp < numQPs; ++qp) {
          MeshScalarT x = coordVec(cell,qp,0);
          MeshScalarT y2pi = 2.0*pi*coordVec(cell,qp,1);
          MeshScalarT muargt = (a*a + 4.0*pi*pi - 2.0*pi*a)*sin(y2pi)*sin(y2pi) + 1.0/4.0*(2.0*pi+a)*(2.0*pi+a)*cos(y2pi)*cos(y2pi); 
          muargt = sqrt(muargt)*exp(a*x);  
          mu(cell,qp) = 1.0/2.0*pow(A, -1.0/n)*pow(muargt, 1.0/n - 1.0); 
        }
      }
      break; 
    case GLENSLAW: 
      std::vector<ScalarT> flowFactorVec; //create vector of the flow factor A at each cell 
      flowFactorVec.resize(workset.numCells);
      switch (flowRate_type) {
        case UNIFORM: 
          for (std::size_t cell=0; cell < workset.numCells; ++cell) 
            flowFactorVec[cell] = 1.0/2.0*pow(A, -1.0/n);
          break; 
        case TEMPERATUREBASED:
          for (std::size_t cell=0; cell < workset.numCells; ++cell) 
	    flowFactorVec[cell] = 1.0/2.0*pow(flowRate(temperature(cell)), -1.0/n);
          break;
        case FROMFILE:
        case FROMCISM: 
          for (std::size_t cell=0; cell < workset.numCells; ++cell)  
	    flowFactorVec[cell] = 1.0/2.0*pow(flowFactorA(cell), -1.0/n);
          break;
      }
      double power = 0.5*(1.0/n - 1.0);
      if (homotopyParam == 0.0) { //set constant viscosity
        for (std::size_t cell=0; cell < workset.numCells; ++cell) {
          for (std::size_t qp=0; qp < numQPs; ++qp) {
            mu(cell,qp) = flowFactorVec[cell]; 
          }
        }
      }
      else { //set Glen's law viscosity with regularization specified by homotopyParam
        ScalarT ff = pow(10.0, -10.0*homotopyParam);
        ScalarT epsilonEqpSq = 0.0; //used to define the viscosity in non-linear Stokes 
        for (std::size_t cell=0; cell < workset.numCells; ++cell) {
          for (std::size_t qp=0; qp < numQPs; ++qp) {
            //evaluate non-linear viscosity, given by Glen's law, at quadrature points
            ScalarT& u00 = Ugrad(cell,qp,0,0); //epsilon_xx
            ScalarT& u11 = Ugrad(cell,qp,1,1); //epsilon_yy
            epsilonEqpSq = u00*u00 + u11*u11 + u00*u11; //epsilon_xx^2 + epsilon_yy^2 + epsilon_xx*epsilon_yy
            epsilonEqpSq += 0.25*(Ugrad(cell,qp,0,1) + Ugrad(cell,qp,1,0))*(Ugrad(cell,qp,0,1) + Ugrad(cell,qp,1,0)); //+0.25*epsilon_xy^2
            for (int dim = 2; dim < numDims; ++dim) //3D case
               epsilonEqpSq += 0.25*(Ugrad(cell,qp,0,dim)*Ugrad(cell,qp,0,dim) + Ugrad(cell,qp,1,dim)*Ugrad(cell,qp,1,dim) ); // + 0.25*epsilon_xz^2 + 0.25*epsilon_yz^2
            epsilonEqpSq += ff; //add regularization "fudge factor" 
            mu(cell,qp) = flowFactorVec[cell]*pow(epsilonEqpSq,  power); //non-linear viscosity, given by Glen's law  
           }
         }
      }
      break;
}
}
void ChromoConditions::recalculateSSConcentrations()
{
    mSSConcentrations.clear();
    if (gradient().empty())
    {
        return;
    }
    
    // If the gradient is isocratic, add a single point only.
    if ((gradient().size() == 2) 
         && (gradient().front().concentrationB() 
             == gradient().back().concentrationB()))
    {
        mSSConcentrations.push_back(
            (100.0 - gradient().front().concentrationB()) / 100.0 
            * secondSolventConcentrationA() 
            + gradient().front().concentrationB() / 100.0
            * secondSolventConcentrationB());
        return;
    }

    double secondSolventConcentrationPump = 0.0;
    double time = dV() / 2.0 / flowRate();
    int segmentNum = -1;
    double localSlope = 0.0;
    double initialSSConcentration, finalSSConcentration, initialTime,
           finalTime, pumpedConcentration;

    while (true)
    {
        if (time > gradient()[segmentNum+1].time())
        {
            if (segmentNum < int(gradient().size() - 1))
            {
                segmentNum += 1;
                initialSSConcentration =
                    (100.0 - gradient()[segmentNum].concentrationB()) / 100.0 
                    * secondSolventConcentrationA() 
                    + gradient()[segmentNum].concentrationB() / 100.0
                    * secondSolventConcentrationB();
                finalSSConcentration =
                    (100.0 - gradient()[segmentNum+1].concentrationB()) / 100.0 
                    * secondSolventConcentrationA() 
                    + gradient()[segmentNum+1].concentrationB() / 100.0
                    * secondSolventConcentrationB();
                initialTime = gradient()[segmentNum].time();
                finalTime = gradient()[segmentNum+1].time();
                localSlope = (finalSSConcentration - initialSSConcentration) 
                    / (finalTime - initialTime);
            }
            else
            {
                break;
            }
        }

        pumpedConcentration = localSlope * (time - initialTime) 
                              + initialSSConcentration;

        // If mixingCorrection is enabled calculate second solvent concentrations
        // from the equation 
        // d[SS] / dt = flowRate / (V0 + VP) * ([SS]pump - [SS])
        // Otherwise, [SS] == [SS]pump
        if (mixingCorrection())
        {
            // Special case for the first time point.
            if (time == dV() / 2.0 / flowRate())
            {
                mSSConcentrations.push_back(
                    initialSSConcentration + 
                    + dV() / (columnInterstitialVolume() + columnPoreVolume())
                    * (pumpedConcentration - mSSConcentrations.back()) / 2.0);
            }
            else
            {
                mSSConcentrations.push_back(
                    mSSConcentrations.back() 
                    + dV() / (columnInterstitialVolume() + columnPoreVolume())
                    * (pumpedConcentration - mSSConcentrations.back()));
            }
        }
        else
        {
            mSSConcentrations.push_back(pumpedConcentration);
        }
        time += dV() / flowRate();
    }
}