too many arguments in function call问题
#include "stdio.h"#include "math.h"
#include <string.h>
#define pi 3.1415926 //contant for pi number
#define D 0.100 //cylinder bore
#define S 0.115 //cylinder stroke
#define B 18.4 //compression ratio
#define Vh 0.000903 //swept volume
#define As 0.302632 //ratio crankshaft radius versus connnecting rod length
#define p0 0.1 //atmo pres
#define n 2300 //engine speed
#define t0 288 //atmo temp
#define Hu 44100 //calorific value
#define ot 20 //temperature added to intake fresh
#define r 0.04
#define tr 800 //
#define R 0.28708
#define m 1
#define l0 14.4
#define tw1 450
#define tw2 500
#define tw3 430
#define Nu 0.99
#define Ml 0.0007
#define Mb0 0.000025
#define Mbr 0.000001
double A,M,P[200],T[200],phi[200],Vm[200];
double qes=229;
double qvb=335;
double qve=420;
double qao=488;
int g;
double main(){
double cv(),Vol(),dVdphi(),pres(),coeff(),dQwdphi(),dQbdphi(),Mb(),exair(),U();
double dUdphi(),rk4(),comp(),comb(),expa(),pri();
double tes,tvb,tve,tao;
tes=(t0+ot+r*tr)/(1+r);
tvb=rk4("compssion",qes,qvb,tes,5.0);
pri();
tve=rk4("combustion",qvb,qve,tvb,1.0);
pri();
tao=rk4("expansion",qve,qao,tve,5.0);
pri();
}
// calculate transient cv
double cv(double x,double y){
double f;
f=-3.0*(0.0975+0.0485/pow(x,0.75))*(y-273)*(y-273)*1.e-6;
f+=2.0*(7.768+3.36/pow(x,0.8))*(y-273)*1.e-4;
f+=(489.6+46.4/pow(y,0.93)*1.e-2);
f*=0.14455;
return(f);
}
// calculate transient volume v(\phi)
double Vol(double x){
double f;
f=2.0/(B-1)+1-cos(x)+(1-sqrt(1-As*As*sin(x)*sin(x))/As);
f*=Vh/2;
return(f);
}
//calculate volume change derivative against \phi
double dVdphi(double x){
double f;
f=sin(x)+As*sin(x)*cos(x)/sqrt(1-As*As*sin(x)*sin(x));
f*=Vh/2;
return(f);
}
//calculate cylinder pressure
double pres(double x,double y){
double f;
f=M*R*y*0.001/Vol(x);
return(f);
}
//calculate transient heat exchange coefficients
double coeff(double x,double y){
double f,c1,c2,v1,cm,p1,t1;
c1=2.28;
c2=3.24*1.e-3;
cm=7.0;
p1=0.9*p0;
v1=Vol(225*pi/180);
t1=(t0+ot+r*tr)/(1+r);
f=130*pow(y,-0.53);
f*=pow(pres(x,y),0.8);
f*=pow(D,-0.2);
f*=pow((c1*cm+c2*Vh*t1*(pres(x,y)-p0)/p1/v1),0.8);
f/=1000;
return(f);
}
//calculate burnt fraction
double mb(double x){
double f,s,h;
s=qve-qvb;
h=(x*180/pi-qvb)/s;
f=Mb0*h+Mbr;
return(f);
}
//calculate transient excess air ratio
double exair(double x){
double f;
f=Ml/0/mb(x);
return(f);
}
//calculate internal energy
double U(double x, double y){
double f;
f=-(0.0972+0.0485/pow(exair(x),0.75))*pow((y-273),3)*1.e-6;
f+=(7.768+3.36/pow(exair(x),0.8))*pow((y-273),2)*1.e-4;
f+=(489.6+46.4/pow(exair(x),0.93))*(y-273)*1.e-2+1356.8;
f*=0.14455;
return(f);
}
//calculate partial derivative of u to excess air ratio
double dUdl(double x, double y){
double f,u0,u1,h=0.01;
u0=U(x,y);
u1=U(x+h,y);
f=(u1-u0)/h;
return(f);
}
//calculate heat transfer per crankshaft angle
double dQwdphi(double x, double y){
int i;
double f=0,A[3],tw[3]={tw1,tw2,tw3};
A[0]=3.14*D*D/4;
A[1]=3.14*D*D/4;
A[2]=4*Vol(x)/D;
for (i=0;i<3;i++)
f=f+coeff(x,y)*A[i]*(tw[i]-y)*30/(pi*n);
return(f);
}
//calculate transient heat release rate
double dQbdphi(double x, double y){
double f,dura;
dura=(qve-qvb)*pi/180;
f=6.908*Nu*Mb0*(m+1.0)*pow((x-qvb*pi/180)/dura,m);
f*=exp(-6.908*pow((x-qvb*pi/180)/dura,(m+1.0)));
f/=dura;
return(f);
}
//codes for printing out step outcome
double pri(){
int i;
for (i=0;i<g;i++){
FILE *fp=fopen("d:\\input.txt","a");
printf("%c %c(%3.0f%cCA): %c",186,237,phi[i],248,179);
printf("P=%5.4f MPa %c",P[i],179);
printf("V=%8.7f m3 %c",Vm[i],179);
printf("T=%8.3f K %c\n",T[i],186);
fprintf(fp,"%4.2f(CA), %8.4F L, %8.3f MPa, %10.4f K, \n",phi[i],1000*Vm[i],P[i],T[i]);
fclose(fp);
}
}
//compression process
double compression(double x, double y){
double f;
M=Ml+Mbr;
A=10000;
f=dQwdphi(x, y)-pres(x, y)*dVdphi(x)*1000;
f=f/(M*cv(x, y));
return(f);
}
//combustion process
double combustion(double x, double y){
double f,dmdphi,dLdphi;
M=Ml+mb(x)+Mbr;
A=exair(x);
dmdphi=dQbdphi(x,y)/Hu;
dLdphi=-Ml*dQbdphi(x,y)/(l0*Hu*mb(x)*mb(x));
f=(dQbdphi(x,y)+dQwdphi(x,y)-1000*pres(x,y)*dVdphi(x)-U(x,y)*dmdphi-M*dUdl(x,y)*dLdphi)/(M*cv(x,y));
return(f);
}
//expansion process
double expansion(double x, double y){
double f;
M=Ml+Mb0+Mbr;
A=Ml/(l0*(Mb0+Mbr));
f=dQwdphi(x, y)-1000*pres(x, y)*dVdphi(x);
f=f/(M*cv(x, y));
return(f);
}
double rk4(char *process, double qstart, double qend, double TK, double step){
double k1,k2,k3,k4;
int i;
phi[0]=qstart;
T[0]=TK;
g=(int)(qend-qstart)/step;
for(i=0;i<=g;i++){
if(strcmp(process,"compression")==0){
k1=step*compression(phi[i]*pi/180,T[i])*pi/180;
k2=step*compression((phi[i]+step/2.0)*pi/180,(T[i]+k1/2.0))*pi/180;
k3=step*compression((phi[i]+step/2.0)*pi/180,(T[i]+k2/2.0))*pi/180;
k4=step*compression((phi[i]+step)*pi/180,(T[i]+k3))*pi/180;
T[i+1]=T[i]+(k1+2*k2+2*k3+k4)/6.0;
phi[i+1]=phi[i]+step;
Vm[i]=Vol(phi[i]*pi/180);
P[i]=pres(phi[i]*pi/180,T[i]);
}
else if(strcmp(process,"combustion")==0){
k1=step*combustion(phi[i]*pi/180,T[i])*pi/180;
k2=step*combustion((phi[i]+step/2.0)*pi/180,(T[i]+k1/2.0))*pi/180;
k3=step*combustion((phi[i]+step/2.0)*pi/180,(T[i]+k2/2.0))*pi/180;
k4=step*combustion((phi[i]+step)*pi/180,(T[i]+k3))*pi/180;
T[i+1]=T[i]+(k1+2*k2+2*k3+k4)/6.0;
phi[i+1]=phi[i]+step;
Vm[i]=Vol(phi[i]*pi/180);
P[i]=pres(phi[i]*pi/180,T[i]);
}
else if(strcmp(process,"expansion")==0){
k1=step*expansion(phi[i]*pi/180,T[i])*pi/180;
k2=step*expansion((phi[i]+step/2.0)*pi/180,(T[i]+k1/2.0))*pi/180;
k3=step*expansion((phi[i]+step/2.0)*pi/180,(T[i]+k2/2.0))*pi/180;
k4=step*expansion((phi[i]+step)*pi/180,(T[i]+k3))*pi/180;
T[i+1]=T[i]+(k1+2*k2+2*k3+k4)/6.0;
phi[i+1]=phi[i]+step;
Vm[i]=Vol(phi[i]*pi/180);
P[i]=pres(phi[i]*pi/180,T[i]);
}
}
return(T[i]);
}