00001
00006 #include <bpm/bpm_messages.h>
00007 #include <bpm/bpm_simulation.h>
00008 #include <bpm/bpm_rf.h>
00009
00015 int add_wave( double amp, double phase, double freq, double ttrig,
00016 double tdecay, double **RF ) {
00017
00018 double curr_time;
00019 int i;
00020
00021 if ( ! RF ) {
00022 bpm_error( "Invalid pointer argument in add_wave(...)",
00023 __FILE__, __LINE__ );
00024 return BPM_FAILURE;
00025 }
00026
00027 for ( i = 0; i < rf_nsamples; i++ ) {
00028
00029 curr_time = i / rf_samplefreq;
00030
00031 if ( curr_time >= ttrig ) {
00032 RF[i][Re] += amp * exp( - ( curr_time - ttrig ) / tdecay ) *
00033 cos( 2.* PI * freq * ( curr_time - ttrig ) + phase );
00034 RF[i][Im] += amp * exp( - ( curr_time - ttrig ) / tdecay ) *
00035 sin( 2.* PI * freq * ( curr_time - ttrig ) + phase );
00036 }
00037 }
00038
00039 return BPM_SUCCESS;
00040 }
00041
00042