예제 #1
0
void Foam::tetrahedron<Point, PointRef>::gradNiDotGradNj
(
    scalarField& buffer
) const
{
    // Warning. Ordering of edges needs to be the same for a tetrahedron
    // class, a tetrahedron cell shape model and a tetCell

    // Warning: Added a mag to produce positive coefficients even if
    // the tetrahedron is twisted inside out.  This is pretty
    // dangerous, but essential for mesh motion.

    // Double change of sign between face area vector and gradient

    scalar magVol = Foam::mag(mag());
    vector sa = Sa();
    vector sb = Sb();
    vector sc = Sc();
    vector sd = Sd();

    buffer[0] = (1.0/9.0)*(sa & sb)/magVol;
    buffer[1] = (1.0/9.0)*(sa & sc)/magVol;
    buffer[2] = (1.0/9.0)*(sa & sd)/magVol;
    buffer[3] = (1.0/9.0)*(sd & sb)/magVol;
    buffer[4] = (1.0/9.0)*(sb & sc)/magVol;
    buffer[5] = (1.0/9.0)*(sd & sc)/magVol;
}
void FsGuiColorDialog::UpdateHSVSliderFromCurrentColor(void)
{
	auto col=GetCurrentColor();
	hueSlider->SetPosition(col.Hd());
	saturationSlider->SetPosition(col.Sd());
	valueSlider->SetPosition(col.Vd());
}
예제 #3
0
void Foam::tetrahedron<Point, PointRef>::gradNiGradNi
(
    tensorField& buffer
) const
{
    // Change of sign between face area vector and gradient
    // does not matter because of square

    scalar magVol = Foam::mag(mag());

    buffer[0] = (1.0/9.0)*sqr(Sa())/magVol;
    buffer[1] = (1.0/9.0)*sqr(Sb())/magVol;
    buffer[2] = (1.0/9.0)*sqr(Sc())/magVol;
    buffer[3] = (1.0/9.0)*sqr(Sd())/magVol;
}
예제 #4
0
void Foam::tetrahedron<Point, PointRef>::gradNiSquared
(
    scalarField& buffer
) const
{
    // Change of sign between face area vector and gradient
    // does not matter because of square

    // Warning: Added a mag to produce positive coefficients even if
    // the tetrahedron is twisted inside out.  This is pretty
    // dangerous, but essential for mesh motion.
    scalar magVol = Foam::mag(mag());

    buffer[0] = (1.0/9.0)*magSqr(Sa())/magVol;
    buffer[1] = (1.0/9.0)*magSqr(Sb())/magVol;
    buffer[2] = (1.0/9.0)*magSqr(Sc())/magVol;
    buffer[3] = (1.0/9.0)*magSqr(Sd())/magVol;
}
예제 #5
0
void Foam::tetrahedron<Point, PointRef>::gradNiGradNj
(
    tensorField& buffer
) const
{
    // Warning. Ordering of edges needs to be the same for a tetrahedron
    // class, a tetrahedron cell shape model and a tetCell

    // Double change of sign between face area vector and gradient

    scalar magVol = Foam::mag(mag());
    vector sa = Sa();
    vector sb = Sb();
    vector sc = Sc();
    vector sd = Sd();

    buffer[0] = (1.0/9.0)*(sa * sb)/magVol;
    buffer[1] = (1.0/9.0)*(sa * sc)/magVol;
    buffer[2] = (1.0/9.0)*(sa * sd)/magVol;
    buffer[3] = (1.0/9.0)*(sd * sb)/magVol;
    buffer[4] = (1.0/9.0)*(sb * sc)/magVol;
    buffer[5] = (1.0/9.0)*(sd * sc)/magVol;
}
예제 #6
0
tmp<volScalarField> WALE<BasicTurbulenceModel>::k
(
    const volTensorField& gradU
) const
{
    volScalarField magSqrSd(magSqr(Sd(gradU)));

    return tmp<volScalarField>
           (
               new volScalarField
               (
                   IOobject
                   (
                       IOobject::groupName("k", this->U_.group()),
                       this->runTime_.timeName(),
                       this->mesh_
                   ),
                   sqr(sqr(Cw_)*this->delta()/Ck_)*
                   (
                       pow3(magSqrSd)
                       /(
                           sqr
                           (
                               pow(magSqr(symm(gradU)), 5.0/2.0)
                               + pow(magSqrSd, 5.0/4.0)
                           )
                           + dimensionedScalar
                           (
                               "SMALL",
                               dimensionSet(0, 0, -10, 0, 0),
                               SMALL
                           )
                       )
                   )
               )
           );
}
예제 #7
0
파일: ECELL.CPP 프로젝트: abcweizhuo/Test3
/*#F:
This determines what material should leave through each outlet,
and rate of change of the contents resulting from the flow, of material, out of each outlet
of the surge unit.
*/
void CElectroCell::EvalProducts(CNodeEvalIndex & NEI)
  {
  StkSpConduit Sd("Sd", chLINEID(), this);
  dCellEff     = Range(0.01, dCellEff, 1.0);
  dPreHeatFrac = Range(0.0, dPreHeatFrac, 1.0);

  switch (SolveMethod())
    {
    case SM_Direct:
      {
      const int iAn = IOWithId_Self(ioidAn);
      const int iCa = IOWithId_Self(ioidCath);
      SpConduit & An = *IOConduit(iAn);
      SpConduit & Ca = *IOConduit(iCa);

      SigmaQInPMin(Sd(), som_ALL, Id_2_Mask(ioidFd));
      m_TempKFeed = Sd().Temp();
  
      const double TotHfAtFeedT_Before = Sd().totHf(som_ALL, m_TempKFeed, Sd().Press());

      m_RB.EvalProducts(Sd());
     
      const double TotHfAtFeedT_After = Sd().totHf(som_ALL, m_TempKFeed, Sd().Press());
      
      if (m_RB())
        {
        // Input energy from the electrical work applied to the cell...
        m_dElecEnergyReact = TotHfAtFeedT_After - TotHfAtFeedT_Before;
        m_dElecEnergyHeat  = (m_dElecEnergyReact/ dCellEff)-m_dElecEnergyReact;
        m_dElecEnergyTotal = m_dElecEnergyReact + m_dElecEnergyHeat;
        
        double dTotHf = Sd().totHf();
        Sd().Set_totHf(dTotHf + m_dElecEnergyTotal); //add remaining energy AFTER reaction
        }
      else
        {
        m_dElecEnergyTotal =  0.0;
        m_dElecEnergyReact =  0.0;
        m_dElecEnergyHeat  =  0.0;
        }

      double Qs = Sd().QMass(som_Sol);
      double Ql = Sd().QMass(som_Liq);
      double Qg = Sd().QMass(som_Gas);
      m_TempKProd = Sd().Temp();

      An.QSetM(Sd(), som_Sol, 0.0, Std_P);
      An.QAddM(Sd(), som_Liq, Ql);
    
      Ca.QSetM(Sd(), som_Sol, Qs, Std_P);
      Ca.QAddM(Sd(), som_Liq, 0.0);

      //put all vapours (if any) to vent (if present)
      const int iVent = IOWithId_Self(ioidVent);
      if (iVent>=0)
        {
        SpConduit & Cvent = *IOConduit(iVent);
        Cvent.QSetM(Sd(), som_Gas, Qg, Std_P);
        }
      else
        {
        An.QAddM(Sd(), som_Gas, Qg); //put vapours somewhere!
        }

      An.SanityCheck();
      Ca.SanityCheck();
      break;
      }
    case SM_Inline:
    case SM_Buffered:
      {
      Contents.ZeroDeriv();
      m_TempKFeed=Sd().Temp();
      if (SolveMethod()==SM_Inline)
        {
        m_RB.EvalProducts(Sd());
        }
      else
        {
        //RB.EvalDerivs(Contents, Sd(), Sd());
        }

      if (m_RB())
        {
        // Input energy from the electrical work applied to the cell...
        m_dElecEnergyReact = m_RB()->HfSumTot();
        m_dElecEnergyHeat  = (m_dElecEnergyReact/ dCellEff)-m_dElecEnergyReact;
        m_dElecEnergyTotal = m_dElecEnergyReact + m_dElecEnergyHeat;
        
        double dTotHf = Sd().totHf();
        Sd().Set_totHf(dTotHf + m_dElecEnergyTotal); //add remaining energy AFTER reaction
        }
      else
        {
        m_dElecEnergyTotal =  0.0;
        m_dElecEnergyReact =  0.0;
        m_dElecEnergyHeat  =  0.0;
        }
      //double emf = 0.0;
      //if (RB())
      //  {
      //  emf = RB()->HfSumTot();
      //  emf = (emf / dCellEff) * -1.0;
      //  Sd().Set_totHf(Sd().totHf() + emf);
      //  }
      //dHeatFlow = emf;

      double SolMass = Contents.Mass(som_Sol);
      double LiqMass = Contents.Mass(som_Liq);
      double ETemp   = Contents.Temp();

      // This prevents any solids leaving with the electrolyte.
      const int ioAn = IOWithId_Self(ioidAn);
      if (ioAn>=0)
        {
        SpMArray AnolyteFilter;
        //Rem.Set(Contents, 0.0, 1.0, 0.0);
        AnolyteFilter.SetToValue(som_Sol, 0.0);
        AnolyteFilter.SetToValue(som_Liq|som_Gas, 1.0);
        SetProdMakeup(PMU_IOId | PMU_Filter, ioidAn, AnolyteFilter, ETemp, Std_P, Contents.Model());
        }

      // This allows the metal and solids to leave in the metal outlet.
      // Solids other than the plated metal leave as sludge.
      const int ioCa = IOWithId_Self(ioidCath);
      if (ioCa>=0)
        {
        SpMArray MetalFilter;
        //Met.Set(Contents, 1.0, 0.0, 0.0);
        MetalFilter.SetToValue(som_Sol, 1.0);
        MetalFilter.SetToValue(som_Liq|som_Gas, 0.0);
        SetProdMakeup(PMU_IOId | PMU_Filter, ioidCath, MetalFilter, ETemp, Std_P, Contents.Model());
        }

      SigmaQInPMin(m_QFeed, som_ALL, First64IOIds);
      EvalProducts_SurgeLevel(SolveInlineMethod(), false, ContentHgtOrd/*, &m_QFeed*/);

      m_TempKProd=Sd().Temp();

      break;
      }
    }
  };
