Пример #1
0
void Sys13::EvalJoinPressures()
  {
  double Pm = AtmosPress();
  for (int i = 0; i < NoFlwIOs(); i++)
      Set_IOP_Self(i,Pm);
  //TRACE("MHM CHECK WITH CNM");
  }
Пример #2
0
void Flare::EvalProducts()
  {
  MN_SrcSnk::EvalProducts();
  if ((FlareDrum==NULL) && (FlareTag[0]!='~'))
    {
    FlareDrum = (pFlashTank/*MdlNode*/)FamilyHead()->FindObj(FlareTag());
    if (FlareDrum==NULL)
      FlareTag[0]='~';
    }
  if (FlareDrum && (NoFlwIOs()>0))
    {
    //    \\FlareDrum->EvalDerivs_AddQm_____(FlareDrum->Contents, *IOConduit(0));
    //FlareDrum->Contents.InFlow().QAdd(*IOConduit(0), 1.0);

    SpContainer &C=FlareDrum->Contents;//M.OverFlow().Target();
    SpConduit &I=C.InFlow();
    if (C.InFlow().ZeroReqd())
      {
      C.InFlow().ClrZeroReqd();
      I.QSetF(*IOConduit(0), som_ALL, 1.0, AtmosPress());
      }
    else
      I.QAddF(*IOConduit(0), som_ALL, 1.0);

    //CNM    FlareDrum->Flux.QAdd(IOFlange(0)->Q, som_ALL, 1.0);
    }
  }
Пример #3
0
/*#F:This determines the pressure of the contents and the pressure at each
inlet and outlet of the surge unit.*/
void MN_Xfer::EvalJoinPressures(long JoinMask)
  {
  switch (NetMethod())
    {
    case NM_Probal:
      {
      const bool OldCode = false;
      if (OldCode)
        {
        if (NoProcessJoins()>=1)
          EvalJoinPressure(0, &m_PCtrl0, m_QFeed());//&QProd());
        //if (NoProcessJoins()>=2)
        //  EvalJoinPressure(1);
        }
      else
        {
        if (NoProcessJoins()>=1)
          EvalJoinPressure(0, &m_PCtrl0, m_QProd());
        if (NoProcessJoins()>=2)
          EvalJoinPressure(1);
        }
      break;
      }
    //case SM_Inline:
    case NM_Dynamic:
      //if (m_PCtrl0.Method())
      if (JoinMask&1)
        {
        int N=0;
        for (int i=0; i<NoProcLnkIOs(); i++)
          {
          if (Nd_Rmt(i)->FlowMode()==LFM_Xfer)
            N++;
          }

        if (NoProcLnkIOs()-N>=2)
          SetJoinPressure(0, JoinP(0), true, true);
        else
          {
          //m_PCtrl0.DoInputs
            //SetJoinPressure(0, AtmosPress(m_Datum)/* JoinP(0)*/, true, true);
          //if (HasModeNear(0, LFM_Xfer))
          EvalJoinPressure(0, &m_PCtrl0);
          }
        //else
        }
      if (JoinMask&2 && NoProcessJoins()>1)
        {
        //if (HasModeNear(1, LFM_Xfer))
        //  EvalJoinPressure(0, &m_PCtrl0);
        //else
        SetJoinPressure(1, AtmosPress(m_Datum)/* JoinP(0)*/, true, true);
        }
      //MdlNode::EvalJoinPressures(JoinMask);
      break;
    }
  };
Пример #4
0
void Flare::EvalJoinPressures()
  {
  double Pm=AtmosPress();
  for (int i = 0; i < NoFlwIOs(); i++)
    //if ((IOs + i)->Conn)
    //  {
    //  pFlange pC = IOFlange(i);
      Set_IOP_Self(i,Pm);
    //  }
  }
