ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/branches/sync4pymol12/src/mengine/src/minimize.c
(Generate patch)
# Line 3 | Line 3
3   #include "pcwin.h"
4   #include "pcmod.h"
5   #include "utility.h"
6 + #include "job_control.h"
7 + #include <sys/timeb.h>
8 + #include <time.h>
9  
10   // mode
11   #define NONE      0
12   #define  Failure     6
13  
14   double energy(void);
15 < void tncg(int,int,int *,double *,double *, double, double (*)(),  void (*)());
16 < void mqn(int , int, int *,double *,double *, double *, double (*)() );
15 > void tncg(double,int,int,int *,double *,double *, double, double (*)(),  void (*)());
16 > void mqn(double,int , int, int *,double *,double *, double *, double (*)() );
17   void search(int,double *,double *,double *,double *,double,double *,int *,double (*)(),int *);
18   void newton2(int, double *,double *,int *, int *, int *, double *);
19   void hessian(int, double *, int *, int *, int *,double *);
# Line 21 | Line 24
24   double get_total_deriv_x(int i);
25   double get_total_deriv_y(int i);
26   double get_total_deriv_z(int i);
27 + void write_sdf(int);
28  
29   struct t_minvar{
30       double cappa, stpmin, stpmax, angmax;
# Line 44 | Line 48
48   {
49     int i,nvar, iter, icount;
50     double minimum,grdmin;
51 <   double minimiz1();
52 <   double etot;
51 >   //   double minimiz1();
52 >   double etot,stime;
53     double *xx;  //  xx[maxvar];
54     int method, maxvar;
55 +   double start_time;
56 +   struct timeval tv;
57    
58     maxvar = 3*natom;
59     xx = dvector(0,maxvar);
# Line 55 | Line 61
61     grdmin = 1.0;
62     scale2 = 12.0; // bfgs  12.0
63  
64 +   if (job_control.monitor)
65 +     {
66 +     gettimeofday(&tv,NULL);
67 +     start_time = tv.tv_sec + (tv.tv_usec/(double)1000000.0);
68 +     }
69 +   else
70 +     start_time = 0;
71     if (minim_control.method == 1 || minim_control.method == 3 || minim_control.method == 4)
72     {
73       nvar = 0;
# Line 79 | Line 92
92       else
93          grdmin = 0.5;
94        
95 <     mqn(nvar,method, &iter,xx, &minimum, &grdmin, minimiz1 );    
95 >     mqn(start_time,nvar,method, &iter,xx, &minimum, &grdmin, minimiz1 );    
96     }
97  
98     if (grdmin > 1.00)
# Line 105 | Line 118
118              nvar++;
119            }
120          }
121 <        tncg(nvar,method,&iter, xx, &minimum, grdmin,minimiz1, newton2);
121 >        tncg(start_time, nvar,method,&iter, xx, &minimum, grdmin,minimiz1, newton2);
122        
123    
124          nvar = 0;
# Line 131 | Line 144
144         return;      
145     }  
146     free_dvector(xx, 0, maxvar);
147 +   if (job_control.monitor)
148 +     job_control.monitor = FALSE;
149   }
150   // ======================================
151 < void mqn(int nvar,int method,int *iter, double *x,  double *minimum, double *grdmin, double (*fgvalue) ())
151 > void mqn(double start_time,int nvar,int method,int *iter, double *x,  double *minimum, double *grdmin, double (*fgvalue) ())
152   {
153        int i,ncalls,nerror;
154        int niter,period,nstart;
# Line 148 | Line 163
163        double fctmin;
164        int restart, terminate;
165        int maxiter, nextiter,status, maxvar;
166 +      struct timeval tv;
167 +      double end_time,old_time,ttime;
168  
169 +      old_time = start_time;
170        maxvar = 3*natom;
171        x_old = dvector(0,maxvar);
172        g_old = dvector(0,maxvar);
# Line 326 | Line 344
344              else
345               restart = TRUE;
346           }
347 +         // check monitor
348 +         if (job_control.monitor)
349 +           {
350 +             gettimeofday(&tv,NULL);
351 +             end_time = tv.tv_sec + (tv.tv_usec/(double)1000000.0);
352 +             ttime = (end_time-old_time);
353 +             if ( ttime > 0 &&  (ttime > job_control.interval) )
354 +               {
355 +                 //             fprintf(pcmlogfile,"Times: %f %f %f\n",start_time,end_time,ttime);
356 +                 old_time = end_time;
357 +                 write_sdf(0);
358 +               }
359 +           }
360 +         // check abort signal
361  
362       }
363   L_DONE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines