Merge branch 'OSO' of github.com:alxvov/lammps into OSO

This commit is contained in:
julient31 2019-07-03 09:38:19 -06:00
commit 5924c558fb
3 changed files with 40 additions and 19 deletions

View File

@ -346,13 +346,13 @@ void MinSpinOSO_CG::calc_search_direction(int iter)
MPI_Allreduce(&g2, &g2_global, 1, MPI_DOUBLE, MPI_SUM, world);
MPI_Allreduce(&g2old, &g2old_global, 1, MPI_DOUBLE, MPI_SUM, world);
// we don't know yet if we need this. Needs to be tested with multiple replica.
// if (update->multireplica == 1) {
// g2 = g2_global;
// g2old = g2old_global;
// MPI_Allreduce(&g2,&g2_global,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
// MPI_Allreduce(&g2old,&g2old_global,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
// }
// Sum over all replicas. Good for GNEB.
if (update->multireplica == 1) {
g2 = g2_global;
g2old = g2old_global;
MPI_Allreduce(&g2,&g2_global,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
MPI_Allreduce(&g2old,&g2old_global,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
}
//if (fabs(g2_global) < 1.0e-40) beta = 0.0;
//else beta = g2_global / g2old_global;

View File

@ -376,7 +376,7 @@ void MinSpinOSO_LBFGS::calc_search_direction(int iter)
MPI_Allreduce(&dyds, &dyds_global, 1, MPI_DOUBLE, MPI_SUM, world);
if (update->multireplica == 1) {
dyds = dyds_global;
MPI_Allreduce(&dyds_global,&dyds,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
MPI_Allreduce(&dyds, &dyds_global, 1,MPI_DOUBLE,MPI_SUM,universe->uworld);
}
if (fabs(dyds_global) > 1.0e-60) rho[m_index] = 1.0 / dyds_global;
@ -403,7 +403,7 @@ void MinSpinOSO_LBFGS::calc_search_direction(int iter)
MPI_Allreduce(&sq, &sq_global, 1, MPI_DOUBLE, MPI_SUM, world);
if (update->multireplica == 1) {
sq = sq_global;
MPI_Allreduce(&sq_global,&sq,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
MPI_Allreduce(&sq,&sq_global,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
}
// update alpha
@ -425,7 +425,7 @@ void MinSpinOSO_LBFGS::calc_search_direction(int iter)
MPI_Allreduce(&yy, &yy_global, 1, MPI_DOUBLE, MPI_SUM, world);
if (update->multireplica == 1) {
yy = yy_global;
MPI_Allreduce(&yy_global,&yy,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
MPI_Allreduce(&yy,&yy_global,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
}
// calculate now search direction
@ -455,7 +455,7 @@ void MinSpinOSO_LBFGS::calc_search_direction(int iter)
MPI_Allreduce(&yr, &yr_global, 1, MPI_DOUBLE, MPI_SUM, world);
if (update->multireplica == 1) {
yr = yr_global;
MPI_Allreduce(&yr_global,&yr,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
MPI_Allreduce(&yr,&yr_global,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
}
beta = rho[c_ind] * yr_global;

View File

@ -216,6 +216,9 @@ int MinSpinOSO_LBFGS_LS::iterate(int maxiter)
}
MPI_Allreduce(&der_e_cur, &der_e_cur_global, 1, MPI_DOUBLE, MPI_SUM, world);
der_e_cur = der_e_cur_global;
if (update->multireplica == 1) {
MPI_Allreduce(&der_e_cur_global,&der_e_cur,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
}
}
if (use_line_search){
@ -405,7 +408,12 @@ void MinSpinOSO_LBFGS_LS::calc_search_direction(int iter)
dyds += ds[m_index][i] * dy[m_index][i];
}
MPI_Allreduce(&dyds, &dyds_global, 1, MPI_DOUBLE, MPI_SUM, world);
if (fabs(dyds) > 1.0e-60) rho[m_index] = 1.0 / dyds_global;
if (update->multireplica == 1) {
dyds = dyds_global;
MPI_Allreduce(&dyds_global,&dyds,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
}
if (fabs(dyds_global) > 1.0e-60) rho[m_index] = 1.0 / dyds_global;
else rho[m_index] = 1.0e60;
// set the q vector
@ -427,7 +435,10 @@ void MinSpinOSO_LBFGS_LS::calc_search_direction(int iter)
sq += ds[c_ind][i] * q[i];
}
MPI_Allreduce(&sq, &sq_global, 1, MPI_DOUBLE, MPI_SUM, world);
if (update->multireplica == 1) {
sq = sq_global;
MPI_Allreduce(&sq_global,&sq,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
}
// update alpha
alpha[c_ind] = rho[c_ind] * sq_global;
@ -445,6 +456,10 @@ void MinSpinOSO_LBFGS_LS::calc_search_direction(int iter)
yy += dy[m_index][i] * dy[m_index][i];
}
MPI_Allreduce(&yy, &yy_global, 1, MPI_DOUBLE, MPI_SUM, world);
if (update->multireplica == 1) {
yy = yy_global;
MPI_Allreduce(&yy_global,&yy,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
}
// calculate now search direction
@ -470,6 +485,10 @@ void MinSpinOSO_LBFGS_LS::calc_search_direction(int iter)
yr += dy[c_ind][i] * p_s[i];
}
MPI_Allreduce(&yr, &yr_global, 1, MPI_DOUBLE, MPI_SUM, world);
if (update->multireplica == 1) {
yr = yr_global;
MPI_Allreduce(&yr_global,&yr,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
}
beta = rho[c_ind] * yr_global;
for (int i = 0; i < 3 * nlocal; i++) {
@ -661,6 +680,9 @@ void MinSpinOSO_LBFGS_LS::make_step(double c, double *energy_and_der)
}
MPI_Allreduce(&der_e_cur, &der_e_cur_global, 1, MPI_DOUBLE, MPI_SUM, world);
der_e_cur = der_e_cur_global;
if (update->multireplica == 1) {
MPI_Allreduce(&der_e_cur_global,&der_e_cur,1,MPI_DOUBLE,MPI_SUM,universe->uworld);
}
energy_and_der[0] = ecurrent;
energy_and_der[1] = der_e_cur;
@ -685,7 +707,6 @@ int MinSpinOSO_LBFGS_LS::calc_and_make_step(double a, double b, int index)
if (awc(der_e_pr, eprevious, e_and_d[1], e_and_d[0]) || index == 3){
MPI_Bcast(&b,1,MPI_DOUBLE,0,world);
for (int i = 0; i < 3 * nlocal; i++) {
p_s[i] = b * p_s[i];
}