/// <summary> /// Calculate VFA/TA (volatile fatty acids / total alkalinity) value /// out of given ADM state vector x /// /// Erwin Voß: /// FOS/TAC-Herleitung, Methodik und Praktische Anwendung, VE efficiency /// solutions GmbH /// /// </summary> /// <param name="x">ADM state vector</param> /// <param name="FOS"></param> /// <param name="TAC"></param> /// <returns></returns> public static physValueBounded calcFOSTACOfADMstate(double[] x, out physValue FOS, out physValue TAC) { // see ref. 1) // FOS = biogas.ADMstate.calcVFAOfADMstate(x, "gHAceq/l"); // see ref. 1) // TAC = biogas.ADMstate.calcTACOfADMstate(x, "gCaCO3eq/l"); // physValueBounded FOS_TAC; if (TAC != new science.physValue("TAC_min", 0, "gCaCO3eq/l")) { FOS_TAC = new physValueBounded(FOS / TAC); } else { FOS_TAC = new science.physValueBounded("FOS_TAC", 0, "gHAceq/gCaCO3eq"); } // FOS_TAC.Symbol = "FOS_TAC"; FOS_TAC.setLB(Double.NegativeInfinity); FOS_TAC.printIsOutOfBounds(); return(FOS_TAC); }
/// <summary> /// TODO: /// Quelle für dieses Verhältnis suchen! /// Einheit in mol/l oder g/l, oder...? /// /// Calculate ratio of acetic to propionic acid in mol/l /// </summary> /// <param name="x">ADM state vector</param> /// <returns></returns> public static physValueBounded calcAcetic_vs_PropionicOfADMstate(double[] x) { string unit = "mol/l"; // mol/l physValue Sac = biogas.ADMstate.calcFromADMstate(x, "Sac", unit); // mol/l physValue Spro = biogas.ADMstate.calcFromADMstate(x, "Spro", unit); physValueBounded Sac_vs_Spro; if (Spro != new science.physValue(0, unit)) { Sac_vs_Spro = new physValueBounded(Sac / Spro); } else { Sac_vs_Spro = new science.physValueBounded("Ac_vs_Pro", 0, "mol/mol"); } // Sac_vs_Spro.Symbol = "Ac_vs_Pro"; Sac_vs_Spro = Sac_vs_Spro.convertUnit("mol/mol"); //Sac_vs_Spro.setLB(0); Sac_vs_Spro.printIsOutOfBounds(); return(Sac_vs_Spro); }
/// <summary> /// Calculate volatile fatty acids out of given ADM state vector x /// </summary> /// <param name="x">ADM state vector</param> /// <param name="unit"></param> /// <returns></returns> public static physValueBounded calcVFAOfADMstate(double[] x, string unit) { string unit_temp = "mol/l"; // mol/l physValue Sac = biogas.ADMstate.calcFromADMstate(x, "Sac", unit_temp); // mol/l physValue Spro = biogas.ADMstate.calcFromADMstate(x, "Spro", unit_temp); // mol/l physValue Sbu = biogas.ADMstate.calcFromADMstate(x, "Sbu", unit_temp); // mol/l physValue Sva = biogas.ADMstate.calcFromADMstate(x, "Sva", unit_temp); // mol/l physValueBounded Svfa = new physValueBounded(Sac + Spro + Sbu + Sva); Svfa = Svfa.convertUnit(unit); Svfa.Symbol = "VFA"; //Svfa.setLB(0); Svfa.printIsOutOfBounds(); return(Svfa); }
/// <summary> /// Calculates given symbol out of state vector x. The symbol in the state vector /// must be measured in FromUnit and is returned in ToUnit. Only returns the double value. /// </summary> /// <param name="x">ADM state vector</param> /// <param name="symbol">component inside the ADM state vector</param> /// <param name="FromUnit">must be the unit in which the component is measured inside /// the state vector x</param> /// <param name="ToUnit"></param> /// <param name="value"></param> public static void calcFromADMstate(double[] x, string symbol, string FromUnit, string ToUnit, out double value) { physValueBounded pvalue = calcFromADMstate(x, symbol, FromUnit, ToUnit); value = pvalue.Value; }
/// <summary> /// sum of all particulate COD containing components of ADM state /// </summary> /// <param name="x">ADM state vector</param> /// <param name="unit"></param> /// <returns></returns> public static physValueBounded calcVSOfADMstate(double[] x, string unit) { // composite (also contains SI and XI, because both of them // are inside volatile solids) [kgCOD/m^3 = gCOD/l] physValue Xc = biogas.ADMstate.calcFromADMstate(x, "Xc", unit); // carbohydrates [kgCOD/m^3 = gCOD/l] physValue Xch = biogas.ADMstate.calcFromADMstate(x, "Xch", unit); // proteins [kgCOD/m^3 = gCOD/l] physValue Xpr = biogas.ADMstate.calcFromADMstate(x, "Xpr", unit); // lipids [kgCOD/m^3 = gCOD/l] physValue Xli = biogas.ADMstate.calcFromADMstate(x, "Xli", unit); // biomass sugar degraders measured in unit physValue Xsu = biogas.ADMstate.calcFromADMstate(x, "Xsu", unit); // biomass amino acids degraders measured in unit physValue Xaa = biogas.ADMstate.calcFromADMstate(x, "Xaa", unit); // biomass LCFA degraders measured in unit physValue Xfa = biogas.ADMstate.calcFromADMstate(x, "Xfa", unit); // biomass valerate, butyrate degraders measured in unit physValue Xc4 = biogas.ADMstate.calcFromADMstate(x, "Xc4", unit); // biomass propionate degraders measured in unit physValue Xpro = biogas.ADMstate.calcFromADMstate(x, "Xpro", unit); // biomass acetate degraders measured in unit physValue Xac = biogas.ADMstate.calcFromADMstate(x, "Xac", unit); // biomass hydrogen degraders measured in unit physValue Xh2 = biogas.ADMstate.calcFromADMstate(x, "Xh2", unit); // particulate products arising from biomass decay [kgCOD/m^3 = gCOD/l] physValue Xp = biogas.ADMstate.calcFromADMstate(x, "Xp", unit); physValue XI = biogas.ADMstate.calcFromADMstate(x, "XI", unit); // //physValue SS= biogas.ADMstate.calcSSOfADMstate(x, unit); // sum of all particulate COD containing components physValueBounded VS = new physValueBounded( Xc + Xch + Xpr + Xli + // composites + ... Xsu + Xaa + Xfa + Xc4 + Xpro + Xac + Xh2 + // biomass Xp + XI); // + // biomass decay + inerts //SS); // soluble solids // VS.Symbol = "VS_COD"; //VS.setLB(0); VS.printIsOutOfBounds(); return(VS); }
/// <summary> /// Calculates the given symbol from the ADM state vector stream x and /// returns it in the given unit ToUnit. /// </summary> /// <param name="x">2dim array: /// 1st dimension: time /// 2nd dimension: ADM state vector</param> /// <param name="symbol">component of the ADM state vector</param> /// <param name="ToUnit"></param> /// <returns></returns> public static physValueBounded[] calcFromADMstate(double[,] x, string symbol, string ToUnit) { // dim 0: assumed to be time physValueBounded[] values = new physValueBounded[x.GetLength(0)]; for (int itime = 0; itime < x.GetLength(0); itime++) { // dim 1: assumed to be ADMstate.dim_stream or dim_state or similar double[] x_current = new double[x.GetLength(1)]; for (int iel = 0; iel < x_current.Length; iel++) { x_current[iel] = x[itime, iel]; } values[itime] = calcFromADMstate(x_current, symbol, ToUnit); } return(values); }
/// <summary> /// Calculates given symbol out of state vector x. The symbol in the state vector /// must be measured in FromUnit and is returned in ToUnit /// </summary> /// <param name="x">ADM state vector</param> /// <param name="symbol">component inside the ADM state vector</param> /// <param name="FromUnit">must be the unit in which the component is measured inside /// the state vector x</param> /// <param name="ToUnit"></param> /// <returns></returns> public static physValueBounded calcFromADMstate(double[] x, string symbol, string FromUnit, string ToUnit) { physValueBounded myValue; if (isofkind(symbol, "sum")) { string Acid; string Base; string Sum; // get the chars for the corresponding acid and base biogas.ADMstate.defineAcidBasePairs(symbol, out Acid, out Base, out Sum); // get concentration of acid and base in the state vector in kgCOD/m^3 physValue acid_value = biogas.ADMstate.getFromADMstate(x, Acid, FromUnit); physValue base_value = biogas.ADMstate.getFromADMstate(x, Base, FromUnit); // sum parameter measured in unit myValue = new physValueBounded(acid_value.convertUnit(ToUnit) + base_value.convertUnit(ToUnit)); } // acid or base or some other physical value else { // concentration of the physical value in kgCOD/m^3 physValue c_physValue = biogas.ADMstate.getFromADMstate(x, symbol, FromUnit); // physical value measured in unit myValue = new physValueBounded(c_physValue.convertUnit(ToUnit)); } // wegen Numerik bei Simulation können Werte schon mal negativ sein... //myValue.setLB(-1); myValue.printIsOutOfBounds(); return(myValue); }
/// <summary> /// Calculates soluble solids out ADM state vector in given unit. /// /// To soluble solids belong: /// - monosaccharides, amino acids, long chain fatty acids, /// - valeric acid, butyric acid, propionic acid, acetic acid, /// - acetic acid, hydrogen, methane, soluble inerts /// </summary> /// <param name="x">ADM state vector</param> /// <param name="unit"></param> /// <returns></returns> public static physValueBounded calcSSOfADMstate(double[] x, string unit) { // monosaccharides measured in unit physValue Ssu = biogas.ADMstate.calcFromADMstate(x, "Ssu", unit); // amino acids measured in unit physValue Saa = biogas.ADMstate.calcFromADMstate(x, "Saa", unit); // LCFA measured in unit physValue Sfa = biogas.ADMstate.calcFromADMstate(x, "Sfa", unit); // sum parameter of valeric acid and valerate measured in unit physValue Sva = biogas.ADMstate.calcFromADMstate(x, "Sva", unit); // sum parameter of butyric acid and butyrate measured in unit physValue Sbu = biogas.ADMstate.calcFromADMstate(x, "Sbu", unit); // sum parameter of propionic acid and propionate measured in unit physValue Spro = biogas.ADMstate.calcFromADMstate(x, "Spro", unit); // sum parameter of acetic acid and acetate measured in unit physValue Sac = biogas.ADMstate.calcFromADMstate(x, "Sac", unit); // hydrogen measured in unit physValue Sh2 = biogas.ADMstate.calcFromADMstate(x, "Sh2", unit); // methane measured in unit physValue Sch4 = biogas.ADMstate.calcFromADMstate(x, "Sch4", unit); // physValue SI = biogas.ADMstate.calcFromADMstate(x, "SI", unit); // physValueBounded SS = new physValueBounded(Ssu + Saa + Sfa + Sva + Sbu + Spro + Sac + Sh2 + Sch4 + SI); SS.Symbol = "SS_COD"; //SS.setLB(0); SS.printIsOutOfBounds(); return(SS); }
/// <summary> /// Calculates total alkalinity out of given ADM state vector /// /// the buffer consists out of: /// - acetate of VFAs, HCO3, aniona and cations /// </summary> /// <param name="x">ADM state vector</param> /// <param name="unit"></param> /// <returns></returns> public static physValueBounded calcTACOfADMstate(double[] x, string unit) { string unit_temp = "mol/l"; // kmol/m³ = mol/l physValue San = new science.physValue("San", x[biogas.ADMstate.pos_San - 1], "mol/l"); // mol/l physValue Shco3 = biogas.ADMstate.calcFromADMstate(x, "Shco3", unit_temp); // mol/l physValue Sac_ = biogas.ADMstate.calcFromADMstate(x, "Sac_", unit_temp); // mol/l physValue Spro_ = biogas.ADMstate.calcFromADMstate(x, "Spro_", unit_temp); // mol/l physValue Sbu_ = biogas.ADMstate.calcFromADMstate(x, "Sbu_", unit_temp); // mol/l physValue Sva_ = biogas.ADMstate.calcFromADMstate(x, "Sva_", unit_temp); // kmol/m³ = mol/l physValue Scat = new science.physValue("Scat", x[biogas.ADMstate.pos_Scat - 1], "mol/l"); // // mol/l physValueBounded TAC = new physValueBounded(San + Shco3 + Sac_ + Spro_ + Sva_ + Sbu_ - Scat); // TAC = TAC.convertUnit(unit); TAC.Symbol = "TAC"; //TAC.setLB(-double.Epsilon); TAC.printIsOutOfBounds(); return(TAC); }