mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-10-31 20:14:32 +00:00 
			
		
		
		
	Add module for unit EM field
This commit is contained in:
		| @@ -13,6 +13,7 @@ | |||||||
| #include <Grid/Hadrons/Modules/MGauge/Random.hpp> | #include <Grid/Hadrons/Modules/MGauge/Random.hpp> | ||||||
| #include <Grid/Hadrons/Modules/MGauge/StochEm.hpp> | #include <Grid/Hadrons/Modules/MGauge/StochEm.hpp> | ||||||
| #include <Grid/Hadrons/Modules/MGauge/Unit.hpp> | #include <Grid/Hadrons/Modules/MGauge/Unit.hpp> | ||||||
|  | #include <Grid/Hadrons/Modules/MGauge/UnitEm.hpp> | ||||||
| #include <Grid/Hadrons/Modules/MLoop/NoiseLoop.hpp> | #include <Grid/Hadrons/Modules/MLoop/NoiseLoop.hpp> | ||||||
| #include <Grid/Hadrons/Modules/MScalar/ChargedProp.hpp> | #include <Grid/Hadrons/Modules/MScalar/ChargedProp.hpp> | ||||||
| #include <Grid/Hadrons/Modules/MScalar/FreeProp.hpp> | #include <Grid/Hadrons/Modules/MScalar/FreeProp.hpp> | ||||||
|   | |||||||
							
								
								
									
										68
									
								
								extras/Hadrons/Modules/MGauge/UnitEm.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								extras/Hadrons/Modules/MGauge/UnitEm.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,68 @@ | |||||||
