From fd5bc857b24f3d62944c45f0d55542deba473aeb Mon Sep 17 00:00:00 2001 From: alxvov Date: Tue, 2 Jul 2019 17:03:15 +0000 Subject: [PATCH] calculate energy in the beginning only once --- src/SPIN/min_spin.cpp | 2 +- src/SPIN/min_spin_oso_cg.cpp | 4 ++-- src/SPIN/min_spin_oso_lbfgs.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SPIN/min_spin.cpp b/src/SPIN/min_spin.cpp index 2bddc110e7..2277281e80 100644 --- a/src/SPIN/min_spin.cpp +++ b/src/SPIN/min_spin.cpp @@ -133,7 +133,7 @@ int MinSpin::iterate(int maxiter) // optimize timestep accross processes / replicas // need a force calculation for timestep optimization - energy_force(0); + if (iter == 0) energy_force(0); dts = evaluate_dt(); // apply damped precessional dynamics to the spins diff --git a/src/SPIN/min_spin_oso_cg.cpp b/src/SPIN/min_spin_oso_cg.cpp index 4449832f54..9ed2cb96ea 100644 --- a/src/SPIN/min_spin_oso_cg.cpp +++ b/src/SPIN/min_spin_oso_cg.cpp @@ -180,8 +180,8 @@ int MinSpinOSO_CG::iterate(int maxiter) // optimize timestep accross processes / replicas // need a force calculation for timestep optimization - - energy_force(0); + + if (iter == 0) energy_force(0); dts = evaluate_dt(); calc_gradient(dts); diff --git a/src/SPIN/min_spin_oso_lbfgs.cpp b/src/SPIN/min_spin_oso_lbfgs.cpp index 2283a55e51..b54c42ebfd 100644 --- a/src/SPIN/min_spin_oso_lbfgs.cpp +++ b/src/SPIN/min_spin_oso_lbfgs.cpp @@ -190,7 +190,7 @@ int MinSpinOSO_LBFGS::iterate(int maxiter) // optimize timestep accross processes / replicas // need a force calculation for timestep optimization - energy_force(0); + if (iter == 0) energy_force(0); // dts = evaluate_dt(); // dts = 1.0; calc_gradient(1.0);