Skip to content

Commit 49be27c

Browse files
committed
Next Steps for adding Force Gradient
1 parent d4d46e3 commit 49be27c

File tree

3 files changed

+65
-6
lines changed

3 files changed

+65
-6
lines changed

integrator.c

+61-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1414
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515
* GNU General Public License for more details.
16-
*
16+
*
1717
* You should have received a copy of the GNU General Public License
1818
* along with tmLQCD. If not, see <http://www.gnu.org/licenses/>.
1919
***********************************************************************/
@@ -28,6 +28,7 @@
2828
#include "global.h"
2929
#include "monomial/monomial.h"
3030
#include "update_momenta.h"
31+
#include "update_momenta_fg.h"
3132
#include "update_gauge.h"
3233
#include "hamiltonian_field.h"
3334
#include "integrator.h"
@@ -43,6 +44,8 @@ static const double omf4_lamb = 0.6822365335719091;
4344
void integrate_2mn(const double tau, const int S, const int halfstep, const double tau2);
4445
/* second order minimal norm integration scheme in velocity version */
4546
void integrate_2mnp(const double tau, const int S, const int halfstep, const double tau2);
47+
/* fourth order force gradient integration scheme */
48+
void integrate_2mnfg(const double tau, const int S, const int halfstep, const double tau2);
4649
/* Leap Frog integration scheme */
4750
void integrate_leap_frog(const double tau, const int S, const int halfstep, const double tau2);
4851
/* fourth order OMF scheme */
@@ -77,6 +80,9 @@ int init_integrator() {
7780
else if(Integrator.type[i] == OMF4) {
7881
Integrator.integrate[i] = &integrate_omf4;
7982
}
83+
else if(Integrator.type[i] == MN2FG) {
84+
Integrator.integrate[i] = &integrate_2mnfg;
85+
}
8086
}
8187
}
8288

