/// <summary> /// Constructor /// </summary> /// <param name="refrigerantCategory">PureFluid, PredefinedMixture, NewMixture, PseudoPureFluid</param> /// <param name="refrigerantName">e.g. : R22,or R410A,or "R22=0.5,R134a=0.5"(0.5 is the mole composition</param> public Refrigerant(RefrigerantCategory refrigerantCategory, string refrigerantName,ReferenceState reference) { //this.Category = refrigerantCategory; this.Name = refrigerantName; if (refrigerantCategory == RefrigerantCategory.PureFluid) { base.LoadFluid(Name + ".fld", 1, new double[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },reference.ToString()); } else if (refrigerantCategory == RefrigerantCategory.PredefinedMixture) { base.LoadPredefinedFluid(Name + ".mix",reference.ToString()); } else if (refrigerantCategory == RefrigerantCategory.NewMixture) { string[] a = refrigerantName.Split(','); double[] b = new double[20]; string c = ""; for (int i = 0; i < a.Length; i++) { c += a[i].Split('=')[0]; b[i] = Convert.ToDouble((a[i].Split('='))[1]); c += ".fld|"; } base.LoadFluid(c, a.Length, b,reference.ToString()); } else { } if (NumberOfComponents < 1) throw new Exception("Number of Components is less than 1"); components = new Comonent[NumberOfComponents]; for (int i = 0; i < NumberOfComponents; i++) { double wm = 0.0, ttp = 0.0, tnbp = 0.0, tc = 0.0, pc = 0.0, Dc = 0.0, Zc = 0.0, acf = 0.0, dip = 0.0, Rgas = 0.0; base.GetComponentInfo(i + 1, ref wm, ref ttp, ref tnbp, ref tc, ref pc, ref Dc, ref Zc, ref acf, ref dip, ref Rgas); components[i] = new Comonent(); components[i].MolecularWeight = wm; components[i].TriplePointTemperature = ttp; components[i].NormalBoilingPointTemperature = tnbp; components[i].CriticalTemperature = tc; components[i].CriticalPressure = pc; components[i].CriticalDensity = Dc; components[i].Compressibility = Zc; components[i].AccentricFactor = acf; components[i].DipoleMoment = dip; components[i].GasConstant = Rgas; components[i].Mass_Fraction = MassFractions[i]; components[i].MoleFraction = MoleFractions[i]; if (NumberOfComponents == 1) components[i].Name = refrigerantName; else if(refrigerantCategory == RefrigerantCategory.PredefinedMixture) components[i].Name = base.hfiles.ToString().Split('|')[i]; else if(refrigerantCategory == RefrigerantCategory.NewMixture) components[i].Name = refrigerantName.Split(',', '=')[i * 2]; } }
/// <summary> /// Constructor /// </summary> /// <param name="refrigerantCategory">PureFluid, PredefinedMixture, NewMixture, PseudoPureFluid</param> /// <param name="refrigerantName">e.g. : R22,or R410A,or "R22=0.5,R134a=0.5"(0.5 is the mole composition</param> public Refrigerant(RefrigerantCategory refrigerantCategory, string refrigerantName, ReferenceState reference) { //this.Category = refrigerantCategory; this.Name = refrigerantName; if (refrigerantCategory == RefrigerantCategory.PureFluid) { base.LoadFluid(Name + ".fld", 1, new double[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, reference.ToString()); } else if (refrigerantCategory == RefrigerantCategory.PredefinedMixture) { base.LoadPredefinedFluid(Name + ".mix", reference.ToString()); } else if (refrigerantCategory == RefrigerantCategory.NewMixture) { string[] a = refrigerantName.Split(','); double[] b = new double[20]; string c = ""; for (int i = 0; i < a.Length; i++) { c += a[i].Split('=')[0]; b[i] = Convert.ToDouble((a[i].Split('='))[1]); c += ".fld|"; } base.LoadFluid(c, a.Length, b, reference.ToString()); } else { } if (NumberOfComponents < 1) { throw new Exception("Number of Components is less than 1"); } components = new Comonent[NumberOfComponents]; for (int i = 0; i < NumberOfComponents; i++) { double wm = 0.0, ttp = 0.0, tnbp = 0.0, tc = 0.0, pc = 0.0, Dc = 0.0, Zc = 0.0, acf = 0.0, dip = 0.0, Rgas = 0.0; base.GetComponentInfo(i + 1, ref wm, ref ttp, ref tnbp, ref tc, ref pc, ref Dc, ref Zc, ref acf, ref dip, ref Rgas); components[i] = new Comonent(); components[i].MolecularWeight = wm; components[i].TriplePointTemperature = ttp; components[i].NormalBoilingPointTemperature = tnbp; components[i].CriticalTemperature = tc; components[i].CriticalPressure = pc; components[i].CriticalDensity = Dc; components[i].Compressibility = Zc; components[i].AccentricFactor = acf; components[i].DipoleMoment = dip; components[i].GasConstant = Rgas; components[i].Mass_Fraction = MassFractions[i]; components[i].MoleFraction = MoleFractions[i]; if (NumberOfComponents == 1) { components[i].Name = refrigerantName; } else if (refrigerantCategory == RefrigerantCategory.PredefinedMixture) { components[i].Name = base.hfiles.ToString().Split('|')[i]; } else if (refrigerantCategory == RefrigerantCategory.NewMixture) { components[i].Name = refrigerantName.Split(',', '=')[i * 2]; } } }