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
|
||||
MULTITHREADFFTW = no
|
||||
MULTITHREADFFTW = yes
|
||||
SINGLEPRECISION = no
|
||||
HAVEHDF5 = yes
|
||||
HAVEHDF5 = no
|
||||
|
||||
##############################################################################
|
||||
### compiler and path settings
|
||||
|
@ -53,6 +53,7 @@ all: $(OBJS) $(TARGET)
|
|||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CC) $(LPATHS) -o $@ $^ $(LFLAGS)
|
||||
|
||||
%.o: %.cc *.hh Makefile
|
||||
$(CC) $(CFLAGS) $(CPATHS) -c $< -o $@
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ namespace convolution{
|
|||
dplus = cparam_.pcf->getValue<double>("cosmology","dplus");
|
||||
|
||||
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),
|
||||
kspacepoisson = (cparam_.pcf->getValueSafe<bool>("poisson","fft_fine",true)|
|
||||
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].re *= ipix;
|
||||
///////kkernel[q].im *= ipix;
|
||||
//kkernel[q].re *= ipix;
|
||||
//kkernel[q].im *= ipix;
|
||||
}else{
|
||||
|
||||
////////kkernel[q].re /= cos(kx*kkmax)*cos(ky*kkmax)*cos(kz*kkmax);
|
||||
|
|
14
main.cc
14
main.cc
|
@ -49,7 +49,7 @@
|
|||
#include "transfer_function.hh"
|
||||
|
||||
#define THE_CODE_NAME "music!"
|
||||
#define THE_CODE_VERSION "0.5.0a"
|
||||
#define THE_CODE_VERSION "0.6.0a"
|
||||
|
||||
|
||||
namespace music
|
||||
|
@ -413,7 +413,7 @@ int main (int argc, const char * argv[])
|
|||
|
||||
refinement_hierarchy rh_TF( rh_Poisson );
|
||||
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 )
|
||||
|
@ -469,9 +469,15 @@ int main (int argc, const char * argv[])
|
|||
{
|
||||
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());
|
||||
//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 );
|
||||
|
||||
}
|
||||
else
|
||||
//... displacement
|
||||
|
@ -529,6 +535,8 @@ int main (int argc, const char * argv[])
|
|||
//... displacement
|
||||
if(bdefd)
|
||||
{
|
||||
//the_poisson_solver->gradient(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());
|
||||
|
|
42
poisson.cc
42
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;
|
||||
|
||||
if( idir==0&&i!=0 )
|
||||
if( idir==0 )
|
||||
grad = sin(ki);
|
||||
else if( idir==1&&j!=0 )
|
||||
else if( idir )
|
||||
grad = sin(kj);
|
||||
else if( idir==2&&k!=0 )
|
||||
else //if( idir==2&&k!=0 )
|
||||
grad = sin(kk);
|
||||
|
||||
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)
|
||||
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)
|
||||
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<>
|
||||
|
@ -768,10 +771,7 @@ inline double poisson_hybrid_kernel<6>(int idir, int i, int j, int k, int n )
|
|||
else if( idir ==2)
|
||||
kgrad = kk;
|
||||
|
||||
return (kgrad/kr/kr-grad/laplace)*M_PI/n*M_PI/n;//laplace/grad;
|
||||
//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);
|
||||
return kgrad/kr/kr-grad/laplace;
|
||||
}
|
||||
|
||||
|
||||
|
@ -780,22 +780,8 @@ void do_poisson_hybrid( fftw_real* data, int idir, int nxp, int nyp, int nzp, bo
|
|||
{
|
||||
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);
|
||||
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;
|
||||
|
||||
//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].im = 0.0;
|
||||
|
|
Loading…
Reference in a new issue