1.修复一个风压不均匀系数计算的bug。
2.要指定是否对分风速进行修正。
This commit is contained in:
222
Test/CheckAgainstExcelFixture.cs
Normal file
222
Test/CheckAgainstExcelFixture.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
175
Test/ConductorTensionFixture.cs
Normal file
175
Test/ConductorTensionFixture.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user