Skip to content

Commit

Permalink
Merge pull request #321 from project8/feature/CMfollowup
Browse files Browse the repository at this point in the history
Feature/versionUpdates
  • Loading branch information
pslocum authored Oct 30, 2024
2 parents 458fb1f + e2f14f7 commit 3d6cf52
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
env:
REGISTRY: ghcr.io
BASE_IMG_REPO: project8/kassiopeia_builder
BASE_IMG_TAG: v4.0.1-dev
BASE_IMG_TAG: v4.1.2-dev
FINAL_BASE_IMG_REPO: project8/luna_base
FINAL_BASE_IMG_TAG: v1.3.4
locust_mc_BUILD_WITH_KASSIOPEIA: ON
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required( VERSION 3.1 )

# Define the project
cmake_policy( SET CMP0048 NEW ) # version in project()
project( locust_mc VERSION 2.8.4)
project( locust_mc VERSION 3.0.0)


list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/Scarab/cmake )
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG final_img_repo=ghcr.io/project8/luna_base
ARG final_img_tag=v1.3.4

ARG build_img_repo=ghcr.io/project8/kassiopeia_builder
ARG build_img_tag=v4.0.1-dev
ARG build_img_tag=v4.1.2-dev

########################
FROM ${build_img_repo}:${build_img_tag} AS build
Expand Down
60 changes: 41 additions & 19 deletions Source/Fields/LMCCylindricalCavity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ namespace locust
LOGGER( lmclog, "CylindricalCavity" );
CylindricalCavity::CylindricalCavity():
fIntermediateFile( false ),
fProbeGain( {1., 1.}),
fCavityProbeZ( {0., 0.} ),
fCavityProbeRFrac( {0.5, 0.5} ),
fCavityProbeTheta( {0.0, 0.0} )
fProbeGain( {1., 1., 1.}),
fCavityProbeZ( {0., 0., 0.} ),
fCavityProbeRFrac( {0.5, 0.5, 0.5} ),
fCavityProbeTheta( {0.0, 0.0, 0.0} )
{}

CylindricalCavity::~CylindricalCavity() {}
Expand Down Expand Up @@ -53,6 +53,11 @@ namespace locust
SetCavityProbeGain(aParam["cavity-probe-gain1"]().as_double(), 1);
}

if ( aParam.has( "cavity-probe-gain2" ) )
{
SetCavityProbeGain(aParam["cavity-probe-gain2"]().as_double(), 2);
}

if ( aParam.has( "cavity-probe-z0" ) )
{
SetCavityProbeZ(aParam["cavity-probe-z0"]().as_double(), 0);
Expand All @@ -63,6 +68,11 @@ namespace locust
SetCavityProbeZ(aParam["cavity-probe-z1"]().as_double(), 1);
}

if ( aParam.has( "cavity-probe-z2" ) )
{
SetCavityProbeZ(aParam["cavity-probe-z2"]().as_double(), 2);
}

if ( aParam.has( "cavity-probe-r-fraction0" ) )
{
SetCavityProbeRFrac(aParam["cavity-probe-r-fraction0"]().as_double(), 0);
Expand All @@ -73,6 +83,11 @@ namespace locust
SetCavityProbeRFrac(aParam["cavity-probe-r-fraction1"]().as_double(), 1);
}

if ( aParam.has( "cavity-probe-r-fraction2" ) )
{
SetCavityProbeRFrac(aParam["cavity-probe-r-fraction2"]().as_double(), 2);
}

if ( aParam.has( "cavity-probe-theta0" ) )
{
SetCavityProbeTheta(aParam["cavity-probe-theta0"]().as_double(), 0);
Expand All @@ -83,6 +98,11 @@ namespace locust
SetCavityProbeTheta(aParam["cavity-probe-theta1"]().as_double(), 1);
}

if ( aParam.has( "cavity-probe-theta2" ) )
{
SetCavityProbeTheta(aParam["cavity-probe-theta2"]().as_double(), 2);
}