Пример #5
0
void   MN_Xfer::SetState(eScdMdlStateActs RqdState)
  {
  MdlNode::SetState(RqdState);
  if (m_NetworkIsolator)
    m_Accumulator->SetState(RqdState);

  m_QFeed().SetState(RqdState);
  m_QProd().SetState(RqdState);

  switch (RqdState)
    {
    case MSA_PBInit:
    case MSA_ZeroFlows:
    case MSA_Empty:
    case MSA_PreSet:
      {
      ResetData(false);

      double P0 = NoFlwIOs() ? AtmosPress(IODatum_Term(0)) : Std_P;
      Set_JoinP(0, P0);
      Set_JoinP_Est(0, P0);
      Set_JoinP_Max(0, dNAN);
      Set_JoinP_MaxSet(0, dNAN);
      for (int i=0; i<NoFlwIOs(); i++)
        {
        Set_IOP_Flng(i, P0);
        Set_IOP_Self(i, P0);
        Set_IOP_Est_Self(i, P0);
        Set_IOP_Est_Flng(i, P0);
        IOConduit(i)->SetState(RqdState);
        if (IOConduitIO(i))
          IOConduitIO(i)->SetState(RqdState);
        if (IOConduitIn(i))
          IOConduitIn(i)->SetState(RqdState);
        SetIOQm_In(i, 0.0);
        SetIOQmEst_In(i, 0.0);
        SetIOQmSpace_Self(i, 0.0);
        SetIOQmAvail_Self(i, 0.0);
        }
      }
      break;
    case MSA_SteadyState:
      LogNote(FullObjTag(), 0, "SteadyState Undefined");
      break;
    }
  };
Пример #6
0
void Flot::EvalJoinPressures()
  {
  switch (SolveMode())
    {
    case PBMODE:
    case SSMODE:
      {
      for (int j=0; j<NJoins(); j++)
        {
        double Pm=AtmosPress(IODatum_Term(j));//(j==0 ? PRqd : GetPBInputPressure(j));
        SetPBJoinPressure(j, Pm, true, true);
        #if dbgFlwNode
        if (dbgEvalJoinPress(sTag()))
          dbgpln("EJP: %12.2f  %s[%i]", Pm, sTag(), j );
        #endif
        }
      }
      //MdlNode::EvalJoinPressures();
      break;
    case DYNMODE:
      MN_Surge::EvalJoinPressures();
      break;
    }
  };
Пример #7
0
void Splitter::EvalProducts()
  {
  try
    {
    if (1)
      {
      // Examples of retrieving Environment Variables
      double X1=StdP;
      double X2=StdT;
      double X3=AtmosPress();
      double X4=AmbientTemp();
      double X5=BaseElevation();
      double X6=WindSpeed();
      double X7=WindDirection();
      }

    //sum all input streams into a working copy
    MStreamI QI;
    FlwIOs.AddMixtureIn_Id(QI, idFeed);

    //get handles to input and output streams...
    MStream & QO0 = FlwIOs[FlwIOs.First[idProd1]].Stream;
    MStream & QO1 = FlwIOs[FlwIOs.First[idProd2]].Stream;

    // Always initialise the outputs as a copy of the inputs. This ensures all "qualities" are copied.
    QO0 = QI;
    QO1 = QI;

    //make outlet temperature and pressure same as input 
    //(not actualy needed because of stream copy above)
    QO0.SetTP(QI.T, QI.P);
    QO1.SetTP(QI.T, QI.P);

    //force input values to be in meaningful ranges...
    dRqdFracSplit = Range(0.0, dRqdFracSplit, 1.0);
    dRqdSolSplit = Range(0.0, dRqdSolSplit, 1.0);
    dRqdLiqSplit = Range(0.0, dRqdLiqSplit, 1.0);
    dRqdVapSplit = Range(0.0, dRqdVapSplit, 1.0);

    //do the work...
    const int NumSpecies = gs_MVDefn.Count();
    for (int i=0; i<NumSpecies; i++)
      {
      if (bDoPhaseSplit)
        {//split by phase
        if (gs_MVDefn[i].Phase() & MP_Sol)
          QO0.M[i] = QI.M[i] * dRqdSolSplit;
        else if (gs_MVDefn[i].Phase() & MP_Liq)
          QO0.M[i] = QI.M[i] * dRqdLiqSplit;
        else
          QO0.M[i] = QI.M[i] * dRqdVapSplit;
        }
      else
        {
        QO0.M[i] = QI.M[i] * dRqdFracSplit;
        }
      QO1.M[i] = QI.M[i] - QO0.M[i]; //remainder goes to second outlet
      }

    //get display values...
    dFeedQm = QI.MassFlow();
    dProdQm0 = QO0.MassFlow();
    dProdQm1 = QO1.MassFlow();
    }
  catch (MMdlException &e)
    {
    Log.Message(MMsg_Error, e.Description);
    }
  catch (MFPPException &e)
    {
    e.ClearFPP();
    Log.Message(MMsg_Error, e.Description);
    }
  catch (MSysException &e)
    {
    Log.Message(MMsg_Error, e.Description);
    }
  catch (...)
    {
    Log.Message(MMsg_Error, "Some Unknown Exception occured");
    }
  }
