00001 00006 #include <bpm/bpm_simulation.h> 00007 #include <math.h> 00008 00009 complex_t get_mode_amplitude( bpmconf_t *bpm, bpmmode_t *mode, bunchconf_t *bunch ) { 00010 00011 double k, L, sigma; 00012 complex_t z; 00013 int idx = ( mode->polarisation == horiz ? 0 : 1); 00014 00015 if ( mode->order == 0 ) { 00016 // monopole mode, sensititvity in Volt/C 00017 z.re = mode->sensitivity * bunch->charge; 00018 z.im = 0.; 00019 00020 } else if ( mode->order == 1 ) { 00021 // dipole mode, sensitivity in Volt/m/C 00022 // need to include the bunch length effects properly!!! 00023 z.re = mode->sensitivity * bunch->bpmposition[idx] * bunch->charge; 00024 00025 // calulcate : 00026 // beam->bunchlength, bpm->cav_length, beam->bpmslope[idx] + beam->bpmtilt[idx] 00027 k = 2*PI / _cLight__ * mode->frequency; 00028 L = bpm->cav_length; 00029 sigma = bunch->length; 00030 00031 if ( L != 0 && bunch->bpmslope[mode->polarisation] !=0 ) { 00032 00033 z.im = mode->sensitivity * bunch->charge * 00034 ( 1/k * ( 1 - (k*L/2) / sin (k*L/2) ) * 00035 bunch->bpmslope[mode->polarisation] 00036 + 2 * sigma * sin (k*sigma/2) ); 00037 00038 } else { 00039 00040 z.im = 0; 00041 00042 } 00043 00044 } else if (mode->order == 2 ) { 00045 // quadrupole mode 00046 z.re = 0.; 00047 z.im = 0.; 00048 bpm_warning( "Quadrupole modes are not implemented yet in libbpm...", __FILE__, __LINE__ ); 00049 00050 } else { 00051 bpm_warning( "HOM (O(>2) modes are not implemented yet in libbpm...", __FILE__, __LINE__ ); 00052 00053 } 00054 00055 return z; 00056 }