public override bool LoadData(List <System.Xml.Linq.XElement> data) { base.LoadData(data); System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.InvariantCulture; foreach (XElement xel in (from xel2 in data where xel2.Name == "InteractionParameters" select xel2).SingleOrDefault().Elements().ToList()) { PCSIP ip = new PCSIP { compound1 = xel.Attribute("Compound1").Value, compound2 = xel.Attribute("Compound2").Value, casno1 = xel.Attribute("CAS1").Value, casno2 = xel.Attribute("CAS2").Value, kij = double.Parse(xel.Attribute("Value").Value, ci) }; Dictionary <string, PCSIP> dic = new Dictionary <string, PCSIP>(); dic.Add(xel.Attribute("CAS1").Value, ip); if (!this.InteractionParameters.ContainsKey(xel.Attribute("CAS1").Value)) { this.InteractionParameters.Add(xel.Attribute("CAS1").Value, dic); } else { if (!this.InteractionParameters[xel.Attribute("CAS1").Value].ContainsKey(xel.Attribute("CAS2").Value)) { this.InteractionParameters[xel.Attribute("CAS1").Value].Add(xel.Attribute("CAS2").Value, ip); } else { this.InteractionParameters[xel.Attribute("CAS1").Value][xel.Attribute("CAS2").Value] = ip; } } } foreach (XElement xel in (from xel2 in data where xel2.Name == "CompoundParameters" select xel2).SingleOrDefault().Elements().ToList()) { PCSParam param = new PCSParam { compound = xel.Attribute("Compound").Value, casno = xel.Attribute("CAS_ID").Value, mw = double.Parse(xel.Attribute("MW").Value, ci), m = double.Parse(xel.Attribute("m").Value, ci), sigma = double.Parse(xel.Attribute("sigma").Value, ci), epsilon = double.Parse(xel.Attribute("epsilon_k").Value, ci), associationparams = xel.Attribute("assocparam").Value.Replace("|", System.Environment.NewLine) }; if (!this.CompoundParameters.ContainsKey(xel.Attribute("CAS_ID").Value)) { this.CompoundParameters.Add(xel.Attribute("CAS_ID").Value, param); } else { this.CompoundParameters[xel.Attribute("CAS_ID").Value] = param; } } return(true); }
public void AddPCS(object sender, EventArgs args) { var pcs = new PCSParam("小板", (this.programTree.SelectedNode.Tag as NodeParam)); new PasteListNode(pcs); new BadmarkListNode(pcs); new ReadCodeListNode(pcs); this.RefreshTree(); }
/// <summary> /// 更新Mark点,修正PCS内的相对坐标 /// </summary> /// <param name="mark1"></param> /// <param name="newMark1"></param> /// <param name="board"></param> public void UpdateMark(MarkParam mark1, PointF newMark1, PCSParam board) { }
private void PCSAFT_Editor_Load(object sender, EventArgs e) { Loaded = false; chkUseLK.Checked = PP.UseLeeKeslerEnthalpy; List <ICompoundConstantProperties> compounds; if (GlobalSettings.Settings.CAPEOPENMode) { compounds = PP._selectedcomps.Values.Select(x => (ICompoundConstantProperties)x).ToList(); } else { compounds = PP.Flowsheet.SelectedCompounds.Values.ToList(); } foreach (ICompoundConstantProperties cp in compounds) { gt0: if (PP.InteractionParameters.ContainsKey(cp.CAS_Number)) { foreach (ICompoundConstantProperties cp2 in compounds) { if (cp.CAS_Number != cp2.CAS_Number) { if (!PP.InteractionParameters[cp.CAS_Number].ContainsKey(cp2.CAS_Number)) { //check if collection has id2 as primary id if (PP.InteractionParameters.ContainsKey(cp2.CAS_Number)) { if (!PP.InteractionParameters[cp2.CAS_Number].ContainsKey(cp.CAS_Number)) { var ip = new PCSIP(); ip.casno1 = cp.CAS_Number; ip.casno2 = cp2.CAS_Number; ip.compound1 = cp.Name; ip.compound2 = cp2.Name; PP.InteractionParameters[cp.CAS_Number].Add(cp2.CAS_Number, ip); dgvkij.Rows.Add(new object[] { cp.Name, cp2.Name, ip.kij }); dgvkij.Rows[dgvkij.Rows.Count - 1].Cells[0].Tag = cp.CAS_Number; dgvkij.Rows[dgvkij.Rows.Count - 1].Cells[1].Tag = cp2.CAS_Number; } } } else { double a12 = PP.InteractionParameters[cp.CAS_Number][cp2.CAS_Number].kij; dgvkij.Rows.Add(new object[] { cp.Name, cp2.Name, a12 }); dgvkij.Rows[dgvkij.Rows.Count - 1].Cells[0].Tag = cp.CAS_Number; dgvkij.Rows[dgvkij.Rows.Count - 1].Cells[1].Tag = cp2.CAS_Number; } } } } else { PP.InteractionParameters.Add(cp.CAS_Number, new Dictionary <string, PCSIP>()); goto gt0; } } dgvparams.Rows.Clear(); foreach (ICompoundConstantProperties cp in compounds) { gt1: if (PP.CompoundParameters.ContainsKey(cp.CAS_Number)) { double mw = PP.CompoundParameters[cp.CAS_Number].mw; double m = PP.CompoundParameters[cp.CAS_Number].m; double sigma = PP.CompoundParameters[cp.CAS_Number].sigma; double epsilon = PP.CompoundParameters[cp.CAS_Number].epsilon; string assocpar = PP.CompoundParameters[cp.CAS_Number].associationparams; dgvparams.Rows.Add(new object[] { cp.Name, cp.CAS_Number, m, sigma, epsilon }); dgvparama.Rows.Add(new object[] { cp.Name, assocpar }); dgvparama.Rows[dgvparama.Rows.Count - 1].Cells[0].Tag = cp.CAS_Number; } else { var par = new PCSParam(); par.compound = cp.Name; par.casno = cp.CAS_Number; par.mw = cp.Molar_Weight; PP.CompoundParameters.Add(cp.CAS_Number, par); goto gt1; } } Loaded = true; }