给水管网管网平差程序
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include
#include
#define A 100
main()
{ int B[A],E[A],IO[A],JO[A],ok=0,i,k,P,LOOP;
float xs,L[A],D[A],q[A],Dq[A],h[A],Dh[A],sq[A],s1[A],s[A],w[A],v[A]; FILE *fp; char F[10];
printf(" Please input DA TA file name... ");
scanf("%s",F); fp=fopen(F,"r");
fscanf(fp,"%d%d%f",&P,&LOOP,&xs);
for(k=1;k<=P;k++) fscanf(fp,"%d%d%f%f%f%d%d",
&B[k],&E[k],&L[k],&D[k],&q[k],&IO[k],&JO[k]);
fclose(fp);
for(k=0;k<=LOOP;k++) Dq[k]=0;
for(k=1;k<=P;k++)
{ if(D[k]<290) D[k]=D[k]-1; D[k]=D[k]/1000;
s1[k]=.001736e-6/pow(D[k],5.3)*L[k];
q[k]=xs*(IO[k]<0)?-q[k]:q[k];
w[k]=3.141592654/4*D[k]*D[k]; }
a1:ok++; printf(" OK=%d\n",ok); if(ok>0) goto a2;
for(k=1;k<=P;k++)
{ q[k]=q[k]+Dq[abs(IO[k])]-Dq[JO[k]];
v[k]=fabs(q[k])/1000/w[k];
s[k]=(v[k]>=1.2)? s1[k]:s1[k]*.852*pow(1+.867/v[k],.3);
h[k]=s[k]*q[k]*fabs(q[k]);}
for(i=1;i<=LOOP;i++)
{ Dh[i]=0; sq[i]=0;
for(k=1;k<=P;k++)
{ if(abs(IO[k])==i) {Dh[i]=Dh[i]+h[k];
sq[i]=sq[i]+s[k]*fabs(q[k]);}
if(JO[k]==i) {Dh[i]=Dh[i]-h[k];
sq[i]=sq[i]+s[k]*fabs(q[k]);} }
Dq[i]=-Dh[i]/2/sq[i]; }
for(i=1;i<=LOOP;i++) if(fabs(Dh[i])>.001) goto a1;
a2: printf(" Please input result file name ... ");
scanf("%s",F); fp=fopen(F,"w");
fprintf(fp," Pipe=%d Loop=%d OK=%d\n",P,LOOP,ok); fprintf(fp,"----------------------------------------------------------\n");
fprintf(fp," No. from to L(m) D(mm) q(L/s) h(m) v(m/s) IO JO"); fprintf(fp,"\n----------------------------------------------------------");
for(k=1;k<=P;k++)
fprintf(fp,"\n(%2d)%4d--%2d %5.0f %6d %8.2f %7.2f %6.2f %4d %3d",k,B[k],E[k], L[k],10*(int)(D[k]*100+.5),q[k],h[k],v[k],IO[k],JO[k]);
fprintf(fp,"\n----------------------------------------------------------\n");
for(i=1;i<=LOOP;i++) { fprintf(fp," Dh[%d]=%5.4fm ",i,Dh[i]);
if(fmod(i,3)==0) fprintf(fp,"\n"); }
fprintf(fp,"\n----------------------------------------------------------");
fclose(fp); }
/*
14 5
2 1 760 .15 12 -1 0
3 2 850 .25 39.6 -2 0
4 1 400 .1
5 4 1 0
5 2 400 .15 4 -1 2
6 3 400 .3 59.6 -2 0
5 4 700 .25 31.
6 1 3
6 5 850 .3 76.4 2 4
4 7 350 .1
5 4 -3 0
5 8 350 .15 4 3 4
6 9 350 .3 58.2 4 0
8 7 700 .15 12.8 3 0
9 8 850 .25 39 4 0
10 6 410 .4 109.9 5 0
10 6 450 .4 109.9 -5 0
********** B1 ******************************************
Pipe=14 Loop=5 OK=7
----------------------------------------------------------
No_ from to L(m) D(mm) q(L/s) h(m) v(m/s) IO JO
----------------------------------------------------------
( 1) 2-- 1 760 150 -9.74 -3.41 0.56 -1 0
( 2) 3-- 2 850 250 -39.08 -3.79 0.80 -2 0
( 3) 4-- 1 400 150 6.26 0.81 0.36 1 0
( 4) 5-- 2 400 150 -2.27 -0.14 0.13 -1 2
( 5) 6-- 3 400 300 -59.08 -1.51 0.84 -2 0
( 6) 5-- 4 700 250 36.36 2.73 0.75 1 3
( 7) 6-- 5 850 300 76.35 5.17 1.08 2 4