|  | /************************************************************************************* | ||||||
|  |  | ||||||
|  | Grid physics library, www.github.com/paboyle/Grid  | ||||||
|  |  | ||||||
|  | Source file: extras/Hadrons/Modules/MGauge/StochEm.cc | ||||||
|  |  | ||||||
|  | Copyright (C) 2015 | ||||||
|  | Copyright (C) 2016 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | This program is free software; you can redistribute it and/or modify | ||||||
|  | it under the terms of the GNU General Public License as published by | ||||||
|  | the Free Software Foundation; either version 2 of the License, or | ||||||
|  | (at your option) any later version. | ||||||
|  |  | ||||||
|  | This program is distributed in the hope that it will be useful, | ||||||
|  | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  | GNU General Public License for more details. | ||||||
|  |  | ||||||
|  | You should have received a copy of the GNU General Public License along | ||||||
|  | with this program; if not, write to the Free Software Foundation, Inc., | ||||||
|  | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||||
|  |  | ||||||
|  | See the full license in the file "LICENSE" in the top level distribution directory | ||||||
|  | *************************************************************************************/ | ||||||
|  | /*  END LEGAL */ | ||||||
|  | #include <Grid/Hadrons/Modules/MGauge/UnitEm.hpp> | ||||||
|  |  | ||||||
|  | using namespace Grid; | ||||||
|  | using namespace Hadrons; | ||||||
|  | using namespace MGauge; | ||||||
|  |  | ||||||
|  | /****************************************************************************** | ||||||
|  | *                  TStochEm implementation                             * | ||||||
|  | ******************************************************************************/ | ||||||
|  | // constructor ///////////////////////////////////////////////////////////////// | ||||||
|  | TUnitEm::TUnitEm(const std::string name) | ||||||
|  | : Module<NoPar>(name) | ||||||
|  | {} | ||||||
|  |  | ||||||
|  | // dependencies/products /////////////////////////////////////////////////////// | ||||||
|  | std::vector<std::string> TUnitEm::getInput(void) | ||||||
|  | { | ||||||
|  |     return std::vector<std::string>(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | std::vector<std::string> TUnitEm::getOutput(void) | ||||||
|  | { | ||||||
|  |     std::vector<std::string> out = {getName()}; | ||||||
|  |      | ||||||
|  |     return out; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // setup /////////////////////////////////////////////////////////////////////// | ||||||
|  | void TUnitEm::setup(void) | ||||||
|  | { | ||||||
|  |     env().registerLattice<EmField>(getName()); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // execution /////////////////////////////////////////////////////////////////// | ||||||
|  | void TUnitEm::execute(void) | ||||||
|  | { | ||||||
|  |     PhotonR photon(); | ||||||
|  |     EmField &a = *env().createLattice<EmField>(getName()); | ||||||
|  |     LOG(Message) << "Generating unit EM potential..." << std::endl; | ||||||
|  |     photon.UnitField(a); | ||||||
|  | } | ||||||
							
								
								
									
										67
									
								
								extras/Hadrons/Modules/MGauge/UnitEm.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								extras/Hadrons/Modules/MGauge/UnitEm.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,67 @@ | |||||||
|  | /************************************************************************************* | ||||||
|  |  | ||||||
|  | Grid physics library, www.github.com/paboyle/Grid  | ||||||
|  |  | ||||||
|  | Source file: extras/Hadrons/Modules/MGauge/StochEm.hpp | ||||||
|  |  | ||||||
|  | Copyright (C) 2015 | ||||||
|  | Copyright (C) 2016 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | This program is free software; you can redistribute it and/or modify | ||||||
|  | it under the terms of the GNU General Public License as published by | ||||||
|  | the Free Software Foundation; either version 2 of the License, or | ||||||
|  | (at your option) any later version. | ||||||
|  |  | ||||||
|  | This program is distributed in the hope that it will be useful, | ||||||
|  | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  | GNU General Public License for more details. | ||||||
|  |  | ||||||
|  | You should have received a copy of the GNU General Public License along | ||||||
|  | with this program; if not, write to the Free Software Foundation, Inc., | ||||||
|  | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||||
|  |  | ||||||
|  | See the full license in the file "LICENSE" in the top level distribution directory | ||||||
|  | *************************************************************************************/ | ||||||
|  | /*  END LEGAL */ | ||||||
|  | #ifndef Hadrons_MGauge_UnitEm_hpp_ | ||||||
|  | #define Hadrons_MGauge_UnitEm_hpp_ | ||||||
|  |  | ||||||
|  | #include <Grid/Hadrons/Global.hpp> | ||||||
|  | #include <Grid/Hadrons/Module.hpp> | ||||||
|  | #include <Grid/Hadrons/ModuleFactory.hpp> | ||||||
|  |  | ||||||
|  | BEGIN_HADRONS_NAMESPACE | ||||||
|  |  | ||||||
|  | /****************************************************************************** | ||||||
|  |  *                         StochEm                                 * | ||||||
|  |  ******************************************************************************/ | ||||||
|  | BEGIN_MODULE_NAMESPACE(MGauge) | ||||||
|  |  | ||||||
|  | class TUnitEm: public Module<NoPar> | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |     typedef PhotonR::GaugeField     EmField; | ||||||
|  |     typedef PhotonR::GaugeLinkField EmComp; | ||||||
|  | public: | ||||||
|  |     // constructor | ||||||
|  |     TUnitEm(const std::string name); | ||||||
|  |     // destructor | ||||||
|  |     virtual ~TUnitEm(void) = default; | ||||||
|  |     // dependency relation | ||||||
|  |     virtual std::vector<std::string> getInput(void); | ||||||
|  |     virtual std::vector<std::string> getOutput(void); | ||||||
|  |     // setup | ||||||
|  |     virtual void setup(void); | ||||||
|  |     // execution | ||||||
|  |     virtual void execute(void); | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | MODULE_REGISTER_NS(UnitEm, TUnitEm, MGauge); | ||||||
|  |  | ||||||
|  | END_MODULE_NAMESPACE | ||||||
|  |  | ||||||
|  | END_HADRONS_NAMESPACE | ||||||
|  |  | ||||||
|  | #endif // Hadrons_MGauge_UnitEm_hpp_ | ||||||
| @@ -6,6 +6,7 @@ modules_cc =\ | |||||||
|   Modules/MGauge/Random.cc \ |   Modules/MGauge/Random.cc \ | ||||||
|   Modules/MGauge/StochEm.cc \ |   Modules/MGauge/StochEm.cc \ | ||||||
|   Modules/MGauge/Unit.cc \ |   Modules/MGauge/Unit.cc \ | ||||||
|  |   Modules/MGauge/UnitEm.cc \ | ||||||
|   Modules/MScalar/ChargedProp.cc \ |   Modules/MScalar/ChargedProp.cc \ | ||||||
|   Modules/MScalar/FreeProp.cc \ |   Modules/MScalar/FreeProp.cc \ | ||||||
|   Modules/MScalar/ScalarVP.cc |   Modules/MScalar/ScalarVP.cc | ||||||
| @@ -26,6 +27,7 @@ modules_hpp =\ | |||||||
|   Modules/MGauge/Random.hpp \ |   Modules/MGauge/Random.hpp \ | ||||||
|   Modules/MGauge/StochEm.hpp \ |   Modules/MGauge/StochEm.hpp \ | ||||||
|   Modules/MGauge/Unit.hpp \ |   Modules/MGauge/Unit.hpp \ | ||||||
|  |   Modules/MGauge/UnitEm.hpp \ | ||||||
|   Modules/MLoop/NoiseLoop.hpp \ |   Modules/MLoop/NoiseLoop.hpp \ | ||||||
|   Modules/MScalar/ChargedProp.hpp \ |   Modules/MScalar/ChargedProp.hpp \ | ||||||
|   Modules/MScalar/FreeProp.hpp \ |   Modules/MScalar/FreeProp.hpp \ | ||||||
|   | |||||||
| @@ -68,6 +68,7 @@ namespace QCD{ | |||||||
|     void StochasticField(GaugeField &out, GridParallelRNG &rng); |     void StochasticField(GaugeField &out, GridParallelRNG &rng); | ||||||
|     void StochasticField(GaugeField &out, GridParallelRNG &rng, |     void StochasticField(GaugeField &out, GridParallelRNG &rng, | ||||||
|                          const GaugeLinkField &weight); |                          const GaugeLinkField &weight); | ||||||
|  |     void UnitField(GaugeField &out); | ||||||
|   private: |   private: | ||||||
|     void invKHatSquared(GaugeLinkField &out); |     void invKHatSquared(GaugeLinkField &out); | ||||||
|     void zmSub(GaugeLinkField &out); |     void zmSub(GaugeLinkField &out); | ||||||
| @@ -219,6 +220,23 @@ namespace QCD{ | |||||||
|      |      | ||||||
|     out = real(out); |     out = real(out); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   template<class Gimpl> | ||||||
|  |   void Photon<Gimpl>::UnitField(GaugeField &out) | ||||||
|  |   { | ||||||
|  |     auto               *grid = dynamic_cast<GridCartesian *>(out._grid); | ||||||
|  |     const unsigned int nd = grid->_ndimension; | ||||||
|  |     GaugeLinkField     r(grid); | ||||||
|  |      | ||||||
|  |     r = Complex(1.0,0.0); | ||||||
|  |  | ||||||
|  |     for(int mu = 0; mu < nd; mu++) | ||||||
|  |     { | ||||||
|  |       pokeLorentz(out, r, mu); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     out = real(out); | ||||||
|  |   } | ||||||
| //  template<class Gimpl> | //  template<class Gimpl> | ||||||
| //  void Photon<Gimpl>::FeynmanGaugeMomentumSpacePropagator_L(GaugeField &out, | //  void Photon<Gimpl>::FeynmanGaugeMomentumSpacePropagator_L(GaugeField &out, | ||||||
| //                                                            const GaugeField &in) | //                                                            const GaugeField &in) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user