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"); } }
void CPrecipitator::EvalLosses(MStream & Prod) { double T = Prod.T; double TA = AmbientTemp(); /// Heat Loss to internal cooling, eg Barriquands if (!m_bCoolerOn && iCoolMethod==COOL_Hx) { m_dLiquorTout = Prod.T; m_dLMTD = 0.0; m_dCoolWaterTout = CoolIn.T; } m_dIntCoolRate=0.0; if (m_bCoolerOn && iCoolType==COOL_INTERNAL && bCoolIn && iCoolMethod == COOL_Hx ) { MStreamI TubeIn; MStreamI TubeOut; MStreamI CoolOut; if (m_bByVolFlow) m_dCoolFlow = m_dIntCoolVolFlow*Prod.Density(); else m_dIntCoolVolFlow = m_dCoolFlow/Prod.Density(); TubeIn.SetM(Prod, MP_All, m_dCoolFlow); TubeOut.SetF(TubeIn, MP_All, 1.0); CoolOut.SetF(CoolIn, MP_All, 1.0); if (TubeIn.MassFlow()>0 && CoolIn.MassFlow()>0) { m_dUA=m_dCoolArea*m_dCoolHTC; CCoolerFn Fn(m_dUA, TubeIn, CoolIn, TubeOut, CoolOut); double TubeOutT; double MxTbOutT=TubeIn.T;// No Transfer double MnTbOutT=CoolIn.T+0.001; double qShell=-CoolIn.totHz()+CoolOut.totHz(MP_All, TubeIn.T); double qTube= -TubeIn.totHz(MP_All, CoolIn.T)+TubeIn.totHz(); if (qShell<qTube) // Limited By Shell - Tube TOut Limited MnTbOutT=MxTbOutT - (qShell)/GTZ(qTube)*(MxTbOutT-MnTbOutT); switch (Fn.FindRoot(0, MnTbOutT, MxTbOutT)) { case RF_OK: TubeOutT = Fn.Result(); break; case RF_LoLimit: TubeOutT = MnTbOutT; break; case RF_HiLimit: TubeOutT = MxTbOutT; break; default: Log.Message(MMsg_Error, "TubeOutT not found - RootFinder:%s", Fn.ResultString(Fn.Error())); TubeOutT=Fn.Result(); break; } TubeOut.T = TubeOutT; m_dIntCoolRate = TubeIn.totHz() - TubeOut.totHz(); m_dCoolWaterTout = CoolOut.T; m_dCoolWaterTin = CoolIn.T; m_dCoolWaterFlow = CoolIn.Mass(); m_dCoolWaterFlowVol = CoolIn.Volume(); m_dLiquorTout = TubeOut.T; m_dLMTD=fabs(LMTD(TubeIn.T, TubeOut.T, CoolIn.T, CoolOut.T)); } } if (iCoolType==COOL_INTERNAL && iCoolMethod == COOL_dQ ) { m_dIntCoolRate = m_dCooldQ; } switch (iCoolType) { case COOL_NONE: m_dCoolRate = 0; break; case COOL_EXTERNAL: m_dCoolRate = m_dExtCoolRate; // kW break; case COOL_INTERNAL: /// Heat Loss to internal cooling, eg draft tube coolers m_dCoolRate = m_dIntCoolRate; break; } /// Evaporation Rate switch (iEvapMethod) { case EVAP_dT: m_dEvapRate = m_dEvapRateK*(T-TA); // kg/s x[3] = m_dEvapRate; break; case EVAP_FIXED: x[3] = m_dEvapRate; break; case EVAP_NONE: x[3] = 0; m_dEvapRate = 0.0; } /// Evaporative Heat Loss ... need to fix this up using stream enthalpies m_dEvapThermalLoss = 2300*m_dEvapRate; // kW... /// Heat Loss to ambient cooling m_dEnvironmentLoss = 0.0; switch (iThermalLossMethod) { case THL_Ambient: m_dEnvironmentLoss = (T-TA)*dThermalLossAmbient; //kW break; case THL_FixedHeatFlow: m_dEnvironmentLoss = dThermalLossRqd; break; } m_dTotThermalLoss = m_dEnvironmentLoss + m_dEvapThermalLoss + m_dCoolRate; }