diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 592aedda..0cecfc97 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index a47eb63b..8470f4f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ) diff --git a/Dockerfile b/Dockerfile index c2411ccf..7b9c217b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Source/Fields/LMCCylindricalCavity.cc b/Source/Fields/LMCCylindricalCavity.cc index e5e4dbef..7f1864d4 100644 --- a/Source/Fields/LMCCylindricalCavity.cc +++ b/Source/Fields/LMCCylindricalCavity.cc @@ -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() {} @@ -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); @@ -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); @@ -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); @@ -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(); @@ -276,11 +296,7 @@ namespace locust std::vector CylindricalCavity::GetFieldAtProbe(int l, int m, int n, bool includeOtherPols, std::vector tKassParticleXP, bool teMode) { - - std::vector rProbe; - rProbe.push_back(GetCavityProbeRFrac()[0] * GetDimR()); - rProbe.push_back(GetCavityProbeRFrac()[1] * GetDimR()); - + std::vector rProbe = GetCavityProbeR(); std::vector thetaProbe = GetCavityProbeTheta(); std::vector zProbe = GetCavityProbeZ(); std::vector thetaEffective; @@ -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> tProbeLocation; - tProbeLocation.push_back({rProbe[0], thetaEffective[0], zProbe[0]}); - tProbeLocation.push_back({rProbe[1], thetaEffective[1], zProbe[1]}); + for (unsigned index=0; index 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 CylindricalCavity::GetCavityProbeRFrac() + std::vector CylindricalCavity::GetCavityProbeR() { - return fCavityProbeRFrac; + return { fCavityProbeRFrac[0] * GetDimR(), fCavityProbeRFrac[1] * GetDimR(), fCavityProbeRFrac[2] * GetDimR()}; } void CylindricalCavity::SetCavityProbeRFrac ( double aFraction, unsigned index ) { diff --git a/Source/Fields/LMCCylindricalCavity.hh b/Source/Fields/LMCCylindricalCavity.hh index a5729acd..9d39180b 100644 --- a/Source/Fields/LMCCylindricalCavity.hh +++ b/Source/Fields/LMCCylindricalCavity.hh @@ -71,7 +71,7 @@ namespace locust virtual std::vector GetFieldAtProbe(int l, int m, int n, bool includeOtherPols, std::vector tKassParticleXP, bool teMode); std::vector GetCavityProbeZ(); void SetCavityProbeZ ( double aZ, unsigned index ); - std::vector GetCavityProbeRFrac(); + std::vector GetCavityProbeR(); void SetCavityProbeRFrac ( double aFraction, unsigned index ); std::vector GetCavityProbeGain(); void SetCavityProbeTheta( double aTheta, unsigned index ); diff --git a/Source/Fields/LMCField.cc b/Source/Fields/LMCField.cc index 7a5f7666..8fab166c 100644 --- a/Source/Fields/LMCField.cc +++ b/Source/Fields/LMCField.cc @@ -80,11 +80,19 @@ namespace locust } } - return true; } + int Field::GetNChannels() + { + return fNChannels; + } + void Field::SetNChannels( int aNumberOfChannels ) + { + fNChannels = aNumberOfChannels; + } + std::vector> Field::ModeSelect(bool bWaveguide, bool bNormCheck) { int nModes = fNModes; diff --git a/Source/Fields/LMCField.hh b/Source/Fields/LMCField.hh index 2924e8fb..a47c0e62 100644 --- a/Source/Fields/LMCField.hh +++ b/Source/Fields/LMCField.hh @@ -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>>> fModeNormFactor; // 4D vector [2][n-modes][n-modes][n-modes]. double fCentralFrequency; int fnPixels; diff --git a/Source/Generators/LMCCavitySignalGenerator.cc b/Source/Generators/LMCCavitySignalGenerator.cc index 945afec9..4a6317ca 100644 --- a/Source/Generators/LMCCavitySignalGenerator.cc +++ b/Source/Generators/LMCCavitySignalGenerator.cc @@ -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; } diff --git a/Source/RxComponents/LMCCavityModes.cc b/Source/RxComponents/LMCCavityModes.cc index 429bff49..9b7ccc15 100644 --- a/Source/RxComponents/LMCCavityModes.cc +++ b/Source/RxComponents/LMCCavityModes.cc @@ -15,7 +15,8 @@ namespace locust LOGGER( lmclog, "CavityModes" ); CavityModes::CavityModes(): - fVoltagePhase( 0 ), + fVoltagePhase( {{{{0.0}}}} ), + fChannelPhaseOffset( {0.0} ), fInterface( KLInterfaceBootstrapper::get_instance()->GetInterface() ) { } @@ -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; } @@ -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); diff --git a/Source/RxComponents/LMCCavityModes.hh b/Source/RxComponents/LMCCavityModes.hh index f6c5b7aa..55566d40 100644 --- a/Source/RxComponents/LMCCavityModes.hh +++ b/Source/RxComponents/LMCCavityModes.hh @@ -49,6 +49,7 @@ namespace locust private: std::vector>>> fVoltagePhase; + std::vector fChannelPhaseOffset; kl_interface_ptr_t fInterface; diff --git a/kassiopeia b/kassiopeia index 72b90c5f..ece521e8 160000 --- a/kassiopeia +++ b/kassiopeia @@ -1 +1 @@ -Subproject commit 72b90c5fff5a2ffdca0f71226cdd2c31240b0b89 +Subproject commit ece521e82590945f6d65d28ec7513390eb97f3fc