1.修复一个风压不均匀系数计算的bug。

2.要指定是否对分风速进行修正。
This commit is contained in:
facat 2020-04-19 14:11:18 +08:00
parent c6e1c0cee0
commit 1e53b4e343
4 changed files with 433 additions and 28 deletions

View File

@ -8,20 +8,20 @@ namespace Test
{
static void Main(string[] args)
{
ConductorTensionFixture fixture = new ConductorTensionFixture();
fixture.Setup();
fixture.BigWindLoad();
fixture.FxFunctionBigWind();
conductortension.Core.calStressLoadNew condition = ConductorTensionFixture.setInput();
condition.DaiFeng = 0;
condition.DaiWen = 50;
condition.DaiBing = 0;
condition.DangJu = 300;
double zhangli=0;
conductortension.Core.CalZhangLi(condition, ref zhangli);
//ConductorTensionFixture fixture = new ConductorTensionFixture();
//fixture.Setup();
//fixture.BigWindLoad();
//fixture.FxFunctionBigWind();
//conductortension.Core.calStressLoadNew condition = ConductorTensionFixture.setInput();
//condition.DaiFeng = 0;
//condition.DaiWen = 50;
//condition.DaiBing = 0;
//condition.DangJu = 300;
//double zhangli=0;
//conductortension.Core.CalZhangLi(condition, ref zhangli);
CheckAgainstExcelFixture checkAgainstExcel=new CheckAgainstExcelFixture();
checkAgainstExcel.SetUp();
checkAgainstExcel.SoftestWindTest();
checkAgainstExcel.WindTest_D_Variable(10,20,10);
checkAgainstExcel.Clean();
Console.ReadKey();

View File

@ -0,0 +1,222 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.IO;
using System.Reflection;
namespace Test
{
[TestFixture]
public class CheckAgainstExcelFixture
{
static Microsoft.Office.Interop.Excel.Application objApp;
static Microsoft.Office.Interop.Excel._Workbook objBook;
static Microsoft.Office.Interop.Excel.Worksheet w_sheet;
conductortension.Core.calStressLoadNew basicCondition;
private object get_value(Microsoft.Office.Interop.Excel.Worksheet sheet, string str_rang)
{
return sheet.get_Range(str_rang, Missing.Value).Value2;
}
private void set_value(Microsoft.Office.Interop.Excel.Worksheet sheet, string str_rang, object value)
{
sheet.get_Range(str_rang, Missing.Value).set_Value(Missing.Value, value);
}
private int GenerateRandomSeed()
{
return (int)DateTime.Now.Ticks;
}
[Test]
public void WindTest()
{
conductortension.Core.calStressLoadNew wind = basicCondition;
wind.DaiWen = wind.FengWen;
//double wind_velocity;
//wind_velocity = Math.Round(wind.FengFeng * Math.Pow(wind.PingJunGaoDu / wind.SheJiFengSuGaoDu, 0.16), 2);
wind.DaiFeng = wind.FengFeng;
wind.DaiZheSuanFengSu = true;
wind.DaiBing = wind.FengBing;
Random ran = new Random(GenerateRandomSeed());
wind.DangJu = ran.Next(1, 800);
Microsoft.Office.Interop.Excel.Range range;
range = w_sheet.get_Range("B81", Missing.Value);
range.set_Value(Missing.Value, wind.DangJu);
double excel_value;
excel_value = (double)(w_sheet.get_Range("H81", Missing.Value).Value2);
double cal_value = 0;
conductortension.Core.CalZhangLi(wind, ref cal_value);
Assert.AreEqual(cal_value, excel_value, 1);
}
[Test, Combinatorial]
public void WindTest_D_Variable([Values(10, 17, 18)] double d, [Values(10, 20, 21, 27, 29, 31.5, 32)] double velocity,[Values(0,5,10,,13,15,,18,20,23,25)] double ice)//导线外径和风速、有冰无冰测试变化测试
{
//修改Eecel线径
double org_d;
org_d = (double)get_value(w_sheet, "J8");
set_value(w_sheet, "J8", d);
//修改风速
double org_velocity;
org_velocity = (double)get_value(w_sheet, "L22");
set_value(w_sheet, "L22", velocity);
//修改冰厚
double org_ice;
org_ice = (double)get_value(w_sheet, "O22");
set_value(w_sheet, "O22", ice);
conductortension.Core.calStressLoadNew wind = basicCondition;
wind.WaiJing = d;
wind.DaiWen = wind.FengWen;
wind.FengFeng = velocity;
wind.FengBing = ice;
//double wind_velocity;
//wind_velocity = Math.Round(wind.FengFeng * Math.Pow(wind.PingJunGaoDu / wind.SheJiFengSuGaoDu, 0.16), 2);
wind.DaiFeng = wind.FengFeng;
wind.DaiBing = wind.FengBing;
wind.DaiZheSuanFengSu = true;
Random ran = new Random(GenerateRandomSeed());
wind.DangJu = ran.Next(1, 800);
Microsoft.Office.Interop.Excel.Range range;
range = w_sheet.get_Range("B81", Missing.Value);
range.set_Value(Missing.Value, wind.DangJu);
double excel_value;
excel_value = (double)(w_sheet.get_Range("H81", Missing.Value).Value2);
double cal_value = 0;
conductortension.Core.CalZhangLi(wind, ref cal_value);
Assert.AreEqual(cal_value, excel_value, 1);
set_value(w_sheet, "J8", org_d);
set_value(w_sheet, "L22", org_velocity);
set_value(w_sheet, "O22", org_ice);
}
[Test]
public void IceTest()
{
conductortension.Core.calStressLoadNew ice = basicCondition;
ice.DaiWen = ice.BingWen;
ice.DaiFeng = ice.BingFeng;
ice.DaiZheSuanFengSu = false;
ice.DaiBing = ice.BingBing;
Random ran = new Random(GenerateRandomSeed());
ice.DangJu = ran.Next(1, 800);
Microsoft.Office.Interop.Excel.Range range;
range = w_sheet.get_Range("B81", Missing.Value);
range.set_Value(Missing.Value, ice.DangJu);
double excel_value;
excel_value = (double)(w_sheet.get_Range("J81", Missing.Value).Value2);
double cal_value = 0;
conductortension.Core.CalZhangLi(ice, ref cal_value);
Assert.AreEqual(cal_value, excel_value, 1);
}
[Test]
public void LowesetTemperatureTest()
{
conductortension.Core.calStressLoadNew loweseTemp = basicCondition;
loweseTemp.DaiWen = loweseTemp.DiWen;
loweseTemp.DaiFeng = loweseTemp.DiFeng;
loweseTemp.DaiBing = loweseTemp.DiBing;
Random ran = new Random(GenerateRandomSeed());
loweseTemp.DangJu = ran.Next(1, 800);
Microsoft.Office.Interop.Excel.Range range;
range = w_sheet.get_Range("B81", Missing.Value);
range.set_Value(Missing.Value, loweseTemp.DangJu);
double excel_value;
excel_value = (double)(w_sheet.get_Range("D81", Missing.Value).Value2);
double cal_value = 0;
conductortension.Core.CalZhangLi(loweseTemp, ref cal_value);
Assert.AreEqual(cal_value, excel_value, 1);
}
[Test]
public void HotestTemperatureTest()
{
conductortension.Core.calStressLoadNew lowestTemp = basicCondition;
lowestTemp.DaiWen = (double)get_value(w_sheet, "I24");
lowestTemp.DaiFeng = (double)get_value(w_sheet, "L24");
lowestTemp.DaiBing = (double)get_value(w_sheet, "O24");
Random ran = new Random(GenerateRandomSeed());
lowestTemp.DangJu = ran.Next(1, 800);
Microsoft.Office.Interop.Excel.Range range;
range = w_sheet.get_Range("B81", Missing.Value);
range.set_Value(Missing.Value, lowestTemp.DangJu);
double excel_value;
excel_value = (double)(w_sheet.get_Range("L81", Missing.Value).Value2);
double cal_value = 0;
conductortension.Core.CalZhangLi(lowestTemp, ref cal_value);
Assert.AreEqual(cal_value, excel_value, 1);
}
[Test]
public void SoftestWindTest()//最小风
{
conductortension.Core.calStressLoadNew softestWind = basicCondition;
softestWind.DaiWen = (double)get_value(w_sheet, "I31");
softestWind.DaiFeng = (double)get_value(w_sheet, "L31");//这里不折算风速
softestWind.DaiZheSuanFengSu = false;
softestWind.DaiBing = (double)get_value(w_sheet, "O31");
Random ran = new Random(GenerateRandomSeed());
softestWind.DangJu = ran.Next(1, 800);
Microsoft.Office.Interop.Excel.Range range;
range = w_sheet.get_Range("B81", Missing.Value);
range.set_Value(Missing.Value, softestWind.DangJu);
double excel_value;
excel_value = (double)(w_sheet.get_Range("H104", Missing.Value).Value2);
double cal_value = 0;
conductortension.Core.CalZhangLi(softestWind, ref cal_value);
Assert.AreEqual(cal_value, excel_value, 1);
}
[OneTimeSetUp]
public void SetUp()
{
objApp = new Microsoft.Office.Interop.Excel.Application();
objBook = objApp.Application.Workbooks.Add(@"d:\code\conductortension\学习-张力计算(临界档距公式法V20090602)-送电室版-Unittest.xls");
w_sheet = objBook.Sheets["三维平台测试"] as Microsoft.Office.Interop.Excel.Worksheet;
objApp.Visible = true;
double E;
E = (double)(w_sheet.get_Range("J5", Missing.Value).Value2);
double alpha;//膨胀系数
alpha = (double)(w_sheet.get_Range("J6", Missing.Value).Value2);
double unit_weight;//单位长度重量 kg/km
unit_weight = (double)(w_sheet.get_Range("J7", Missing.Value).Value2) * 1000;
double d;//直径mm
d = (double)(w_sheet.get_Range("J8", Missing.Value).Value2);
double area;//截面mm2
area = (double)(w_sheet.get_Range("J9", Missing.Value).Value2);
double rated_broken_tension;//N 额定拉断力
rated_broken_tension = (double)(w_sheet.get_Range("J10", Missing.Value).Value2) / .95;
double F;//导线安全系数
F = (double)(w_sheet.get_Range("K11", Missing.Value).Value2);
double ave_tension_percent;//% 平均运行张力百分数
ave_tension_percent = (double)(w_sheet.get_Range("K12", Missing.Value).Value2) * 100;
basicCondition.MoLiang = E;
basicCondition.XianPengZhang = alpha;
basicCondition.ZhongLiang = unit_weight;
basicCondition.WaiJing = d;
basicCondition.JieMianJi = area;
basicCondition.EDingLaDuanLi = rated_broken_tension;
basicCondition.BaoZhengPoDuanZhangLiXiShu = 95;
basicCondition.AnQuan = F;
basicCondition.NianPingJunXishu = ave_tension_percent;
basicCondition.SheJiFengSuGaoDu = 10;
basicCondition.PingJunGaoDu = 20;
//读取气象区
basicCondition.DiWen = (double)(w_sheet.get_Range("I20", Missing.Value).Value2);
basicCondition.DiFeng = (double)(w_sheet.get_Range("L20", Missing.Value).Value2);
basicCondition.DiBing = (double)(w_sheet.get_Range("O20", Missing.Value).Value2);
basicCondition.PingWen = (double)(w_sheet.get_Range("I21", Missing.Value).Value2);
basicCondition.PingFeng = (double)(w_sheet.get_Range("L21", Missing.Value).Value2);
basicCondition.PingBing = (double)(w_sheet.get_Range("O21", Missing.Value).Value2);
basicCondition.FengWen = (double)(w_sheet.get_Range("I22", Missing.Value).Value2);
basicCondition.FengFeng = (double)(w_sheet.get_Range("L22", Missing.Value).Value2);
basicCondition.FengBing = (double)(w_sheet.get_Range("O22", Missing.Value).Value2);
basicCondition.BingWen = (double)(w_sheet.get_Range("I23", Missing.Value).Value2);
basicCondition.BingFeng = (double)(w_sheet.get_Range("L23", Missing.Value).Value2);
basicCondition.BingBing = (double)(w_sheet.get_Range("O23", Missing.Value).Value2);
}
[OneTimeTearDown]
public void Clean()
{
objBook.Close(false, null, null);
objApp.Application.Quit();
}
}
}

View File

@ -0,0 +1,175 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using conductortension;
namespace Test
{
[TestFixture]
public class ConductorTensionFixture
{
private conductortension.Core.calStressLoadNew basicInput;
public static conductortension.Core.calStressLoadNew setInput()
{
conductortension.Core.calStressLoadNew t_basicInput;
t_basicInput = new conductortension.Core.calStressLoadNew();
t_basicInput.WaiJing = 33.8;
t_basicInput.ZhongLiang = 2078.4;
t_basicInput.SheJiFengSuGaoDu = 10;
t_basicInput.PingJunGaoDu = 20;
t_basicInput.MoLiang = 63700;
t_basicInput.XianPengZhang = 20.8 * 1e-6;
t_basicInput.AnQuan = 2.5;
t_basicInput.JieMianJi = 672.81;
t_basicInput.BaoZhengPoDuanZhangLiXiShu = 95;
t_basicInput.EDingLaDuanLi = 142680.5 / 0.95;
t_basicInput.NianPingJunXishu = 25;
t_basicInput.PingFeng = 0;
t_basicInput.PingBing = 0;
t_basicInput.PingWen = 15;
t_basicInput.FengFeng = 27;
t_basicInput.FengBing = 0;
t_basicInput.FengWen = -5;
t_basicInput.DiFeng = 0;
t_basicInput.DiBing = 0;
t_basicInput.DiWen = -20;
t_basicInput.BingFeng = 10;
t_basicInput.BingBing = 10;
t_basicInput.BingWen = -5;
return t_basicInput;
}
[OneTimeSetUp]
public void Setup()
{
basicInput = setInput();
}
[Test]
public void BigWindLoad()//大风综合荷载
{
conductortension.Core.calStressLoadNew condition = basicInput;
double Hezai=0;
condition.DaiBing = condition.FengBing;
condition.DaiFeng = condition.FengFeng;
//double wind_velocity = 0;//折算到平均高下的风速
//wind_velocity = Math.Round(condition.DaiFeng * Math.Pow(condition.PingJunGaoDu / condition.SheJiFengSuGaoDu, 0.16), 2);
//condition.DaiFeng = wind_velocity;
condition.DaiZheSuanFengSu = true;
conductortension.Core.CalHeZai(condition, ref Hezai);
Assert.AreEqual(25.8280, Hezai, 1e-4);
}
[Test]
public void AverageTemperatureLoad()//平均温综合荷载
{
conductortension.Core.calStressLoadNew condition = basicInput;
double Hezai = 0;
condition.DaiBing = condition.PingBing;
condition.DaiFeng = condition.PingFeng;
conductortension.Core.CalHeZai(condition, ref Hezai);
Assert.AreEqual(20.3821, Hezai, 1e-4);
}
[Test]
public void IceLoad()//覆冰综合荷载
{
conductortension.Core.calStressLoadNew condition = basicInput;
double Hezai = 0;
condition.DaiFeng = condition.BingFeng;
condition.DaiBing = condition.BingBing;
condition.DaiZheSuanFengSu = false;
conductortension.Core.CalHeZai(condition, ref Hezai);
Assert.AreEqual(32.7762, Hezai, 1e-4);
}
[Test]
public void FxFunctionBigWind()//计算大风下的Fx
{
conductortension.Core.calStressLoadNew condition=basicInput;
condition.DaiBing = condition.FengBing;
condition.DaiFeng = condition.FengFeng;
condition.DaiWen = condition.FengWen;
double Hezai=0;
//double wind_velocity;
//wind_velocity = Math.Round(condition.DaiFeng * Math.Pow(condition.PingJunGaoDu / condition.SheJiFengSuGaoDu, 0.16), 2);
//condition.DaiFeng = wind_velocity;
condition.DaiZheSuanFengSu = true;
conductortension.Core.CalHeZai(condition, ref Hezai);
double val;
val = conductortension.Core.Fx(condition.MoLiang, Hezai, condition.BaoZhengPoDuanZhangLiXiShu * condition.EDingLaDuanLi/100 / condition.AnQuan, condition.XianPengZhang, condition.JieMianJi, condition.DaiWen,1);
Assert.AreEqual(0.000543576 - 78.20182267, val, 1e-4);
}
[Test]
public void FxFunctionAverageTemperature()//平均温下的Fx
{
conductortension.Core.calStressLoadNew condition = basicInput;
condition.DaiBing = condition.PingBing;
condition.DaiFeng = condition.PingFeng;
condition.DaiWen = condition.PingWen;
double Hezai = 0;
condition.DaiFeng = 0;
conductortension.Core.CalHeZai(condition, ref Hezai);
double val;
val = conductortension.Core.Fx(condition.MoLiang, Hezai, condition.BaoZhengPoDuanZhangLiXiShu * condition.EDingLaDuanLi / 100 *condition.NianPingJunXishu/100, condition.XianPengZhang, condition.JieMianJi, condition.DaiWen,1);
Assert.AreEqual(0.0008666 - 72.89103917, val, 1e-4);
}
[Test]
public void FxFunctionIce()//覆冰下的Fx
{
conductortension.Core.calStressLoadNew condition = basicInput;
condition.DaiBing = condition.BingBing;
condition.DaiFeng = condition.BingFeng;
condition.DaiWen = condition.BingWen;
condition.DaiZheSuanFengSu = false;
double Hezai = 0;
conductortension.Core.CalHeZai(condition, ref Hezai);
double val;
val = conductortension.Core.Fx(condition.MoLiang, Hezai, condition.BaoZhengPoDuanZhangLiXiShu * condition.EDingLaDuanLi / 100 / condition.AnQuan, condition.XianPengZhang, condition.JieMianJi, condition.DaiWen,1);
Assert.AreEqual(0.000875377 - 78.20182267, val, 1e-4);
}
[Test]
public void HighTemperateureTension()//高温下张力
{
conductortension.Core.calStressLoadNew condition = basicInput;
condition.DaiFeng = 0;
condition.DaiWen = 50;
condition.DaiBing = 0;
condition.DangJu = 300;
double zhangli = 0;
conductortension.Core.CalZhangLi(condition, ref zhangli);
Assert.AreEqual(29374, zhangli, 1);
}
[Test]
public void LowTemperatureTension()//低温下张力
{
conductortension.Core.calStressLoadNew condition = basicInput;
condition.DaiFeng = 0;
condition.DaiWen = -20;
condition.DaiBing = 0;
condition.DangJu = 200;
double zhangli = 0;
conductortension.Core.CalZhangLi(condition, ref zhangli);
Assert.AreEqual(53800, zhangli, 1);
}
[Test]
public void IceTension()//覆冰下张力
{
conductortension.Core.calStressLoadNew condition = basicInput;
condition.DaiFeng = 10;
condition.DaiWen = -5;
condition.DaiBing = 10;
condition.DangJu = 200;
condition.DaiZheSuanFengSu = false;
double zhangli = 0;
conductortension.Core.CalZhangLi(condition, ref zhangli);
Assert.AreEqual(55284, zhangli, 1);
}
}
}

28
core.cs
View File

@ -114,17 +114,21 @@ namespace conductortension
calStressLoadNew FuBing = inPut;
ZuiDiWen.DaiBing = ZuiDiWen.DiBing;
ZuiDiWen.DaiFeng = ZuiDiWen.DiFeng;
ZuiDiWen.DaiZheSuanFengSu = false;
ZuiDiWen.DaiWen = ZuiDiWen.DiWen;
NianPingJun.DaiBing = NianPingJun.PingBing;
NianPingJun.DaiFeng = NianPingJun.PingFeng;
NianPingJun.DaiZheSuanFengSu = false;
NianPingJun.DaiWen = NianPingJun.PingWen;
DaFeng.DaiBing = DaFeng.FengBing;
double wind_velocity;
wind_velocity = Math.Round(DaFeng.FengFeng * Math.Pow(DaFeng.PingJunGaoDu / DaFeng.SheJiFengSuGaoDu, 0.16), 2);
DaFeng.DaiFeng = wind_velocity;//大风工况风速折算到平均高。
//double wind_velocity;
//wind_velocity = Math.Round(DaFeng.FengFeng * Math.Pow(DaFeng.PingJunGaoDu / DaFeng.SheJiFengSuGaoDu, 0.16), 2);
DaFeng.DaiFeng = DaFeng.FengFeng;
DaFeng.DaiZheSuanFengSu = true;
DaFeng.DaiWen = DaFeng.FengWen;
FuBing.DaiBing = FuBing.BingBing;
FuBing.DaiFeng = FuBing.BingFeng;
FuBing.DaiZheSuanFengSu = false;
FuBing.DaiWen = FuBing.BingWen;
//2:计算并存储各个工况荷载
CalHeZai(ZuiDiWen, ref ChuShiZuiDiQiWen[1]);
@ -287,6 +291,7 @@ namespace conductortension
public double SheJiFengSuGaoDu; //设计基准风速高度
public double BaoZhengPoDuanZhangLiXiShu; //保证破断张力取计算拉断力的%,即张力系数
public double dxLoad; //线荷载
public bool DaiZheSuanFengSu;//是否对待计算工况风速进行折算。
}
public static bool CalHeZai(calStressLoadNew inPut, ref double HeZai)
@ -308,12 +313,13 @@ namespace conductortension
ChuiZhiHeZai = 9.80665 * 0.9 * Math.PI * inPut.DaiBing * (inPut.DaiBing + inPut.WaiJing) / 1000; //'导线冰荷载
double a = 1;//定义风压不均匀系数a
double dx3 = 0;//
if (inPut.DaiBing == 0) //'无冰工况
double wind_v = inPut.DaiFeng;//计算荷载用风速
if (inPut.DaiZheSuanFengSu)
{
if (inPut.DaiFeng < 20)
wind_v = Math.Round(inPut.DaiFeng * Math.Pow(inPut.PingJunGaoDu / inPut.SheJiFengSuGaoDu, 0.16), 2);
}
double dx3 = 0;
if (inPut.DaiFeng < 20)//要用没折算过的风速
a = 1;
else if (inPut.DaiFeng < 27)
a = 0.85;
@ -321,12 +327,14 @@ namespace conductortension
a = 0.75;
else
a = 0.7;
dx3 = Math.Pow(inPut.DaiFeng, 2) * inPut.WaiJing * u * a * bi / 1600;// '导线无冰风荷载
if (inPut.DaiBing == 0) //'无冰工况
{
dx3 = Math.Pow(wind_v, 2) * inPut.WaiJing * u * a * bi / 1600;// '导线无冰风荷载
}
else
{
//a = 1; // '有冰工况定义风压不均匀系数a=1
dx3 = 1.2 * Math.Pow(inPut.DaiFeng, 2) * (inPut.WaiJing + 2 * inPut.DaiBing) * a * bi / 1600; // '导线有冰风荷载
dx3 = 1.2 * Math.Pow(wind_v, 2) * (inPut.WaiJing + 2 * inPut.DaiBing) * a * bi / 1600; // '导线有冰风荷载
}
HeZai = Math.Sqrt(Math.Pow((ZiZhongHeZai + ChuiZhiHeZai), 2) + Math.Pow(dx3, 2));// '存储导线荷载