public override void SetOverallPropList(string propName, PropertyBasis basis, IEnumerable <double> value) { CasterLogger.Debug($"Set property {propName} for overall: {value}"); double[] temp = value as double[] ?? value.ToArray(); _capeThermoMaterial.SetOverallProp(propName, basis.ToString(), value); //_alreadyFlashed = false; CasterLogger.Debug($"Set property complete"); }
/// <summary> /// set single phase composition, eg.set V or L in RadFrac /// </summary> public void SetSinglePhaseComposition(Phases phase, PropertyBasis basis, Dictionary <string, double> composition) { double[] temp = new double[CompoundNum]; for (int i = 0; i < CompoundNum; i++) { temp[i] = composition[Compounds[i]]; } SetSinglePhaseComposition(phase, PropertyBasis.Mole, temp); }
public override double[] GetOverallPropList(string propName, PropertyBasis basis, bool calculate = false) { CasterLogger.Debug($"Get property {propName} for overall"); object value = null; _capeThermoMaterial.GetOverallProp(propName, basis.ToString(), ref value); CasterLogger.Debug($"Property {propName} result: {value}"); return(value as double[]); }
public override void SetSinglePhasePropList(string propName, Phases phase, PropertyBasis basis, IEnumerable <double> value) { CasterLogger.Debug($"Set property {propName} for phase {phase}: {value}"); if (PresentPhases.All(p => p.Value != phase.Value)) { PresentPhases = AllowedPhases; } double[] temp = value as double[] ?? value.ToArray(); _capeThermoMaterial.SetSinglePhaseProp(propName, phase.Value, basis.ToString(), temp); //_alreadyFlashed = false; CasterLogger.Debug($"Set property complete"); }
/// <summary> /// get the vapor or liquid part composition of the material, must be flashed first! /// </summary> public Dictionary <string, double> GetSinglePhaseComposition(Phases phase, PropertyBasis basis) { var composition = new Dictionary <string, double>(); var compoundList = Compounds; double[] compositionList = GetSinglePhasePropList("fraction", phase, basis); for (int i = 0; i < compoundList.Length; i++) { composition.Add(compoundList[i], compositionList[i]); } return(composition); }
/// <summary> /// get single phase property, return a double number, will try to calculate property first, if not present, return 0; if property is an array, throw exception /// </summary> public double GetSinglePhasePropDouble(string propName, Phases phase, PropertyBasis basis, bool calculate = true) { CasterLogger.Debug($"GetSinglePhasePropDouble for {propName} in {phase} Calculate: {calculate}"); if (PresentPhases.All(p => p.Value != phase.Value)) { return(0); } var result = GetSinglePhasePropList(propName, phase, basis, calculate).SingleOrDefault(); CasterLogger.Debug($"GetSinglePhasePropDouble result: {result}"); return(result); }
/// <summary> /// Calculate or get property /// </summary> /// <param name="propName">property name, defined in CO reference</param> /// <param name="phases">empty means </param> /// <param name="basis"></param> /// <param name="calculate"></param> /// <returns></returns> protected double[] GetPropList(string propName, PropertyBasis basis, Phases[] phases = null, bool calculate = true) { object value = null; try { // overall don't need calculate if (calculate && phases != null && phases.Length != 0) { CasterLogger.Debug($"Calculate property {propName} for {phases}"); _capeThermoMaterialObject.CalcProp(new[] { propName }, phases, "mixture"); } } catch (Exception e) { Debug.WriteLine("Calculate single phase prop {0} fails. {1}", propName, e.Message); } if (phases == null || phases.Length == 0) // overall { CasterLogger.Debug($"Get property {propName} for overall phase"); value = _capeThermoMaterialObject.GetProp(propName, "Overall", null, "mixture", basis.ToString()); } else if (phases.Length == 1) // one phase { CasterLogger.Debug($"Get property {propName} for {phases[0]}"); value = _capeThermoMaterialObject.GetProp(propName, phases[0].Value, null, "mixture", basis.ToString()); } else if (phases.Length == 2) // two phases, example: kvalues { CasterLogger.Debug($"Get property {propName} for {phases[0]} and {phases[1]}"); string phaseName = null; if (phases.Contains(Phases.Vapor) && phases.Contains(Phases.Liquid)) { phaseName = Phases.Vapor.Value + Phases.Liquid.Value; // vapor in front } else { phaseName = phases[0].Value + phases[1].Value; } value = _capeThermoMaterialObject.GetProp(propName, phaseName, null, "mixture", basis.ToString()); } else { CasterLogger.Error($"Only support overall, 1 phase or 2 phases"); throw new ArgumentOutOfRangeException($"Only support overall, 1 phase or 2 phases"); } CasterLogger.Debug($"Get property {propName}: {value}"); return(value as double[]); }
/// <summary> /// set property /// </summary> /// <param name="propName">property name, defined in CO reference</param> /// <param name="phases">empty means overall, if it's vapor and liquid, will be combined to "vaporliquid", otherwise, just add the names</param> /// <returns></returns> protected void SetPropList(string propName, PropertyBasis basis, IEnumerable <double> value, Phases[] phases = null) { CasterLogger.Debug($"Set property for {propName}: {value}"); double[] temp = value as double[] ?? value.ToArray(); if (phases == null || phases.Length == 0) // overall { CasterLogger.Debug($"Set property {propName} for overall phase"); _capeThermoMaterialObject.SetProp(propName, "Overall", null, "mixture", basis.ToString(), temp); } else if (phases.Length == 1) // one phase { CasterLogger.Debug($"Set property {propName} for {phases[0]}"); _capeThermoMaterialObject.SetProp(propName, phases[0].Value, null, null, basis.ToString(), temp); } else if (phases.Length == 2) // two phases { CasterLogger.Debug($"Set property {propName} for {phases[0]} and {phases[1]}"); string phaseName = null; if (phases.Contains(Phases.Vapor) && phases.Contains(Phases.Liquid)) { phaseName = Phases.Vapor.Value + Phases.Liquid.Value; // vapor in front } else { phaseName = phases[0].Value + phases[1].Value; } _capeThermoMaterialObject.SetProp(propName, phaseName, null, "mixture", basis.ToString(), temp); } else { CasterLogger.Error($"Only support overall, 1 phase or 2 phases"); throw new ArgumentOutOfRangeException($"Only support overall, 1 phase or 2 phases"); } //_alreadyFlashed = false; CasterLogger.Debug($"Set property completed"); }
/// <summary> /// set two phase property /// </summary> public void SetTwoPhasePropDouble(string propName, Phases phase1, Phases phase2, PropertyBasis basis, double value) { CasterLogger.Debug($"SetTwoPhasePropDouble {propName} for {phase1} and {phase2}, {value}"); SetTwoPhasePropList(propName, phase1, phase2, basis, new[] { value }); CasterLogger.Debug($"SetTwoPhasePropDouble completed"); }
/// <summary> /// set two phase property, /// </summary> /// <paramCollection name="value">the value to be set, MUST be IEnumerable double, if you want to set other data structure, use the raw interface</paramCollection> public abstract void SetTwoPhasePropList(string propName, Phases phase1, Phases phase2, PropertyBasis basis, IEnumerable <double> value);
/// <summary> /// Get two phase property, if a phase is not present, will return new double[CompoundNum] /// </summary> public abstract double[] GetTwoPhasePropList(string propName, Phases phase1, Phases phase2, PropertyBasis basis, bool calculate = true);
/// <summary> /// get overall property, return a double array, if result is a single number, will return a single element array /// </summary> public abstract double[] GetOverallPropList(string propName, PropertyBasis basis, bool calculate = false);
public override double[] GetTwoPhasePropList(string propName, Phases phase1, Phases phase2, PropertyBasis basis, bool calculate = true) { return(GetPropList(propName, basis, new[] { phase1, phase2 }, calculate)); }
public override double[] GetTwoPhasePropList(string propName, Phases phase1, Phases phase2, PropertyBasis basis, bool calculate = true) { CasterLogger.Debug($"Get property {propName} for phase {phase1} and {phase2}"); object value = null; if (PresentPhases.All(p => p.Value != phase1.Value) || PresentPhases.All(p => p.Value != phase2.Value)) { return(new double[CompoundNum]); } string[] phaseList = { phase1.Value, phase2.Value }; try { _capeThermoPropertyRoutine.CalcTwoPhaseProp(new[] { propName }, phaseList); } catch (Exception e) { Debug.WriteLine("Calculate two phase prop {0} fails. {1}", propName, e.Message); } _capeThermoMaterial.GetTwoPhaseProp(propName, phaseList, basis.ToString(), ref value); CasterLogger.Debug($"Property {propName} result: {value}"); return(value as double[]); }
/// <summary> /// get single phase flow /// </summary> public double GetSinglePhaseFlow(Phases phase, PropertyBasis basis) { return(GetSinglePhasePropDouble("phaseFraction", phase, basis, false) * TotalFlow); }
/// <summary> /// set single pahse property /// </summary> public void SetSinglePhasePropDouble(string propName, Phases phase, PropertyBasis basis, double value) { CasterLogger.Debug($"SetSinglePhasePropDouble for {propName} in {phase}: {value}"); SetSinglePhasePropList(propName, phase, basis, new[] { value }); CasterLogger.Debug($"SetSinglePhasePropDouble completed."); }
/// <summary> /// set overall property /// </summary> /// <paramCollection name="value">the value to be set, MUST be IEnumerable double, if you want to set other data structure, use the raw interface</paramCollection> public abstract void SetOverallPropList(string propName, PropertyBasis basis, IEnumerable <double> value);
/// <summary> /// set overall property /// </summary> public void SetOverallPropDouble(string propName, PropertyBasis basis, double value) { CasterLogger.Debug($"SetOverallPropDouble for {propName}, value is {value}"); SetOverallPropList(propName, basis, new[] { value }); CasterLogger.Debug($"SetOverallPropDouble completed."); }
public override double[] GetOverallPropList(string propName, PropertyBasis basis, bool calculate = false) { return(GetPropList(propName, basis)); }
public override double[] GetSinglePhasePropList(string propName, Phases phase, PropertyBasis basis, bool calculate = true) { CasterLogger.Debug($"Get property {propName} for phase {phase}"); object value = null; if (PresentPhases.All(p => p.Value != phase.Value)) { return(new double[CompoundNum]); //default is 0 for every element } try { if (calculate) { _capeThermoPropertyRoutine.CalcSinglePhaseProp(new[] { propName }, phase.Value); } } catch (Exception e) { CasterLogger.ErrorFormatted("Calculate single phase prop {0} fails. {1}", propName, e.Message); Debug.WriteLine("Calculate single phase prop {0} fails. {1}", propName, e.Message); } _capeThermoMaterial.GetSinglePhaseProp(propName, phase.Value, basis.ToString(), ref value); CasterLogger.Debug($"Property {propName} result: {value}"); return(value as double[]); }
public override void SetOverallPropList(string propName, PropertyBasis basis, IEnumerable <double> value) { SetPropList(propName, basis, value); }
/// <summary> /// Set composition of single phase, the composition is ordered by Compounds /// </summary> public void SetSinglePhaseComposition(Phases phase, PropertyBasis basis, IEnumerable <double> composition) { var enumerable = composition as double[] ?? composition.ToArray(); SetSinglePhasePropList("fraction", phase, PropertyBasis.Mole, enumerable); }
public override void SetTwoPhasePropList(string propName, Phases phase1, Phases phase2, PropertyBasis basis, IEnumerable <double> value) { SetPropList(propName, basis, value, new[] { phase1, phase2 }); }
/// <summary> /// get overall property, return a double number, if not present, return 0; if result is an array, throw an exception /// </summary> public double GetOverallPropDouble(string propName, PropertyBasis basis) { CasterLogger.Debug($"GetOverallPropDouble for {propName}"); return(GetOverallPropList(propName, basis).Single()); }