From 66d2304fc18a10b09bf4ed93a662f3081c53aeb9 Mon Sep 17 00:00:00 2001 From: facat Date: Fri, 21 May 2021 09:16:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: facat --- .gitignore | 8 ++ excel_addin/Properties/AssemblyInfo.cs | 36 +++++++ excel_addin/Solve.cs | 77 +++++++++++++++ excel_addin/Tension.cs | 131 +++++++++++++++++++++++++ excel_addin/excel_addin.csproj | 67 +++++++++++++ excel_addin/excel_addin.csproj.user | 6 ++ excel_addin/excel_addin.dna | 3 + 7 files changed, 328 insertions(+) create mode 100644 .gitignore create mode 100644 excel_addin/Properties/AssemblyInfo.cs create mode 100644 excel_addin/Solve.cs create mode 100644 excel_addin/Tension.cs create mode 100644 excel_addin/excel_addin.csproj create mode 100644 excel_addin/excel_addin.csproj.user create mode 100644 excel_addin/excel_addin.dna diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3905e71 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +bin +*.sln +*.xls +*.xll +Debug +Release +*.suo +*.dll \ No newline at end of file diff --git a/excel_addin/Properties/AssemblyInfo.cs b/excel_addin/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..476e6e5 --- /dev/null +++ b/excel_addin/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("excel_addin")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("excel_addin")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4b2132cf-b91a-438b-8822-7cd8b7c4781b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/excel_addin/Solve.cs b/excel_addin/Solve.cs new file mode 100644 index 0000000..e5429fe --- /dev/null +++ b/excel_addin/Solve.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace excel_addin +{ + public static class Solve + { + //解状态方程的牛顿法 + public static double nt_equation(double A, double B, double sigma) + { + return Math.Pow(sigma, 3) + A * Math.Pow(sigma, 2) - B; + } + + + public static double d_eqution(double A, double sigma) + { + return 3 * Math.Pow(sigma, 2) + 2 * A * sigma; + } + + public static double newton(double A, double B, double sigma, ref bool succeed) + { + succeed = false; + double _sigma = sigma; + int i; + for (i = 0; i < 20; i++) + { + double fx = nt_equation(A, B, _sigma); + double d_fx = d_eqution(A, _sigma); + double d_sigma = -fx / d_fx; + if (Math.Abs(d_sigma) < 1e-5) + { + succeed = true; + break; + } + + _sigma = _sigma + d_sigma; + } + return _sigma; + } + //从状态方程接触张力 + //start_tension 牛顿法初值 + //alpha 是膨胀系数 + //E 弹性模量 + //area 导线截面 + //conrol_t 控制条件温度 + //conrol_load 控制条件荷载 + //conrol_tension 控制条件张力 + //load 计算工况荷载 + //t 计算工况温度 + //l 档距 + public static double tensionFrmoStateEquation(double start_tension, double E, double alpha, double area, double control_load, double control_tension, double control_t, double load, double t, double l) + { + double A, B; + //A = E / 24 * Math.Pow(control_load * l / control_tension, 2) - control_tension / area + alpha * E * (t - control_t); + A = Fx(E, control_load, control_tension, alpha, area, control_t, l) + alpha * E * t; + B = E * Math.Pow(load / area * l, 2) / 24; + double tension;//牛顿法初值 + bool succeed = false; + tension = newton(A, B, start_tension / area, ref succeed) * area; + if (succeed) + { + return tension; + } + return double.NaN; + } + //alpha 是膨胀系数 + //E 弹性模量 + //area 导线截面 + //t 温度 + // l 档距 + public static double Fx(double E, double load, double tension, double alpha, double area, double t, double l) + { + return E * Math.Pow(load * l / tension, 2) / 24 - tension / area - alpha * E * t; + } + } +} diff --git a/excel_addin/Tension.cs b/excel_addin/Tension.cs new file mode 100644 index 0000000..8f54426 --- /dev/null +++ b/excel_addin/Tension.cs @@ -0,0 +1,131 @@ +//using System; +using System.Collections.Generic; +//using System.Linq; +//using System.Text; + +using ExcelDna.Integration; +using System; +namespace excel_addin +{ + public static class Excel_Addin + { + + + + + [ExcelFunction(Description = "覆冰增重荷载")]//仅包含覆冰重量 + public static double ice_load(double d, double iceThickness)//d导线直径,单位mm,iceThickness 覆冰厚度 单位mm + { + double val = 9.80665 * 0.9 * Math.PI * iceThickness * (iceThickness + d) / 1000; + return val; + } + + [ExcelFunction(Description = "计算杆塔用风压不均匀系数")] + public static double alpha_load(double basicV)//basicV 基本风速 单位m/s + { + double _a = 0; + if (basicV < 20) + { + _a = 1; + + } + else + { + if (basicV >= 20 && basicV < 27) + { + _a = 0.85; + } + else + { + if (basicV >= 27 && basicV < 31.5) + { + _a = 0.75; + } + else + { + if (basicV >= 31.5) + { + _a = 0.7; + } + } + } + + } + return _a; + } + + [ExcelFunction(Description = "计算风偏用风压不均匀系数")] + public static double alpha_swing(double basicV)//basicV 基本风速 单位m/s + { + double _a = 0; + if (basicV < 20) + { + _a = 1; + + } + else + { + if (basicV >= 20 && basicV < 27) + { + _a = 0.75; + } + else + { + if (basicV >= 27 && basicV < 31.5) + { + _a = 0.61; + } + else + { + if (basicV >= 31.5) + { + _a = 0.61; + } + } + } + + } + return _a; + } + + [ExcelFunction(Description = "覆冰后风荷载增大系数")] + public static double iceB(int iceThickness)//iceThickness 覆冰厚度 单位mm + { + var code = new Dictionary(); + code.Add(0, 1.0); + code.Add(5, 1.1); + code.Add(10, 1.2); + code.Add(15, 1.3); + if (iceThickness >= 20) + { + throw new Exception("缺少20mm冰以上覆冰后荷载增大系数!"); + } + return code[iceThickness]; + } + + [ExcelFunction(Description = "电线受风形体系数")] + public static double mu_sc(double d,int iceThickness)//d导线直径,单位mm,iceThickness 覆冰厚度 单位mm + { + if (iceThickness > 0) + { + return 1.2; + } + if (d < 17) + { + return 1.2; + } + //if d >=17 + return 1.1; + } + + + [ExcelFunction(Description = "电线单位风荷载")] + public static double wind_loadPN(double ave_h_v, double d, double alpha_load,double mu_sc, int iceThickness)//ave_h_v平均高处的风速 , d 导线直径 单位mm,alpha_load 风压不均匀系数,mu_sc电线体型系数,iceThickness 覆冰厚度 单位mm + { + double val = 0.625 * Math.Pow(ave_h_v, 2) * (d + 2 * iceThickness) * alpha_load*mu_sc / 1000; + return val; + } + + + } +} diff --git a/excel_addin/excel_addin.csproj b/excel_addin/excel_addin.csproj new file mode 100644 index 0000000..0bc6b55 --- /dev/null +++ b/excel_addin/excel_addin.csproj @@ -0,0 +1,67 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {C8EA3C82-B3C8-47A3-A2B9-9CF06FA54FE5} + Library + Properties + excel_addin + excel_addin + v2.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + Always + + + Always + + + + + + + Always + + + + + \ No newline at end of file diff --git a/excel_addin/excel_addin.csproj.user b/excel_addin/excel_addin.csproj.user new file mode 100644 index 0000000..ec0cd55 --- /dev/null +++ b/excel_addin/excel_addin.csproj.user @@ -0,0 +1,6 @@ + + + Program + C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE + + \ No newline at end of file diff --git a/excel_addin/excel_addin.dna b/excel_addin/excel_addin.dna new file mode 100644 index 0000000..2e6b958 --- /dev/null +++ b/excel_addin/excel_addin.dna @@ -0,0 +1,3 @@ + + + \ No newline at end of file