See "V S S Chan 1999" PhD thesis for explanation of the code Appendix #include "stdio.h" #include "math.h" #define B_cont 2.5824e12 #define wave_length 5145.0 #define molar_mass 254.000 #define Mega_heltz 1e+6 main() /*This routine calculates the iodine absorption profile of the P13/R15 line system at 514.5nm*/ { FILE *fopen(),*fp1; int freq_loop1,freq_loop2; float alf_length; float absorb_coeff,trans1,temp; double absorb_cont,cnst1,cnst2,thermal_line,trans2,fact1,fact2,fact3,fact4,freq_offset1,freq_offset2; char fname[50]; printf("\n This program calculates the iodine absorption profile P13/R15 line system (514.5nm)"); printf("\n Written by Victor Chan 25/2/95"); printf("\n\n\n"); printf("\n Enter filename to save the calculated data in\n"); gets(fname); fp1=fopen(fname,"w"); printf("\n Input the length of the absorption line filter (ALF) in cm\n "); scanf("%f",&alf_length); printf("\n Input cell wall temperature of the ALF in degree C\n"); scanf("\n%f",&temp); fprintf(fp1,"\n Iodine absorption profile calculation"); fprintf(fp1,"\n Length of the ALF = %f cm",alf_length); fprintf(fp1,"\n Cell wall temperature of the ALF = %f degree C",temp); trans1 = (41-temp)/40; /* calculates the transmission at resonance using linear scaling*/ /* using 40 as the cut off point, according to Komine*/ */ if(temp>41) /* absorption coefficent at the line centre is a function of temperature */ { trans1 = 0.001; /* assign a transmission value to prevent a negative value */ } temp = temp+273.14; /* this model is from Miles et al 1991 */ /* Instanstanous filtered Rayleigh scattering....*/ printf("\n temperature of the cell is %f k",temp); printf("\n length of the ALF is %f cm",alf_length); absorb_coeff = -(log(trans1)/alf_length); absorb_cont = absorb_coeff*alf_length; cnst1 = 2*(temp/molar_mass); cnst2 = sqrt(cnst1); thermal_line = (1/wave_length)/cnst2*B_cont; fprintf(fp1,"\n absorption constant at iodine molcular resonance = %f ",absorb_cont); for(freq_loop1=100;freq_loop1>0;freq_loop1--) { /* this loop calculates the low frequency side */ freq_offset1 = freq_loop1*10; freq_offset1 = freq_offset1*Mega_heltz; fact1 = freq_offset1/thermal_line; fact2 = fact1*fact1; fact3 = exp(-fact2); fact4 = absorb_cont * fact3; trans2 = exp(-fact4); freq_offset1 = freq_offset1*1.75; /* this simulates the broadening of frequency */ fprintf(fp1,"\n %f %f",-freq_offset1/Mega_heltz,trans2*100); } for(freq_loop2=0;freq_loop2<101;freq_loop2++) { freq_offset2 = freq_loop2*10; /* this loop calculates the high frequency side */ freq_offset2 = freq_offset2*Mega_heltz; fact1 = freq_offset2/thermal_line; fact2 = fact1*fact1; fact3 = exp(-fact2); fact4 = absorb_cont * fact3; trans2 = exp(-fact4); freq_offset2 = freq_offset2*1.45; fprintf(fp1,"\n %f %f",freq_offset2/Mega_heltz,trans2*100); } fclose(fp1); }