Skip to content

Commit

Permalink
synch
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlutsko committed Sep 9, 2024
1 parent 28ff8b5 commit a19299f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
15 changes: 13 additions & 2 deletions include/Species.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,17 @@ class FMT_Species : public Species
{ convolute_weight_with(TI(i,j),v,result, bConjugate);}

void convolute_weight_with(int pos, const DFT_FFT &v, DFT_FFT &result, bool bConjugate = false) const
{
convolute_weight_with(fmt_weighted_densities[pos].wk(),v,result,bConjugate);
}

void convolute_weight_with(const DFT_Vec_Complex& wk, const DFT_FFT &v, DFT_FFT &result, bool bConjugate = false) const
{
if(v.get_is_dirty() == true) throw std::runtime_error("Need real and fourier parts of input to FMT_Species::convolute_weight_with(...) to be consistent");

result.Four().Schur(v.cFour(), fmt_weighted_densities[pos].wk(),bConjugate);
result.Four().Schur(v.cFour(), wk,bConjugate);
result.do_fourier_2_real();
}
}

// Loop over the weighted densities and ask each one to add its contribution to dPhi
// In other words: SUM_{a} SUM_j d PHI/d n_{a}(j) w_{a}(j-i)
Expand Down Expand Up @@ -637,6 +642,12 @@ class FMT_Species_EOS : public FMT_Species
virtual void calculateForce(bool needsTensor, void *param = NULL);

void add_second_derivative(const DFT_FFT &v, DFT_Vec &d2F, const void *param);

void convolute_eos_eta_weight_with(const DFT_FFT &v, DFT_FFT &result, bool bConjugate = false) const
{ convolute_weight_with(eos_weighted_density_[0].wk(), v, result, bConjugate );}



// double get_eos_measure(long pos) const { return eos_weighted_density_[0].real(pos);}

// TODO
Expand Down
17 changes: 6 additions & 11 deletions src/FMT_Species_EOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ FMT_Species_EOS::FMT_Species_EOS(double D_EOS, EOS &eos, double avdw, Density& d
double FMT_Species_EOS::effDensity(long I)
{
double hsd3 = hsd_*hsd_*hsd_*D_EOS_*D_EOS_*D_EOS_;
// double eta = eos_weighted_density_[0].real(I);
double x = (6/(M_PI*hsd3)) * eos_weighted_density_[0].real(I);
double x = (6/(M_PI*hsd3)) * eos_weighted_density_[0].real(I);

return x;
}
Expand All @@ -58,8 +57,8 @@ double FMT_Species_EOS::get_bulk_dfex(double x, const void *param) const
{
if(eos_.isNull()) return 0;

double eta = M_PI*x*hsd_*hsd_*hsd_/6;
FMT &fmt = *((FMT*) param);
double eta = M_PI*x*hsd_*hsd_*hsd_/6;
FMT &fmt = *((FMT*) param);
double fdft = x*fmt.get_fex(eta) + avdw_*x*x;
return eos_.fex(x) - fdft;
}
Expand All @@ -72,7 +71,6 @@ double FMT_Species_EOS::get_bulk_ddfex_deta(double x, const void *param) const
FMT &fmt = *((FMT*) param);

double dfdft_dx = fmt.get_fex(HSeta) + HSeta*fmt.get_dfex_deta(HSeta) + 2*avdw_*x;

double dx_deta = 6/(M_PI*hsd_*hsd_*hsd_*D_EOS_*D_EOS_*D_EOS_);

return dx_deta*(eos_.f1ex(x) - dfdft_dx);
Expand All @@ -90,7 +88,7 @@ double FMT_Species_EOS::get_bulk_d2dfex_deta2(double x, const void *param) const
double d2fdft_dx2 = dHSeta_dx*(2*fmt.get_dfex_deta(HSeta) + HSeta*fmt.get_d2fex_deta2(HSeta)) + 2*avdw_;

double dx_deta = 6/(M_PI*hsd_*hsd_*hsd_*D_EOS_*D_EOS_*D_EOS_);

return dx_deta*dx_deta*(eos_.f2ex(x) - d2fdft_dx2);
}

Expand Down Expand Up @@ -159,7 +157,6 @@ void FMT_Species_EOS::add_second_derivative(const DFT_FFT &v, DFT_Vec &d2F, cons
int Ny = density1.Ny();
int Nz = density1.Nz();
double dV = density1.dV();
double hsd = getHSD();

// Some working space
DFT_FFT result(Nx,Ny,Nz);
Expand All @@ -169,9 +166,7 @@ void FMT_Species_EOS::add_second_derivative(const DFT_FFT &v, DFT_Vec &d2F, cons

// N.B. the fmt weights have all necessary normalization factors built in, including dV
bool bConjugate = false;
// convolute_eta_weight_with(v, result, bConjugate);
// Psi.Real().IncrementBy(result.Real());
convolute_eta_weight_with(v, Psi, bConjugate);
convolute_eos_eta_weight_with(v, Psi, bConjugate);

// Get Lambda: Lambda(K) = (d2dfex(K)/deta(K) deta(K))psi(K)
DFT_FFT Lambda(Nx,Ny,Nz);
Expand All @@ -188,6 +183,6 @@ void FMT_Species_EOS::add_second_derivative(const DFT_FFT &v, DFT_Vec &d2F, cons

//the fmt weights have all necessary normalization factors built in, including dV
bConjugate = true;
convolute_eta_weight_with(Lambda, result, bConjugate);
convolute_eos_eta_weight_with(Lambda, result, bConjugate);
d2F.IncrementBy_Scaled_Vector(result.Real(),dV);
}

0 comments on commit a19299f

Please sign in to comment.