Skip to content
Snippets Groups Projects
Commit d1982bd0 authored by Gareth Tribello's avatar Gareth Tribello Committed by carlocamilloni
Browse files

Fixed code for fourier transform and fixed regtest

parent 6b889160
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
......@@ -75,6 +75,7 @@ private:
public:
static void registerKeywords( Keywords& keys );
explicit FourierTransform(const ActionOptions&ao);
void clearAverage();
#ifndef __PLUMED_HAS_FFTW
void performOperations( const bool& from_update ) {}
#else
......@@ -171,32 +172,21 @@ FourierTransform::FourierTransform(const ActionOptions&ao):
#endif
}
void FourierTransform::clearAverage() {
std::vector<double> fspacing;
std::vector<std::string> ft_min( ingrid->getMin() ), ft_max( ingrid->getMax() );
for(unsigned i=0; i<ingrid->getDimension(); ++i) {
Tools::convert( 0.0, ft_min[i] ); Tools::convert( 2.0*pi*ingrid->getNbin()[i]/ ingrid->getGridExtent(i), ft_max[i] );
}
mygrid->setBounds( ft_min, ft_max, ingrid->getNbin(), fspacing); resizeFunctions();
ActionWithAveraging::clearAverage();
}
#ifdef __PLUMED_HAS_FFTW
void FourierTransform::performOperations( const bool& from_update ) {
// Spacing of the real grid
std::vector<double> g_spacing ( ingrid->getGridSpacing() );
// Spacing of the k-grid
std::vector<double> ft_spacing;
// Extents of the k-grid
std::vector<std::string> ft_min( ingrid->getMin() ), ft_max( ingrid->getMax() );
// Number of bins in the k-grid (equal to the number of bins in the real grid)
std::vector<unsigned> ft_bins ( ingrid->getNbin() );
for (unsigned i=0; i<ingrid->getDimension(); ++i) {
// Check PBC in current grid dimension
if( !ingrid->isPeriodic(i) ) ft_bins[i]++;
// Compute k-grid extents
double dmin, dmax;
Tools::convert(ft_min[i],dmin); Tools::convert(ft_max[i],dmax);
// We want to have the min of k-grid at point (0,0)
dmin=0.0;
dmax=2.0*pi*ft_bins[i]/( ingrid->getGridExtent(i) );
Tools::convert(dmin,ft_min[i]); Tools::convert(dmax,ft_max[i]);
}
// This is the actual setup of the k-grid
mygrid->setBounds( ft_min, ft_max, ft_bins, ft_spacing); resizeFunctions();
// *** CHECK CORRECT k-GRID BOUNDARIES ***
//log<<"Real grid boundaries: \n"
......@@ -206,8 +196,6 @@ void FourierTransform::performOperations( const bool& from_update ) {
// <<" min_x: "<<ft_min[0]<<" min_y: "<<ft_min[1]<<"\n"
// <<" max_x: "<<ft_max[0]<<" max_y: "<<ft_max[1]<<"\n";
// Get the size of the input data arrays (to allocate FFT data)
std::vector<unsigned> N_input_data( ingrid->getNbin() );
size_t fft_dimension=1; for(unsigned i=0; i<N_input_data.size(); ++i) fft_dimension*=static_cast<size_t>( N_input_data[i] );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment