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[]);
        }
        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)
 {
     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");
 }
        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>
 /// 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>
        /// 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[]);
        }