private void SetupPropertyPackage() { flowsheet.PropertyPackages.Clear(); if (hasLowPressure) { var pp = (PropertyPackage)flowsheet.AvailablePropertyPackages["Raoult's Law"].Clone(); pp.UniqueID = Guid.NewGuid().ToString(); pp.Tag = pp.ComponentName + " (" + (flowsheet.PropertyPackages.Count + 1).ToString() + ")"; flowsheet.AddPropertyPackage(pp); return; } if (hasHC | hasHCW) { var pp = (PropertyPackage)flowsheet.AvailablePropertyPackages["Peng-Robinson (PR)"].Clone(); pp.UniqueID = Guid.NewGuid().ToString(); pp.Tag = pp.ComponentName + " (" + (flowsheet.PropertyPackages.Count + 1).ToString() + ")"; flowsheet.AddPropertyPackage(pp); return; } if (hasPolarChemicals) { var pp = (PropertyPackage)flowsheet.AvailablePropertyPackages["NRTL"].Clone(); pp.UniqueID = Guid.NewGuid().ToString(); pp.Tag = pp.ComponentName + " (" + (flowsheet.PropertyPackages.Count + 1).ToString() + ")"; flowsheet.AddPropertyPackage(pp); return; } if (hasRefrigeration) { var pp = (PropertyPackage)flowsheet.AvailablePropertyPackages["CoolProp"].Clone(); pp.UniqueID = Guid.NewGuid().ToString(); pp.Tag = pp.ComponentName + " (" + (flowsheet.PropertyPackages.Count + 1).ToString() + ")"; flowsheet.AddPropertyPackage(pp); return; } if (hasSingleCompoundWater) { var pp = (PropertyPackage)flowsheet.AvailablePropertyPackages["Steam Tables (IAPWS-IF97)"].Clone(); pp.UniqueID = Guid.NewGuid().ToString(); pp.Tag = pp.ComponentName + " (" + (flowsheet.PropertyPackages.Count + 1).ToString() + ")"; flowsheet.AddPropertyPackage(pp); return; } if (hasElectrolytes) { var pp = (PropertyPackage)flowsheet.AvailablePropertyPackages["Extended UNIQUAC (Aqueous Electrolytes)"].Clone(); pp.UniqueID = Guid.NewGuid().ToString(); pp.Tag = pp.ComponentName + " (" + (flowsheet.PropertyPackages.Count + 1).ToString() + ")"; flowsheet.AddPropertyPackage(pp); return; } }
void Initialize() { ppcontainer = new DynamicLayout(); facontainer = new DynamicLayout(); var proppacks = flowsheet.AvailablePropertyPackages.Keys.ToList(); proppacks.Insert(0, "Select an item..."); s.CreateAndAddLabelRow(container, "Property Packages"); s.CreateAndAddDescriptionRow(container, "A Property Package is a set of " + "models and methods/equations which are responsible for the calculation of compound and phase properties and for providing " + "thermodynamic properties for Unit Operation calculations, like enthalpy and entropy.\n\n" + "You need to add at least one Property Package to your simulation."); s.CreateAndAddDropDownRow(container, "Add New Property Package", proppacks, 0, (sender, e) => { var item = sender.SelectedValue.ToString(); if (item != "Select an item...") { var pp = (PropertyPackage)flowsheet.AvailablePropertyPackages[item].Clone(); pp.UniqueID = Guid.NewGuid().ToString(); pp.Tag = pp.ComponentName + " (" + (flowsheet.PropertyPackages.Count + 1).ToString() + ")"; flowsheet.AddPropertyPackage(pp); Application.Instance.AsyncInvoke(() => { AddPropPackItem(pp); ppcontainer.Create(); ppcontainer.Invalidate(); }); sender.SelectedIndex = 0; } }); s.CreateAndAddLabelRow(container, "Added Property Packages"); s.CreateAndAddControlRow(container, ppcontainer); foreach (PropertyPackage pp in flowsheet.PropertyPackages.Values) { AddPropPackItem(pp); } var flashalgos = flowsheet.AvailableFlashAlgorithms.Values.Where((x) => !x.InternalUseOnly).Select((x) => x.Name).ToList(); flashalgos.Insert(0, "Select an item..."); s.CreateAndAddLabelRow(container, "Flash Algorithms"); s.CreateAndAddDescriptionRow(container, "The Flash Algorithms in DWSIM are the components responsible for determining a particular set " + "of phases at thermodynamic equilibrium, their amounts (and the amounts of the compounds on each phase) at the specified conditions like " + "Temperature, Pressure, Total Enthalpy and Total Entropy. Some Flash Algorithms are capable of predicting equilibrium between one vapor " + "and one liquid phase, while others support another co-existing liquid and/or solid phase. As the amount of phases considered in " + "equilibrium increases, the calculation time/complexity also increases while the results' reliability decreases.\n\n" + "Some flash algorithms are more capable/reliable than others, depending on the mixture for which the flash calculation request is being " + "requested. DWSIM features a selection of flash algorithms that are capable of calculating VLE, VLLE and SLE.\n\n" + "The 'Nested Loops (VLE)' algorithm satisfies the requirements of most Vapor-Liquid Equilibria systems."); s.CreateAndAddDropDownRow(container, "Add New Flash Algorithm", flashalgos, 0, (sender, e) => { var item = sender.SelectedValue.ToString(); if (item != "Select an item...") { var fa = (IFlashAlgorithm)flowsheet.AvailableFlashAlgorithms[item].Clone(); fa.Tag = fa.Name + " (" + (flowsheet.FlowsheetOptions.FlashAlgorithms.Count + 1).ToString() + ")"; flowsheet.FlowsheetOptions.FlashAlgorithms.Add(fa); Application.Instance.AsyncInvoke(() => { AddFlashAlgorithmItem(fa); facontainer.Create(); facontainer.Invalidate(); }); sender.SelectedIndex = 0; } }); s.CreateAndAddLabelRow(container, "Added Flash Algorithms"); s.CreateAndAddControlRow(container, facontainer); foreach (IFlashAlgorithm fa in flowsheet.FlowsheetOptions.FlashAlgorithms) { AddFlashAlgorithmItem(fa); } }