|
#include "math.h"
$ H, X$ T8 O3 f7 j3 G#include "stdio.h"
2 z4 C( p5 d; a' b- a+ e#define PI 3.1415926
) Q" }) I' o( o
$ Y' L% b0 w3 u0 K# ]$ y5 R" wdouble D,S,L,ge,n,Ne,gnum,ysb,Hu,Lo,M,R,P_SC,T_SC;
7 U2 O q0 J1 a/*缸径、行程、连杆长、比油耗、转速、功率、气缸数、压缩比、低热值、理论空燃比、Weibe函数常数m、气体常数、进气门关闭时压力和温度 */7 \* |9 p: d% f' k& M
double m_T[720],m_P[720],m_a[720];* A8 ]2 @$ N$ K Z
/*气缸温度、压力、瞬时过量空气系数 */0 G1 a# u$ y4 |6 H* M- R) ~2 m% u6 ]
int m_CA[720],A_SC,A_CB,A_CE,A_EO,A_SO,A_EC;
; _/ x( e4 j' h0 y- \6 T( g* o double Pa,Ta,hs,P,V,T,CA,m,mf,nmd,Pe,mBo,mL,dXY;* I7 v/ ], Y! T1 ]& G) [- o
double Cv();2 \+ N- y) @- Q1 H* d
double dV_dCA();/ t8 }! w! n8 ^" u0 [/ k7 d2 _* x
double dQw_dCA();/ @) {# f2 M- |9 W& N
double dQB_dCA();
7 q- T: ]# {/ o7 C" e% | double U();4 o% l' c7 @! Z1 @) F
double V_CA();
9 X. o9 u( K& N double dU_dnmd();
' \* i9 z4 s6 t double dT_Ys_dCA();
8 e# c$ Q: h; e% Y double dT_Pz_dCA();& B4 k4 t6 p9 ^0 u, L8 g
double dT_Rs_dCA();
$ T) ^/ @# K% m- C0 j! ~- V3 R: q* H double dT_Hq_dCA();1 s" |: F% [: A5 H; Y
double dT_dCA(double an);* k8 y( M6 r( [0 {4 Y( t
void Calculate();
+ M, Y: g5 } k: b
) _! N; b/ \$ V' B/* A编写各子函数程序*/
! X- S1 n$ V, T5 a& {% F. a3 r double Cv() /*求定容比热*/
3 s1 ?; u: Y: ~, v{8 Q3 h6 V' G0 d, v% }
" W% Q9 Z X* j1 [% v# o
}
8 L5 J; F7 Q+ S9 n- N3 M( |( t8 y% d& x2 Q: v4 j; n$ \
, T9 Y" ^. f. O3 t3 J _& x3 E
double dV_dCA() /*求dv/dφ*/! u/ ]5 l+ {: ~
{
# y" o2 d: ]7 l: G% Z3 _# W: U# ~6 \/ N& q' }
}4 s0 e; l- x# F" G, d
6 T: t2 D8 X+ r% \1 x7 N, F
4 B9 `: D# g$ K; X$ Adouble V_CA() /*求气缸容积*/% x9 x8 E4 ^: x3 G; u1 y9 ?$ V& H
{
6 D, d* I8 g+ D
; F6 [0 n1 k- j+ ^. u/ Q0 O! b}" v! e# ~9 r- w5 j% f8 a
v/ \ j! H( A* G) \0 V! j
" V" C. g0 E* J1 u' @! i v: Q
double dQw_dCA() /*求dQw/dφ*/& q& [' x$ X8 w2 Y' ~
{
/ X. p7 M# o# E/ n( N. Y0 e \4 X8 V: s5 ]( n* R( `6 J4 A
}
- x9 G. X; Y! x) w! C; n1 P
3 y; ?2 U. C+ n
+ w, u0 y: J- ]& U% I; Fdouble dQB_dCA() /*求dQB/dφ*/7 l% f, E& `& z. \; k% {5 Q7 {
{1 O! u5 K+ o, J8 \, |" [
, \. h; x: d$ {( S
}( _! x; ~4 g9 J/ M
/ b8 \0 H7 V4 h( T1 m' h
, j; E2 a2 I) B: H( V+ T* g: mdouble U() /*求u*/- s. {. H3 m5 \2 w
{
" S. l. S- N( y, u9 y! x
$ i) s3 \5 W/ L$ j) U: O. U8 Q4 V}
/ ~2 Z/ ^9 ?- O* h# ~/ D4 ~
' f- i. I4 m4 m2 [2 b" F
4 a4 U U1 w! i; d- K& V- wdouble dU_dnmd() /*求du/dλ*/: ?* s! k9 G' b* C
{. R3 _+ {1 \' Y
9 d+ s6 q8 f6 z' b v* H}
8 Q9 x% c4 _( X* U+ c; O0 @' |6 [1 F3 q4 j+ G
double dT_Ys_dCA() /*压缩期*/
- x6 E" x: j4 z$ ^{ o, R' e+ {, W! ^1 Y& O. ?
( W# [' @. r6 @1 k; G( J5 W+ h}. Y7 X0 }: ~; ?( H4 ]9 j8 t
- B9 Z5 }' c8 u& p Z$ F- V
- b$ C: a" ?3 ~& i6 w* u
double dT_Pz_dCA() /*膨胀期*/; Q8 c7 Y' a I0 I7 m G8 V
{* r6 {( T/ B, z2 N' i' f
8 I# C; m7 F0 P}; _9 p$ a) c# X
/ M7 Q- G, b+ k( ]% j: _
7 d" _- {: [7 i$ x0 n/ m8 q# A! sdouble dT_Rs_dCA() /*燃烧期*/) N. `- d; N1 Z, w( Z- T% E
{
) S' ?8 R& ^6 K& D1 P N6 C2 u: Q M t$ S A! p' j0 ]8 _
}
+ o- \8 T* M: t9 t4 o4 n
8 |8 a$ j* q2 W8 L6 j: e
- X: T) E$ a! x- Fdouble dT_dCA(double an) /*求dT/dφ*/' r7 H |3 s+ y3 ]2 P
{
+ X1 z5 s" u! i8 z: m- }- {# w3 z CA=an*PI/180;
% [4 e8 w# N+ F1 c& t- B V=V_CA();
% s+ L' s) M. I Z if(A_SC<an && an<A_CB) return dT_Ys_dCA();
; u. |6 o0 A) w+ @ if(A_CB<=an && an<=A_CE) return dT_Rs_dCA();: K9 r( ?2 D( C
if(A_CE<an && an<=A_EO) return dT_Pz_dCA();
0 f6 ~; u8 U) p/ o if(A_EO<an && an<=A_SO) /*换气过程不计算,线性赋值,避免零值 */
1 g0 U% h1 l* d; l! l P=110000+(m_P[(int)A_EO]-110000)*(A_SO-an)/(A_SO-A_EO);
/ f: _ u) K7 g if(A_SO<an || an<A_EC) $ T* @! ^- [8 n% i/ n: b
P=110000-20000*(an>A_SO?an-A_SO:an-A_SO+720)/(A_EC-A_SO+720);
. b: i1 B5 z. y6 _6 Y$ c if(A_EC<=an && an<=A_SC) P=90000;
- [4 I4 n9 e' I/ S3 |6 J5 g return 0;# G. `$ m5 ~( \' n" b0 K
}7 P" L; n, r6 E
2 ?* Z2 d& O% ~# O. U, i
void Calculate(void)$ ~, K7 x5 ]8 E( n* U, h
{
1 J$ S7 ]; a% J. B& f7 U3 s, H double Tpre,K1,K2,an;8 F6 Z( z, s: A/ g' R
int index;
5 E! m+ Q! Q# K% j7 c' H8 j* | Pe=30*4.0*Ne/(gnum*100000*n*S*PI*D*D/4); /*平均有效压力bar*/
$ j) z- ^2 D$ o mBo=Ne*ge/(30000000*n*gnum); /*单缸循环供油量kg */
$ z1 w* I' }" ?' V CA=A_SC*PI/180; /*进气关闭时的角度转弧度*/
' a1 w# e9 _- ~" w% Q1 I6 I V=V_CA();/*进气关闭时角度下的气缸容积*/
) j5 F; L. C+ }' e/ U) v* z( s" d P=P_SC;5 z' I* ?' [+ g8 q3 f5 g/ E+ r" N
T=T_SC;. Y# b/ M) t1 Z/ k6 ~5 Y+ o5 e
index=(int)A_SC;
* g& T$ F4 o P5 p! |- e m_T[index]=T;
( N0 v0 J% n& t/ G7 c; p( |$ S2 P m_P[index]=P;
" ?2 l' m9 K) R h# J m=P*V/(R*T);/*进气关闭时角度下的气缸内工质质量*/
* V" J) @ t$ e mL=m-0.01*mBo;/*进气关闭时角度下的气缸内空气质量*/* E: C! G- t# c% G8 N5 U9 E1 ^0 w# b
mf=m-mL;
: E; B( p! [" G Tpre=T;7 e l( p0 f% X/ l6 \$ F
an=A_SC+1;
' [5 ]! X/ b k% y2 B" h; H4 }5 J) [$ Z( M- W K" R
do{
6 T2 w' {3 z6 r: H; d! b% ]. t4 b5 W7 K9 \
/*B 编写欧拉法求解常微分方程程序 */, s/ h, e6 K8 e8 _. \, {7 o' z$ j
$ a: b, T8 q; N6 `& ^ }while(an!=A_SC+1);
4 E n3 Q e9 X+ F0 t}
$ b% n, \% v {: c; k7 |0 d; C l, z8 [% c
void main(void)
l( |4 T7 Q- J{% v! }8 S" [/ l" ^" k
int i;) A! ~2 M( y* S# _6 d
FILE *fp;
9 m8 T$ y. x7 G D=0.11; /*发动机数据按各自的任务书输入 */
8 l8 c$ w7 s. ~. {2 [ S=0.13;" V7 x$ X/ v0 n j! {; e' V
L=0.21;
. {- R- _& s7 v, E2 u B ge=236.0;
7 a: P3 }6 X# ^ n=2400;- _+ `, Y: j& v9 D+ ?6 X
Ne=101568;
4 q& _6 r4 ^( E% }/ T& N gnum=6; ysb=17; M=0.7;, M1 B& e& V% _/ m: s
Hu=41868000;1 u( b6 @. R$ U2 l% }, t
R=287.08;
! B2 \9 r9 t2 }" A0 f Pa=101000; /*大气压力*/
# b F3 b: p* y3 v Ta=300; /*大气温度*/
; J S' ^, q# O4 g hs=(735.0+R)*Ta; /*大气焓值*/; F& N$ B# e+ ^1 Q% I0 j9 x8 C
P_SC=90000;
2 K+ r. B$ Y! M- e2 }& h- ^! w T_SC=313;
3 T/ e2 T8 d! p2 x9 p. C" T% l: e0 Y' o4 P
A_SC=216; /*进气门关闭*/
( L6 N$ V/ X9 {' i A_CB=350; /*燃烧开始*/# k0 a7 i& Q% `* `
A_CE=410; /*燃烧结束*/0 k1 K( e1 w4 U# s1 j
A_EO=484; /*排气门开启*/: D; Y8 i+ l7 q, J9 m
A_SO=705; /*进气门开启*/
# z7 T3 O4 X9 j3 H$ s6 ] A_EC=15; /*排气门关闭*/% T; g" }5 _4 Q2 L3 }9 J
% C4 o9 e) l9 ^1 g
Lo=14.4;
: `6 d& g7 i6 G' C' B1 R
! }. n% S- u# L$ c for(i=0;i<720;i++)
7 x( O4 {3 O/ [; x/ Q9 \8 n( ~ {7 e2 \+ f8 e/ J* ?& q& C" k
m_P[i]=0;
6 T$ z3 s; n! g, L7 h m_CA[i]=i;
- E- r1 \9 Z/ F& i& W( x m_T[i]=0;% x0 ^ x ?( _4 G% g) P9 Z
}, Q% z/ g, A& S$ Z- c f
! D" `1 o. Q, Y _7 c
Calculate();
4 m0 |' n1 w. g/ P( b. o
& v. O8 D. G& b /*C编写数据输出程序,计算结束后按顺序输出0-720转角的“缸压,温度”数据到outdata.txt文件 */
h5 z& o) E* t: u& O# [ c5 `7 P H- n
}6 j0 v* t2 A; @+ p
0 `$ D- j; k- e( h ?# p7 S
6 A2 j) J) E: M: ^2 s |
|