-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add very simple vacuum propagator, mainly as a test of tensor machinery
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1 +1,7 @@ | ||
|
||
|
||
add_library(propagator STATIC vacuum-propagator.hpp vacuum-propagator.cpp) | ||
target_link_libraries(propagator PUBLIC tensor) | ||
|
||
target_include_directories(propagator PUBLIC "${CMAKE_SOURCE_DIR}") | ||
set_target_properties(propagator PROPERTIES LINKER_LANGUAGE CXX) |
This file contains 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,17 @@ | ||
#include <nuTens/propagator/vacuum-propagator.hpp> | ||
|
||
|
||
Tensor VacuumPropagator::calculateProbs(){ | ||
Tensor weightMatrix; | ||
weightMatrix.ones({1,nGenerations, nGenerations}, NTdtypes::kComplexFloat).requiresGrad(false); | ||
|
||
for(int i = 0; i < nGenerations; i++){ | ||
weightMatrix.setValue({0, i, "..."}, Tensor::exp(Tensor::div(Tensor::scale(Tensor::mul(masses, masses), -1.0j * baseline), Tensor::scale(energies, 2.0)))); | ||
} | ||
weightMatrix.requiresGrad(true); | ||
|
||
Tensor sqrtProbabilities = Tensor::matmul(PMNSmatrix.conj(), Tensor::transpose(Tensor::mul(PMNSmatrix, weightMatrix), 1, 2)); | ||
Tensor probabilities = Tensor::mul(sqrtProbabilities.abs(), sqrtProbabilities.abs()); | ||
|
||
return probabilities; | ||
} |
This file contains 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,37 @@ | ||
#pragma once | ||
|
||
#include <nuTens/tensors/tensor.hpp> | ||
#include <vector> | ||
|
||
class VacuumPropagator{ | ||
|
||
public: | ||
|
||
VacuumPropagator(int nGenerations, float baseline) | ||
: | ||
baseline(baseline), | ||
nGenerations(nGenerations) | ||
{}; | ||
|
||
Tensor calculateProbs(); | ||
|
||
/// @name Setters | ||
/// @{ | ||
void setEnergies(Tensor newEnergies){ energies = newEnergies; } | ||
|
||
void setMasses(Tensor newMasses){ masses = newMasses; } | ||
|
||
inline void setPMNS(Tensor newPMNS){ PMNSmatrix = newPMNS; } | ||
|
||
inline void setPMNS(const std::vector<int> &indices, float value){ PMNSmatrix.setValue(indices, value); } | ||
|
||
inline void setPMNS(const std::vector<int> &indices, std::complex<float> value){ PMNSmatrix.setValue(indices, value); } | ||
/// @} | ||
|
||
private: | ||
Tensor PMNSmatrix; | ||
Tensor masses; | ||
Tensor energies; | ||
int nGenerations; | ||
float baseline; | ||
}; |