void MN_Xfer::DumpDerivs() { dbgpln("--Xfr %-12s", FullObjTag()); for (int i = 0; i < NoFlwIOs(); i++) if (IO_In(i)) dbgpln(" In >> :[%14.6g][%14.6g]|[%14.6g] %14.6g %14.3fC %s", IOConduit(i)->QMass(som_SL), IOConduit(i)->QMass(som_Gas) , IOConduit(i)->msHz(), IOConduit(i)->totHf()/GTZ(IOConduit(i)->QMass(som_ALL)), K2C(IOConduit(i)->Temp()), Nd_Rmt(i)->FullObjTag()); for (i = 0; i < NoFlwIOs(); i++) if (IO_Out(i)) dbgpln(" Out << :[%14.6g][%14.6g]|[%14.6g] %14.6g %14.3fC %s", IOConduit(i)->QMass(som_SL), IOConduit(i)->QMass(som_Gas) , IOConduit(i)->msHz(), IOConduit(i)->totHf()/GTZ(IOConduit(i)->QMass(som_ALL)), K2C(IOConduit(i)->Temp()), Nd_Rmt(i)->FullObjTag()); }
/*#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; } };
void MN_Xfer::ConfigureJoins() { if (m_NetworkIsolator) { Set_NoJoins(2); for (int i=0; i<NoProcessIOs(); i++) { if (Nd_Rmt(i)->FlowMode()==LFM_Xfer) SetIO_Open(i, 1, false, ESS_Denied); else SetIO_Open(i, 0, false, ESS_Denied); } } else { int N=0; for (int i=0; i<NoProcLnkIOs(); i++) { if (Nd_Rmt(i)->FlowMode()==LFM_Xfer) N++; } bool UseClosedJoin=(NoProcLnkIOs()-N>=2); Set_NoJoins(1); for (int i=0; i<NoProcLnkIOs(); i++) { if (Nd_Rmt(i)->FlowMode()==LFM_Xfer) SetIO_Open(i, 0, false, ESS_Denied); else if (UseClosedJoin) // enforce estimated flow mass balance SetIO_Join(i, 0); else SetIO_Open(i, 0, false, ESS_Denied); } } int jj=1+1; for (int ii=NoProcLnkIOs(), jj=1+1; ii<NoFlwIOs(); ii++) { int Id=IOId_Self(ii); if (Id==IOId_XferLeak) SetIO_Join(ii, 0); else SetIO_Direct(ii, jj++); } };
bool MN_BstRes::PropagateNetInfo(CPropagateNetInfoCtrl & Ctrl, long IONo) { if (!FlwNode::DoPropagateNetInfo(Ctrl, IONo, true)) return false; for (int i=0; i<NoFlwIOs(); i++) { if (i!=IONo) Nd_Rmt(i)->PropagateNetInfo(Ctrl, IOIONo_Rmt(i)); } return true; };
bool MN_Xfer::PropagateNetInfo(CPropagateNetInfoCtrl & Ctrl, long IONo) { if (!FlwNode::DoPropagateNetInfo(Ctrl, IONo, false)) return false; if (!m_NetworkIsolator) { for (int i=0; i<NoFlwIOs(); i++) Nd_Rmt(i)->PropagateNetInfo(Ctrl, IOIONo_Rmt(i)); } return true; };
void FlashTank::BuildDataDefn(DataDefnBlk &DDB) { DDB.BeginStruct(this); DDB.Double ("Pressure", "P", DC_P, "kPag", xidPMean, this, 0); DDB.Double ("Temperature", "T", DC_T, "C", xidTemp, this, 0); DDB.Double ("Density", "Rho", DC_Rho, "kg/m^3", xidRho, this, 0); DDB.Double ("Level", "Lvl", DC_Frac, "%", xidLevel, this, 0); DDB.Text ("Datum"); DDB.Double ("Datum", "Z", DC_L , "m", &dDatum, this, isResult|0 | DYNMODE); DDB.Double ("Datum_Rqd", "Z_Rqd",DC_L , "m", &dDatum_Rqd, this, isParmStopped | DYNMODE|NAN_OK); DDB.Text (" "); DDB.Double ("POffset", "", DC_DP, "kPa", &POffset, this, 0); DDB.Text (""); DDB.CheckBoxBtn("Closed", "", DC_ , "", xidClosed, this, isParmStopped|(!gs_Environment.OK() ? noView|noFile|noSnap|noScenario:0) , DDBYesNo); DDB.CheckBoxBtn("Networked", "", DC_ , "", xidNetPressDamp, this, isParmStopped|(!gs_Environment.OK() || !Contents.Closed() ? noView|noFile|noSnap|noScenario:0) , DDBYesNo); VLE.Add_OnOff(DDB); VLE.BuildDataDefn(DDB, NULL, NULL, DDB_RqdPage, 0); if (SolveMode()==DYNMODE) { DDB.Object(&Contents, this, NULL, NULL, DDB_RqdPage); DDB.Object(&PresetImg, this, NULL, NULL, DDB_RqdPage); } DDB.Page("IOs"); Strng Commnt, Nm; for (int i=0; i<NoFlwIOs(); i++) { Nm.Set("IO_%02i", i); DDB.Double(Nm(), "", DC_Qm , "kg/s", xidIO_Qm0+i, this, 0); #ifndef UsingZTagObj DDB.VolatileTags(Nm(), Nm()); #endif Commnt.Set("%s", Nd_Rmt(i)->FullObjTag()); DDB.TagComment(Commnt()); } DDB.Double("IO_Sigma", "", DC_Qm , "kg/s", xidIO_QmSigma, this, 0); DDB.EndStruct(); };
/*This provides access to the variables of the model and calls the BuildDataDefn for objects used by the model.*/ void BeltCnv::BuildDataDefn(DataDefnBlk & DDB) { DDB.BeginStruct(this); //DDB.Page ("Parms"); DDB.Text (""); DDB.Visibility(NM_Dynamic|SM_All|HM_All); BuildDataDefnElevation(DDB); DDB.Text(""); DDB.Double ("BeltSpeed", "", DC_Ldt, "m/s", xidBeltSpeed, this, isResult); DDB.Visibility(); DDB.Double ("Length", "L", DC_L, "m", xidBeltLength, this, isParm); DDB.Visibility(NM_Dynamic|SM_All|HM_All); DDB.Double ("MaxSpeed", "", DC_Ldt, "m/s", &m_MaxVelocity, this, isParm); DDB.Double ("MaxLoading", "MaxSpillLoad", DC_MpL, "kg/m", &m_MaxSpillLoading, this, isParm); DDB.Double ("MinLoading", "", DC_MpL, "kg/m", &m_MinLoading, this, isParm|InitHidden); DDB.Long ("MaxTurndown", "", DC_, "", &m_MaxTurnDown, this, isParm|InitHidden); DDB.Visibility(NM_Dynamic|SM_All|HM_All); DDB.Double ("", "MaxStallLoad", DC_M, "kg", &m_MaxStallLoading, this, isParm); DDB.CheckBox("", "StartIfStalled", DC_, "", &m_fStartIfStalled, this, isParm); DDB.Byte ("", "WasRunning", DC_, "", &m_fWasRunning, this, isResult|InitHidden); DDB.Double ("TotalMass", "", DC_M, "kg", xidTotalMass, this, isResult); DDB.Double ("AvgLoading", "", DC_MpL, "kg/m", xidAvgLoading, this, isResult); if (OrigPrjFileVerNo()<90 && DDB.ForFileSnpScn()) DDB.String ("SpillArea", "", DC_, "", &m_sAreaTag, this, isParmStopped); DDB.Double ("TotalSpilt", "", DC_M, "kg", xidTotSpilt, this, isParm); DDB.Double ("TotalVented", "", DC_M, "kg", xidTotVented, this, isParm); DDB.Page("BeltDrive", DDB_RqdPage); DDB.Text ("Power Draw"); DDB.Double ("NoLoadPower", "", DC_Pwr, "kW", &m_NLPower, this, isParm); DDB.Double ("FullLoadPower","", DC_Pwr, "kW", &m_FLPower, this, isParm); DDB.Double ("Power", "", DC_Pwr, "kW", &m_Power, this, isResult); DDB.Text(""); m_Pwr.BuildDataDefn(DDB); m_BeltSB.BuildDataDefn(DDB, this, "Speed", 1); DDB.Visibility(); DDB.Text(""); DDB.Long ("NoWtMtrs", "", DC_, "", xidNWtMtrs, this, isParm); static DDBValueLst DDB1[] = { {QPT_None, "None" }, {QPT_FixedPts, "Fixed Points"}, {QPT_AllSections, "All Section Pts"}, {QPT_MinSections, "Min Section Pts"}, {0}}; DDB.CheckBox("ShowProfile", "", DC_, "", xidShowProf, this, isParm|SetOnChange); DDB.Visibility(NM_Dynamic|SM_All|HM_All, m_fShowProfile); DDB.Long ("ProfDispType", "", DC_, "", xidProfDispType, this, isParm, DDB1); //DDB.Visibility(NM_Dynamic|SM_All|HM_All, m_fShowProfile && m_ProfDispType==QPT_FixedPts); //DDB.Long ("ProfilePts", "", DC_, "", xidProfPts, this, isParm); DDB.Visibility(NM_Dynamic|SM_All|HM_All); DDB.Long ("NSections", "", DC_, "", xidNSections, this, isResult); if (DDB.BeginStruct(this, "MinSect", 0, DDB_NoPage)) { DDB.Double ("Length", "", DC_Frac, "%", &m_Q.m_dMinFracSectLen, this, isParm); DDB.Visibility(NM_Dynamic|SM_All|HM_All, m_Q.m_dMinFracSectLen>0); DDB.Double ("LoadTol", "", DC_Frac, "%", &m_Q.m_dLoadTol, this, isParm); DDB.Double ("TempTol", "", DC_Frac, "%", &m_Q.m_dTempTol, this, isParm); DDB.Double ("MFracTol", "", DC_Frac, "%", &m_Q.m_dMFracTol, this, isParm); } DDB.EndStruct(); DDB.Text(""); BuildDataDefnShowIOs(DDB); if (m_WtMtrPos.GetSize()) { DDB.Page("WtMtrs", DDB_RqdPage); if (DDB.BeginArray(this, "WtMtr", "WtMtr", m_WtMtrPos.GetSize(), 0)) { for (int i=0; i<m_WtMtrPos.GetSize(); i++) if (DDB.BeginElement(this, i)) { DDB.Double("Pos", "", DC_L , "m", xidWtrMtrPos0+i, this, isParm); DDB.Double("Loading", "", DC_MpL, "kg/m", xidWtrMtrLd0+i, this, isResult|0); DDB.Double("Rate", "", DC_Qm, "kg/s", xidWtrMtrRate0+i, this, isResult|0); DDB.Text(""); } } DDB.EndArray(); } int FdLst[MaxIOList], PrLst[MaxIOList]; int nFd=0, nPr=0; for (int i=0; i<NoFlwIOs(); i++) if (IOId_Self(i)==idFeed) FdLst[nFd++]=i; else if (IOId_Self(i)==idProd) PrLst[nPr++]=i; int DoOld=((!DDB.ForFiling() && !DDB.ForSnapShot() && !DDB.ForScenario() && !DDB.ForView()) || (DDB.ForFiling() && DDB.DoingPutData())); Strng Nm; DDB.Page("Feeds", DDB_RqdPage); if (DDB.BeginArray(this, "Fd", "BltCnvFd", nFd, 0)) for (i=0; i<nFd; i++) if (DDB.BeginElement(this, Nd_Rmt(FdLst[i])->FullObjTag())) { DDB.Double ("Pos", "", DC_L , "m", xidFeedPos0+i, this, isParm); DDB.Visibility(NM_Dynamic|SM_All|HM_All); DDB.CheckBoxBtn("Limited", "", DC_, "", xidFeedLimited0+i, this, isParm); DDB.Visibility(NM_Dynamic|SM_All|HM_All, m_Q.FeedLimited(i)); DDB.Double ("Capacity", "", DC_Frac, "%", xidFeedCapFrac0+i, this, isParm); DDB.Visibility(); DDB.Double ("Qm", "", DC_Qm , "kg/s", xidFeedQm0+i, this, 0); DDB.Text(""); if (DoOld) { DDB.BeginElement(this, i); DDB.Double("Pos", "", DC_L , "m", xidFeedPos0+i, this, isParm); DDB.Double("Qm", "", DC_Qm , "kg/s", xidFeedQm0+i, this, 0); } } DDB.EndArray(); DDB.Page("Products", DDB_RqdPage); if (DDB.BeginArray(this, "Pr", "BltCnvPr", nPr, 0)) for (i=0; i<nPr; i++) if (DDB.BeginElement(this, Nd_Rmt(PrLst[i])->FullObjTag())) { DDB.Double("Pos", "", DC_L , "m", xidProdPos0+i, this, isParm); DDB.Double("Removal","", DC_Frac , "%", xidProdRemove0+i, this, isParm); DDB.Double("Qm", "", DC_Qm , "kg/s", xidProdQm0+i, this, 0); DDB.Double("Loss", "", DC_Qm , "kg/s", xidProdLoss0+i, this, 0); DDB.Text(""); if (DoOld) { DDB.BeginElement(this, i); //DDB.TagComment(Nd_Rmt(PrLst[i])->FullObjTag()); //DDB.BeginElement(this, Nd_Rmt(PrLst[i])->FullObjTag()); DDB.Double("Pos", "", DC_L , "m", xidProdPos0+i, this, isParm); DDB.Double("Removal","", DC_Frac , "%", xidProdRemove0+i, this, isParm); DDB.Double("Qm", "", DC_Qm , "kg/s", xidProdQm0+i, this, 0); DDB.Double("Loss", "", DC_Qm , "kg/s", xidProdLoss0+i, this, 0); } } DDB.EndArray(); if (m_fShowProfile) DDB.Object(&m_Q.Profile(), this); //BuildDataDefnAreaIOs(DDB); DDB.EndStruct(); };
void MN_Xfer::EvalIntegral(CNodeEvalIndex & NEI) { //dbgpln("EvalIntegral - %s %s %s %s", InlineIntegral()?"Inline":" ", IntegralDone()?"IntDone":" ", GetActiveHold()?"Hold":" ", Tag()); if (m_NetworkIsolator) { //flag VLEOn=0 && VLE.Enabled(); dword IOMsk=First64IOIds; //StkSpConduit QPF("QPF", chLINEID(), this); m_Accumulator->ZeroDeriv(); #if dbgMSurge if (dbgODEOperate() || dbgODEOperateDbgBrk() && fDoDbgBrk) { dbgp(" %*s",151-24,""); if (dbgODEOperateSpc()) for (int s=0; s<SVValueCount(); s++) dbgp(" %12.12s", SVImg(s).Tag()); dbgpln(" %s.Contents", FullObjTag()); dbgp("InI:--- : T:%+13.6f = %13.6f P:%+13.6f = %13.6f M:%+13.6f = %13.6f L:%+13.6f = %13.6f", m_CnStart.DTemp(Contents), m_Accumulator->Temp(), m_CnStart.DPress(Contents), m_Accumulator->Press(), m_CnStart.DMass(Contents), m_Accumulator->Mass(), m_CnStart.DLevel(Contents)*100, m_Accumulator->Level()*100, FullObjTag()); if (dbgODEOperateSpc()) for (int s=0; s<SVValueCount(); s++) dbgp(" %12.5g", m_Accumulator->MArray()[s]); dbgpln(" %s.Contents", FullObjTag()); } #endif for (int i = 0; i < NoProcessIOs(); i++) { SpConduit * Cd; //if (VLEOn && IO_In(i)) // { // QPF->QSetF(*IOConduit(i), som_ALL, 1.0); // VLE.PFlash(QPF(), m_Accumulator->Press(), 0.0, VLEF_Null); // Cd=&QPF(); // } //else Cd=IOConduit(i); //double FracAbove=(IOAbsFracHgt_Term(i, Contents)-m_Accumulator->Level())/GTZ(IOAperture(i)); //FracAbove=Range(0.0, FracAbove, 1.0); double EntR=1.0;//FracAbove*IOEntrainRateSL(i)*Cd->QMass(som_SL)+ //(1.0-FracAbove)*IOEntrainRateG(i)*Cd->QMass(som_Gas); m_Accumulator->AddDeriv(*Cd, IOSign(i), EntR); #if dbgMSurge if (dbgODEOperate() || dbgODEOperateDbgBrk() && fDoDbgBrk) { dbgp("dM :IO > Sgn:%2i EntR:%10.4f CdQm:%10.4f %*s",IOSign(i),EntR,Cd->QMass(),151-39-24,""); if (dbgODEOperateSpc()) for (int s=0; s<SVValueCount(); s++) dbgp(" %12.5g", m_Accumulator->pModel->m_DC.m_pFd->m_M[s]*ICGetTimeInc()); dbgpln(" %s", Nd_Rmt(i)->FullObjTag()); dbgp(" < %*s",151-24,""); if (dbgODEOperateSpc()) for (int s=0; s<SVValueCount(); s++) dbgp(" %12.5g", m_Accumulator->pModel->m_DC.m_pPr->m_M[s]*ICGetTimeInc()); dbgpln(" %s %s", IOQmEst_In(i)?"IN":"", IOQmEst_Out(i)?"Out":""); } #endif } //dbgpln("EvalIntegral - AddInflow"); //m_Accumulator->AddInFlowDeriv(); //if (m_Accumulator->SpillExists()) // { // //if (m_Accumulator->Spill.Cd.QMass()>0) // // dbgpln("EvalIntegral - AddDeriv Overflow: %14.3f %s", m_Accumulator->Spill.Cd.QMass(), FullObjTag()); // m_Accumulator->AddDeriv(m_Accumulator->Spill.Cd, -1.0); // } //if (m_Accumulator->VentExists()) // { // //if (m_Accumulator->Vent.Cd.QMass()>0) // // dbgpln("EvalIntegral - AddDeriv Vent : %14.3f %s", m_Accumulator->Vent.Cd.QMass(), FullObjTag()); // m_Accumulator->AddDeriv(m_Accumulator->Vent.Cd, -1.0); // } #if dbgMSurge if (dbgODEOperate() || dbgODEOperateDbgBrk() && fDoDbgBrk) { dbgp("dM :Ovr > %*s",151-24,""); if (dbgODEOperateSpc()) for (int s=0; s<SVValueCount(); s++) dbgp(" %12.5g", m_Accumulator->pModel->m_DC.m_pFd->m_M[s]*ICGetTimeInc()); dbgpln(" %s.Contents", FullObjTag()); dbgp(" < %*s",151-24,""); if (dbgODEOperateSpc()) for (int s=0; s<SVValueCount(); s++) dbgp(" %12.5g", m_Accumulator->pModel->m_DC.m_pPr->m_M[s]*ICGetTimeInc()); dbgpln(""); } #endif m_Accumulator->pModel->m_DC.Finalise(m_Accumulator->pModel, ICGetTimeInc()); //m_Accumulator->m_DC.Finalise(this, ICGetTimeInc()); #if dbgMSurge if (dbgODEOperate() || dbgODEOperateDbgBrk() && fDoDbgBrk) { dbgp("dM :Final> %*s",151-24,""); if (dbgODEOperateSpc()) for (int s=0; s<SVValueCount(); s++) dbgp(" %12.5g", m_Accumulator->pModel->m_DC.m_pFd->m_M[s]*ICGetTimeInc()); dbgpln(" %s.Contents", FullObjTag()); dbgp(" < %*s",151-24,""); if (dbgODEOperateSpc()) for (int s=0; s<SVValueCount(); s++) dbgp(" %12.5g", m_Accumulator->pModel->m_DC.m_pPr->m_M[s]*ICGetTimeInc()); dbgpln(""); dbgp(" = %*s",151-24,""); if (dbgODEOperateSpc()) for (int s=0; s<SVValueCount(); s++) dbgp(" %12.5g", (m_Accumulator->pModel->m_DC.m_pFd->m_M[s]-m_Accumulator->pModel->m_DC.m_pPr->m_M[s])*ICGetTimeInc()); dbgpln(""); } #endif if (!GetActiveHold()) { m_Accumulator->ApplyDerivs(ICGetTimeInc(), true); //VLE.VFlash(Contents, 0.0, VLEF_Null); } //#if dbgMSurge //if (dbgODEOperate() || dbgODEOperateDbgBrk() && fDoDbgBrk) // { // dbgp("InI:End : T:%+13.6f = %13.6f P:%+13.6f = %13.6f M:%+13.6f = %13.6f L:%+13.6f = %13.6f", // m_CnStart.DTemp(Contents), m_Accumulator->Temp(), // m_CnStart.DPress(Contents), m_Accumulator->Press(), // m_CnStart.DMass(Contents), m_Accumulator->Mass(), // m_CnStart.DLevel(Contents)*100, m_Accumulator->Level()*100); // if (dbgODEOperateSpc()) // for (int s=0; s<SVValueCount(); s++) // dbgp(" %12.5g", m_Accumulator->MArray()[s]); // dbgpln(" %s.Contents", FullObjTag()); // } //#endif } SetIntegralDone(true); }