Commit df1b947a by Francois Gygi

removed dependency on Context

git-svn-id: http://qboxcode.org/svn/qb/trunk@1336 cba15fb0-1239-40c8-b417-11db7ca47a34
parent 1f5ee0d3
......@@ -29,7 +29,7 @@ using namespace std;
////////////////////////////////////////////////////////////////////////////////
XCPotential::XCPotential(const ChargeDensity& cd, const string functional_name):
cd_(cd), ctxt_(cd.vcontext()), vft_(*cd_.vft()), vbasis_(*cd_.vbasis())
cd_(cd), vft_(*cd_.vft()), vbasis_(*cd_.vbasis())
{
if ( functional_name == "LDA" )
{
......@@ -148,8 +148,9 @@ void XCPotential::update(vector<vector<double> >& vr)
vr[1][i] += v_dn[i];
}
}
double tsum = exc_ * vbasis_.cell().volume() / vft_.np012();
ctxt_.dsum(1,1,&tsum,1);
double sum = exc_ * vbasis_.cell().volume() / vft_.np012();
double tsum;
MPI_Allreduce(&sum,&tsum,1,MPI_DOUBLE,MPI_SUM,vbasis_.comm());
exc_ = tsum;
}
else
......@@ -318,8 +319,9 @@ void XCPotential::update(vector<vector<double> >& vr)
vr[1][ir] += v1_dn[ir] + vxctmp[1][ir];
}
}
double tsum = esum * vbasis_.cell().volume() / vft_.np012();
ctxt_.dsum(1,1,&tsum,1);
double sum = esum * vbasis_.cell().volume() / vft_.np012();
double tsum;
MPI_Allreduce(&sum,&tsum,1,MPI_DOUBLE,MPI_SUM,vbasis_.comm());
exc_ = tsum;
}
}
......@@ -360,11 +362,11 @@ void XCPotential::compute_stress(valarray<double>& sigma_exc)
}
}
const double fac = 1.0 / vft_.np012();
double tsum;
double sum, tsum;
// Next line: factor omega in volume element cancels 1/omega in
// definition of sigma_exc
tsum = - fac * dxc_;
ctxt_.dsum(1,1,&tsum,1);
sum = - fac * dxc_;
MPI_Allreduce(&sum,&tsum,1,MPI_DOUBLE,MPI_SUM,vbasis_.comm());
// Note: contribution to sigma_exc is a multiple of the identity
sigma_exc[0] = tsum;
......@@ -481,16 +483,16 @@ void XCPotential::compute_stress(valarray<double>& sigma_exc)
}
}
double fac = 1.0 / vft_.np012();
double tsum[6];
double sum[6],tsum[6];
// Next line: factor omega in volume element cancels 1/omega in
// definition of sigma_exc
tsum[0] = - fac * ( dsum + sum0 );
tsum[1] = - fac * ( dsum + sum1 );
tsum[2] = - fac * ( dsum + sum2 );
tsum[3] = - fac * sum3;
tsum[4] = - fac * sum4;
tsum[5] = - fac * sum5;
ctxt_.dsum(6,1,&tsum[0],6);
sum[0] = - fac * ( dsum + sum0 );
sum[1] = - fac * ( dsum + sum1 );
sum[2] = - fac * ( dsum + sum2 );
sum[3] = - fac * sum3;
sum[4] = - fac * sum4;
sum[5] = - fac * sum5;
MPI_Allreduce(sum,tsum,6,MPI_DOUBLE,MPI_SUM,vbasis_.comm());
sigma_exc[0] = tsum[0];
sigma_exc[1] = tsum[1];
......
......@@ -32,7 +32,6 @@ class XCPotential
{
private:
const Context& ctxt_;
const ChargeDensity& cd_;
XCFunctional* xcf_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment