Changeset 6c96f4
- Timestamp:
- May 21, 2008, 1:42:05 PM (17 years ago)
- Children:
- f75030
- Parents:
- a6e314
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
util/VibrAlyzer.c
ra6e314 r6c96f4 23 23 double *time_steps, *temperatures; // contain data value pairs 24 24 int counter; // keeps track of data pairs array size 25 double freq_start, freq_step ; // frequency start and step width (end determined by number of points in temp.file)25 double freq_start, freq_step, freq_end; // frequency start and step width (end determined by number of points in temp.file) 26 26 char *filename; // filename of temp.file 27 27 char line[255]; // line buffer for parsing the temperature file 28 int i ,j; // runtime variable28 int i; // runtime variable 29 29 double result, iresult; // temporary result value for fourier transformation 30 30 double frequency; // current frequency during dumb O(N^2) integration … … 67 67 counter=0; 68 68 while (fgets(line,255, temperature_file)) { 69 sscanf(line,"%lg %lg", &time_steps[counter-1], &temperatures[counter-1]); 69 sscanf(line,"%lg %lg", &time_steps[counter], &temperatures[counter]); 70 //fprintf(stderr, "%lg\t%lg\n", time_steps[counter], temperatures[counter]); 70 71 counter++; 71 72 } 72 // for debugging only: print read values 73 // auto-set good values for start and step based on step range 74 if ((freq_start == -1) || (freq_step == -1)) { 75 // we cannot detect frequencies above twice a time step and not below half the time range 76 freq_start = 1./(fabs(time_steps[counter-1] - time_steps[0])*gauge); 77 freq_step = ( 1./(fabs(time_steps[1] - time_steps[0])*gauge) - 1./(fabs(time_steps[counter-1] - time_steps[0])*gauge) )/counter; 78 fprintf(stderr, "Using %lg and frequency start and %lg as step size.\n", freq_start/(2.*2.*M_PI), freq_step/(2.*2.*M_PI)); 79 } else { 80 freq_start *= (2.*2.*M_PI); 81 freq_step *= (2.*2.*M_PI); 82 } 83 84 // for debugging only: print read values 73 85 //for(i=0;i<(counter-1);i++) { 74 86 // printf("%lg\t%lg\n",time_steps[i],temperatures[i]); 75 87 //} 76 88 89 printf("#frequency(a.u.)\tcos\tsin"); 77 90 // discretely integrate over desired frequency range 78 frequency = freq_start;79 for( j=0;j<(counter-1);j++) {91 freq_end = freq_start+freq_step*counter-1; 92 for(frequency = freq_start;frequency < freq_end;frequency += freq_step) { 80 93 result = iresult = 0.; 81 94 for(i=0;i<(counter-1);i++) { … … 87 100 // have the correct frequency! 88 101 printf("%lg\t%lg\t%lg\n",frequency/(2.*2.*M_PI),result/(counter-1),iresult/(counter-1)); 89 frequency += freq_step;90 102 } 91 103
Note:
See TracChangeset
for help on using the changeset viewer.