diff --git a/cal_gate.c b/cal_gate.c
index 4597247..e05e479 100644
--- a/cal_gate.c
+++ b/cal_gate.c
@@ -7,14 +7,14 @@
typedef enum {
- gate_full_open_with_free_flow, /*A*/
- gate_full_open_with_submerged_flow, /*B*/
- gate_control_with_free_flow, /*C*/
- gate_control_with_submerged_flow, /*D*/
- gate_full_open_with_free_flow_drop_step, /*E*/
- gate_full_open_with_submerged_flow_drop_step, /*F*/
- gate_control_with_free_flow_drop_step, /*G*/
- gate_control_with_submerged_flow_drop_step /*H*/
+ gate_full_open_with_free_flow, /*A 闸门全开自由流*/
+ gate_full_open_with_submerged_flow, /*B 闸门全开淹没流*/
+ gate_control_with_free_flow, /*C 闸门控制自由流*/
+ gate_control_with_submerged_flow, /*D 闸门控制淹没流*/
+ gate_full_open_with_free_flow_drop_step, /*E 闸门全开自由流 有跌槛*/
+ gate_full_open_with_submerged_flow_drop_step, /*F 闸门全开淹没流 有跌槛*/
+ gate_control_with_free_flow_drop_step, /*G 闸门控制自由流 有跌槛*/
+ gate_control_with_submerged_flow_drop_step /*H 闸门控制淹没流 有跌槛*/
}patterns_of_water;
enum {
@@ -23,10 +23,10 @@ enum {
};
enum{
- warped_wingwall=1,
- flat_wingwall,
- eight_c_wingwall,
- parallel_wingwall
+ warped_wingwall=1, /*弯曲墙面*/
+ flat_wingwall, /*平整墙面*/
+ eight_c_wingwall, /*八字墙面*/
+ parallel_wingwall /*平行墙面*/
};
struct A{
@@ -85,9 +85,10 @@ typedef struct total{
-
-
-
+/*
+ *几种墙面分别对应的系数
+ *
+*/
coefficient_infor coefficient={.A.m_warped_wingwall=0.325, .A.m_warped_wingwall_ds=0.380, .A.m_flat_wingwall=0.310, .A.m_flat_wingwall_ds=0.365,\
.A.m_eight_c_wingwall=0.330, .A.m_eight_c_wingwall_ds=0.390, .A.m_parallel_wingwall=0.295, .A.m_parallel_wingwall_ds=0.355,\
.B.fai_warped_wingwall=0.850,.B.fai_flat_wingwall=0.825, .B.fai_eight_c_wingwall=0.860,.B.fai_parallel_wingwall=0.795,\
@@ -100,10 +101,10 @@ coefficient_infor coefficient={.A.m_warped_wingwall=0.325, .A.m_warped_wingwall
/*
- *
- *
- *
- *
+ *函数名: data_validity_check()
+ *参数: *param
+ *功能: 检查传入的参数是否是有效参数
+ *返回值: 0表示参数是合法的,非0表示不合法
*
*/
char data_validity_check(struct param_gate *param)
@@ -136,10 +137,13 @@ char data_validity_check(struct param_gate *param)
}
/*
- *
- *
- *
- *
+ *函数名: discrimination_of_flow_pattern()
+ *参数: openning_height_of_gate 开闸高度
+ * water_depth_front_of_gate 闸前水位
+ * water_depth_behind_of_gate 闸后水位
+ * drop_step 跌槛
+ *功能: 根据以上参数,判断出是那个水流模型
+ *返回值: 水流模型
*
*/
@@ -169,12 +173,38 @@ patterns_of_water discrimination_of_flow_pattern(double openning_height_of_gate,
}
+struct datas{
+ double original_data_front;
+ double original_data_after;
+ double value;
+};
+
+struct datas table[46]={{0.00,0.05,1.00},{0.05,0.15,0.990},{0.15,0.25,0.980},{0.25,0.35,0.970},{0.35,0.45,0.956},{0.45,0.475,0.947},{0.475,0.525,0.937},{0.525,0.575,0.925},\
+ {0.575,0.625,0.907},{0.625,0.675,0.885},{0.675,0.710,0.856},{0.710,0.730,0.843},{0.730,0.750,0.828},{0.750,0.770,0.813},{0.770,0.790,0.800},{0.790,0.805,0.778},\
+ {0.805,0.815,0.767},{0.815,0.825,0.755},{0.825,0.835,0.742},{0.835,0.845,0.728},{0.845,0.855,0.713},{0.855,0.865,0.698},{0.865,0.875,0.681},{0.875,0.885,0.662},\
+ {0.885,0.895,0.642},{0.895,0.9025,0.621},{0.9025,0.9075,0.608},{0.9075,0.9125,0.595},{0.9125,0.9175,0.580},{0.9175,0.9225,0.565},{0.9225,0.9275,0.549},\
+ {0.9275,0.9325,0.532},{0.9325,0.9375,0.514},{0.9375,0.9425,0.484},{0.9425,0.9475,0.473},{0.9475,0.9525,0.450},{0.9525,0.9575,0.427},{0.9575,0.9625,0.403},\
+ {0.9625,0.9675,0.375},{0.9675,0.9725,0.344},{0.9725,0.9775,0.318},{0.9775,0.9825,0.267},{0.9825,0.9875,0.225},{0.9875,0.9925,0.175},{0.9925,0.9975,0.115},\
+ {0.9975,1.0000,0.000}
+};
+
+double find(double target)
+{
+ int i=0;
+ for(i=0;i<46;i++)
+ {
+ if(target>=table[i].original_data_front && target
=0.00 && s<0.05)
- return 1.00;
- else if(s>=0.06 && s<0.15)
- return 0.990;
- else if(s>=0.15 && s<0.25)
- return 0.980;
- else if(s>=0.25 && s<0.35)
- return 0.970;
- else if(s>=0.35 && s<0.45)
- return 0.956;
- else if(s>=0.45 && s<0.475)
- return 0.947;
- else if(s>=0.475 && s<0.525)
- return 0.937;
- else if(s>=0.525 && s<0.575)
- return 0.925;
- else if(s>=0.575 && s<0.625)
- return 0.907;
- else if(s>=0.625 && s<0.675)
- return 0.885;
- else if(s>=0.675 && s<0.710)
- return 0.856;
- else if(s>=0.710 && s<0.730)
- return 0.843;
- else if(s>=0.730 && s<0.750)
- return 0.828;
- else if(s>=0.750 && s<0.770)
- return 0.813;
- else if(s>=0.770 && s<0.790)
- return 0.800;
- else if(s>=0.790 && s<0.805)
- return 0.778;
- else if(s>=0.805 && s<0.815)
- return 0.767;
- else if(s>=0.815 && s<0.825)
- return 0.755;
- else if(s>=0.825 && s<0.835)
- return 0.742;
- else if(s>=0.835 && s<0.845)
- return 0.728;
- else if(s>=0.845 && s<0.855)
- return 0.713;
- else if(s>=0.855 && s<0.865)
- return 0.698;
- else if(s>=0.865 && s<0.875)
- return 0.681;
- else if(s>=0.875 && s<0.885)
- return 0.662;
- else if(s>=0.885 && s<0.895)
- return 0.642;
- else if(s>=0.895 && s<0.9025)
- return 0.621;
- else if(s>=0.9025 && s<0.9075)
- return 0.608;
- else if(s>=0.9075 && s<0.9125)
- return 0.595;
- else if(s>=0.9125 && s<0.9175)
- return 0.580;
- else if(s>=0.9175 && s<0.9225)
- return 0.565;
- else if(s>=0.9225 && s<0.9275)
- return 0.549;
- else if(s>=0.9275 && s<0.9325)
- return 0.532;
- else if(s>=0.9325 && s<0.9375)
- return 0.514;
- else if(s>=0.9375 && s<0.9425)
- return 0.484;
- else if(s>=0.9425 && s<0.9475)
- return 0.473;
- else if(s>=0.9475 && s<0.9525)
- return 0.450;
- else if(s>=0.9525 && s<0.9575)
- return 0.427;
- else if(s>=0.9575 && s<0.9625)
- return 0.403;
- else if(s>=0.9625 && s<0.9675)
- return 0.375;
- else if(s>=0.9675 && s<0.9725)
- return 0.344;
- else if(s>=0.9725 && s<0.9775)
- return 0.318;
- else if(s>=0.9775 && s<0.9825)
- return 0.267;
- else if(s>=0.9825 && s<0.9875)
- return 0.225;
- else if(s>=0.9875 && s<0.9925)
- return 0.175;
- else if(s>=0.9925 && s<0.9975)
- return 0.115;
- else if(s>=0.9975 && s<1.000)
- return 0.000;
+ return find(s);
}
/*
- *
- *
- *
- *
+ *函数名: cal_gate_full_open_with_free_flow()
+ *参数: water_depth_front_of_gate 闸前水深
+ * water_depth_behind_of_gate 闸后水深
+ * gate_width 闸门宽度
+ * wingwall 翼墙类型
+ * ds 跌槛
+ *功能: 根据参数,计算出闸门全开自由流模型下的瞬时流量
+ *返回值: 瞬时流量
*
*/
@@ -319,6 +261,17 @@ double cal_gate_full_open_with_free_flow(double water_depth_front_of_gate,double
return instantaneousFlow;
}
+/*
+ *函数名: cal_gate_full_open_with_submerged_flow()
+ *参数: water_depth_front_of_gate 闸前水深
+ * water_depth_behind_of_gate 闸后水深
+ * gate_width 闸门宽度
+ * wingwall 翼墙类型
+ * ds 跌槛
+ *功能: 根据参数,计算出闸门全开淹没流模型下的瞬时流量
+ *返回值: 瞬时流量
+ *
+*/
double cal_gate_full_open_with_submerged_flow(double water_depth_front_of_gate,double water_depth_behind_of_gate,double gate_width,int wingwall,int ds)
{
double instantaneousFlow;
@@ -356,6 +309,18 @@ double cal_gate_full_open_with_submerged_flow(double water_depth_front_of_gate,d
return instantaneousFlow;
}
+/*
+ *函数名: cal_gate_control_with_free_flow()
+ *参数: water_depth_front_of_gate 闸前水深
+ * water_depth_behind_of_gate 闸后水深
+ * height_of_gate 闸门开启高度
+ * gate_width 闸门宽度
+ * wingwall 翼墙类型
+ * ds 跌槛
+ *功能: 根据参数,计算出闸门控制自由流模型下的瞬时流量
+ *返回值: 瞬时流量
+ *
+*/
double cal_gate_control_with_free_flow(double water_depth_front_of_gate,double water_depth_behind_of_gate,double height_of_gate,double gate_width,int wingwall,int ds)
{
double instantaneousFlow;
@@ -389,6 +354,18 @@ double cal_gate_control_with_free_flow(double water_depth_front_of_gate,double w
return instantaneousFlow;
}
+/*
+ *函数名: cal_gate_control_with_submerged_flow()
+ *参数: water_depth_front_of_gate 闸前水深
+ * water_depth_behind_of_gate 闸后水深
+ * height_of_gate 闸门开启高度
+ * gate_width 闸门宽度
+ * wingwall 翼墙类型
+ * ds 跌槛
+ *功能: 根据参数,计算出闸门控制淹没流模型下的瞬时流量
+ *返回值: 瞬时流量
+ *
+*/
double cal_gate_control_with_submerged_flow(double water_depth_front_of_gate,double water_depth_behind_of_gate,double height_of_gate,double gate_width,int wingwall,int ds)
{
double instantaneousFlow;
@@ -423,59 +400,22 @@ double cal_gate_control_with_submerged_flow(double water_depth_front_of_gate,dou
}
-/*
- *
- *
- *
- *
- *
-*/
-#if 0
-double Calculation_of_InstantaneousFlow(double openning_height_of_gate, double water_depth_front_of_gate,double water_depth_behind_of_gate,double gate_width,int wingwall,int drop_step)
-{
- patterns_of_water get_pattern;
- double temp;
- get_pattern = discrimination_of_flow_pattern(openning_height_of_gate,water_depth_front_of_gate,water_depth_behind_of_gate,drop_step);
- switch(get_pattern){
- case gate_full_open_with_free_flow:
- temp = cal_gate_full_open_with_free_flow(water_depth_front_of_gate,gate_width,wingwall,drop_step);
- break;
- case gate_full_open_with_submerged_flow:
- temp = cal_gate_full_open_with_submerged_flow(water_depth_front_of_gate,water_depth_behind_of_gate,gate_width,wingwall,drop_step);
- break;
- case gate_control_with_free_flow:
- temp = cal_gate_control_with_free_flow(water_depth_front_of_gate,water_depth_behind_of_gate,openning_height_of_gate,gate_width,wingwall,drop_step);
- break;
- case gate_control_with_submerged_flow:
- temp = cal_gate_control_with_submerged_flow(water_depth_front_of_gate,water_depth_behind_of_gate,openning_height_of_gate,gate_width,wingwall,drop_step);
- break;
- case gate_full_open_with_free_flow_drop_step:
- temp = cal_gate_full_open_with_free_flow(water_depth_front_of_gate,gate_width,wingwall,drop_step);
- break;
- case gate_full_open_with_submerged_flow_drop_step:
- temp = cal_gate_full_open_with_submerged_flow(water_depth_front_of_gate,water_depth_behind_of_gate,gate_width,wingwall,drop_step);
- break;
- case gate_control_with_free_flow_drop_step:
- temp = cal_gate_control_with_free_flow(water_depth_front_of_gate,water_depth_behind_of_gate,openning_height_of_gate,gate_width,wingwall,drop_step);
- break;
- case gate_control_with_submerged_flow_drop_step:
- temp = cal_gate_control_with_submerged_flow(water_depth_front_of_gate,water_depth_behind_of_gate,openning_height_of_gate,gate_width,wingwall,drop_step);
- break;
- }
- return temp;
-}
-#endif
-//double openning_height_of_gate, double water_depth_front_of_gate,double water_depth_behind_of_gate,double gate_width,int wingwall,int drop_step
+/*
+ *函数名: Calculation_of_InstantaneousFlow()
+ *参数: *param 指向struct param_gate的指针
+ *
+ *功能: 根据参数,计算出瞬时流量
+ *返回值: 瞬时流量
+ *
+*/
int Calculation_of_InstantaneousFlow(double *value,struct param_gate *param)
{
patterns_of_water get_pattern;
-
- double temp;
if(data_validity_check(param)!=0)
return -1;
@@ -483,35 +423,34 @@ int Calculation_of_InstantaneousFlow(double *value,struct param_gate *param)
get_pattern = discrimination_of_flow_pattern(param->openning_height_of_gate,param->water_depth_front_of_gate,param->water_depth_behind_of_gate,param->drop_step);
switch(get_pattern){
case gate_full_open_with_free_flow:
- temp = cal_gate_full_open_with_free_flow(param->water_depth_front_of_gate,param->gate_width,param->wingwall,param->drop_step);
+ *value = cal_gate_full_open_with_free_flow(param->water_depth_front_of_gate,param->gate_width,param->wingwall,param->drop_step);
break;
case gate_full_open_with_submerged_flow:
- temp = cal_gate_full_open_with_submerged_flow(param->water_depth_front_of_gate,param->water_depth_behind_of_gate,param->gate_width,param->wingwall,param->drop_step);
+ *value = cal_gate_full_open_with_submerged_flow(param->water_depth_front_of_gate,param->water_depth_behind_of_gate,param->gate_width,param->wingwall,param->drop_step);
break;
case gate_control_with_free_flow:
- temp = cal_gate_control_with_free_flow(param->water_depth_front_of_gate,param->water_depth_behind_of_gate,\
+ *value = cal_gate_control_with_free_flow(param->water_depth_front_of_gate,param->water_depth_behind_of_gate,\
param->openning_height_of_gate,param->gate_width,param->wingwall,param->drop_step);
break;
case gate_control_with_submerged_flow:
- temp = cal_gate_control_with_submerged_flow(param->water_depth_front_of_gate,param->water_depth_behind_of_gate,\
+ *value = cal_gate_control_with_submerged_flow(param->water_depth_front_of_gate,param->water_depth_behind_of_gate,\
param->openning_height_of_gate,param->gate_width,param->wingwall,param->drop_step);
break;
case gate_full_open_with_free_flow_drop_step:
- temp = cal_gate_full_open_with_free_flow(param->water_depth_front_of_gate,param->gate_width,param->wingwall,param->drop_step);
+ *value = cal_gate_full_open_with_free_flow(param->water_depth_front_of_gate,param->gate_width,param->wingwall,param->drop_step);
break;
case gate_full_open_with_submerged_flow_drop_step:
- temp = cal_gate_full_open_with_submerged_flow(param->water_depth_front_of_gate,param->water_depth_behind_of_gate,param->gate_width,param->wingwall,param->drop_step);
+ *value = cal_gate_full_open_with_submerged_flow(param->water_depth_front_of_gate,param->water_depth_behind_of_gate,param->gate_width,param->wingwall,param->drop_step);
break;
case gate_control_with_free_flow_drop_step:
- temp = cal_gate_control_with_free_flow(param->water_depth_front_of_gate,param->water_depth_behind_of_gate,\
+ *value = cal_gate_control_with_free_flow(param->water_depth_front_of_gate,param->water_depth_behind_of_gate,\
param->openning_height_of_gate,param->gate_width,param->wingwall,param->drop_step);
break;
case gate_control_with_submerged_flow_drop_step:
- temp = cal_gate_control_with_submerged_flow(param->water_depth_front_of_gate,param->water_depth_behind_of_gate,\
+ *value = cal_gate_control_with_submerged_flow(param->water_depth_front_of_gate,param->water_depth_behind_of_gate,\
param->openning_height_of_gate,param->gate_width,param->wingwall,param->drop_step);
break;
}
- *value = temp;
return 0;
}
diff --git a/cal_gate.h b/cal_gate.h
index 1b579c8..e5e335d 100644
--- a/cal_gate.h
+++ b/cal_gate.h
@@ -12,6 +12,10 @@ struct param_gate{
double gate_width;
};
-int Calculation_of_InstantaneousFlow(double * value,struct param_gate *param);
+
+//double Calculation_of_InstantaneousFlow(double openning_height_of_gate, double water_depth_front_of_gate,double water_depth_behind_of_gate,double gate_width,int wingwall,int drop_step);
+int Calculation_of_InstantaneousFlow(double *value,struct param_gate *param);
+
+
#endif
diff --git a/test-hdsmf/test.c b/test-hdsmf/test.c
index 6c154d6..83708de 100644
--- a/test-hdsmf/test.c
+++ b/test-hdsmf/test.c
@@ -8,7 +8,9 @@
int main()
{
void *param;
-
+ int results=0;
+ double temp;
+
param=malloc(40);
*((int*)param)=1;
@@ -21,9 +23,9 @@ int main()
printf("For Test\r\n");
-
+ results=Calculation_of_InstantaneousFlow(&temp,param);
- printf("ins:%f\r\n",Calculation_of_InstantaneousFlow(param));
+ printf("exec:%d,ins:%f\r\n",results,temp);
//printf("ins:%f\r\n",Calculation_of_InstantaneousFlow(5,1.2,0.1,1.2,1,0));
free(param);
return 0;