Пример #8
0
void BeltCnv::EvalJoinPressures(long JoinMask)
  {
  for (int i = 0; i < NoFlwIOs(); i++)
    Set_IOP_Self(i, AtmosPress(IODatum_Term(i)));
  };
Пример #9
0
void MN_BstRes::EvalProducts(CNodeEvalIndex & NEI)
{
    if (NoFlwIOs()<2)
        return;

    if (!bOnLine && !IO_Zero(0))
    {
        const int In  = TwoIOInIndex();
        const int Out = OtherEnd(In);
        SpConduit & Fi=*IOConduit(In);
        SpConduit & Fo=*IOConduit(Out);
        dDuty = 0.0;
        Fo.QCopy(Fi);
        IOFB(0,0)->SetQm(Sign(IOFB(0,0)->GetQm())*Fo.QMass(som_ALL));
        if (NetProbalMethod())
        {
            dPout = Fo.Press();
            dTout = Fo.Temp();
        }
        else
        {
            m_FTB.BeginEvalProducts(Fo);
            IOFB(0,0)->EvalProducts(IOP_Flng(In), IOP_Flng(Out), Fo, m_FTB);//);
            m_FTB.EndEvalProducts();
        }
        return;
    }

    if (NetProbalMethod())
    {
        const int In  = TwoIOInIndex();
        const int Out = OtherEnd(In);
        SpConduit & Fi=*IOConduit(In);
        SpConduit & Fo=*IOConduit(Out);
        if (IO_Zero(0))
        {
            Fi.QSetTraceMass();//QZero();
            Fo.QSetTraceMass();//QZero();
            IOFB(0,0)->SetQm(0.0);
            dDuty = 0.0;
            dPout = Fo.Press();
            dTout = Fo.Temp();
        }
        else
        {
            Fo.QCopy(Fi);
            IOFB(0,0)->SetQm(Sign(IOFB(0,0)->GetQm())*Fo.QMass(som_ALL));
            dPout = Fo.Press();
            switch (iPressMethod)
            {
            case BRPM_None :
                break;
            case BRPM_Fixed:
                dPout = Range(1.0, dPout_Rqd, 1.0e15);
                break;
            case BRPM_Boost:
            case BRPM_Drop :
                dPout = Range(1.0, dPout+dPressBoost_Rqd, 1.0e15);
                break;
            case BRPM_Atmos:
                dPout = AtmosPress();
                break;
            case BRPM_SatP : /*dPout = todo*/
                break;
            }

            if (bIsentropic)
            {   //for pump maintain entropy...
                const double TOut = Fo.Temp();
                const double h0 = Fo.totHf();
                const double s0 = Fo.totSf();
                CPumpTempFnd Fnd(Fo, dPout);
                Fnd.SetTarget(s0);
                if (Valid(dTout))
                {
                    Fnd.SetEstimate(dTout, -1.0);
                    //dTout = dNAN;
                }
                bool OK = 0;
                const double MnX = max(dTout-100.0, ZeroCinK); //WHAT LIMITS SHOULD BE USED???!!!
                const double MxX = dTout+200.0; //WHAT LIMITS SHOULD BE USED???!!!
                int iRet = Fnd.Start(MnX, MxX);
                if (iRet==RF_EstimateOK) //estimate is good, solve not required
                {
                    OK=1;
                }
                else
                {
                    if (iRet==RF_BadEstimate)
                        iRet = Fnd.Start(MnX, MxX); // Restart
                    if (iRet==RF_OK)
                        if (Fnd.Solve_Brent()==RF_OK)
                        {
                            OK=1;
                        }
                    if (iRet==RF_LoLimit)
                    {
                        //dCalcT = MnX;
                    }
                    else if (iRet==RF_HiLimit)
                    {
                        //dCalcT = MxX;
                    }
                }
                //SetCI(?, !OK); //Brent solve problem!
                dDuty = Fo.totHf() - h0;
            }
            else
            {
                if (Valid(dTout_Rqd))
                {
                    const double h0 = Fo.totHf();
                    Fo.SetTemp(dTout_Rqd);
                    dDuty = Fo.totHf() - h0;
                }
                else if (fabs(dDuty_Rqd)>1.0e-12)
                {
                    const double h0 = Fo.totHf();
                    Fo.Set_totHf(h0+dDuty_Rqd);
                    dDuty = dDuty_Rqd;
                }
                else
                    dDuty = 0.0;
                const double h1 = Fo.totHf();
                Fo.SetPress(dPout);
                Fo.Set_totHf(h1); //restore enthalpy
            }
            m_VLE.PFlash(Fo, IOP_Flng(Out), 0.0, VLEF_Null);
            dTout = Fo.Temp();
        }
    }
    else
    {   //dynamic...
        CLinkRec & L=m_Links[0];

        if (fabs(L.FB.m_Qm)==0)
        {
            SpConduit & Fi=*IOConduit(0);
            SpConduit & Fo=*IOConduit(1);

            if (m_LeakI.Enabled)
                m_LeakI.EvalProducts(Fi, false);
            else
                Fi.QSetTraceMass();

            L.Cd.QSetTraceMass();
            m_FTB.BeginEvalProducts(L.Cd);
            L.FB.EvalProducts(L.PB(0).P, L.PB(1).P, L.Cd, m_FTB);
            m_FTB.EndEvalProducts();

            if (m_LeakO.Enabled)
                m_LeakO.EvalProducts(Fo, false);
            else
                Fo.QSetTraceMass();
            dDuty = 0.0;
        }
        else
        {
            int In=(L.FB.m_Qm>0 ? 0:1);
            int Out=OtherEnd(In);

            SpConduit & Fi=*IOConduit(In);
            SpConduit & Fo=*IOConduit(Out);

            Fo.QCopy(Fi);

            //heat loss/gain for simple heater:
            const double PresO = Fo.Press();
            if (Valid(dTout_Rqd))
            {
                const double h0 = Fo.totHf();
                Fo.SetTemp(dTout_Rqd);
                dDuty = Fo.totHf() - h0;
                const double h1 = Fo.totHf();
                Fo.SetPress(PresO);
                Fo.Set_totHf(h1); //restore enthalpy
            }
            else if (fabs(dDuty_Rqd)>1.0e-12)
            {
                const double h0 = Fo.totHf();
                Fo.Set_totHf(h0+dDuty_Rqd);
                dDuty = dDuty_Rqd;
                const double h1 = Fo.totHf();
                Fo.SetPress(PresO);
                Fo.Set_totHf(h1); //restore enthalpy
            }
            else
                dDuty = 0.0;

            if (In==IOId_2IOIn && m_LeakI.Enabled)
                m_LeakI.EvalProducts(Fo, true);
            if (In==IOId_2IOOut && m_LeakO.Enabled)
                m_LeakO.EvalProducts(Fo, true);

            L.Cd.QCopy(Fo);

            m_FTB.BeginEvalProducts(Fo);
            L.FB.SetQm(Sign(L.FB.GetQm())*Fo.QMass(som_ALL));
            L.FB.EvalProducts(L.PB(In).P, L.PB(Out).P, L.Cd, m_FTB);

            if (m_VLE.Enabled())
            {
                m_FTB.AddVLEBegin();
                m_VLE.PFlash(Fo, L.PB(Out).P, /*Valid(L.FB.ShaftPower()) ? L.FB.ShaftPower()/0.8 :*/ 0.0, VLEF_Null);
                m_FTB.AddVLEEnd();
            }
            m_FTB.EndEvalProducts();

            if (Out==IOId_2IOOut && m_LeakO.Enabled)
                m_LeakO.EvalProducts(Fo, true);
            if (Out==IOId_2IOIn && m_LeakI.Enabled)
                m_LeakI.EvalProducts(Fo, true);
        }
    }
}
Пример #10
0
Sys13::Sys13(pTagObjClass pClass_, pchar TagIn, pTaggedObject pAttach, TagObjAttachment eAttach) :
  MdlNode(pClass_, TagIn, pAttach, eAttach),
  VH1301  ("VH1301", this, TOA_Embedded),
  VH1302  ("VH1302", this, TOA_Embedded),
  VGA1301 ("VGA1301", this, TOA_Embedded),
  VBA1301 ("VBA1301", this, TOA_Embedded),
  HBA1301 ("HBA1301", this, TOA_Embedded),
  TEGStore("TEGStore", this, TOA_Embedded),
  Q1("Q1", this, TOA_Embedded),
  Q2("Q2", this, TOA_Embedded),
  Q3("Q3", this, TOA_Embedded),
  Q4("Q4", this, TOA_Embedded),
  Q5("Q5", this, TOA_Embedded),
  Q6("Q6", this, TOA_Embedded),
  Q7("Q7", this, TOA_Embedded),
  Q8("Q8", this, TOA_Embedded),
  Q9("Q9", this, TOA_Embedded),
  Qa("Qa", this, TOA_Embedded),
  Qb("Qb", this, TOA_Embedded),
  Qc("Qc", this, TOA_Embedded)
  {
  AttachClassInfo(nc_Process, S13IOAreaList);
  AllDataHere = 1;

  VH1301.SetVolume(2.6);
  VH1302.SetVolume(2.6);
  VGA1301.SetVolume(1.0);
  VBA1301.SetVolume(26.0);
  HBA1301.SetVolume(2.0);
  TEGStore.SetVolume(2.0);

  VH1301.SetStateAction(IE_Integrate);
  VH1302.SetStateAction(IE_Integrate);
  VGA1301.SetStateAction(IE_Integrate);
  VBA1301.SetStateAction(IE_Integrate);
  HBA1301.SetStateAction(IE_Integrate);
  TEGStore.SetStateAction(IE_Integrate);

  Q1m=0.0;
  Q2m=0.0;
  Q3m=0.0;
  Q4m=0.0;
  Q5m=0.0;
  Q6m=0.0;
  Q7m=0.0;
  Q8m=0.0;
  Q9m=0.0;
  Qam=0.0;
  Qbm=0.0;
  Qcm=0.0;

  bLC13111=0;
  bLC13114=0;              bLC13117=0;
  bLC13120=0;
  bPKA1301B=0;
  bPKA1301A=0;
  bPKA1301B=0;
  bPK1302A=0;
  bPK1302B=0;
  bUHA1301A=0;
  bUHA1301B=0;
  VH1301_Lvl=0.5;
  VH1301_P=AtmosPress()+300.0;
  VH1302_Lvl=0.5;
  VH1302_P=AtmosPress()+300.0;
  VGA1301_LvlSet=0.55;
  VGA1301_Lvl=0.5;
  VGA1301_P=AtmosPress()+300.0;
  HBA1301_LvlSet=0.5;
  HBA1301_Lvl=0.5;
  HBA1301_P=AtmosPress()+300.0;
  VBA1301_Lvl=0.5;

  VGA1301_T=C_2_K(100.0);
  HBA1301_T=C_2_K(100);
  VBA1301_T=C_2_K(20.0);
  VH1301_T=C_2_K(20.0);
  VH1302_T=C_2_K(20.0);

  //VB1001_LvlSet=0.65; //  changed for external controller
  //VB1001_Lvl=0.7;     // mhm comeback - this level has to come from the glycol contacter
  //FEA13050_Qm=0.0;
  QmBoil=1.0;
  QmRich=0.0;
  QmLean=0.0;
  QmCirc=1.0;
  QmXfer=1.0;
  QmFill=1.0;
  QmSetl=10.0;

  VLVin_Posn = 1.0;


  TEGStore.ZeroMass();
  TEGStore.SetSpMass(TEG.li(), 1.0);
  TEGStore.SetTemp(C_2_K(20.0));

  };