if (aParam.has( "intermediate-file" ))
{
fIntermediateFile = aParam["intermediate-file"]().as_bool();
Expand Down Expand Up @@ -276,11 +296,7 @@ namespace locust

std::vector<double> CylindricalCavity::GetFieldAtProbe(int l, int m, int n, bool includeOtherPols, std::vector<double> tKassParticleXP, bool teMode)
{

std::vector<double> rProbe;
rProbe.push_back(GetCavityProbeRFrac()[0] * GetDimR());
rProbe.push_back(GetCavityProbeRFrac()[1] * GetDimR());

std::vector<double> rProbe = GetCavityProbeR();
std::vector<double> thetaProbe = GetCavityProbeTheta();
std::vector<double> zProbe = GetCavityProbeZ();
std::vector<double> thetaEffective;
Expand All @@ -289,24 +305,30 @@ namespace locust
{
//If mode has theta dependence, mode polarization is set by electron location. Probe coupling must be set relative to that angle
double thetaElectron = tKassParticleXP[1];
thetaEffective.push_back(thetaProbe[0] - thetaElectron);
thetaEffective.push_back(thetaProbe[1] - thetaElectron);
for (unsigned index=0; index<GetNChannels(); index++)
{
thetaEffective.push_back(thetaProbe[index] - thetaElectron);
}
}
else
{
thetaEffective = thetaProbe;
thetaEffective = thetaProbe;
}

std::vector<std::vector<double>> tProbeLocation;
tProbeLocation.push_back({rProbe[0], thetaEffective[0], zProbe[0]});
tProbeLocation.push_back({rProbe[1], thetaEffective[1], zProbe[1]});
for (unsigned index=0; index<GetNChannels(); index++)
{
tProbeLocation.push_back({rProbe[index], thetaEffective[index], zProbe[index]});
}

//Assumes probe couples to E of mode. If mode is polarized, transforms angle to reference frame of electron
std::vector<double> tEFieldAtProbe;
tEFieldAtProbe.push_back( NormalizedEFieldMag(GetNormalizedModeField(l,m,n,tProbeLocation[0],0,teMode)) );
tEFieldAtProbe.push_back( NormalizedEFieldMag(GetNormalizedModeField(l,m,n,tProbeLocation[1],0,teMode)) );
for (unsigned index=0; index<GetNChannels(); index++)
{
tEFieldAtProbe.push_back( NormalizedEFieldMag(GetNormalizedModeField(l,m,n,tProbeLocation[index],0,teMode)) );
}

return {fProbeGain[0] * tEFieldAtProbe[0], fProbeGain[1] * tEFieldAtProbe[1]};
return {fProbeGain[0] * tEFieldAtProbe[0], fProbeGain[1] * tEFieldAtProbe[1], fProbeGain[2] * tEFieldAtProbe[2]};

}

Expand Down Expand Up @@ -655,9 +677,9 @@ namespace locust
{
fCavityProbeZ[index] = aZ;
}
std::vector<double> CylindricalCavity::GetCavityProbeRFrac()
std::vector<double> CylindricalCavity::GetCavityProbeR()
{
return fCavityProbeRFrac;
return { fCavityProbeRFrac[0] * GetDimR(), fCavityProbeRFrac[1] * GetDimR(), fCavityProbeRFrac[2] * GetDimR()};
}
void CylindricalCavity::SetCavityProbeRFrac ( double aFraction, unsigned index )
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Fields/LMCCylindricalCavity.hh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace locust
virtual std::vector<double> GetFieldAtProbe(int l, int m, int n, bool includeOtherPols, std::vector<double> tKassParticleXP, bool teMode);
std::vector<double> GetCavityProbeZ();
void SetCavityProbeZ ( double aZ, unsigned index );
std::vector<double> GetCavityProbeRFrac();
std::vector<double> GetCavityProbeR();
void SetCavityProbeRFrac ( double aFraction, unsigned index );
std::vector<double> GetCavityProbeGain();
void SetCavityProbeTheta( double aTheta, unsigned index );
Expand Down
10 changes: 9 additions & 1 deletion Source/Fields/LMCField.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,19 @@ namespace locust
}
}


return true;

}

int Field::GetNChannels()
{
return fNChannels;
}
void Field::SetNChannels( int aNumberOfChannels )
{
fNChannels = aNumberOfChannels;
}

