第一次提交。

Signed-off-by: facat <facat@facat.com>
This commit is contained in:
facat 2021-05-21 09:16:20 +08:00
commit 66d2304fc1
7 changed files with 328 additions and 0 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
bin
*.sln
*.xls
*.xll
Debug
Release
*.suo
*.dll

View File

@ -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")]

77
excel_addin/Solve.cs Normal file
View File

@ -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;
}
}
}

131
excel_addin/Tension.cs Normal file
View File

@ -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<int, double>();
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;
}
}
}

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C8EA3C82-B3C8-47A3-A2B9-9CF06FA54FE5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>excel_addin</RootNamespace>
<AssemblyName>excel_addin</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ExcelDna.Integration, Version=1.1.0.0, Culture=neutral, PublicKeyToken=f225e9659857edbe, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Solve.cs" />
<Compile Include="Tension.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="excel_addin.dna">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="excel_addin.xll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="excel_addin.xls">
</None>
</ItemGroup>
<ItemGroup>
<Content Include="ExcelDna.Integration.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<StartAction>Program</StartAction>
<StartProgram>C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE</StartProgram>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,3 @@
<DnaLibrary Name="Sample Excel-DNA Library in C#">
<ExternalLibrary Path="excel_addin.dll"/>
</DnaLibrary>