예제 #8
0
bool ConstraintBSpline::controlPointBoundsDeduction() const
{
    // Get variable bounds
    auto xlb = bspline.getDomainLowerBound();
    auto xub = bspline.getDomainUpperBound();

    // Use these instead?
//    for (unsigned int i = 0; i < bspline.getNumVariables(); i++)
//    {
//        xlb.at(i) = variables.at(i)->getLowerBound();
//        xub.at(i) = variables.at(i)->getUpperBound();
//    }

    double lowerBound = variables.back()->getLowerBound(); // f(x) = y > lowerBound
    double upperBound = variables.back()->getUpperBound(); // f(x) = y < upperBound

    // Get knot vectors and basis degrees
    auto knotVectors = bspline.getKnotVectors();
    auto basisDegrees = bspline.getBasisDegrees();

    // Compute n value for each variable
    // Total number of control points is ns(0)*...*ns(d-1)
    std::vector<unsigned int> numBasisFunctions = bspline.getNumBasisFunctions();

    // Get matrix of coefficients
    DenseMatrix cps = controlPoints;
    DenseMatrix coeffs = cps.block(bspline.getNumVariables(), 0, 1, cps.cols());

    for (unsigned int d = 0; d < bspline.getNumVariables(); d++)
    {
        if (assertNear(xlb.at(d), xub.at(d)))
            continue;

        auto n = numBasisFunctions.at(d);
        auto p = basisDegrees.at(d);
        std::vector<double> knots = knotVectors.at(d);
        assert(knots.size() == n+p+1);

        // Tighten lower bound
        unsigned int i = 1;
        for (; i <= n; i++)
        {
            // Knot interval of interest: [t_0, t_i]

            // Selection matrix
            DenseMatrix S = DenseMatrix::Ones(1,1);

            for (unsigned int d2 = 0; d2 < bspline.getNumVariables(); d2++)
            {
                DenseMatrix temp(S);

                DenseMatrix Sd_full = DenseMatrix::Identity(numBasisFunctions.at(d2),numBasisFunctions.at(d2));
                DenseMatrix Sd(Sd_full);
                if (d == d2)
                    Sd = Sd_full.block(0,0,n,i);

                S = kroneckerProduct(temp, Sd);
            }

            // Control points that have support in [t_0, t_i]
            DenseMatrix selc = coeffs*S;
            DenseVector minCP = selc.rowwise().minCoeff();
            DenseVector maxCP = selc.rowwise().maxCoeff();
            double minv = minCP(0);
            double maxv = maxCP(0);

            // Investigate feasibility
            if (minv > upperBound || maxv < lowerBound)
                continue; // infeasible
            else
                break; // feasible
        }

        // New valid lower bound on x(d) is knots(i-1)
        if (i > 1)
        {
            if (!variables.at(d)->updateLowerBound(knots.at(i-1)))
                return false;
        }

        // Tighten upper bound
        i = 1;
        for (; i <= n; i++)
        {
            // Knot interval of interest: [t_{n+p-i}, t_{n+p}]

            // Selection matrix
            DenseMatrix S = DenseMatrix::Ones(1,1);

            for (unsigned int d2 = 0; d2 < bspline.getNumVariables(); d2++)
            {
                DenseMatrix temp(S);

                DenseMatrix Sd_full = DenseMatrix::Identity(numBasisFunctions.at(d2),numBasisFunctions.at(d2));
                DenseMatrix Sd(Sd_full);
                if (d == d2)
                    Sd = Sd_full.block(0,n-i,n,i);

                S = kroneckerProduct(temp, Sd);
            }

            // Control points that have support in [t_{n+p-i}, t_{n+p}]
            DenseMatrix selc = coeffs*S;
            DenseVector minCP = selc.rowwise().minCoeff();
            DenseVector maxCP = selc.rowwise().maxCoeff();
            double minv = minCP(0);
            double maxv = maxCP(0);

            // Investigate feasibility
            if (minv > upperBound || maxv < lowerBound)
                continue; // infeasible
            else
                break; // feasible
        }

        // New valid lower bound on x(d) is knots(n+p-(i-1))
        if (i > 1)
        {
            if (!variables.at(d)->updateUpperBound(knots.at(n+p-(i-1))))
                return false;
            // NOTE: the upper bound seems to not be tight! can we use knots.at(n+p-i)?
        }

    }

    return true;
}
예제 #9
0
/*This determines what material should leave through each outlet,
and rate of change of the contents resulting from the flow, of material, 
out of each outlet of the surge unit.
*/
void CentrifugeMB::EvalProducts(CNodeEvalIndex & NEI)
  {
  StkSpConduit Sd("Sd", chLINEID(), this);
  StkSpConduit Wd("Wd", chLINEID(), this);

  SpConduit Dummy1;
  SpConduit Dummy2;

  switch (SolveMethod())
    {
    case SM_Direct:
      {
      //RqdSolidsToFiltrate = Range(1.0e-8, RqdSolidsToFiltrate, 0.3);
      RqdSolidsToFiltrate = Range(0.0, RqdSolidsToFiltrate, 1.0);
      RqdCakeMoist  = Range(0.0, RqdCakeMoist,  0.99);
      WashEff       = Range(0.01, WashEff, 1.0);

      const int iCl = IOWithId_Self(ioidLiq);
      const int iCs = IOWithId_Self(ioidSol);
      SpConduit & Cl = *IOConduit(iCl);
      SpConduit & Cs = *IOConduit(iCs);

      const int iWw = IOWithId_Self(ioidwash);
      const int iW2 = IOWithId_Self(ioidwsh2);
      const int iFW = IOWithId_Self(ioidFW);
      const int iSW = IOWithId_Self(ioidSW);

      SpConduit & QWw = (iWw >= 1 ? *IOConduit(iWw) : Dummy1);
      SpConduit & QW2 = (iW2 >= 1 ? *IOConduit(iW2) : Dummy2);

      SigmaQInPMin(QFd, som_ALL, Id_2_Mask(ioidFd));
      const bool HasFeed = (QFd.QMass(som_ALL)>UsableMass);
      const double TtlWashSol = QWw.QMass(som_Sol) + QW2.QMass(som_Sol);

      //double CFeed = QFd.SpecieConc(QFd.Temp(), iScanEffSpecie, som_Liq);
      double CFeed = QFd.SpecieConc(QFd.Temp(), iWashEffSpecie, som_Liq);
      double CWash1 = QWw.SpecieConc(QWw.Temp(), iWashEffSpecie, som_Liq);
      double CWash2 = QW2.SpecieConc(QW2.Temp(), iWashEffSpecie, som_Liq);

      bool FeedLiqLow = false;
      double CCake1 = 0.0;
      if (fOn/* && HasFeed*/)
        {
        m_RB.EvalProducts(QFd);
        m_EHX.EvalProducts(QFd);

		    const double MSol    = QFd.QMass(som_Sol);
        const double MLiq    = QFd.QMass(som_Liq);
        const double wash1   = QWw.QMass(som_Liq);
        const double wash2   = QW2.QMass(som_Liq);
        const double TtlLiqIn = MLiq + wash1 + wash2;
        
        //will not achieve requirements if there are any solids in wash!!!
        const double MSol2Filt = MSol * RqdSolidsToFiltrate;
        const double RSol      = MSol - MSol2Filt;
        double MLiq2Cake = (RqdCakeMoist * RSol)/(1 - RqdCakeMoist); 
        FeedLiqLow = (TtlLiqIn<MLiq2Cake);
		    SetCI(1, /*fOn && */HasFeed && FeedLiqLow);
        if (FeedLiqLow)
          {//force all liquids to cake
          MLiq2Cake = TtlLiqIn;
          }
        const double TotLiq    = max(TtlLiqIn - MLiq2Cake, 1e-6);
        const double Sol2Filt  = GEZ(MLiq - MLiq2Cake) * MSol2Filt/TotLiq;

        Cs.QSetM(QFd, som_Sol, RSol, IOP_Self(iCs));
        Cs.QAddM(QWw, som_Sol, QWw.QMass(som_Sol));
        Cs.QAddM(QW2, som_Sol, QW2.QMass(som_Sol));

        Cl.QSetM(QFd, som_Liq, GEZ(MLiq - MLiq2Cake), IOP_Self(iCl));
        Cl.QAddM(QFd, som_Sol, Sol2Filt);

        //=======================================================
        if ((MSol > 1e-6) && (MLiq > 1e-6))
          {
          double Cf, Cw1, Cw2, e1, e2, w1, w2;

          w1 = min(MLiq2Cake*WashEff, wash1);
          w2 = min(MLiq2Cake*WashEff, wash2);
          e1 = w1/max(MLiq2Cake,1e-6);
          e2 = w2/max(MLiq2Cake,1e-6);

          // The liquid composition of the solids.
          Cf  = MLiq2Cake * (1.0 - e1 - e2 + e1*e2);
          Cw1 = w1 - w2*e1;
          Cw2 = w2;

          Cs.QAddM(QFd, som_Liq, Cf);
          Cs.QAddM(QWw, som_Liq, Cw1);
          CCake1 = Cs.SpecieConc(Cs.Temp(), iWashEffSpecie, som_Liq);
          Cs.QAddM(QW2, som_Liq, Cw2);

          // The filtrate and washing streams
          double Ff, Fw1, Fw2;
          Ff  = MLiq2Cake - Cf;
          Fw1 = wash1 - Cw1;
          Fw2 = wash2 - Cw2;

          if (iFW >= 1)
            {
            rSpConduit FW =*IOConduit(iFW);
            
            if (iSW >= 1)
              {//more than one washing output stream connected
              double Sw1, Sw2;
              rSpConduit SW =*IOConduit(iSW);
              Sw1 = wash1 * MSol2Filt/TotLiq;
              Sw2 = wash2 * MSol2Filt/TotLiq;

              FW.QSetM(QFd, som_Liq, w1, IOP_Self(iFW));
              FW.QAddM(QWw, som_Liq, wash1 - w1);
              FW.QAddM(QFd, som_Sol, Sw1);

              SW.QSetM(QFd, som_Liq, w2 - w1*e2, IOP_Self(iSW));
              SW.QAddM(QWw, som_Liq, w1*e2);
              SW.QAddM(QW2, som_Liq, Fw2);
              SW.QAddM(QFd, som_Sol, Sw2);
              }
            else  // everything goes to the first washings stream
              {
              FW.QSetM(QFd, som_Liq, Ff, IOP_Self(iFW));
              FW.QAddM(QWw, som_Liq, Fw1);
              FW.QAddM(QW2, som_Liq, Fw2);
              FW.QAddM(QFd, som_Sol, MSol2Filt - Sol2Filt);
              }
            }
          else  // everything goes to the filtrate
            {
            Cl.QAddM(QFd, som_Liq, Ff);
            Cl.QAddM(QWw, som_Liq, Fw1);
            Cl.QAddM(QW2, som_Liq, Fw2);
            Cl.QAddM(QFd, som_Sol, MSol2Filt - Sol2Filt);
            }
          }
        else
          {
          Cs.QAddM(QFd, som_Sol, MSol2Filt);
          Cl.QAddM(QFd, som_Liq, MLiq2Cake);
          Cl.QAddM(QWw, som_Liq, wash1);
          Cl.QAddM(QW2, som_Liq, wash2);
          }
        }
      else
        {//off
        SigmaQInPMin(Cs, som_ALL, Id_2_Mask(ioidFd));
        SigmaQInPMin(Cl, som_ALL, Id_2_Mask(ioidwash)|Id_2_Mask(ioidwsh2));
        if (iFW >= 1)
          {
          rSpConduit FW =*IOConduit(iFW);
          FW.QZero();
          }
        if (iSW >= 1)
          {
          rSpConduit SW =*IOConduit(iSW);
          SW.QZero();
          }
        }

      ActCakeLiq      = Cs.MassFrac(som_Liq);
      ActCakeSolids   = Cs.MassFrac(som_Sol);
      ActFiltSolids   = Cl.MassFrac(som_Sol);
      ActFiltSolConc  = Cl.PhaseConc(C_2_K(25.0), som_Sol, som_ALL);
      ActFiltSolConcT = Cl.PhaseConc(Cl.Temp(), som_Sol, som_ALL);
      //double Cuf = Cs.SpecieConc(Cs.Temp(), iScanEffSpecie, som_Liq);
      //double Cof = Cl.SpecieConc(Cl.Temp(), iScanEffSpecie, som_Liq);
      //ActScandrettEff = (CFeed - Cuf)/NZ(CFeed - Cof);
      const double CCake2 = Cs.SpecieConc(Cs.Temp(), iWashEffSpecie, som_Liq);
      dSpWashEff  = (CFeed - CCake1)/NZ(CFeed - CWash1);
      dSpWashEff2 = (CFeed - CCake2)/NZ(CFeed - CWash2);

      const double CMErr = fabs(ActCakeLiq - RqdCakeMoist); //CakeMoisture error
      const bool SolInWashErr = (CMErr > 1.0e-5 && TtlWashSol>1.0e-6);
		  SetCI(2, fOn && /*bTrackStatus && */HasFeed && !FeedLiqLow && !SolInWashErr && CMErr > 1.0e-5);
		  SetCI(3, fOn && /*bTrackStatus && */HasFeed && SolInWashErr);
      break;
      }
    case SM_Inline:
    case SM_Buffered:
      {
      Contents.ZeroDeriv();
      //double CFeed = Sd().SpecieConc(Sd().Temp(), iScanEffSpecie, som_Liq);
      //double CFeed = Sd().SpecieConc(Sd().Temp(), iWashEffSpecie, som_Liq);
      //double CWash1 = QWw.SpecieConc(QWw.Temp(), iWashEffSpecie, som_Liq);
      //double CWash2 = QW2.SpecieConc(QW2.Temp(), iWashEffSpecie, som_Liq);
      m_RB.EvalProducts(Sd());
      m_EHX.EvalProducts(Sd());

      double SolMass = Contents.Mass(som_Sol);
      double LiqMass = Contents.Mass(som_Liq);

      //RqdSolidsToFiltrate = Range(1.0e-8, RqdSolidsToFiltrate, 0.3);
      RqdSolidsToFiltrate  = Range(0.0, RqdSolidsToFiltrate, 1.0);
      RqdCakeMoist   = Range(0.0, RqdCakeMoist, 1.0);
      double CakeSol, LiqSol;
      LiqSol  = RqdSolidsToFiltrate / GTZ(1.0 - RqdSolidsToFiltrate);
      CakeSol = (1.0 - RqdCakeMoist) / GTZ(RqdCakeMoist);


      if (SolMass>1.0e-12 && LiqMass>1.0e-12)
        {
        SetProdMakeup(PMU_IOId | PMU_SLRatio, ioidLiq, Contents, LiqSol);
        SetProdMakeup(PMU_IOId | PMU_SLRatio, ioidSol, Contents, CakeSol);
        }
      else
        {
        // Just Operate as a Tank
        }

      SigmaQInPMin(m_QFeed, som_ALL, First64IOIds);
      EvalProducts_SurgeLevel(SolveInlineMethod(), false, ContentHgtOrd/*, &m_QFeed*/);

      if (NoProcessJoins()>=1)
        Xfer_EvalProducts(0, Joins[0].Pressure(), NULL, &m_QProdSrg, NULL, NULL, NULL);

      ActCakeLiq      = IOConduit(IOWithId_Self(ioidSol))->MassFrac(som_Liq);
      ActCakeSolids   = IOConduit(IOWithId_Self(ioidSol))->MassFrac(som_Sol);
      ActFiltSolids   = IOConduit(IOWithId_Self(ioidSol))->MassFrac(som_Sol);
      ActFiltSolConc  = IOConduit(IOWithId_Self(ioidSol))->PhaseConc(C_2_K(25.0), som_Sol, som_ALL);
      ActFiltSolConcT = IOConduit(IOWithId_Self(ioidSol))->PhaseConc(IOConduit(IOWithId_Self(ioidSol))->Temp(), som_Sol, som_ALL);
      //double Cuf = IOConduit(IOWithId_Self(ioidSol))->SpecieConc(IOConduit(IOWithId_Self(ioidSol))->Temp(), iScanEffSpecie, som_Liq);
      //double Cof = IOConduit(IOWithId_Self(ioidSol))->SpecieConc(IOConduit(IOWithId_Self(ioidSol))->Temp(), iScanEffSpecie, som_Liq);
      //ActScandrettEff = (CFeed - Cuf)/NZ(CFeed - Cof);

      break;
      }
    }
  }
