|
#include "math.h"
# ^" n; ?/ p* F" p/ O#include "stdio.h"
# a6 u% k3 K& t#define PI 3.1415926( H/ F! h7 z8 t8 R
2 G" I/ N# a% w: @/ G
double D,S,L,ge,n,Ne,gnum,ysb,Hu,Lo,M,R,P_SC,T_SC;
3 {$ x' O# ^3 P, [( y' S/*缸径、行程、连杆长、比油耗、转速、功率、气缸数、压缩比、低热值、理论空燃比、Weibe函数常数m、气体常数、进气门关闭时压力和温度 */
- q# h' y8 `; O! _ double m_T[720],m_P[720],m_a[720];
" m2 B7 _" `# _/*气缸温度、压力、瞬时过量空气系数 */1 u( w* X$ h* _
int m_CA[720],A_SC,A_CB,A_CE,A_EO,A_SO,A_EC;
4 s. \8 y3 w* A1 r; d" ` double Pa,Ta,hs,P,V,T,CA,m,mf,nmd,Pe,mBo,mL,dXY;
# d# x! \: ?1 K+ F! Y/ h double Cv();$ I' \. E6 A; W' M- ?3 r
double dV_dCA();
: D; v8 b0 C% D9 z, H* d" @' ] double dQw_dCA();. ^! K0 N: Y1 H5 _4 i( i* O
double dQB_dCA();& _5 X! x* O3 W. u' _4 v; H& T! [
double U();
1 h' a' z9 E& h double V_CA();; `! R$ R- L/ m7 w$ E+ |
double dU_dnmd();
( g4 e% b8 W# z2 w* L! P6 k double dT_Ys_dCA(); ]+ b7 n$ }: v5 b' e# C
double dT_Pz_dCA();( C/ a# `( |9 V, B) J! _
double dT_Rs_dCA();' C f" T. q& j4 o! y
double dT_Hq_dCA();& @, C S% b7 D! `/ {3 n- J
double dT_dCA(double an);( B3 q& `* X, l/ E5 `$ I2 j# K
void Calculate();6 K+ J4 U! w% c7 e$ ]2 h* B* Z& \
& B5 s5 p4 }& C9 w; H: [* a
/* A编写各子函数程序*/; I5 P3 Y* w+ M" d* k* m
double Cv() /*求定容比热*/3 u* G9 ]7 q6 Q* @" N: L
{9 ?' c" z& x* Q7 A
6 p, k! s6 V3 m8 o# x+ L4 w: Q8 X
}
' O* O i6 h2 f/ a: C# B2 X* Z. c- S1 t1 w
' W% S @1 H. b0 I# R4 i. ~! I
double dV_dCA() /*求dv/dφ*/
0 {, N& c' }, |8 _* ?9 l{
" a2 w; T. V J( m) d/ x0 a t2 g5 v- Y
}1 z: ?' ]5 E: B! W3 ^
8 i; b0 M# t, y: G
+ v8 G' G1 L# H( R" `4 D1 Gdouble V_CA() /*求气缸容积*/! K6 g. k" U# s) b8 O) Z
{; R- S4 U* W' _
/ @9 @6 v$ c8 W( A; a}
0 B. b. L7 ]4 V8 P
& h3 x& ]4 m! b3 p+ Q i: r, ^, B5 s
3 ]* Q6 L, |4 Zdouble dQw_dCA() /*求dQw/dφ*/7 w$ z8 J4 Q; x$ p# A
{
% t/ U: h! d/ }
7 o+ P, F$ r; f2 s M" y8 B}5 B3 J2 M9 [. \# {: o* ^
: e( b+ r* M3 ?" e$ j( G% z. v" {
! E) ^9 E# @3 vdouble dQB_dCA() /*求dQB/dφ*/
$ d6 `: Q4 i1 ?. b' c0 ]( s- {$ v( b{5 j& L: ^- V; @ ~" o
7 b/ ~1 a+ U- {! Q# ]}( j* ]6 ~4 R: C
# k4 N7 G) B' I6 t; X0 t4 f
4 J2 W) ]5 {2 idouble U() /*求u*/: Q+ V% [; q3 k
{
* G& [. E- c, K0 K4 B( y, q. m3 z5 }% D& r
}( M7 x* S0 {) I' e6 E3 ~% h
" S2 x: n6 T3 w) c& v8 m q
% Z9 |: k& c3 l: z$ Z: b5 m4 Kdouble dU_dnmd() /*求du/dλ*/0 P" \" f6 r& C
{) n/ @0 b" o2 F4 V- R
9 w* \9 l. w! E) E
}
3 C( f+ t0 p0 i0 i5 _" f% }* P7 s
0 P! t8 v6 A i3 f! u* }& [double dT_Ys_dCA() /*压缩期*/
9 F" A( t/ w5 Q' y5 ~- n0 b{7 V' m6 ^$ }( t; s8 k
2 \' q3 T* s" p( D" Y}/ [- J+ C" s: K# W& B
/ t- R7 n# G0 L9 c& p0 @
" T$ ^9 o* a$ d5 j. X: mdouble dT_Pz_dCA() /*膨胀期*/6 ]' Q9 P( _4 M" S- x# x0 f
{0 U; y+ f. b# r0 y {
; a0 S% H% {# M8 j' [- W}& T2 B; m2 Q' O, r9 B1 P, z2 I
2 p) K* V8 C% _ h
. ^1 z+ L2 M8 A) ~double dT_Rs_dCA() /*燃烧期*/
; X. J) }& r" b2 a5 s{2 C" i. N) }9 C( y
2 P, p1 Y4 ^# a( {6 u}8 i2 r0 A) ^ Y' u" W$ V& A& o* z/ D
& o* } {+ o; @, M/ j/ V1 D4 X% |( C
( j% z; ?9 _* d1 R& Ddouble dT_dCA(double an) /*求dT/dφ*/- i+ b: P5 F5 B4 [. `. J: [
{8 b, s% M; q6 f- M4 z6 G
CA=an*PI/180;- g+ c% x3 e# V5 I$ m1 b+ V
V=V_CA();
2 t% G" g! G. [2 M9 J7 X. n if(A_SC<an && an<A_CB) return dT_Ys_dCA();1 R- [4 D$ Q0 l% S# ?
if(A_CB<=an && an<=A_CE) return dT_Rs_dCA(); s# s9 y3 s+ [
if(A_CE<an && an<=A_EO) return dT_Pz_dCA();
" H2 D4 Q. x# T5 \ if(A_EO<an && an<=A_SO) /*换气过程不计算,线性赋值,避免零值 */1 P& H& J$ q: w$ |
P=110000+(m_P[(int)A_EO]-110000)*(A_SO-an)/(A_SO-A_EO);( V: I( b) E1 |% Y" x6 @
if(A_SO<an || an<A_EC) 9 w5 T4 U8 b) V+ X) G7 A# J
P=110000-20000*(an>A_SO?an-A_SO:an-A_SO+720)/(A_EC-A_SO+720);
; s/ E0 \( g; \; s7 }0 O0 z5 s if(A_EC<=an && an<=A_SC) P=90000;+ Z3 j! ?, A* x/ q$ W, w V' @
return 0;! W4 g& W4 b q$ Q
}
% c( R5 w. h) c9 B+ D2 d! B, q) r9 ^
void Calculate(void)
+ U1 ?2 k0 ~8 ^% s* X/ h{: w3 }$ t& D" A' V8 j
double Tpre,K1,K2,an;
- m# q% w0 |! t/ X; p' H5 } int index;
7 F4 y8 b- S) e3 e Pe=30*4.0*Ne/(gnum*100000*n*S*PI*D*D/4); /*平均有效压力bar*/0 Q4 ^( j4 [2 W2 H* L
mBo=Ne*ge/(30000000*n*gnum); /*单缸循环供油量kg */: B; E0 e6 {5 u' H7 {( z# Y% T# g6 a& A
CA=A_SC*PI/180; /*进气关闭时的角度转弧度*/
+ z5 H8 S5 M9 S9 g6 n N+ P7 \ V=V_CA();/*进气关闭时角度下的气缸容积*/. k# `1 F5 r: e( q/ b$ i8 N c
P=P_SC;9 o+ N8 y: B7 ~) _. U$ X8 J
T=T_SC;
4 b7 I2 h K+ Z$ b2 y index=(int)A_SC;
+ V( \" U. ]+ I9 \ m_T[index]=T;6 o* E& a# f3 Q* ^- J+ I
m_P[index]=P;
9 @+ [3 d7 b" Q _; r# k m=P*V/(R*T);/*进气关闭时角度下的气缸内工质质量*/3 K; q& B( W/ E1 h
mL=m-0.01*mBo;/*进气关闭时角度下的气缸内空气质量*/& h/ C8 A0 `4 W7 ^8 b4 J
mf=m-mL;( f! z9 v( o% O
Tpre=T;* C) G/ ]) a% X, H9 P- q
an=A_SC+1;
( N$ G6 Q% O ^1 K' f$ [% o' \: S
7 I; p1 g3 B4 X$ B2 R do{
$ D4 Q3 y$ v9 h. g2 T- B: [
1 ?* c' i1 y/ z2 N n7 B /*B 编写欧拉法求解常微分方程程序 */& f* \" S# j8 d1 `. e5 a' `3 E
: C& P8 ` A- @1 G, d, W+ ^" p }while(an!=A_SC+1);
* J& z. Y ~" B$ m6 e2 h# c}
7 \! o8 d3 Y. X+ R# ^" t7 R! D/ e7 ^2 y; W# u. n2 K
void main(void)- M. h5 k& G0 w) B( B6 o# L
{
* D) G* v/ f" _8 _$ y# n! Z int i;$ S- c8 L+ p0 v! Q9 C
FILE *fp;7 R. F0 ?% u; _' u' }
D=0.11; /*发动机数据按各自的任务书输入 */2 Q. ~$ a$ r/ Z3 n. w1 B/ P* \
S=0.13;
% G/ H- B, h5 d5 @% w* [' O$ ^ L=0.21;+ G# Q6 ^. O E. r& Y2 b& `
ge=236.0;
+ c5 x4 A2 h& H. a a n=2400;
% s( g, ?6 s! W) t* p8 a9 Y' C% ^ Ne=101568;' v( e7 r# a3 e9 e" T1 _0 G* W% ^& ]
gnum=6; ysb=17; M=0.7;
) `* b8 @8 d9 b- m; F* _, v M Hu=41868000;. ~" v6 B z6 @1 s% `' v5 d: F; h
R=287.08;4 w5 I! ~: U7 ^1 A; Z4 D) o
Pa=101000; /*大气压力*/+ M3 Z# d1 G' O
Ta=300; /*大气温度*/
9 ^" w6 o9 ~& M6 b- H6 k5 R hs=(735.0+R)*Ta; /*大气焓值*/1 c) @: T2 i9 L+ g
P_SC=90000;
4 e( c/ u; X) _' S2 { T_SC=313;7 V- ~ n4 i& E' \
' v. c9 ?+ u, `4 e. ^( N$ t4 } A_SC=216; /*进气门关闭*/% _6 f1 U, X3 k; D+ S# `' h
A_CB=350; /*燃烧开始*/
J, R. C6 M9 s" |% p- ^, j A_CE=410; /*燃烧结束*/
8 o7 J$ T& Q4 {; ]- k) ?7 q, c A_EO=484; /*排气门开启*/
; s1 W0 k z' N' J; B; I A_SO=705; /*进气门开启*/& u0 [4 l6 D/ d; p4 @
A_EC=15; /*排气门关闭*/
3 N8 M' @; K. p. }% F' u2 ~0 e
* D" i1 [' i4 y: B# U Lo=14.4;
2 p9 J$ ~ U6 f2 j# O$ q+ n+ r% H$ X% r( |) U# e. o
for(i=0;i<720;i++)
7 K" R/ b. }) C* F {
8 h) F% \$ n+ c; n/ N' m m_P[i]=0;
, @! K6 M6 K! L* r% M' W m_CA[i]=i;! v2 Q4 C; d) Y! h$ N' h1 D4 Z
m_T[i]=0;- P5 Y8 A" {6 Q+ k0 W
}6 |6 q% A+ F6 n& |7 V/ h
% J5 N) C. M9 J6 W Calculate();; X% l" B: q3 h1 p3 A
; T x- i/ A+ M9 L2 W6 m /*C编写数据输出程序,计算结束后按顺序输出0-720转角的“缸压,温度”数据到outdata.txt文件 */1 J# ?- M( A# n2 f
* I3 {1 y. S D, r2 q
}, E% N7 W9 V+ l" Y t( s
6 ~ V: @$ ~& q$ y
* W4 S9 l) ]; V" o+ Z' q |
|