@@ -224,12 +230,12 @@ void integrate_2mn(const double tau, const int S, const int halfstep, const doub
224230
}
225231
else {
226232
for(i = 1; i < itgr->n_int[S]; i++){
227-
itgr->integrate[S-1](eps/2., S-1, 0, eps/2.);
233+
itgr->integrate[S-1](eps/2., S-1, 0, eps/2);
228234
update_momenta(itgr->mnls_per_ts[S], oneminus2lambda*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
229-
itgr->integrate[S-1](eps/2., S-1, 0, eps/2.);
235+
itgr->integrate[S-1](eps/2., S-1, 0, eps/2);
230236
update_momenta(itgr->mnls_per_ts[S], 2*itgr->lambda[S]*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
231237
}
232-
itgr->integrate[S-1](eps/2., S-1, 0, eps/2.);
238+
itgr->integrate[S-1](eps/2., S-1, 0, eps/2);
233239
update_momenta(itgr->mnls_per_ts[S], oneminus2lambda*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
234240
if(S == itgr->no_timescales-1) {
235241
itgr->integrate[S-1](eps/2., S-1, 1, eps/2.);
@@ -278,6 +284,55 @@ void integrate_2mnp(const double tau, const int S, const int halfstep, const dou
278284
}
279285
}
280286

287+
/* For 2MNFG lamda MUST be equal to 1/6 */
288+
void integrate_2mnfg(const double tau, const int S, const int halfstep, const double tau2) {
289+
int i,j=0;
290+
integrator * itgr = &Integrator;
291+
double eps,eps2, oneminus2lambda = (1.-2.*itgr->lambda[S]);
292+
293+
if(S == itgr->no_timescales-1) {
294+
dohalfstep(tau, S);
295+
}
296+
297+
eps = tau/((double)itgr->n_int[S]);
298+
eps2 = tau2/((double)itgr->n_int[S]);
299+
if(S == 0) {
300+
301+
for(j = 1; j < itgr->n_int[0]; j++) {
302+
update_gauge(0.5*eps, &itgr->hf);
303+
update_momenta_fg(itgr->mnls_per_ts[0], oneminus2lambda*eps, itgr->no_mnls_per_ts[0], &itgr->hf, eps);
304+
update_gauge(0.5*eps, &itgr->hf);
305+
update_momenta(itgr->mnls_per_ts[0], 2.*itgr->lambda[0]*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
306+
}
307+
update_gauge(0.5*eps, &itgr->hf);
308+
update_momenta_fg(itgr->mnls_per_ts[0], oneminus2lambda*eps, itgr->no_mnls_per_ts[0], &itgr->hf, eps);
309+
update_gauge(0.5*eps, &itgr->hf);
310+
if(halfstep != 1) {
311+
update_momenta(itgr->mnls_per_ts[0], itgr->lambda[0]*(eps+eps2), itgr->no_mnls_per_ts[0], &itgr->hf);
312+
}
313+
}
314+
else {
315+
for(i = 1; i < itgr->n_int[S]; i++){
316+
itgr->integrate[S-1](eps/2., S-1, 0, eps/2);
317+
update_momenta_fg(itgr->mnls_per_ts[S], oneminus2lambda*eps, itgr->no_mnls_per_ts[S], &itgr->hf, eps);
318+
itgr->integrate[S-1](eps/2., S-1, 0, eps/2);
319+
update_momenta(itgr->mnls_per_ts[S], 2*itgr->lambda[S]*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
320+
}
321+
itgr->integrate[S-1](eps/2., S-1, 0, eps/2);
322+
update_momenta_fg(itgr->mnls_per_ts[S], oneminus2lambda*eps, itgr->no_mnls_per_ts[S], &itgr->hf, eps);
323+
if(S == itgr->no_timescales-1) {
324+
itgr->integrate[S-1](eps/2., S-1, 1, eps/2.);
325+
}
326+
else itgr->integrate[S-1](eps/2., S-1, halfstep, eps2/2.);
327+
if(halfstep != 1 && S != itgr->no_timescales-1) {
328+
update_momenta(itgr->mnls_per_ts[S], itgr->lambda[S]*(eps+eps2), itgr->no_mnls_per_ts[S], &itgr->hf);
329+
}
330+
}
331+
332+
if(S == itgr->no_timescales-1) {
333+
dohalfstep(tau, S);
334+
}
335+
}
281336

282337
void integrate_leap_frog(const double tau, const int S, const int halfstep,const double tau2) {
283338
int i;
@@ -329,7 +384,7 @@ void dohalfstep(const double tau, const int S) {
329384
update_momenta(itgr->mnls_per_ts[i], 0.5*eps, itgr->no_mnls_per_ts[i], &itgr->hf);
330385
eps /= ((double)itgr->n_int[i-1]);
331386
}
332-
else if(itgr->type[i] == MN2){
387+
else if((itgr->type[i] == MN2) || (itgr->type[i] == MN2FG)){
333388
update_momenta(itgr->mnls_per_ts[i], itgr->lambda[i]*eps, itgr->no_mnls_per_ts[i], &itgr->hf);
334389
eps /= ((double)itgr->n_int[i-1])*2;
335390
}
@@ -341,7 +396,7 @@ void dohalfstep(const double tau, const int S) {
341396
if(itgr->type[0] == LEAPFROG) {
342397
update_momenta(itgr->mnls_per_ts[0], 0.5*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
343398
}
344-
else if(itgr->type[0] == MN2) {
399+
else if((itgr->type[0] == MN2)||(itgr->type[0] == MN2FG)) {
345400
update_momenta(itgr->mnls_per_ts[0], itgr->lambda[0]*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
346401
}
347402
else if(itgr->type[0] == OMF4) {

integrator.h

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#define MN2 6
3232
#define MN2p 7
3333
#define OMF4 8
34+
#define MN2FG 9
3435

3536
typedef void (*integratefk)(const double, const int, const int, const double);
3637

read_input.l

+3
Original file line numberDiff line numberDiff line change
@@ -1789,6 +1789,9 @@ static inline void rmQuotes(char *str){
17891789
else if(strcmp(type, "OMF4")==0) {
17901790
Integrator.type[a] = OMF4;
17911791
}
1792+
else if(strcmp(type, "2MNFG")==0) {
1793+
Integrator.type[a] = MN2FG;
1794+
}
17921795
else {
17931796
fprintf(stderr, "Unknown integrator type %s in line %d\n", yytext, line_of_file);
17941797
exit(1);

0 commit comments

Comments
 (0)