예제 #10
0
bool invert(const Mat_<_Tp, chs>&src, Mat_<_Tp, chs>& dst, int method = DECOMP_LU)
{
	FBC_Assert(src.data != NULL && dst.data != NULL);
	FBC_Assert(src.cols > 0 && src.rows > 0 && dst.cols > 0 && dst.rows > 0);
	FBC_Assert(typeid(double).name() == typeid(_Tp).name() || typeid(float).name() == typeid(_Tp).name());
	FBC_Assert(src.cols == dst.rows && src.rows == dst.cols);

	bool result = false;
	size_t esz = sizeof(_Tp) * chs; // size_t esz = CV_ELEM_SIZE(type);
	int m = src.rows, n = src.cols;

	if (method == DECOMP_SVD) { // TODO
		FBC_Assert(0);
	}

	FBC_Assert(m == n);

	if (method == DECOMP_EIG) { // TODO
		FBC_Assert(0);
	}

	FBC_Assert(method == DECOMP_LU || method == DECOMP_CHOLESKY);

	if (n <= 3) {
		const uchar* srcdata = src.ptr();
		uchar* dstdata = const_cast<uchar*>(dst.ptr());
		size_t srcstep = src.step;
		size_t dststep = dst.step;

		if (n == 2) { // TODO
			FBC_Assert(0);
		} else if (n == 3) {
			if (typeid(float).name() == typeid(_Tp).name() && chs == 1) {
				double d = det3(Sf);

				if (d != 0.) {
					double t[12];

					result = true;
					d = 1./d;
					t[0] = (((double)Sf(1,1) * Sf(2,2) - (double)Sf(1,2) * Sf(2,1)) * d);
					t[1] = (((double)Sf(0,2) * Sf(2,1) - (double)Sf(0,1) * Sf(2,2)) * d);
					t[2] = (((double)Sf(0,1) * Sf(1,2) - (double)Sf(0,2) * Sf(1,1)) * d);

					t[3] = (((double)Sf(1,2) * Sf(2,0) - (double)Sf(1,0) * Sf(2,2)) * d);
					t[4] = (((double)Sf(0,0) * Sf(2,2) - (double)Sf(0,2) * Sf(2,0)) * d);
					t[5] = (((double)Sf(0,2) * Sf(1,0) - (double)Sf(0,0) * Sf(1,2)) * d);

					t[6] = (((double)Sf(1,0) * Sf(2,1) - (double)Sf(1,1) * Sf(2,0)) * d);
					t[7] = (((double)Sf(0,1) * Sf(2,0) - (double)Sf(0,0) * Sf(2,1)) * d);
					t[8] = (((double)Sf(0,0) * Sf(1,1) - (double)Sf(0,1) * Sf(1,0)) * d);

					Df(0,0) = (float)t[0]; Df(0,1) = (float)t[1]; Df(0,2) = (float)t[2];
					Df(1,0) = (float)t[3]; Df(1,1) = (float)t[4]; Df(1,2) = (float)t[5];
					Df(2, 0) = (float)t[6]; Df(2, 1) = (float)t[7]; Df(2, 2) = (float)t[8];
				}
			} else {
				double d = det3(Sd);
				if (d != 0.) {
					result = true;
					d = 1. / d;
					double t[9];

					t[0] = (Sd(1, 1) * Sd(2, 2) - Sd(1, 2) * Sd(2, 1)) * d;
					t[1] = (Sd(0, 2) * Sd(2, 1) - Sd(0, 1) * Sd(2, 2)) * d;
					t[2] = (Sd(0, 1) * Sd(1, 2) - Sd(0, 2) * Sd(1, 1)) * d;

					t[3] = (Sd(1, 2) * Sd(2, 0) - Sd(1, 0) * Sd(2, 2)) * d;
					t[4] = (Sd(0, 0) * Sd(2, 2) - Sd(0, 2) * Sd(2, 0)) * d;
					t[5] = (Sd(0, 2) * Sd(1, 0) - Sd(0, 0) * Sd(1, 2)) * d;

					t[6] = (Sd(1, 0) * Sd(2, 1) - Sd(1, 1) * Sd(2, 0)) * d;
					t[7] = (Sd(0, 1) * Sd(2, 0) - Sd(0, 0) * Sd(2, 1)) * d;
					t[8] = (Sd(0, 0) * Sd(1, 1) - Sd(0, 1) * Sd(1, 0)) * d;

					Dd(0, 0) = t[0]; Dd(0, 1) = t[1]; Dd(0, 2) = t[2];
					Dd(1, 0) = t[3]; Dd(1, 1) = t[4]; Dd(1, 2) = t[5];
					Dd(2, 0) = t[6]; Dd(2, 1) = t[7]; Dd(2, 2) = t[8];
				}
			}
		} else {
			assert(n == 1);

			if (typeid(float).name() == typeid(_Tp).name() && chs == 1)
			{
				double d = Sf(0, 0);
				if (d != 0.) {
					result = true;
					Df(0, 0) = (float)(1. / d);
				}
			} else {
				double d = Sd(0, 0);
				if (d != 0.) {
					result = true;
					Dd(0, 0) = 1. / d;
				}
			}
		}

		if (!result)
			dst.setTo(Scalar(0));
		return result;
	}

	FBC_Assert(0); // TODO

	return result;
}
예제 #11
0
void Crush1::EvalProducts(CNodeEvalIndex & NEI)
  {
  flag On = (bOnLine && (NetProbalMethod() || MSB.Speed(this)>DischOnSpeed));
  const int ioProd = IOWithId_Self(ioidProd);
  if (ioProd>=0 && On)
    {
    CB.ClrCI(3);
    SigmaQInPMin(Disch, som_ALL, Id_2_Mask(ioidFeed));
    BOOL ValidData = (Disch.QMass(som_Sol)>1.0e-6);
		SpConduit Sd("Sd", this, TOA_Free);
    Sd.QCopy(Disch);
    ValidData = ValidData && CB.IsValidData(Sd);

    if (ValidData)
      {
      double F80 = SQSzDist1::Ptr(Disch.Model())->SizePassingFraction(-1, -1, 0.80);

      CB.CrushProduct(Sd, Disch);

      //double Excess;
      double MassRate = Disch.QMass(som_Sol);
      double P80 = SQSzDist1::Ptr(Disch.Model())->SizePassingFraction(-1, -1, 0.80);
      if (Valid(P80) && (P80 > 1e-10) && Valid(F80) && (F80 > 1e-10))
        {
        F80 = F80 * 1e6;  // Convert to microns
        P80 = P80 * 1e6;
        Power  = 10.0 * MassRate * BWI * (1.0/Sqrt(P80) - 1.0/Sqrt(F80));  
        //Excess = Motor - Power;
        }
      else
        {
        Power  = 0.0;
        //Excess = 0.0;
        }
      //if (Excess > 0.0)
      //  Heat = Excess * Eff;
      //else
      //  Heat = 0.0;

      //Disch.Set_totEnthalpy(Disch.totEnthalpy() + Heat);
      }
    else
      {
      //Disch.QZero();
      Power = 0.0;
      }

    IOConduit(ioProd)->QCopy(Disch);
    }
  else
    {
    Power = 0.0;
    CB.SetCI(3, !m_Pwr.SupplyConnected());
    if (ioProd>=0)
      {
      SpConduit & Qp=*IOConduit(ioProd); //Qp product
      Qp.QZero();
      SigmaQInPMin(Qp, som_ALL, Id_2_Mask(ioidFeed)); //set product = feed
      }
    }
  }