-
Notifications
You must be signed in to change notification settings - Fork 31
Add KSIntSurfaceScattering to simulate scatterings on a surface #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
richeldichel
wants to merge
7
commits into
KATRIN-Experiment:main
Choose a base branch
from
richeldichel:MetalSurfaceScattering
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
47d2391
Add KSIntSurfaceScattering to simulate scatterings on a surface
richeldichel 57d40c0
KSIntSurfaceScattering: Apply minor fixes and suggestions from code r…
richeldichel 56ddce2
Wrap debug statements with #ifdef Kassiopeia_ENABLE_DEBUG
richeldichel 62d986b
Update bindings documentation
richeldichel 68de7a4
Implemented suggested improvements
2xB ea8825e
Merge pull request #2 from 2xB/MetalSurfaceScattering
richeldichel 63fe833
KSIntSurfaceScattering: Fix inverted backscatter probability check an…
richeldichel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
25,417 changes: 12,830 additions & 12,587 deletions
25,417
Documentation/Bindings/bindings_Kassiopeia.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
Kassiopeia/Bindings/Interactions/Include/KSIntSurfaceScatteringBuilder.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| ////////////////////////////////////////////////////////////////////////// | ||
| // Routine to simulate scattering of an electron on a surface with a given | ||
| // probability for backscattering of the electron and a given probability | ||
| // for production of a secondary electron from the surface. | ||
| ////////////////////////////////////////////////////////////////////////// | ||
| #ifndef Kassiopeia_KSIntSurfaceScatteringBuilder_h_ | ||
| #define Kassiopeia_KSIntSurfaceScatteringBuilder_h_ | ||
|
|
||
| #include "KComplexElement.hh" | ||
| #include "KSIntSurfaceScattering.h" | ||
|
|
||
| using namespace Kassiopeia; | ||
| namespace katrin | ||
| { | ||
| typedef KComplexElement<KSIntSurfaceScattering> KSIntSurfaceScatteringBuilder; | ||
|
|
||
| template<> inline bool KSIntSurfaceScatteringBuilder::AddAttribute(KContainer* aContainer) | ||
| { | ||
| if (aContainer->GetName() == "name") { | ||
| aContainer->CopyTo(fObject, &KNamed::SetName); | ||
| return true; | ||
| } | ||
| if (aContainer->GetName() == "sec_electron_probability") { | ||
| aContainer->CopyTo(fObject, &KSIntSurfaceScattering::SetSecElectronProbability); | ||
| return true; | ||
| } | ||
| if (aContainer->GetName() == "sec_electron_mean_energy") { | ||
| aContainer->CopyTo(fObject, &KSIntSurfaceScattering::SetSecElectronMeanEnergy); | ||
| return true; | ||
| } | ||
| if (aContainer->GetName() == "scat_probability") { | ||
| aContainer->CopyTo(fObject, &KSIntSurfaceScattering::SetScatProbability); | ||
| return true; | ||
| } | ||
| if (aContainer->GetName() == "scat_loss_fraction") { | ||
| aContainer->CopyTo(fObject, &KSIntSurfaceScattering::SetScatLossFraction); | ||
| return true; | ||
| } | ||
| if (aContainer->GetName() == "side") { | ||
| aContainer->CopyTo(fObject, &KSIntSurfaceScattering::SetSide); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| } // namespace katrin | ||
|
|
||
| #endif |
25 changes: 25 additions & 0 deletions
25
Kassiopeia/Bindings/Interactions/Source/KSIntSurfaceScatteringBuilder.cxx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| ////////////////////////////////////////////////////////////////////////// | ||
| // Routine to simulate scattering of an electron on a surface with a given | ||
| // probability for backscattering of the electron and a given probability | ||
| // for production of a secondary electron from the surface. | ||
| ////////////////////////////////////////////////////////////////////////// | ||
| #include "KSIntSurfaceScatteringBuilder.h" | ||
|
|
||
| #include "KSRootBuilder.h" | ||
|
|
||
| using namespace Kassiopeia; | ||
| using namespace std; | ||
|
|
||
| namespace katrin | ||
| { | ||
| template<> KSIntSurfaceScatteringBuilder::~KComplexElement() = default; | ||
|
|
||
| STATICINT sKSIntSurfaceScatteringStructure = KSIntSurfaceScatteringBuilder::Attribute<std::string>("name") + | ||
| KSIntSurfaceScatteringBuilder::Attribute<double>("sec_electron_probability") + | ||
| KSIntSurfaceScatteringBuilder::Attribute<double>("sec_electron_mean_energy") + | ||
| KSIntSurfaceScatteringBuilder::Attribute<double>("scat_probability") + | ||
| KSIntSurfaceScatteringBuilder::Attribute<double>("scat_loss_fraction") + | ||
| KSIntSurfaceScatteringBuilder::Attribute<std::string>("side"); | ||
|
|
||
| STATICINT sKSIntSurfaceScatteringElement = KSRootBuilder::ComplexElement<KSIntSurfaceScattering>("ksint_surface_scattering"); | ||
| } // namespace katrin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| ////////////////////////////////////////////////////////////////////////// | ||
| // Routine to simulate scattering of an electron on a surface with a given | ||
| // probability for backscattering of the electron and a given probability | ||
| // for production of a secondary electron from the surface. | ||
| ////////////////////////////////////////////////////////////////////////// | ||
| #ifndef Kassiopeia_KSIntSurfaceScattering_h_ | ||
| #define Kassiopeia_KSIntSurfaceScattering_h_ | ||
|
|
||
| #include "KField.h" | ||
| #include "KSInteractionsMessage.h" | ||
| #include "KSSurfaceInteraction.h" | ||
| #include "KThreeVector.hh" | ||
|
|
||
| #include <string> | ||
| namespace Kassiopeia | ||
| { | ||
|
|
||
| class KSStep; | ||
|
|
||
| enum class KSIntSurfaceScatteringSide | ||
| { | ||
| Both, | ||
| Top, | ||
| Bottom | ||
| }; | ||
|
|
||
| class KSIntSurfaceScattering : public KSComponentTemplate<KSIntSurfaceScattering, KSSurfaceInteraction> | ||
| { | ||
| public: | ||
| KSIntSurfaceScattering(); | ||
| KSIntSurfaceScattering(const KSIntSurfaceScattering& aCopy); | ||
| KSIntSurfaceScattering* Clone() const override; | ||
| ~KSIntSurfaceScattering() override; | ||
|
|
||
| public: | ||
| void ExecuteInteraction(const KSParticle& anInitialParticle, | ||
| KSParticle& aFinalParticle, | ||
| KSParticleQueue& aSecondaries) override; | ||
| void CreateSecondaryElectron(const KSParticle& anInitialParticle, | ||
| KSParticle& aFinalParticle, | ||
| KSParticleQueue& aSecondaries); | ||
| void ExecuteReflection(const KSParticle& anInitialParticle, | ||
| KSParticle& aFinalParticle, | ||
| KSParticleQueue& aSecondaries); | ||
| katrin::KThreeVector GetReflectionDirection(const KSParticle& anInitialParticle, | ||
| const double tSinTheta, | ||
| const double tCosTheta, | ||
| const double tAzimuthalAngle); | ||
|
|
||
| void SetSide(std::string side_name) | ||
| { | ||
| if (side_name == "both") { | ||
| fSide = KSIntSurfaceScatteringSide::Both; | ||
| return; | ||
| } | ||
|
|
||
| if (side_name == "top") { | ||
| fSide = KSIntSurfaceScatteringSide::Top; | ||
| return; | ||
| } | ||
|
|
||
| if (side_name == "bottom") { | ||
| fSide = KSIntSurfaceScatteringSide::Bottom; | ||
| return; | ||
| } | ||
|
|
||
| intmsg(eError) << "surface diffuse interaction named <" << GetName() | ||
| << "> does not understand side <" << side_name | ||
| << ">. Valid sides are: both, top, bottom." << eom; | ||
| return; | ||
| } | ||
|
|
||
| public: | ||
| K_SET_GET(double, ScatProbability) | ||
| K_SET_GET(double, ScatLossFraction) | ||
| K_SET_GET(double, SecElectronProbability) | ||
| K_SET_GET(double, SecElectronMeanEnergy) | ||
| K_SET_GET(KSIntSurfaceScatteringSide, Side) | ||
| }; | ||
|
|
||
| } // namespace Kassiopeia | ||
|
|
||
| #endif | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.