mirror of
https://github.com/cosmo-sims/MUSIC.git
synced 2024-09-19 17:03:46 +02:00
Fixed a normalization issue for they hybrid Poisson solver.
Option 'avg_fine' now defaults to 'true'.
This commit is contained in:
parent
3ec25ad49a
commit
aa9e88310e
4 changed files with 37 additions and 34 deletions
5
Makefile
5
Makefile
|
@ -1,8 +1,8 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
### compile time configuration options
|
### compile time configuration options
|
||||||
MULTITHREADFFTW = no
|
MULTITHREADFFTW = yes
|
||||||
SINGLEPRECISION = no
|
SINGLEPRECISION = no
|
||||||
HAVEHDF5 = yes
|
HAVEHDF5 = no
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
### compiler and path settings
|
### compiler and path settings
|
||||||
|
@ -53,6 +53,7 @@ all: $(OBJS) $(TARGET)
|
||||||
|
|
||||||
$(TARGET): $(OBJS)
|
$(TARGET): $(OBJS)
|
||||||
$(CC) $(LPATHS) -o $@ $^ $(LFLAGS)
|
$(CC) $(LPATHS) -o $@ $^ $(LFLAGS)
|
||||||
|
|
||||||
%.o: %.cc *.hh Makefile
|
%.o: %.cc *.hh Makefile
|
||||||
$(CC) $(CFLAGS) $(CPATHS) -c $< -o $@
|
$(CC) $(CFLAGS) $(CPATHS) -c $< -o $@
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace convolution{
|
||||||
template< typename real_t >
|
template< typename real_t >
|
||||||
void perform( kernel * pk, void *pd )
|
void perform( kernel * pk, void *pd )
|
||||||
{
|
{
|
||||||
// return;
|
//return;
|
||||||
parameters cparam_ = pk->cparam_;
|
parameters cparam_ = pk->cparam_;
|
||||||
double fftnorm = pow(2.0*M_PI,1.5)/sqrt(cparam_.lx*cparam_.ly*cparam_.lz)/sqrt((double)(cparam_.nx*cparam_.ny*cparam_.nz));
|
double fftnorm = pow(2.0*M_PI,1.5)/sqrt(cparam_.lx*cparam_.ly*cparam_.lz)/sqrt((double)(cparam_.nx*cparam_.ny*cparam_.nz));
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ namespace convolution{
|
||||||
dplus = cparam_.pcf->getValue<double>("cosmology","dplus");
|
dplus = cparam_.pcf->getValue<double>("cosmology","dplus");
|
||||||
|
|
||||||
bool
|
bool
|
||||||
bavgfine = cparam_.pcf->getValueSafe<bool>("setup","avg_fine",false),
|
bavgfine = cparam_.pcf->getValueSafe<bool>("setup","avg_fine",true),
|
||||||
bperiodic = cparam_.pcf->getValueSafe<bool>("setup","periodic_TF",true),
|
bperiodic = cparam_.pcf->getValueSafe<bool>("setup","periodic_TF",true),
|
||||||
kspacepoisson = (cparam_.pcf->getValueSafe<bool>("poisson","fft_fine",true)|
|
kspacepoisson = (cparam_.pcf->getValueSafe<bool>("poisson","fft_fine",true)|
|
||||||
cparam_.pcf->getValueSafe<bool>("poisson","kspace",false));
|
cparam_.pcf->getValueSafe<bool>("poisson","kspace",false));
|
||||||
|
@ -401,6 +401,8 @@ namespace convolution{
|
||||||
kkernel[q].im /= cos(kx*kkmax)*cos(ky*kkmax)*cos(kz*kkmax);
|
kkernel[q].im /= cos(kx*kkmax)*cos(ky*kkmax)*cos(kz*kkmax);
|
||||||
///////kkernel[q].re *= ipix;
|
///////kkernel[q].re *= ipix;
|
||||||
///////kkernel[q].im *= ipix;
|
///////kkernel[q].im *= ipix;
|
||||||
|
//kkernel[q].re *= ipix;
|
||||||
|
//kkernel[q].im *= ipix;
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
////////kkernel[q].re /= cos(kx*kkmax)*cos(ky*kkmax)*cos(kz*kkmax);
|
////////kkernel[q].re /= cos(kx*kkmax)*cos(ky*kkmax)*cos(kz*kkmax);
|
||||||
|
|
16
main.cc
16
main.cc
|
@ -49,7 +49,7 @@
|
||||||
#include "transfer_function.hh"
|
#include "transfer_function.hh"
|
||||||
|
|
||||||
#define THE_CODE_NAME "music!"
|
#define THE_CODE_NAME "music!"
|
||||||
#define THE_CODE_VERSION "0.5.0a"
|
#define THE_CODE_VERSION "0.6.0a"
|
||||||
|
|
||||||
|
|
||||||
namespace music
|
namespace music
|
||||||
|
@ -413,7 +413,7 @@ int main (int argc, const char * argv[])
|
||||||
|
|
||||||
refinement_hierarchy rh_TF( rh_Poisson );
|
refinement_hierarchy rh_TF( rh_Poisson );
|
||||||
modify_grid_for_TF( rh_Poisson, rh_TF, cf );
|
modify_grid_for_TF( rh_Poisson, rh_TF, cf );
|
||||||
rh_TF.output();
|
//rh_TF.output();
|
||||||
|
|
||||||
|
|
||||||
if( !the_transfer_function_plugin->tf_is_distinct() && do_baryons )
|
if( !the_transfer_function_plugin->tf_is_distinct() && do_baryons )
|
||||||
|
@ -469,9 +469,15 @@ int main (int argc, const char * argv[])
|
||||||
{
|
{
|
||||||
if( bdefd )
|
if( bdefd )
|
||||||
{
|
{
|
||||||
data_forIO = f;
|
//data_forIO = f;
|
||||||
poisson_hybrid(*data_forIO.get_grid(data_forIO.levelmax()), icoord, grad_order, data_forIO.levelmin()==data_forIO.levelmax());
|
//poisson_hybrid(*data_forIO.get_grid(data_forIO.levelmax()), icoord, grad_order, data_forIO.levelmin()==data_forIO.levelmax());
|
||||||
|
//the_poisson_solver->gradient_add(icoord, u, data_forIO );
|
||||||
|
////
|
||||||
|
data_forIO.zero();
|
||||||
|
*data_forIO.get_grid(data_forIO.levelmax()) = *f.get_grid(f.levelmax());
|
||||||
|
poisson_hybrid(*data_forIO.get_grid(data_forIO.levelmax()), icoord, grad_order, data_forIO.levelmin()==data_forIO.levelmax());
|
||||||
the_poisson_solver->gradient_add(icoord, u, data_forIO );
|
the_poisson_solver->gradient_add(icoord, u, data_forIO );
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
//... displacement
|
//... displacement
|
||||||
|
@ -529,6 +535,8 @@ int main (int argc, const char * argv[])
|
||||||
//... displacement
|
//... displacement
|
||||||
if(bdefd)
|
if(bdefd)
|
||||||
{
|
{
|
||||||
|
//the_poisson_solver->gradient(icoord, u, data_forIO );
|
||||||
|
////
|
||||||
data_forIO.zero();
|
data_forIO.zero();
|
||||||
*data_forIO.get_grid(data_forIO.levelmax()) = *f.get_grid(f.levelmax());
|
*data_forIO.get_grid(data_forIO.levelmax()) = *f.get_grid(f.levelmax());
|
||||||
poisson_hybrid(*data_forIO.get_grid(data_forIO.levelmax()), icoord, grad_order, data_forIO.levelmin()==data_forIO.levelmax());
|
poisson_hybrid(*data_forIO.get_grid(data_forIO.levelmax()), icoord, grad_order, data_forIO.levelmin()==data_forIO.levelmax());
|
||||||
|
|
44
poisson.cc
44
poisson.cc
|
@ -675,11 +675,11 @@ inline double poisson_hybrid_kernel<2>(int idir, int i, int j, int k, int n )
|
||||||
|
|
||||||
double grad = 1.0, laplace = 1.0;
|
double grad = 1.0, laplace = 1.0;
|
||||||
|
|
||||||
if( idir==0&&i!=0 )
|
if( idir==0 )
|
||||||
grad = sin(ki);
|
grad = sin(ki);
|
||||||
else if( idir==1&&j!=0 )
|
else if( idir )
|
||||||
grad = sin(kj);
|
grad = sin(kj);
|
||||||
else if( idir==2&&k!=0 )
|
else //if( idir==2&&k!=0 )
|
||||||
grad = sin(kk);
|
grad = sin(kk);
|
||||||
|
|
||||||
laplace = 2.0*((-cos(ki)+1.0)+(-cos(kj)+1.0)+(-cos(kk)+1.0));
|
laplace = 2.0*((-cos(ki)+1.0)+(-cos(kj)+1.0)+(-cos(kk)+1.0));
|
||||||
|
@ -692,7 +692,10 @@ inline double poisson_hybrid_kernel<2>(int idir, int i, int j, int k, int n )
|
||||||
else if( idir ==2)
|
else if( idir ==2)
|
||||||
kgrad = kk;
|
kgrad = kk;
|
||||||
|
|
||||||
return (kgrad/kr/kr-grad/laplace)*M_PI/n*M_PI/n;
|
//return (kgrad/kr/kr-grad/laplace)*M_PI/n*M_PI/n;
|
||||||
|
//return grad/laplace;
|
||||||
|
return kgrad/kr/kr-grad/laplace;
|
||||||
|
//return kgrad/kr/kr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,8 +733,8 @@ inline double poisson_hybrid_kernel<4>(int idir, int i, int j, int k, int n )
|
||||||
else if( idir ==2)
|
else if( idir ==2)
|
||||||
kgrad = kk;
|
kgrad = kk;
|
||||||
|
|
||||||
return (kgrad/kr/kr-grad/laplace)*M_PI/n*M_PI/n;
|
//return (kgrad/kr/kr-grad/laplace)*M_PI/n*M_PI/n;
|
||||||
|
return kgrad/kr/kr-grad/laplace;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
@ -768,10 +771,7 @@ inline double poisson_hybrid_kernel<6>(int idir, int i, int j, int k, int n )
|
||||||
else if( idir ==2)
|
else if( idir ==2)
|
||||||
kgrad = kk;
|
kgrad = kk;
|
||||||
|
|
||||||
return (kgrad/kr/kr-grad/laplace)*M_PI/n*M_PI/n;//laplace/grad;
|
return kgrad/kr/kr-grad/laplace;
|
||||||
//return kgrad/kr/kr*M_PI/n*M_PI/n;
|
|
||||||
//return grad/laplace*M_PI/n*M_PI/n;
|
|
||||||
//return (kgrad/kr/kr-grad/laplace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -780,23 +780,9 @@ void do_poisson_hybrid( fftw_real* data, int idir, int nxp, int nyp, int nzp, bo
|
||||||
{
|
{
|
||||||
double fftnorm = 1.0/(nxp*nyp*nzp);
|
double fftnorm = 1.0/(nxp*nyp*nzp);
|
||||||
|
|
||||||
|
fftnorm = 1.0/pow(2.0*M_PI,3)/(nxp*nyp*nzp);
|
||||||
|
|
||||||
|
|
||||||
if(periodic)
|
|
||||||
fftnorm *= nxp/(4.0*M_PI*M_PI);//sqrt(8.0);
|
|
||||||
|
|
||||||
|
|
||||||
/*if(periodic)
|
|
||||||
fftnorm *= M_PI*M_PI/nxp/nyp/nzp;
|
|
||||||
else
|
|
||||||
fftnorm *= M_PI*M_PI/nxp/nyp/nzp;
|
|
||||||
|
|
||||||
if( idir == 0 )
|
|
||||||
fftnorm *= nxp;
|
|
||||||
else if( idir == 1 )
|
|
||||||
fftnorm *= nyp;
|
|
||||||
else
|
|
||||||
fftnorm *= nzp;*/
|
|
||||||
|
|
||||||
fftw_complex *cdata = reinterpret_cast<fftw_complex*>(data);
|
fftw_complex *cdata = reinterpret_cast<fftw_complex*>(data);
|
||||||
rfftwnd_plan iplan, plan;
|
rfftwnd_plan iplan, plan;
|
||||||
|
|
||||||
|
@ -859,6 +845,12 @@ void do_poisson_hybrid( fftw_real* data, int idir, int nxp, int nyp, int nzp, bo
|
||||||
|
|
||||||
cdata[ii].re += ksum*fftnorm;
|
cdata[ii].re += ksum*fftnorm;
|
||||||
|
|
||||||
|
//if( i==nxp/2||j==nyp/2||k==nzp/2 )
|
||||||
|
//{
|
||||||
|
// cdata[ii].re = 0.0;
|
||||||
|
// cdata[ii].im = 0.0;
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
cdata[0].re = 0.0;
|
cdata[0].re = 0.0;
|
||||||
cdata[0].im = 0.0;
|
cdata[0].im = 0.0;
|
||||||
|
|
Loading…
Reference in a new issue