Révision 207
| TrouNoir/trou_noir_1997.c (revision 207) | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
Programme original realise en Fortran 77 en mars 1994 |
|
| 3 |
pour les Travaux Pratiques de Modelisation Numerique |
|
| 4 |
DEA d'astrophysique et techniques spatiales de Meudon |
|
| 5 |
|
|
| 6 |
par Herve Aussel et Emmanuel Quemener |
|
| 7 |
|
|
| 8 |
Conversion en C par Emmanuel Quemener en aout 1997 |
|
| 9 |
|
|
| 10 |
Remerciements a : |
|
| 11 |
|
|
| 12 |
- Herve Aussel pour sa procedure sur le spectre de corps noir |
|
| 13 |
- Didier Pelat pour l'aide lors de ce travail |
|
| 14 |
- Jean-Pierre Luminet pour son article de 1979 |
|
| 15 |
- Le Numerical Recipies pour ses recettes de calcul |
|
| 16 |
- Luc Blanchet pour sa disponibilite lors de mes interrogations en RG |
|
| 17 |
|
|
| 18 |
Mes Coordonnees : Emmanuel Quemener |
|
| 19 |
Departement Optique |
|
| 20 |
ENST de Bretagne |
|
| 21 |
BP 832 |
|
| 22 |
29285 BREST Cedex |
|
| 23 |
|
|
| 24 |
Emmanuel.Quemener@enst-bretagne.fr |
|
| 25 |
|
|
| 26 |
Compilation sous gcc ( Compilateur GNU sous Linux ) : |
|
| 27 |
|
|
| 28 |
gcc -O6 -m486 -o trou_noir trou_noir.c -lm |
|
| 29 |
*/ |
|
| 30 |
|
|
| 31 |
#include <stdio.h> |
|
| 32 |
#include <math.h> |
|
| 33 |
#include <stdlib.h> |
|
| 34 |
#include <string.h> |
|
| 35 |
|
|
| 36 |
#define nbr 200 /* Nombre de colonnes du spectre */ |
|
| 37 |
|
|
| 38 |
#define PI 3.14159265359 |
|
| 39 |
|
|
| 40 |
double atanp(double x,double y) |
|
| 41 |
{
|
|
| 42 |
double angle; |
|
| 43 |
|
|
| 44 |
angle=atan2(y,x); |
|
| 45 |
|
|
| 46 |
if (angle<0) |
|
| 47 |
{
|
|
| 48 |
angle+=2*PI; |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
return angle; |
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
|
|
| 55 |
double f(double v) |
|
| 56 |
{
|
|
| 57 |
return v; |
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
double g(double u,double m,double b) |
|
| 61 |
{
|
|
| 62 |
// return (3.*m/b*pow(u,2)-u); |
|
| 63 |
return (3.*m/b*pow(u,2)-u); |
|
| 64 |
} |
|
| 65 |
|
|
| 66 |
|
|
| 67 |
void calcul(double *us,double *vs,double up,double vp, |
|
| 68 |
double h,double m,double b) |
|
| 69 |
{
|
|
| 70 |
double c[4],d[4]; |
|
| 71 |
|
|
| 72 |
c[0]=h*f(vp); |
|
| 73 |
c[1]=h*f(vp+c[0]/2.); |
|
| 74 |
c[2]=h*f(vp+c[1]/2.); |
|
| 75 |
c[3]=h*f(vp+c[2]); |
|
| 76 |
d[0]=h*g(up,m,b); |
|
| 77 |
d[1]=h*g(up+d[0]/2.,m,b); |
|
| 78 |
d[2]=h*g(up+d[1]/2.,m,b); |
|
| 79 |
d[3]=h*g(up+d[2],m,b); |
|
| 80 |
|
|
| 81 |
*us=up+(c[0]+2.*c[1]+2.*c[2]+c[3])/6.; |
|
| 82 |
*vs=vp+(d[0]+2.*d[1]+2.*d[2]+d[3])/6.; |
|
| 83 |
} |
|
| 84 |
|
|
| 85 |
void rungekutta(double *ps,double *us,double *vs, |
|
| 86 |
double pp,double up,double vp, |
|
| 87 |
double h,double m,double b) |
|
| 88 |
{
|
|
| 89 |
calcul(us,vs,up,vp,h,m,b); |
|
| 90 |
*ps=pp+h; |
|
| 91 |
} |
|
| 92 |
|
|
| 93 |
|
|
| 94 |
double decalage_spectral(double r,double b,double phi, |
|
| 95 |
double tho,double m) |
|
| 96 |
{
|
|
| 97 |
return (sqrt(1-3*m/r)/(1+sqrt(m/pow(r,3))*b*sin(tho)*sin(phi))); |
|
| 98 |
} |
|
| 99 |
|
|
| 100 |
void spectre(int nt[nbr],double fx[nbr],double rf,int q,double b,double db, |
|
| 101 |
double h,double r,double m,double bss,double *flx) |
|
| 102 |
{
|
|
| 103 |
int fi; |
|
| 104 |
|
|
| 105 |
fi=(int)(rf*nbr/bss); |
|
| 106 |
nt[fi]+=1; |
|
| 107 |
*flx=pow(r/m,q)*pow(rf,4)*b*db*h; |
|
| 108 |
fx[fi]=fx[fi]+*flx; |
|
| 109 |
} |
|
| 110 |
|
|
| 111 |
void spectre_cn(int nt[nbr],double fx[nbr],double rf,double b,double db, |
|
| 112 |
double h,double r,double m,double bss,double *flx) |
|
| 113 |
{
|
|
| 114 |
double nu_rec,nu_em,qu,v,temp,temp_em,flux_int,m_point,planck,c,k; |
|
| 115 |
int fi,posfreq; |
|
| 116 |
|
|
| 117 |
planck=6.62e-34; |
|
| 118 |
k=1.38e-23; |
|
| 119 |
temp=3.e7; |
|
| 120 |
// m_point=1.e14; |
|
| 121 |
m_point=10.; |
|
| 122 |
v=1.-3./r; |
|
| 123 |
|
|
| 124 |
qu=1/sqrt(1-3./r)/sqrt(r)*(sqrt(r)-sqrt(6)+sqrt(3)/2*log((sqrt(r)+sqrt(3))/(sqrt(r)-sqrt(3))*(sqrt(6)-sqrt(3))/(sqrt(6)+sqrt(3)))); |
|
| 125 |
|
|
| 126 |
temp_em=temp*sqrt(m)*exp(0.25*log(m_point))*exp(-0.75*log(r))* |
|
| 127 |
exp(-0.125*log(v))*exp(0.25*log(qu)); |
|
| 128 |
|
|
| 129 |
flux_int=0; |
|
| 130 |
*flx=0; |
|
| 131 |
|
|
| 132 |
for (fi=1;fi<nbr;fi++) |
|
| 133 |
{
|
|
| 134 |
nu_em=bss*fi/nbr; |
|
| 135 |
nu_rec=nu_em*rf; |
|
| 136 |
posfreq=1./bss*nu_rec*nbr; |
|
| 137 |
if ((posfreq>0)&&(posfreq<nbr)) |
|
| 138 |
{
|
|
| 139 |
flux_int=2*planck/9e16*pow(nu_em,3)/(exp(planck*nu_em/k/temp_em)-1.)*pow(rf,3)*b*db*h; |
|
| 140 |
fx[posfreq]+=flux_int; |
|
| 141 |
*flx+=flux_int; |
|
| 142 |
nt[posfreq]+=1; |
|
| 143 |
} |
|
| 144 |
} |
|
| 145 |
|
|
| 146 |
printf("%f %f %f %f\n",b,db,r,*flx);
|
|
| 147 |
} |
|
| 148 |
|
|
| 149 |
void impact(double d,double phi,int dim,double r,double b,double tho,double m, |
|
| 150 |
double **zp,double **fp, |
|
| 151 |
int nt[200],double fx[200],int q,double db, |
|
| 152 |
double h,double bss,int raie) |
|
| 153 |
{
|
|
| 154 |
double xe,ye; |
|
| 155 |
int xi,yi; |
|
| 156 |
double flx,rf; |
|
| 157 |
xe=d*sin(phi); |
|
| 158 |
ye=-d*cos(phi); |
|
| 159 |
|
|
| 160 |
xi=(int)xe+dim/2; |
|
| 161 |
yi=(int)ye+dim/2; |
|
| 162 |
|
|
| 163 |
rf=decalage_spectral(r,b,phi,tho,m); |
|
| 164 |
|
|
| 165 |
if (raie==0) |
|
| 166 |
{
|
|
| 167 |
spectre(nt,fx,rf,q,b,db,h,r,m,bss,&flx); |
|
| 168 |
} |
|
| 169 |
else |
|
| 170 |
{
|
|
| 171 |
spectre_cn(nt,fx,rf,b,db,h,r,m,bss,&flx); |
|
| 172 |
} |
|
| 173 |
|
|
| 174 |
if (zp[xi][yi]==0.) |
|
| 175 |
{
|
|
| 176 |
zp[xi][yi]=1./rf; |
|
| 177 |
} |
|
| 178 |
|
|
| 179 |
if (fp[xi][yi]==0.) |
|
| 180 |
{
|
|
| 181 |
fp[xi][yi]=flx; |
|
| 182 |
} |
|
| 183 |
} |
|
| 184 |
|
|
| 185 |
void sauvegarde_pgm(char nom[24],unsigned int **image,int dim) |
|
| 186 |
{
|
|
| 187 |
FILE *sortie; |
|
| 188 |
unsigned long i,j; |
|
| 189 |
|
|
| 190 |
sortie=fopen(nom,"w"); |
|
| 191 |
|
|
| 192 |
fprintf(sortie,"P5\n"); |
|
| 193 |
fprintf(sortie,"%i %i\n",dim,dim); |
|
| 194 |
fprintf(sortie,"255\n"); |
|
| 195 |
|
|
| 196 |
for (j=0;j<dim;j++) for (i=0;i<dim;i++) |
|
| 197 |
{
|
|
| 198 |
fputc(image[i][j],sortie); |
|
| 199 |
} |
|
| 200 |
|
|
| 201 |
fclose(sortie); |
|
| 202 |
} |
|
| 203 |
|
|
| 204 |
void sauvegarde_dat(char nom[24],double tableau[3][nbr],int raie) |
|
| 205 |
{
|
|
| 206 |
FILE *sortie; |
|
| 207 |
unsigned long i; |
|
| 208 |
|
|
| 209 |
sortie=fopen(nom,"w"); |
|
| 210 |
|
|
| 211 |
fprintf(sortie,"# Trou Noir entoure d'un Disque d'Accretion\n"); |
|
| 212 |
|
|
| 213 |
if (raie==0) |
|
| 214 |
{
|
|
| 215 |
fprintf(sortie,"# Colonne 1 : Frequence_Recue/Frequence_Emise\n"); |
|
| 216 |
} |
|
| 217 |
else |
|
| 218 |
{
|
|
| 219 |
fprintf(sortie,"# Colonne 1 : Fr?quence d'Emission en Hertz\n"); |
|
| 220 |
} |
|
| 221 |
|
|
| 222 |
fprintf(sortie,"# Colonne 2 : Intensite Normalisee\n"); |
|
| 223 |
fprintf(sortie,"# Colonne 3 : Nombre d'Impacts Normalise\n"); |
|
| 224 |
|
|
| 225 |
for (i=1;i<nbr;i++) |
|
| 226 |
{
|
|
| 227 |
fprintf(sortie,"%f\t%f\t%f\n",tableau[0][i],tableau[1][i],tableau[2][i]); |
|
| 228 |
} |
|
| 229 |
|
|
| 230 |
fclose(sortie); |
|
| 231 |
} |
|
| 232 |
|
|
| 233 |
int main(int argc,char *argv[]) |
|
| 234 |
{
|
|
| 235 |
|
|
| 236 |
double m,rs,ri,re,tho,ro; |
|
| 237 |
int q; |
|
| 238 |
|
|
| 239 |
double bss,stp; |
|
| 240 |
int nmx,dim; |
|
| 241 |
double d,bmx,db,b,h; |
|
| 242 |
double up,vp,pp; |
|
| 243 |
double us,vs,ps; |
|
| 244 |
double rp[2000]; |
|
| 245 |
double **zp,**fp; |
|
| 246 |
unsigned int **izp,**ifp; |
|
| 247 |
double zmx,fmx,zen,fen; |
|
| 248 |
double flux_tot,impc_tot; |
|
| 249 |
double fx[nbr]; |
|
| 250 |
int nt[nbr]; |
|
| 251 |
double tableau[3][nbr]; |
|
| 252 |
double phi,thi,thx,phd,php,nr,r; |
|
| 253 |
int ni,ii,i,imx,j,n,tst,dist,raie,pc,fcl,zcl; |
|
| 254 |
double nh; |
|
| 255 |
|
|
| 256 |
if (argc==2) |
|
| 257 |
{
|
|
| 258 |
if (strcmp(argv[1],"-aide")==0) |
|
| 259 |
{
|
|
| 260 |
printf("\nSimulation d'un disque d'accretion autour d'un trou noir\n");
|
|
| 261 |
printf("\nParametres a definir :\n\n");
|
|
| 262 |
printf(" 1) Dimension de l'Image\n");
|
|
| 263 |
printf(" 2) Masse relative du trou noir\n");
|
|
| 264 |
printf(" 3) Dimension du disque exterieur\n");
|
|
| 265 |
printf(" 4) Distance de l'observateur\n");
|
|
| 266 |
printf(" 5) Inclinaison par rapport au disque (en degres)\n");
|
|
| 267 |
printf(" 6) Observation a distance FINIE ou INFINIE\n");
|
|
| 268 |
printf(" 7) Rayonnement de disque MONOCHROMATIQUE ou CORPS_NOIR\n");
|
|
| 269 |
printf(" 8) Normalisation des flux INTERNE ou EXTERNE\n");
|
|
| 270 |
printf(" 9) Normalisation de z INTERNE ou EXTERNE\n");
|
|
| 271 |
printf(" 10) Impression des images NEGATIVE ou POSITIVE\n");
|
|
| 272 |
printf(" 11) Nom de l'image des Flux\n");
|
|
| 273 |
printf(" 12) Nom de l'image des decalages spectraux\n");
|
|
| 274 |
printf(" 13) Nom du fichier contenant le spectre\n");
|
|
| 275 |
printf(" 14) Valeur de normalisation des flux\n");
|
|
| 276 |
printf(" 15) Valeur de normalisation des decalages spectraux\n");
|
|
| 277 |
printf("\nSi aucun parametre defini, parametres par defaut :\n\n");
|
|
| 278 |
printf(" 1) Dimension de l'image : 256 pixels de cote\n");
|
|
| 279 |
printf(" 2) Masse relative du trou noir : 1\n");
|
|
| 280 |
printf(" 3) Dimension du disque exterieur : 12 \n");
|
|
| 281 |
printf(" 4) Distance de l'observateur : 100 \n");
|
|
| 282 |
printf(" 5) Inclinaison par rapport au disque (en degres) : 10\n");
|
|
| 283 |
printf(" 6) Observation a distance FINIE\n");
|
|
| 284 |
printf(" 7) Rayonnement de disque MONOCHROMATIQUE\n");
|
|
| 285 |
printf(" 8) Normalisation des flux INTERNE\n");
|
|
| 286 |
printf(" 9) Normalisation des z INTERNE\n");
|
|
| 287 |
printf(" 10) Impression des images NEGATIVE ou POSITIVE\n");
|
|
| 288 |
printf(" 11) Nom de l'image des flux : flux.pgm\n");
|
|
| 289 |
printf(" 12) Nom de l'image des z : z.pgm\n");
|
|
| 290 |
printf(" 13) Nom du fichier contenant le spectre : spectre.dat\n");
|
|
| 291 |
printf(" 14) <non definie>\n");
|
|
| 292 |
printf(" 15) <non definie>\n");
|
|
| 293 |
} |
|
| 294 |
} |
|
| 295 |
|
|
| 296 |
if ((argc==14)||(argc==16)) |
|
| 297 |
{
|
|
| 298 |
printf("# Utilisation les valeurs definies par l'utilisateur\n");
|
|
| 299 |
|
|
| 300 |
dim=atoi(argv[1]); |
|
| 301 |
m=atof(argv[2]); |
|
| 302 |
re=atof(argv[3]); |
|
| 303 |
ro=atof(argv[4]); |
|
| 304 |
tho=PI/180.*(90-atof(argv[5])); |
|
| 305 |
|
|
| 306 |
rs=2.*m; |
|
| 307 |
ri=3.*rs; |
|
| 308 |
q=-2; |
|
| 309 |
|
|
| 310 |
if (strcmp(argv[6],"FINIE")==0) |
|
| 311 |
{
|
|
| 312 |
dist=0; |
|
| 313 |
} |
|
| 314 |
else |
|
| 315 |
{
|
|
| 316 |
dist=1; |
|
| 317 |
} |
|
| 318 |
|
|
| 319 |
if (strcmp(argv[7],"MONOCHROMATIQUE")==0) |
|
| 320 |
{
|
|
| 321 |
raie=0; |
|
| 322 |
} |
|
| 323 |
else |
|
| 324 |
{
|
|
| 325 |
raie=1; |
|
| 326 |
} |
|
| 327 |
|
|
| 328 |
if (strcmp(argv[8],"EXTERNE")==0) |
|
| 329 |
{
|
|
| 330 |
fen=atof(argv[14]); |
|
| 331 |
} |
|
| 332 |
|
|
| 333 |
if (strcmp(argv[9],"EXTERNE")==0) |
|
| 334 |
{
|
|
| 335 |
zen=atof(argv[15]); |
|
| 336 |
} |
|
| 337 |
|
|
| 338 |
} |
|
| 339 |
else |
|
| 340 |
{
|
|
| 341 |
printf("# Utilisation les valeurs par defaut\n");
|
|
| 342 |
|
|
| 343 |
dim=256; |
|
| 344 |
m=1.; |
|
| 345 |
rs=2.*m; |
|
| 346 |
ri=3.*rs; |
|
| 347 |
re=12.; |
|
| 348 |
ro=100.; |
|
| 349 |
tho=PI/180.*80; |
|
| 350 |
q=-2; |
|
| 351 |
dist=0; |
|
| 352 |
raie=0; |
|
| 353 |
} |
|
| 354 |
|
|
| 355 |
printf("# Dimension de l'image : %i\n",dim);
|
|
| 356 |
printf("# Masse : %f\n",m);
|
|
| 357 |
printf("# Rayon singularite : %f\n",rs);
|
|
| 358 |
printf("# Rayon interne : %f\n",ri);
|
|
| 359 |
printf("# Rayon externe : %f\n",re);
|
|
| 360 |
printf("# Distance de l'observateur : %f\n",ro);
|
|
| 361 |
printf("# Inclinaison a la normale en radian : %f\n",tho);
|
|
| 362 |
|
|
| 363 |
for (i=0;i<nbr;i++) |
|
| 364 |
{
|
|
| 365 |
fx[i]=0.; |
|
| 366 |
nt[i]=0; |
|
| 367 |
} |
|
| 368 |
|
|
| 369 |
zp=(double**)calloc(dim,sizeof(double*)); |
|
| 370 |
zp[0]=(double*)calloc(dim*dim,sizeof(double)); |
|
| 371 |
|
|
| 372 |
fp=(double**)calloc(dim,sizeof(double*)); |
|
| 373 |
fp[0]=(double*)calloc(dim*dim,sizeof(double)); |
|
| 374 |
|
|
| 375 |
izp=(unsigned int**)calloc(dim,sizeof(unsigned int*)); |
|
| 376 |
izp[0]=(unsigned int*)calloc(dim*dim,sizeof(unsigned int)); |
|
| 377 |
|
|
| 378 |
ifp=(unsigned int**)calloc(dim,sizeof(unsigned int*)); |
|
| 379 |
ifp[0]=(unsigned int*)calloc(dim*dim,sizeof(unsigned int)); |
|
| 380 |
|
|
| 381 |
for (i=1;i<dim;i++) |
|
| 382 |
{
|
|
| 383 |
zp[i]=zp[i-1]+dim; |
|
| 384 |
fp[i]=fp[i-1]+dim; |
|
| 385 |
izp[i]=izp[i-1]+dim; |
|
| 386 |
ifp[i]=ifp[i-1]+dim; |
|
| 387 |
} |
|
| 388 |
|
|
| 389 |
nmx=dim; |
|
| 390 |
stp=dim/(2.*nmx); |
|
| 391 |
bmx=1.25*re; |
|
| 392 |
b=0.; |
|
| 393 |
thx=asin(bmx/ro); |
|
| 394 |
pc=0; |
|
| 395 |
|
|
| 396 |
if (raie==0) |
|
| 397 |
{
|
|
| 398 |
bss=2; |
|
| 399 |
} |
|
| 400 |
else |
|
| 401 |
{
|
|
| 402 |
bss=3e21; |
|
| 403 |
} |
|
| 404 |
|
|
| 405 |
for (n=1;n<=nmx;n++) |
|
| 406 |
{
|
|
| 407 |
h=PI/500.; |
|
| 408 |
d=stp*n; |
|
| 409 |
|
|
| 410 |
if (dist==1) |
|
| 411 |
{
|
|
| 412 |
db=bmx/(double)nmx; |
|
| 413 |
b=db*(double)n; |
|
| 414 |
up=0.; |
|
| 415 |
vp=1.; |
|
| 416 |
} |
|
| 417 |
else |
|
| 418 |
{
|
|
| 419 |
thi=thx/(double)nmx*(double)n; |
|
| 420 |
db=ro*sin(thi)-b; |
|
| 421 |
b=ro*sin(thi); |
|
| 422 |
up=sin(thi); |
|
| 423 |
vp=cos(thi); |
|
| 424 |
} |
|
| 425 |
|
|
| 426 |
pp=0.; |
|
| 427 |
nh=1; |
|
| 428 |
|
|
| 429 |
rungekutta(&ps,&us,&vs,pp,up,vp,h,m,b); |
|
| 430 |
|
|
| 431 |
rp[(int)nh]=fabs(b/us); |
|
| 432 |
|
|
| 433 |
do |
|
| 434 |
{
|
|
| 435 |
nh++; |
|
| 436 |
pp=ps; |
|
| 437 |
up=us; |
|
| 438 |
vp=vs; |
|
| 439 |
rungekutta(&ps,&us,&vs,pp,up,vp,h,m,b); |
|
| 440 |
|
|
| 441 |
rp[(int)nh]=b/us; |
|
| 442 |
|
|
| 443 |
} while ((rp[(int)nh]>=rs)&&(rp[(int)nh]<=rp[1])); |
|
| 444 |
|
|
| 445 |
for (i=nh+1;i<2000;i++) |
|
| 446 |
{
|
|
| 447 |
rp[i]=0.; |
|
| 448 |
} |
|
| 449 |
|
|
| 450 |
imx=(int)(8*d); |
|
| 451 |
|
|
| 452 |
for (i=0;i<=imx;i++) |
|
| 453 |
{
|
|
| 454 |
phi=2.*PI/(double)imx*(double)i; |
|
| 455 |
phd=atanp(cos(phi)*sin(tho),cos(tho)); |
|
| 456 |
phd=fmod(phd,PI); |
|
| 457 |
ii=0; |
|
| 458 |
tst=0; |
|
| 459 |
|
|
| 460 |
do |
|
| 461 |
{
|
|
| 462 |
php=phd+(double)ii*PI; |
|
| 463 |
nr=php/h; |
|
| 464 |
ni=(int)nr; |
|
| 465 |
|
|
| 466 |
if ((double)ni<nh) |
|
| 467 |
{
|
|
| 468 |
r=(rp[ni+1]-rp[ni])*(nr-ni*1.)+rp[ni]; |
|
| 469 |
} |
|
| 470 |
else |
|
| 471 |
{
|
|
| 472 |
r=rp[ni]; |
|
| 473 |
} |
|
| 474 |
|
|
| 475 |
if ((r<=re)&&(r>=ri)) |
|
| 476 |
{
|
|
| 477 |
tst=1; |
|
| 478 |
impact(d,phi,dim,r,b,tho,m,zp,fp,nt,fx,q,db,h,bss,raie); |
|
| 479 |
} |
|
| 480 |
|
|
| 481 |
ii++; |
|
| 482 |
} while ((ii<=2)&&(tst==0)); |
|
| 483 |
} |
|
| 484 |
} |
|
| 485 |
|
|
| 486 |
fmx=fp[0][0]; |
|
| 487 |
zmx=zp[0][0]; |
|
| 488 |
|
|
| 489 |
for (i=0;i<dim;i++) for (j=0;j<dim;j++) |
|
| 490 |
{
|
|
| 491 |
if (fmx<fp[i][j]) |
|
| 492 |
{
|
|
| 493 |
fmx=fp[i][j]; |
|
| 494 |
} |
|
| 495 |
|
|
| 496 |
if (zmx<zp[i][j]) |
|
| 497 |
{
|
|
| 498 |
zmx=zp[i][j]; |
|
| 499 |
} |
|
| 500 |
} |
|
| 501 |
|
|
| 502 |
printf("\nLe flux maximal detecte est de %f",fmx);
|
|
| 503 |
printf("\nLe decalage spectral maximal detecte est de %f\n\n",zmx);
|
|
| 504 |
|
|
| 505 |
if (strcmp(argv[8],"EXTERNE")==0) |
|
| 506 |
{
|
|
| 507 |
fmx=fen; |
|
| 508 |
} |
|
| 509 |
|
|
| 510 |
if (strcmp(argv[9],"EXTERNE")==0) |
|
| 511 |
{
|
|
| 512 |
zmx=zen; |
|
| 513 |
} |
|
| 514 |
|
|
| 515 |
for (i=0;i<dim;i++) for (j=0;j<dim;j++) |
|
| 516 |
{
|
|
| 517 |
zcl=(int)(255/zmx*zp[i][dim-1-j]); |
|
| 518 |
fcl=(int)(255/fmx*fp[i][dim-1-j]); |
|
| 519 |
|
|
| 520 |
if (strcmp(argv[8],"NEGATIVE")==0) |
|
| 521 |
{
|
|
| 522 |
if (zcl>255) |
|
| 523 |
{
|
|
| 524 |
izp[i][j]=0; |
|
| 525 |
} |
|
| 526 |
else |
|
| 527 |
{
|
|
| 528 |
izp[i][j]=255-zcl; |
|
| 529 |
} |
|
| 530 |
|
|
| 531 |
if (fcl>255) |
|
| 532 |
{
|
|
| 533 |
ifp[i][j]=0; |
|
| 534 |
} |
|
| 535 |
else |
|
| 536 |
{
|
|
| 537 |
ifp[i][j]=255-fcl; |
|
| 538 |
} |
|
| 539 |
|
|
| 540 |
} |
|
| 541 |
else |
|
| 542 |
{
|
|
| 543 |
if (zcl>255) |
|
| 544 |
{
|
|
| 545 |
izp[i][j]=255; |
|
| 546 |
} |
|
| 547 |
else |
|
| 548 |
{
|
|
| 549 |
izp[i][j]=zcl; |
|
| 550 |
} |
|
| 551 |
|
|
| 552 |
if (fcl>255) |
|
| 553 |
{
|
|
| 554 |
ifp[i][j]=255; |
|
| 555 |
} |
|
| 556 |
else |
|
| 557 |
{
|
|
| 558 |
ifp[i][j]=fcl; |
|
| 559 |
} |
|
| 560 |
|
|
| 561 |
} |
|
| 562 |
|
|
| 563 |
} |
|
| 564 |
|
|
| 565 |
flux_tot=0; |
|
| 566 |
impc_tot=0; |
|
| 567 |
|
|
| 568 |
for (i=1;i<nbr;i++) |
|
| 569 |
{
|
|
| 570 |
flux_tot+=fx[i]; |
|
| 571 |
impc_tot+=nt[i]; |
|
| 572 |
} |
|
| 573 |
|
|
| 574 |
for (i=1;i<nbr;i++) |
|
| 575 |
{
|
|
| 576 |
tableau[0][i]=bss*i/nbr; |
|
| 577 |
tableau[1][i]=fx[i]/flux_tot; |
|
| 578 |
tableau[2][i]=(double)nt[i]/(double)impc_tot; |
|
| 579 |
} |
|
| 580 |
|
|
| 581 |
if ((argc==14)||(argc==16)) |
|
| 582 |
{
|
|
| 583 |
sauvegarde_pgm(argv[11],ifp,dim); |
|
| 584 |
sauvegarde_pgm(argv[12],izp,dim); |
|
| 585 |
sauvegarde_dat(argv[13],tableau,raie); |
|
| 586 |
} |
|
| 587 |
else |
|
| 588 |
{
|
|
| 589 |
sauvegarde_pgm("z.pgm",izp,dim);
|
|
| 590 |
sauvegarde_pgm("flux.pgm",ifp,dim);
|
|
| 591 |
sauvegarde_dat("spectre.dat",tableau,raie);
|
|
| 592 |
} |
|
| 593 |
|
|
| 594 |
free(zp[0]); |
|
| 595 |
free(zp); |
|
| 596 |
free(fp[0]); |
|
| 597 |
free(fp); |
|
| 598 |
|
|
| 599 |
free(izp[0]); |
|
| 600 |
free(izp); |
|
| 601 |
free(ifp[0]); |
|
| 602 |
free(ifp); |
|
| 603 |
|
|
| 604 |
} |
|
| 605 |
|
|
| 606 |
|
|
Formats disponibles : Unified diff