Exemplo n.º 1
0
        public override Phases[] GetListOfPresentPhases(out eCapePhaseStatus[] presentPhaseStatus)
        {
            CasterLogger.Debug("GetListOfPresentPhases");
            object phaseLabel;

            presentPhaseStatus = null;   //CO1.0 Not support
            if (_capeThermoMaterialObject == null)
            {
                return(null);
            }
            try
            {
                phaseLabel = _capeThermoMaterialObject.PhaseIds;
            }
            catch (Exception e)
            {
                CasterLogger.ErrorFormatted("No present phase. {0}", e.Message);
                Debug.WriteLine("No present phase. {0}", e.Message);
                phaseLabel = new string[0];
            }

            string[] phaseStringList = phaseLabel as string[];
            Phases[] phaseList       = (from phaseString in phaseStringList
                                        select new Phases(phaseString)).ToArray();
            var phases = string.Join(", ", phaseList.Select(p => p.Value).ToArray());

            CasterLogger.Debug("Material present phases: " + phases);
            return(phaseList);
        }
Exemplo n.º 2
0
        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[]);
        }
Exemplo n.º 3
0
        public override Phases[] GetListOfAllowedPhase(out string[] phaseAggregationList, out string keyCompoundId)
        {
            CasterLogger.Debug("GetListOfAllowedPhase");
            object allowedPhaseObject     = null;
            object phaseAggregationObject = null;
            object keyCompoundIdObject    = null;

            phaseAggregationList = null;
            keyCompoundId        = null;
            try
            {
                _capeThermoPhases.GetPhaseList(ref allowedPhaseObject, ref phaseAggregationObject, ref keyCompoundIdObject);
            }
            catch (Exception e)
            {
                CasterLogger.ErrorFormatted("Cannot get AllowedPhase. {0}", e.Message);
                Debug.WriteLine("Cannot get AllowedPhase. {0}", e.Message);
            }
            if (allowedPhaseObject == null)
            {
                return new[] { Phases.Vapor, Phases.Liquid }
            }
            ;

            phaseAggregationList = phaseAggregationObject as string[];
            keyCompoundId        = keyCompoundIdObject as string;

            string[] phaseStringList = allowedPhaseObject as string[];
            Phases[] phaseList       = (from phaseString in phaseStringList
                                        select new Phases(phaseString)).ToArray();

            //Set Proper Phase name
            var phases = string.Join(", ", phaseList.Select(p => p.Value).ToArray());

            CasterLogger.Debug("Material allowd phases: " + phases);
            if (phaseList.FirstOrDefault(phase => phase.Value.Contains("vap")) != null)
            {
                Phases.Vapor = phaseList.First(phase => phase.Value.Contains("vap"));
            }
            if (phaseList.FirstOrDefault(phase => phase.Value.Contains("liq")) != null)
            {
                Phases.Liquid = phaseList.First(phase => phase.Value.Contains("liq"));
            }
            if (phaseList.FirstOrDefault(phase => phase.Value.Contains("solid")) != null)
            {
                Phases.Liquid = phaseList.First(phase => phase.Value.Contains("solid"));
            }

            return(phaseList);
        }
Exemplo n.º 4
0
 public override string[] UpdateCompoundList()
 {
     try
     {
         aliasName = _capeThermoMaterialObject.ComponentIds as string[];
         CasterLogger.Debug("UpdateCompoundList result" + aliasName);
         return(aliasName);
     }
     catch (Exception e)
     {
         CasterLogger.ErrorFormatted("Unable to get compound list. Make sure to call UpdateComoundList after compound list changed. {0}", e.Message);
         Debug.WriteLine("Unable to get compound list. Make sure to call UpdateComoundList after compound list changed. {0}", e.Message);
         return(null);
     }
 }
Exemplo n.º 5
0
        public override string[] UpdateCompoundList()
        {
            CasterLogger.Debug("UpdateCompoundList");
            object compoundId = null, formulaId = null, names = null, boilTemps = null, molwts = null, casnos = null;

            try
            {
                _capeThermoCompounds.GetCompoundList(ref compoundId, ref formulaId,
                                                     ref names, ref boilTemps, ref molwts, ref casnos);
            }
            catch (Exception e)
            {
                CasterLogger.ErrorFormatted("Unable to get compound list. Make sure to call UpdateComoundList after compound list changed. {0}", e.Message);
                Debug.WriteLine("Unable to get compound list. Make sure to call UpdateComoundList after compound list changed. {0}", e.Message);
            }
            CasterLogger.Debug("Compound List: " + aliasName);
            return(aliasName = compoundId as string[]);
        }
Exemplo n.º 6
0
 public override double GetCompoundConstPropDouble(string propName, string compoundId)
 {
     CasterLogger.Debug($"GetCompoundConstPropDouble compound {compoundId} for {propName}");
     object[] value = _capeThermoCompounds.GetCompoundConstant(new[] { propName }, new[] { compoundId });
     CasterLogger.Debug("GetCompoundConstPropDouble result " + value);
     try
     {
         return(Convert.ToDouble(value.SingleOrDefault()));
     }
     catch (Exception) { }
     try
     {
         return((value.Single() as double[]).SingleOrDefault());
     }
     catch (Exception e)
     {
         CasterLogger.ErrorFormatted("Get compound constant prop fails. {0}", e.Message);
         Debug.WriteLine("Get compound constant prop fails. {0}", e.Message);
     }
     return(0);
 }
Exemplo n.º 7
0
 public override bool DoFlash(string[] flashSpec1, string[] flashSpec2, string solutionType, bool showWarning = false)
 {
     CasterLogger.Debug($"DoFlash for {flashSpec1} and {flashSpec2} in Solution type: {solutionType}");
     try
     {
         PresentPhases = AllowedPhases;
         _capeThermoEquilibriumRoutine.CalcEquilibrium(flashSpec1, flashSpec2, solutionType);
         //_alreadyFlashed = true;
     }
     catch (Exception e)
     {
         if (showWarning)
         {
             MessageBox.Show("Flash failed. " + e.Message);
         }
         CasterLogger.ErrorFormatted("Flash failed. {0}", e.Message);
         Debug.WriteLine("Flash failed. {0}", e.Message);
         return(false);
     }
     CasterLogger.Debug($"Finish DoFlash");
     return(true);
 }