Compare commits

...

2 Commits

Author SHA1 Message Date
facat c812ddb7f3 增加大量代码。
Signed-off-by: facat <facat@facat.com>
2021-05-31 13:55:23 +08:00
facat 9c992c41bb 完成了状态方程求解。 2021-05-24 05:08:05 +08:00
4 changed files with 409 additions and 88 deletions

View File

@ -38,40 +38,7 @@ namespace excel_addin
}
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;
}
}
}

View File

@ -11,12 +11,13 @@ namespace excel_addin
{
//全局用临界档距,是个单例
private static List<double[]> gCriticalSpan;
[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;
double val;
val = 9.80665 * 0.9 * Math.PI * iceThickness * (iceThickness + d) / 1000;
return val;
}
@ -24,33 +25,33 @@ namespace excel_addin
public static double alpha_load(double basicV)//basicV 基本风速 单位m/s
{
double _a = 0;
if (basicV < 20)
{
_a = 1;
}
else
{
if (basicV >= 20 && basicV < 27)
if (basicV < 20)
{
_a = 0.85;
_a = 1;
}
else
{
if (basicV >= 27 && basicV < 31.5)
if (basicV >= 20 && basicV < 27)
{
_a = 0.75;
_a = 0.85;
}
else
{
if (basicV >= 31.5)
if (basicV >= 27 && basicV < 31.5)
{
_a = 0.7;
_a = 0.75;
}
else
{
if (basicV >= 31.5)
{
_a = 0.7;
}
}
}
}
}
}
return _a;
}
@ -58,74 +59,285 @@ namespace excel_addin
public static double alpha_swing(double basicV)//basicV 基本风速 单位m/s
{
double _a = 0;
if (basicV < 20)
{
_a = 1;
}
else
{
if (basicV >= 20 && basicV < 27)
if (basicV < 20)
{
_a = 0.75;
_a = 1;
}
else
{
if (basicV >= 27 && basicV < 31.5)
if (basicV >= 20 && basicV < 27)
{
_a = 0.61;
_a = 0.75;
}
else
{
if (basicV >= 31.5)
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];
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 -9999999;
}
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;
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;
double val;
val = 0.625 * Math.Pow(ave_h_v, 2) * (d + 2 * iceThickness) * alpha_load * mu_sc / 1000;
return val;
}
//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;
}
//临界档距
public static double[] criticalSpanForExcel(int maxSpan, double Epsilon, double Alpha, double area, double lowTemp_t, double lowTemp_load, double lowTemp_tens, double avrTemp_t, double avrTemp_load, double avrTemp_tens, double strongWind_t, double strongWind_load, double strongWind_tens, double ice_t, double ice_load, double ice_tens)
{
List<double[]> criticalSpanList = criticalSpan(maxSpan, Epsilon, Alpha, area, lowTemp_t, lowTemp_load, lowTemp_tens, avrTemp_t, avrTemp_load, avrTemp_tens, strongWind_t, strongWind_load, strongWind_tens, ice_t, ice_load, ice_tens);
double[] value = new double[criticalSpanList.Count * 2];
for (int foo = 0; foo < criticalSpanList.Count; foo++)
{
value[2 * foo] = criticalSpanList[foo][0];
value[2 * foo + 1] = criticalSpanList[foo][1];
}
return value;
}
//临界档距
public static List<double[]> criticalSpan(int maxSpan, double Epsilon, double Alpha, double area, double lowTemp_t, double lowTemp_load, double lowTemp_tens, double avrTemp_t, double avrTemp_load, double avrTemp_tens, double strongWind_t, double strongWind_load, double strongWind_tens, double ice_t, double ice_load, double ice_tens)
{
List<double[]> criticalSpanList = new List<double[]>();
//计算4个工况下的Fx
//t_dangju 试探最大Fx时使用的档距
int[] MaxFxConditionFlag = new int[maxSpan + 1];//记录不同档距下哪种工况的Fx最大。1代表最低温2代表年平均温3代表大风4代表覆冰。0位置元素无效。
for (int span = 1; span <= maxSpan; span++)
{
double Fx_lowTemp;
double Fx_avrTemp;
double Fx_strongWind;
double Fx_Ice;
Fx_lowTemp = Fx(Epsilon, lowTemp_load, lowTemp_tens, Alpha, area, lowTemp_t, span);
Fx_avrTemp = Fx(Epsilon, avrTemp_load, avrTemp_tens, Alpha, area, avrTemp_t, span);
Fx_strongWind = Fx(Epsilon, strongWind_load, strongWind_tens, Alpha, area, strongWind_t, span);
Fx_Ice = Fx(Epsilon, ice_load, ice_tens, Alpha, area, ice_t, span);
double maxFx;
maxFx = Fx_lowTemp;
MaxFxConditionFlag[span] = 1;
if (maxFx < Fx_avrTemp)
{
maxFx = Fx_avrTemp;
MaxFxConditionFlag[span] = 2;
}
if (maxFx < Fx_strongWind)
{
maxFx = Fx_strongWind;
MaxFxConditionFlag[span] = 3;
}
if (maxFx < Fx_Ice)
{
maxFx = Fx_Ice;
MaxFxConditionFlag[span] = 4;
}
MaxFxConditionFlag[0] = MaxFxConditionFlag[1];//为了后面判断临界档距突变不会从1米档距开始跳变。
double currentTension = 0;
double currentLoad = 0;
double currentTemperature = 0;
switch (MaxFxConditionFlag[span])
{
case 1:
currentLoad = lowTemp_load;
currentTension = lowTemp_tens;
currentTemperature = lowTemp_t;
break;
case 2:
currentLoad = avrTemp_load;
currentTension = avrTemp_tens;
currentTemperature = avrTemp_t;
break;
case 3:
currentLoad = strongWind_load;
currentTension = strongWind_tens;
currentTemperature = strongWind_t;
break;
case 4:
currentLoad = ice_load;
currentTension = ice_tens;
currentTemperature = ice_t;
break;
default:
break;
}
if (MaxFxConditionFlag[span] != MaxFxConditionFlag[span - 1])//有突变,找到了临界档距的范围
{
double formerTension = 0;
double formerLoad = 0;
double formerTemperature = 0;
switch (MaxFxConditionFlag[span - 1])
{
case 1:
formerLoad = lowTemp_load;
formerTension = lowTemp_tens;
formerTemperature = lowTemp_t;
break;
case 2:
formerLoad = avrTemp_load;
formerTension = avrTemp_tens;
formerTemperature = avrTemp_t;
break;
case 3:
formerLoad = strongWind_load;
formerTension = strongWind_tens;
formerTemperature = strongWind_t;
break;
case 4:
formerLoad = ice_load;
formerTension = ice_tens;
formerTemperature = ice_t;
break;
default:
break;
}
double t1 = 24 / Epsilon * (formerTension - currentTension) / area;
double t2 = 24 * Alpha * (formerTemperature - currentTemperature);
double t3 = Math.Pow(formerLoad / formerTension, 2) - Math.Pow(currentLoad / currentTension, 2);
double _criticalSpan = Math.Sqrt((t1 + t2) / t3);
//List中存有数组0位置为临界档距1位置为控制条件
criticalSpanList.Add(new double[] { _criticalSpan, MaxFxConditionFlag[span - 1] });
}
}
criticalSpanList.Add(new double[] { maxSpan, MaxFxConditionFlag[maxSpan] });
gCriticalSpan = new List<double[]>(criticalSpanList);
return criticalSpanList;
}
//从状态方程接触张力
//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 = Solve.newton(A, B, start_tension / area, ref succeed) * area;
if (succeed)
{
return tension;
}
return -999999999999;
}
//拓展代表档距
public static double[] expandSpan(int startSpan, int endSpan, int stepSpan,double [] criticalSpan)
{
List<double> spans = new List<double>();
spans.Add(startSpan);
for (int foo = 1; foo < Convert.ToInt32(1.0 * (endSpan - startSpan) / stepSpan); foo++)
{
spans.Add(startSpan + stepSpan * foo);
}
spans.Add(endSpan);
for (int bar = 0; bar < criticalSpan.Length; bar++)
{
spans.Add(criticalSpan[bar]);
}
spans.Sort();
return spans.ToArray();
}
//架线表k值
public static double tensionK(double load, double tension) //load 综合荷载N ,tension 张力 N
{
double value;
value = load / tension / 2;
return value;
}
//最大弧垂
public static double line_arc(double load, double tension, double span)
{
double value;
value = load * span * span / 8 / tension;
return value;
}
//百米架线弧垂
public static double Meter100LineArc(double control_load, double control_tension,double control_temp ,double lower_temp,double E, double alpha, double area,double span) //control_load 综合荷载N ,control_tension 张力 N,control_temp 控制条件温度, lower_temp 需要的降温后温度,E 弹性模量,alpha 膨胀系数, area 截面积, span 档距
{
double lower_tension = tensionFrmoStateEquation(control_tension, E, alpha, area, control_load, control_tension, control_temp, control_load, lower_temp, span);//降温后张力
return line_arc(control_load, lower_tension, 100);
}
}
}