std::vector<std::vector<int>> Field::ModeSelect(bool bWaveguide, bool bNormCheck)
{
int nModes = fNModes;
Expand Down
4 changes: 4 additions & 0 deletions Source/Fields/LMCField.hh
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,15 @@ namespace locust
void SetPlotModeMaps( bool aFlag );
void SetOutputPath( std::string aPath );
std::string GetOutputPath();
void SetNChannels( int aNumberOfChannels );
int GetNChannels();




private:
int fNModes;
int fNChannels;
std::vector<std::vector<std::vector<std::vector<double>>>> fModeNormFactor; // 4D vector [2][n-modes][n-modes][n-modes].
double fCentralFrequency;
int fnPixels;
Expand Down
8 changes: 5 additions & 3 deletions Source/Generators/LMCCavitySignalGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,12 @@ namespace locust
if (fRandomPreEventSamples) RandomizeStartDelay();

fPowerCombiner->SizeNChannels(fNChannels);
if (fNChannels > 2)
fInterface->fField->SetNChannels(fNChannels);

if (fNChannels > 3)
{
LERROR(lmclog,"The cavity simulation only supports up to 2 channels right now.");
throw std::runtime_error("Only 1 or 2 channels is allowed.");
LERROR(lmclog,"The cavity simulation only supports up to 3 channels right now.");
throw std::runtime_error("Only 1, 2, or 3 channels is allowed.");
return false;
}

Expand Down
20 changes: 17 additions & 3 deletions Source/RxComponents/LMCCavityModes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace locust
LOGGER( lmclog, "CavityModes" );

CavityModes::CavityModes():
fVoltagePhase( 0 ),
fVoltagePhase( {{{{0.0}}}} ),
fChannelPhaseOffset( {0.0} ),
fInterface( KLInterfaceBootstrapper::get_instance()->GetInterface() )
{
}
Expand All @@ -36,7 +37,20 @@ namespace locust

SetNCavityModes(fInterface->fField->GetNModes());

SizeNChannels(GetNChannels());

fChannelPhaseOffset.resize(3);
if ( aParam.has( "channel0-phase-offset-deg" ) )
{
fChannelPhaseOffset[0] = LMCConst::Pi() / 180. * aParam["channel0-phase-offset-deg"]().as_double();
}
if ( aParam.has( "channel1-phase-offset-deg" ) )
{
fChannelPhaseOffset[1] = LMCConst::Pi() / 180. * aParam["channel1-phase-offset-deg"]().as_double();
}
if ( aParam.has( "channel2-phase-offset-deg" ) )
{
fChannelPhaseOffset[2] = LMCConst::Pi() / 180. * aParam["channel2-phase-offset-deg"]().as_double();
}

return true;
}
Expand Down Expand Up @@ -70,7 +84,7 @@ namespace locust
double dopplerFrequency = cavityDopplerFrequency[0]; // Only one shift, unlike in waveguide.
SetVoltagePhase( GetVoltagePhase(channelIndex, l, m, n) + dopplerFrequency * dt, channelIndex, l, m, n ) ;
double voltageValue = excitationAmplitude * EFieldAtProbe;
voltageValue *= cos(GetVoltagePhase(channelIndex, l, m, n));
voltageValue *= cos(GetVoltagePhase(channelIndex, l, m, n) + fChannelPhaseOffset[channelIndex] );

aSignal->LongSignalTimeComplex()[sampleIndex][0] += 2. * voltageValue * totalScalingFactor * sin(phi_LO);
aSignal->LongSignalTimeComplex()[sampleIndex][1] += 2. * voltageValue * totalScalingFactor * cos(phi_LO);
Expand Down
1 change: 1 addition & 0 deletions Source/RxComponents/LMCCavityModes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace locust

private:
std::vector<std::vector<std::vector<std::vector<double>>>> fVoltagePhase;
std::vector<double> fChannelPhaseOffset;
kl_interface_ptr_t fInterface;


Expand Down
2 changes: 1 addition & 1 deletion kassiopeia
Submodule kassiopeia updated 108 files

0 comments on commit 3d6cf52

Please sign in to comment.