00001
00006 #include <bpm/bpm_simulation.h>
00007 #include <bpm/bpm_nr.h>
00008 #include <bpm/bpm_interface.h>
00009
00010 int add_mode_response( bpmconf_t *bpm, bpmmode_t *mode, bunchconf_t *bunch, doublewf_t *rf ) {
00011
00012 int i,imax = 0;
00013 complex_t amp;
00014
00015 if ( ! rf ) {
00016 bpm_error( "BPM signal waveform is not pre-allocated in add_mode_response()",
00017 __FILE__, __LINE__ );
00018 return BPM_FAILURE;
00019 }
00020
00021
00022 amp = get_mode_amplitude( bpm, mode, bunch );
00023
00024
00025 if ( rf->ns < mode->response->ns ) imax = rf->ns; else imax = mode->response->ns;
00026
00027
00028
00029
00030 if (mode->order == 1) {
00031 for (i=0;i<imax;i++){
00032 rf->wf[i] += mode->response->wf[i].re*amp.re + mode->response->wf[i].im*amp.im;
00033 }
00034 } else {
00035 for (i=0;i<imax;i++){
00036 rf->wf[i] += mode->response->wf[i].re*amp.re;
00037 }
00038 }
00039 return BPM_SUCCESS;
00040 }