23
excel_addin/UDF.bas Normal file
View File

@ -0,0 +1,23 @@
Attribute VB_Name = "UDF"
Option Explicit
Function findControlCondition(span As Double, findStartCell As Range, count As Integer, column As Integer)
Dim foo As Integer
Dim criticalSpanN As Double
Dim criticalSpanN_1 As Double
Dim value As Double
For foo = 1 To count
criticalSpanN_1 = Cells(findStartCell.Row - 1 + foo - 1, findStartCell.column).value
criticalSpanN = Cells(findStartCell.Row - 1 + foo, findStartCell.column).value
If span <= criticalSpanN And span > criticalSpanN_1 Then
value = Cells(findStartCell.Row - 1 + foo, findStartCell.column - 1 + column).value
foo = count 'Ìø³öÑ­»·
End If
Next foo
findControlCondition = value
End Function

View File

@ -0,0 +1,119 @@
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "제欺혓窟"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = "$K$11" Or Target.Address = "$H$17" Or Target.Address = "$K$17" Or Target.Address = "$O$17" Then
Dim criticalSpan As Variant
Dim length As Integer
Dim maxSpan As Integer
Dim Epsilon As Double
Dim Alpha As Double
Dim area As Double
Dim lowTemp_t As Double
Dim lowTemp_load As Double
Dim lowTemp_tens As Double
Dim avrTemp_t As Double
Dim avrTemp_load As Double
Dim avrTemp_tens As Double
Dim strongWind_t As Double
Dim strongWind_load As Double
Dim strongWind_tens As Double
Dim ice_t As Double
Dim ice_load As Double
Dim ice_tens As Double
maxSpan = 1000
Epsilon = Range("J5")
Alpha = Range("J6")
area = Range("J9")
lowTemp_t = Range("I20")
lowTemp_load = Range("AD20")
lowTemp_tens = Range("AE20")
avrTemp_t = Range("I21")
avrTemp_load = Range("AD21")
avrTemp_tens = Range("AE21")
strongWind_t = Range("I22")
strongWind_load = Range("AD22")
strongWind_tens = Range("AE22")
ice_t = Range("I23")
ice_load = Range("AD23")
ice_tens = Range("AE23")
criticalSpan = Application.Run("criticalSpanForExcel", maxSpan, Epsilon, Alpha, area, lowTemp_t, lowTemp_load, lowTemp_tens, avrTemp_t, avrTemp_load, avrTemp_tens, strongWind_t, strongWind_load, strongWind_tens, ice_t, ice_load, ice_tens)
length = UBound(criticalSpan)
Dim startCell As Range
Set startCell = Range("W2")
Dim foo As Integer
Range("W2:AH2") = ""
For foo = 1 To length
Cells(startCell.Row, startCell.column - 1 + foo) = criticalSpan(foo)
Next foo
'
expandSpan
End If
Application.EnableEvents = True
End Sub
Private Sub expandSpan()
Dim startSpan As Integer
Dim endSpan As Integer
Dim stepSpan As Integer
startSpan = Range("H17")
endSpan = Range("K17")
stepSpan = Range("O17")
Dim criticalSpan() As Double
Dim foo As Integer
Dim value As Double
Dim criticalSpanN As Integer
criticalSpanN = 0
For foo = 1 To 10
If Cells(Range("W2").Row, Range("W2").column + 2 * (foo - 1)) <> "" Then
criticalSpanN = criticalSpanN + 1
ReDim Preserve criticalSpan(1 To criticalSpanN)
criticalSpan(foo) = Cells(Range("W2").Row, Range("W2").column + 2 * (foo - 1))
End If
Next foo
Dim expandedSpan As Variant
expandedSpan = Application.Run("expandSpan", startSpan, endSpan, stepSpan, criticalSpan)
For foo = 1 To UBound(expandedSpan)
Cells(Range("B69").Row - 1 + foo, Range("B69").column) = expandedSpan(foo)
Next foo
'
Range("X69:Z69").Select
Selection.AutoFill Destination:=Range("X69" & ":Z" & 69 + UBound(expandedSpan) - 1), Type:=xlFillDefault
'
Dim rangeA As String
Dim rangeB As String
For foo = 1 To 9
rangeA = Chr((Asc("D") + 2 * (foo - 1)))
rangeB = Chr((Asc("D") + 2 * foo - 1))
Range(rangeA & "69:" & rangeB & "69").Select
Selection.AutoFill Destination:=Range(rangeA & "69:" & rangeB & (69 + UBound(expandedSpan) - 1)), Type:=xlFillDefault
Next foo
'k
For foo = 1 To 9
rangeA = Chr((Asc("D") + 2 * (foo - 1)))
rangeB = Chr((Asc("D") + 2 * foo - 1))
Range(rangeA & "161:" & rangeB & "161").Select
Selection.AutoFill Destination:=Range(rangeA & "161:" & rangeB & (161 + UBound(expandedSpan) - 1)), Type:=xlFillDefault
Next foo
'k
For foo = 1 To 9
rangeA = Chr((Asc("D") + 2 * (foo - 1)))
rangeB = Chr((Asc("D") + 2 * foo - 1))
Range(rangeA & "209:" & rangeB & "209").Select
Selection.AutoFill Destination:=Range(rangeA & "209:" & rangeB & (209 + UBound(expandedSpan) - 1)), Type:=xlFillDefault
Next foo
End Sub