Skip to content

Commit

Permalink
Allow command-line specification of mode map filename. Define tempora…
Browse files Browse the repository at this point in the history
…ry mode normalization == 1.0 for uploaded mode maps, until the required interpolation is implemented.
  • Loading branch information
pslocum committed Nov 15, 2023
1 parent 00a2236 commit 936de20
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
49 changes: 41 additions & 8 deletions Source/Fields/LMCCylindricalCavity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,29 @@ namespace locust
SetCavityProbeTheta(aParam["cavity-probe-theta1"]().as_double(), 1);
}

if( aParam.has( "modemap-filename" ) )
if( aParam.has( "upload-modemap-filename" ) ) // import "realistic" test mode map
{
fFieldCore = new ModeMapCylindricalCavity();
scarab::path dataDir = aParam.get_value( "data-dir", ( TOSTRING(PB_DATA_INSTALL_DIR) ) );
if (!fFieldCore->ReadModeMapTE_E((dataDir / aParam["modemap-filename"]().as_string()).string()))

if (!fFieldCore->ReadModeMapTE_E((dataDir / aParam["upload-modemap-filename"]().as_string()).string()))
{
LERROR(lmclog,"There was a problem uploading the mode map.");
exit(-1);
}
SetNormFactorsTE( SetUnityNormFactors(GetNModes()));
SetNormFactorsTM( SetUnityNormFactors(GetNModes()));
}
else
else // otherwise default to ideal Pozar mode map
{
fFieldCore = new PozarCylindricalCavity();
scarab::path dataDir = aParam.get_value( "data-dir", ( TOSTRING(PB_DATA_INSTALL_DIR) ) );
fFieldCore->ReadBesselZeroes((dataDir / "BesselZeros.txt").string(), 0 );
fFieldCore->ReadBesselZeroes((dataDir / "BesselPrimeZeros.txt").string(), 1 );
SetNormFactorsTE(CalculateNormFactors(GetNModes(),1));
SetNormFactorsTM(CalculateNormFactors(GetNModes(),0));
CheckNormalization(GetNModes()); // E fields integrate to 1.0 for both TE and TM modes.
}

SetNormFactorsTE(CalculateNormFactors(GetNModes(),1));
SetNormFactorsTM(CalculateNormFactors(GetNModes(),0));

CheckNormalization(GetNModes()); // E fields integrate to 1.0 for both TE and TM modes.

if( PlotModeMaps() )
{
Expand All @@ -119,6 +119,39 @@ namespace locust
return true;
}

std::vector<std::vector<std::vector<double>>> CylindricalCavity::SetUnityNormFactors(int nModes)
{
LPROG(lmclog, "Setting mode normalization factors to 1.0 ... " );

std::vector<std::vector<std::vector<double>>> tNormFactor;
tNormFactor.resize(nModes);

for (unsigned m=0; m<nModes; m++)
{
tNormFactor[m].resize(nModes);
for (unsigned n=0; n<nModes; n++)
{
tNormFactor[m][n].resize(nModes);
}
}

for (unsigned l=0; l<nModes; l++)
{
for (unsigned m=0; m<nModes; m++)
{
for (unsigned n=0; n<nModes; n++)
{
tNormFactor[l][m][n] = 1.;
}
}
}

return tNormFactor;

}



std::vector<std::vector<std::vector<double>>> CylindricalCavity::CalculateNormFactors(int nModes, bool bTE)
{

Expand Down
1 change: 1 addition & 0 deletions Source/Fields/LMCCylindricalCavity.hh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace locust
virtual std::vector<double> GetDopplerFrequency(int l, int m, int n, std::vector<double> tKassParticleXP);
virtual std::vector<double> GetNormalizedModeField(int l, int m, int n, std::vector<double> tKassParticleXP, bool includeOtherPols, bool teMode);
virtual std::vector<std::vector<std::vector<double>>> CalculateNormFactors(int nModes, bool bTE);
virtual std::vector<std::vector<std::vector<double>>> SetUnityNormFactors(int nModes);
virtual std::vector<double> GetTE_E(int l, int m, int n, double r, double theta, double z, bool includeOtherPols);
virtual std::vector<double> GetTM_E(int l, int m, int n, double r, double theta, double z, bool includeOtherPols);
virtual double CalculateDotProductFactor(int l, int m, int n, std::vector<double> tKassParticleXP, std::vector<double> anE_normalized, double tThisEventNSamples);
Expand Down
1 change: 1 addition & 0 deletions Source/Fields/LMCField.hh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ namespace locust
virtual std::vector<double> GetNormalizedModeField(int l, int m, int n, std::vector<double> tKassParticleXP, bool includeOtherPols, bool teMode) {return {0.};};
double NormalizedEFieldMag(std::vector<double> field);
virtual std::vector<std::vector<std::vector<double>>> CalculateNormFactors(int nModes, bool bTE) {return {{{0.}}};};
virtual std::vector<std::vector<std::vector<double>>> SetUnityNormFactors(int nModes) {return {{{0.}}};};
virtual std::vector<double> GetTE_E(int l, int m, int n, double r, double theta, double z, bool includeOtherPols) {return {0.};};
virtual std::vector<double> GetTM_E(int l, int m, int n, double r, double theta, double z, bool includeOtherPols) {return {0.};};
virtual double CalculateDotProductFactor(int l, int m, int n, std::vector<double> tKassParticleXP, std::vector<double> aTE_E_normalized, double tThisEventNSamples) {return {0.};};
Expand Down

0 comments on commit 936de20

Please sign in to comment.