diff --git a/Source/Fields/LMCCylindricalCavity.cc b/Source/Fields/LMCCylindricalCavity.cc index 7f1864d4..6a645fdc 100644 --- a/Source/Fields/LMCCylindricalCavity.cc +++ b/Source/Fields/LMCCylindricalCavity.cc @@ -17,7 +17,9 @@ namespace locust fProbeGain( {1., 1., 1.}), fCavityProbeZ( {0., 0., 0.} ), fCavityProbeRFrac( {0.5, 0.5, 0.5} ), - fCavityProbeTheta( {0.0, 0.0, 0.0} ) + fCavityProbeTheta( {0.0, 0.0, 0.0} ), + fCaterpillarCavity( false ), + fApplyDopplerShift( true ) {} CylindricalCavity::~CylindricalCavity() {} @@ -33,6 +35,16 @@ namespace locust return false; } + if( aParam.has( "caterpillar-cavity" ) ) + { + fCaterpillarCavity = aParam["caterpillar-cavity"]().as_bool(); + } + + if( aParam.has( "apply-doppler-shift" ) ) + { + fApplyDopplerShift = aParam["apply-doppler-shift"]().as_bool(); + } + if( aParam.has( "cavity-radius" ) ) { SetDimR( aParam["cavity-radius"]().as_double() ); @@ -227,11 +239,16 @@ namespace locust double vz = tKassParticleXP[5]; double term1 = fFieldCore->GetBesselNKPrimeZeros(l,m) / GetDimR(); double term2 = n * LMCConst::Pi() / GetDimL(); + if ( fCaterpillarCavity ) + { + // Assume n-channels is the same as the number of etalon sections: + term2 *= GetNChannels(); + } double lambda = 1. / pow( 1. / 4. / LMCConst::Pi() / LMCConst::Pi() * ( term1*term1 + term2*term2 ), 0.5); double lambda_c = 2 * LMCConst::Pi() * GetDimR() / fFieldCore->GetBesselNKPrimeZeros(l,m); double vp = LMCConst::C() / pow( 1. - lambda*lambda/lambda_c/lambda_c, 0.5 ); double dopplerShift = 0.; - if (vp > 0.) dopplerShift = vz / vp; + if ((vp > 0.) && (fApplyDopplerShift)) dopplerShift = vz / vp; freqPrime.push_back( ( 1. + dopplerShift ) * tKassParticleXP[7] ); return freqPrime; } @@ -325,7 +342,23 @@ namespace locust std::vector tEFieldAtProbe; for (unsigned index=0; index fCavityProbeRFrac; std::vector fCavityProbeTheta; std::vector fProbeGain; + bool fCaterpillarCavity; + bool fApplyDopplerShift; }; diff --git a/Source/Fields/LMCField.cc b/Source/Fields/LMCField.cc index 8fab166c..420ef717 100644 --- a/Source/Fields/LMCField.cc +++ b/Source/Fields/LMCField.cc @@ -16,8 +16,9 @@ namespace locust fCentralFrequency(1.63e11), fAvgDotProductFactor( 0. ), fNModes( 2 ), + fNChannels( 1 ), fbMultiMode( false ), - fTM111( false ), + fTM111( false ), fR( 0.18 ), fL( 3.0 ), fX( 0.010668 ), diff --git a/Source/Fields/LMCModeMapCavity.cc b/Source/Fields/LMCModeMapCavity.cc index 3ab5455d..1d00c877 100644 --- a/Source/Fields/LMCModeMapCavity.cc +++ b/Source/Fields/LMCModeMapCavity.cc @@ -116,7 +116,7 @@ namespace locust std::string token; std::stringstream ss(lineContent); int wordCount = 0; - double r, theta, z; + double r, theta, z; int i,j,k; double Erho,Etheta; double Ex, Ey, Ez; @@ -124,19 +124,19 @@ namespace locust { if (wordCount == 0) { - r = std::stod(token); + r = std::stod(token); i = (int)((r-fDim1_min)/(fDim1_max-fDim1_min)*(fnPixel1)); // var1 position - } + } else if (wordCount == 1) - { - theta = std::stod(token); - j = (int)((theta-fDim2_min)/(fDim2_max-fDim2_min)*(fnPixel2)); // var2 position - } + { + theta = std::stod(token); + j = (int)((theta-fDim2_min)/(fDim2_max-fDim2_min)*(fnPixel2)); // var2 position + } else if (wordCount == 2) - { - z = std::stod(token); - k = (int)((z-fDim3_min)/(fDim3_max-fDim3_min)*(fnPixel3)); // var3 position - } + { + z = std::stod(token); + k = (int)((z-fDim3_min)/(fDim3_max-fDim3_min)*(fnPixel3)); // var3 position + } else if (wordCount == 3) Ex = std::stod(token); // mode E field value else if (wordCount == 4) Ey = std::stod(token); // mode E field value else if (wordCount == 5) Ez = std::stod(token); // mode E field value @@ -148,10 +148,10 @@ namespace locust ++wordCount; } - if ((i==fnPixel1) or (j==fnPixel2) or (k==fnPixel3)) - { - continue; - } + if ((i==fnPixel1) or (j==fnPixel2) or (k==fnPixel3)) + { + continue; + } if ((i>=fnPixel1) or (j>=fnPixel2) or (k>=fnPixel3)) { LERROR(lmclog,"Imported mode map dimensions don't agree with those in \"" << aFilename <<".\" Double check dim[1,2,3]-max."); @@ -159,26 +159,27 @@ namespace locust } //Must convert E field from cartesian coordinates to cylindrical coordinates - if(r<1.e-10) - { - Erho = 0.; - Etheta = 0.; - } - else - { + if(r<1.e-10) + { + Erho = 0.; + Etheta = 0.; + } + else + { Erho = ((Ex * r*cos(theta)) + Ey * r*sin(theta)) / r; - Etheta = ((Ey * r*cos(theta)) - Ex * r*sin(theta)) / r; - } + Etheta = ((Ey * r*cos(theta)) - Ex * r*sin(theta)) / r; + } std::vector E_input = {Erho,Etheta,Ez}; fModeMapTE_E[i][j][k] = E_input; -// printf("read var1 is %g, var2 is %g, E is %g\n", fModeMapTE_E.back()[0], fModeMapTE_E.back()[1], fModeMapTE_E.back()[2]); + //printf("read var1 is %g, var2 is %g, E is %g\n", fModeMapTE_E.back()[0], fModeMapTE_E.back()[1], fModeMapTE_E.back()[2]); + } } modeMapFile.close(); - //Reset dimensions from import file to actual cavity dimensions in case they don't match up + //Reset dimensions from import file to actual cavity dimensions in case they don't match up MatchCavityDimensions(aParam); return true;