| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Diagnostics; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Text.Json.Nodes; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace DPumpHydr.WinFrmUI.Volute.ViewModel |
| | | { |
| | |
| | | public double SectionArea { get; set; }//é¢ç§¯:ç±occè®¡ç® |
| | | public double BaseWidth { get; set; }//åºé¨å®½åº¦ å°±æ¯B3 |
| | | public double BaseCircleRadius { get; set; }//åºé¨ååå¾ å°±æ¯D3/2 |
| | | public eSectionShapeType ShapeType { get; set; } |
| | | |
| | | public void Initialparameters(int index, SectionBaseInfo sectionBaseInfo) |
| | | { |
| | | this.Index = index; |
| | | this.Gama_Left = sectionBaseInfo.GaMa1[index]; |
| | | this.Gama_Right = sectionBaseInfo.GaMa2[index]; |
| | | this.H = sectionBaseInfo.H[index]; |
| | | this.R_out = sectionBaseInfo.R_out; |
| | | this.R_Left = sectionBaseInfo.R_Left[index]; |
| | | this.R_Right = sectionBaseInfo.R_Right[index]; |
| | | this.ShapeType = sectionBaseInfo.ShapeType;// |
| | | this.BaseWidth = sectionBaseInfo.BaseWidth; |
| | | this.BaseCircleRadius = sectionBaseInfo.BaseCircleRadius; |
| | | } |
| | | |
| | | public string DeriveArgument(ViewModel.SectionBaseInfo sectionBaseInfo) |
| | | { |
| | | var jsonArray = new StringBuilder("[\n"); |
| | | for (int i = 1; i < sectionBaseInfo.GaMa1.Count - 1; i++) |
| | | { |
| | | Initialparameters(i, sectionBaseInfo); |
| | | jsonArray.Append(" {\n"); |
| | | jsonArray.AppendFormat(" \"Index\":{0},\n", this.Index); |
| | | jsonArray.AppendFormat(" \"Gama_Left\":{0:F2},\n", this.Gama_Left); |
| | | jsonArray.AppendFormat(" \"Gama_Right\":{0:F2},\n", this.Gama_Right); |
| | | jsonArray.AppendFormat(" \"H\":{0:F2},\n", this.H); |
| | | jsonArray.AppendFormat(" \"R_out\":{0:F2},\n", this.R_out); |
| | | jsonArray.AppendFormat(" \"R_Left\":{0:F2},\n", this.R_Left); |
| | | jsonArray.AppendFormat(" \"R_Right\":{0:F2},\n", this.R_Right); |
| | | jsonArray.AppendFormat(" \"SectionArea\":{0:F2},\n", this.SectionArea); |
| | | jsonArray.AppendFormat(" \"BaseWidth\":{0:F2},\n", this.BaseWidth); |
| | | jsonArray.AppendFormat(" \"BaseCircleRadius\":{0:F2}\n", this.BaseCircleRadius); |
| | | jsonArray.Append(" },\n"); // ç»æå¯¹è±¡ |
| | | } |
| | | jsonArray.Length -= 2; |
| | | jsonArray.Append("\n"); |
| | | jsonArray.Append("]"); // ç»ææ°ç» |
| | | return jsonArray.ToString(); |
| | | } |
| | | |
| | | //public static void WriteToFile(string json, string filePath) |
| | | //{ |
| | | // File.WriteAllText(filePath, json); |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®é¢ç§¯è®¡ç®é«åº¦ |
| | | /// </summary> |
| | | public double CalcHeightByArea(eSectionShapeType SectionType) |
| | | { |
| | | { |
| | | double a = (Math.Tan(Gama_Left * Math.PI / 180) + Math.Tan(Gama_Right * Math.PI / 180)) / 2; |
| | | double b = BaseWidth; |
| | | double c = (90 + Gama_Right) / 360 * Math.PI * R_Left * R_Left + (90 + Gama_Left) / 360 * Math.PI * R_Right * R_Right |
| | | - R_Left * R_Left * Math.Tan((45 + Gama_Right / 2) * Math.PI / 180) - R_Right * R_Right * Math.Tan((45 + Gama_Left / 2) * Math.PI / 180) - SectionArea; |
| | | double delta = b * b - 4 * a * c; |
| | | if (delta < 0) return -1; |
| | | if ( SectionType == eSectionShapeType.ç©å½¢ )//ç©å½¢ |
| | | if (delta < 0) return -1; |
| | | if (SectionType == eSectionShapeType.ç©å½¢)//ç©å½¢ |
| | | { |
| | | return -c / b; |
| | | return -c / b; |
| | | } |
| | | else |
| | | { |
| | | if (delta < 0) return -1; |
| | | return (-b + Math.Sqrt(delta)) / (2 * a); |
| | | if (delta < 0) return -1; |
| | | return (-b + Math.Sqrt(delta)) / (2 * a); |
| | | } |
| | | } |
| | | |
| | | private double DecreaseR = 0.5; |
| | | public bool CalculateR(eSectionShapeType SectionType, HdrBaseInfo BaseInfo, bool isFirst) |
| | | { |
| | | if (!isFirst) |
| | | { |
| | | R_Left = R_Left - DecreaseR; |
| | | R_Right = R_Right - DecreaseR; |
| | | //private double DecreaseR = 0.5; |
| | | //public bool CalculateR(HdrBaseInfo BaseInfo, SectionBaseInfo sectionBaseInfo, GeomBaseInfo geomBaseInfo, bool isFirst) |
| | | //{ |
| | | // if (!isFirst) |
| | | // { |
| | | // R_Left = R_Left - DecreaseR; |
| | | // R_Right = R_Right - DecreaseR; |
| | | |
| | | if (R_Left > (H - 1)) |
| | | R_Left = Math.Round(H * 0.85 - 1,0); |
| | | if (R_Right > (H - 1)) |
| | | R_Right = Math.Round(H * 0.85 - 1,0); |
| | | // if (R_Left > (H - 1)) |
| | | // R_Left = Math.Round(H * 0.85 - 1,0); |
| | | // if (R_Right > (H - 1)) |
| | | // R_Right = Math.Round(H * 0.85 - 1,0); |
| | | |
| | | if (R_Left < 2) |
| | | R_Left = 2; |
| | | if (R_Right < 2) |
| | | R_Right = 2; |
| | | } |
| | | else//æ¯ç¬¬ä¸æ¬¡è®¡ç® |
| | | { |
| | | //èµå¼ï¼R1 R2 R3 R4 |
| | | if (SectionType == eSectionShapeType.对称) //typeï¼0ï¼å¯¹ç§°æ¢¯å½¢ |
| | | R_Left = Math.Round(BaseWidth * 0.55 + 0.5 - 4,0); |
| | | else if (SectionType == eSectionShapeType.ä¸å¯¹ç§°)//typeï¼1ï¼ä¸å¯¹ç§°æ¢¯å½¢ |
| | | R_Left = Math.Round(BaseWidth * 0.55 + 0.5 - 4,0); |
| | | else if (SectionType == eSectionShapeType.ç©å½¢)//typeï¼2ï¼ç©å½¢ |
| | | R_Left = Math.Round(BaseWidth * 0.4 + 0.5 - 2,0); |
| | | // if (R_Left < 2) |
| | | // R_Left = 2; |
| | | // if (R_Right < 2) |
| | | // R_Right = 2; |
| | | // } |
| | | // else//æ¯ç¬¬ä¸æ¬¡è®¡ç® |
| | | // { |
| | | |
| | | // //èµå¼ï¼R1 R2 R3 R4 |
| | | // if (sectionBaseInfo.ShapeType == eSectionShapeType.对称) //typeï¼0ï¼å¯¹ç§°æ¢¯å½¢ |
| | | // R_Left = Math.Round(BaseWidth * 0.55 + 0.5 - 4,0); |
| | | // else if (sectionBaseInfo.ShapeType == eSectionShapeType.ä¸å¯¹ç§°)//typeï¼1ï¼ä¸å¯¹ç§°æ¢¯å½¢ |
| | | // R_Left = Math.Round(BaseWidth * 0.55 + 0.5 - 4,0); |
| | | // else if (sectionBaseInfo.ShapeType == eSectionShapeType.ç©å½¢)//typeï¼2ï¼ç©å½¢ |
| | | // R_Left = Math.Round(BaseWidth * 0.4 + 0.5 - 2,0); |
| | | |
| | | |
| | | if (BaseInfo.IsSXB) |
| | | R_Left = Math.Round(R_Left / 2,0); |
| | | //if (DesignMode == YSSnxOpen::DesignMode::AssPawuQnshQw1) |
| | | //{ |
| | | // R_Left = int(R_Left * 0.7); |
| | | //} |
| | | double m_R3 = 0; |
| | | double t = 0; |
| | | if (BaseWidth <= 35) |
| | | m_R3 = 5; |
| | | else if (BaseWidth <= 60 && BaseWidth > 35) |
| | | { |
| | | t = Math.Round(BaseWidth * 0.6, 0) - Math.Round(BaseWidth * 0.6 / 10.0, 0) * 10; |
| | | if (t <= 2) |
| | | m_R3 = Math.Round(BaseWidth * 0.6 / 10.0, 0) * 10; |
| | | else if (t > 2 && t <= 7) |
| | | m_R3 = Math.Round(BaseWidth * 0.6 / 10.0, 0) * 10 + 5; |
| | | else if (t > 7) |
| | | m_R3 = Math.Round(BaseWidth * 0.6 / 10.0, 0) * 10 + 10; |
| | | } |
| | | else if (BaseWidth > 60 && BaseWidth <= 90) |
| | | { |
| | | t = Math.Round(BaseWidth * 0.9, 0) - Math.Round(BaseWidth * 0.9 / 10.0, 0) * 10; |
| | | if (t <= 2) |
| | | m_R3 = Math.Round(BaseWidth * 0.9 / 10.0, 0) * 10; |
| | | else if (t > 2 && t <= 7) |
| | | m_R3 = Math.Round(BaseWidth * 0.9 / 10.0, 0) * 10 + 5; |
| | | else if (t > 7) |
| | | m_R3 = Math.Round(BaseWidth * 0.9 / 10.0, 0) * 10 + 10; |
| | | } |
| | | else if (BaseWidth > 90) |
| | | { |
| | | t = Math.Round(BaseWidth * 0.3, 0) - Math.Round(BaseWidth * 0.3 / 10.0, 0) * 10; |
| | | if (t <= 2) |
| | | m_R3 = Math.Round(BaseWidth * 0.3 / 10.0, 0) * 10; |
| | | else if (t > 2 && t <= 7) |
| | | m_R3 = Math.Round(BaseWidth * 0.3 / 10.0, 0) * 10 + 5; |
| | | else if (t > 7) |
| | | m_R3 = Math.Round(BaseWidth * 0.3 / 10.0, 0) * 10 + 10; |
| | | } |
| | | // if (BaseInfo.IsSXB) |
| | | // R_Left = Math.Round(R_Left / 2,0); |
| | | // //if (DesignMode == YSSnxOpen::DesignMode::AssPawuQnshQw1) |
| | | // //{ |
| | | // // R_Left = int(R_Left * 0.7); |
| | | // //} |
| | | // double m_R3 = 0; |
| | | // double t = 0; |
| | | // if (BaseWidth <= 35) |
| | | // m_R3 = 5; |
| | | // else if (BaseWidth <= 60 && BaseWidth > 35) |
| | | // { |
| | | // t = Math.Round(BaseWidth * 0.6, 0) - Math.Round(BaseWidth * 0.6 / 10.0, 0) * 10; |
| | | // if (t <= 2) |
| | | // m_R3 = Math.Round(BaseWidth * 0.6 / 10.0, 0) * 10; |
| | | // else if (t > 2 && t <= 7) |
| | | // m_R3 = Math.Round(BaseWidth * 0.6 / 10.0, 0) * 10 + 5; |
| | | // else if (t > 7) |
| | | // m_R3 = Math.Round(BaseWidth * 0.6 / 10.0, 0) * 10 + 10; |
| | | // } |
| | | // else if (BaseWidth > 60 && BaseWidth <= 90) |
| | | // { |
| | | // t = Math.Round(BaseWidth * 0.9, 0) - Math.Round(BaseWidth * 0.9 / 10.0, 0) * 10; |
| | | // if (t <= 2) |
| | | // m_R3 = Math.Round(BaseWidth * 0.9 / 10.0, 0) * 10; |
| | | // else if (t > 2 && t <= 7) |
| | | // m_R3 = Math.Round(BaseWidth * 0.9 / 10.0, 0) * 10 + 5; |
| | | // else if (t > 7) |
| | | // m_R3 = Math.Round(BaseWidth * 0.9 / 10.0, 0) * 10 + 10; |
| | | // } |
| | | // else if (BaseWidth > 90) |
| | | // { |
| | | // t = Math.Round(BaseWidth * 0.3, 0) - Math.Round(BaseWidth * 0.3 / 10.0, 0) * 10; |
| | | // if (t <= 2) |
| | | // m_R3 = Math.Round(BaseWidth * 0.3 / 10.0, 0) * 10; |
| | | // else if (t > 2 && t <= 7) |
| | | // m_R3 = Math.Round(BaseWidth * 0.3 / 10.0, 0) * 10 + 5; |
| | | // else if (t > 7) |
| | | // m_R3 = Math.Round(BaseWidth * 0.3 / 10.0, 0) * 10 + 10; |
| | | // } |
| | | |
| | | R_Right = R_Left; |
| | | R_out = 1000.0; |
| | | // R_Right = R_Left; |
| | | // R_out = 1000.0; |
| | | |
| | | //æªé¢R1 å R4çåå°è§åº¦ DecreaseR |
| | | if (BaseWidth < 15) |
| | | { |
| | | DecreaseR = 0.5; |
| | | } |
| | | else if (BaseWidth >= 15 && BaseWidth < 25) |
| | | { |
| | | DecreaseR = 1; |
| | | } |
| | | else if (BaseWidth >= 25 && BaseWidth < 45) |
| | | { |
| | | DecreaseR = 1.5; |
| | | } |
| | | else if (BaseWidth >= 45) |
| | | { |
| | | DecreaseR = 2; |
| | | } |
| | | // //æªé¢R1 å R4çåå°è§åº¦ DecreaseR |
| | | // if (BaseWidth < 15) |
| | | // { |
| | | // DecreaseR = 0.5; |
| | | // } |
| | | // else if (BaseWidth >= 15 && BaseWidth < 25) |
| | | // { |
| | | // DecreaseR = 1; |
| | | // } |
| | | // else if (BaseWidth >= 25 && BaseWidth < 45) |
| | | // { |
| | | // DecreaseR = 1.5; |
| | | // } |
| | | // else if (BaseWidth >= 45) |
| | | // { |
| | | // DecreaseR = 2; |
| | | // } |
| | | |
| | | if (BaseInfo.IsSXB) |
| | | DecreaseR = 1; |
| | | } |
| | | // if (BaseInfo.IsSXB) |
| | | // DecreaseR = 1; |
| | | // } |
| | | |
| | | return true; |
| | | } |
| | | // return true; |
| | | //} |
| | | } |
| | | } |