1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
int main(int argc,char * argv[])
{
unsigned int i,j,k;
/*******************************
* *
* all initial data are stored *
* *
*******************************/
IniCond * ic=CreateEmptyIniCond();
/* Z : numbers of zones
rpm : rotation per minute
bore : length of the bore in cm
rod : length of the rod in cm
halfstroke : length of the half stroke in cm
compratio : compression ratio
turb : constant for the turbulence
discret : discretisation of the crank angle for the output of the integration
CA : initial crank angle in dV
nbcycle : number of cycle compression-exhaust
*/
unsigned short Z,nbcycle;
double rpm,bore,rod,halfstroke,compratio,turb,discret,CA;
char thermdata[50]; /* file containing thermodynamic data for each species */
char syst[50]; /* file containing the system */
/* Les paramètres de la ligne de commande ont une durée de vie égale à
celle du programme, c'est garanti par la définition du langage C
By default, the inputs file called "input.txt" but the user can use
another file which will be read in argv[1]
*/
char * inputfile= (argc==1) ? "input.txt" : argv[1];
LoadInitialInputs(inputfile,&Z,ic,&rpm,&bore,&rod,&halfstroke,&compratio,&turb,&CA,&discret,&nbcycle,syst,thermdata);
Mechanism * mec=LoadMechanism(syst,thermdata); /* mechanism is load */
Temporary * temp=CreateTemporary(mec->nr,mec->ns,Z);
/*
esp_EGR : vector which contains the number of the species of EGR
comp_EGR : vector which contains the molar composition of each species
*/
k=NumberSpaces(ic->egr->comp)+1; /* numbers species constituting EGR */
Vector * esp_EGR=CreateVector(k,0.);
Vector * comp_EGR=CreateVector(k,0.);
CreateVectorEGR(ic->egr->comp,mec,esp_EGR,comp_EGR);
const unsigned short neq=Z*(mec->ns+1); /* numbers of equations */
Vector * atoms=CreateVector(3,0.0);
atoms->data[0]=7; atoms->data[1]=16;
Engine * e=CreateEngine(rpm,bore,rod,halfstroke,compratio);
const double t0=RCONST((CA+180.0)/e->six_regime); /* initial time in s */
const double dt=discret/e->six_regime; /* time step of discretisation in s */
const realtype R=8.31451e7; /* gaz constante (erg/mol.K) */
const realtype pa=1.0133e6; /* atmospheric pressure in dyne/cm2 */
/************************************************
* *
* pseudo-random initial condition of each zone *
* *
************************************************/
/* Create serial vector of length neq for initial conditions */
N_Vector y=NULL;
y = N_VNew_Serial(neq);
if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
/*
y : index i(ns+1) to i(ns+1)+ns-1 : mass of each species of the ith
zone i=0...N-1
y : index (i+1)ns+i : temperature of the ith zone i=0...N-1
ns : numbers of species of the mechanism
*/
/* pseudo-random initial equivalence air-fuel ratio of each zone */
double * pseafr=malloc(Z*sizeof(*pseafr)); assert(pseafr!=NULL);
/* pseudo-random initial mass of each zone */
double * mz=malloc(Z*sizeof(*mz)); assert(mz!=NULL);
/* pseudo-random initial temperatures of each zone */
double * Tini=malloc(Z*sizeof(*Tini)); assert(Tini!=NULL);
double mtot; /* initial total mass of the mixture */
RandomInitialCondition(t0,Z,ic,mec,e,esp_EGR,comp_EGR,atoms,R,y,mz,pseafr,Tini,&mtot);
+ la suite de mon main.c |
Partager