projects
/
physik
/
posic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
changed signes -> more intuitive!
[physik/posic.git]
/
moldyn.c
diff --git
a/moldyn.c
b/moldyn.c
index
e961ca2
..
415581c
100644
(file)
--- a/
moldyn.c
+++ b/
moldyn.c
@@
-13,6
+13,8
@@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <sys/time.h>
+#include <time.h>
#include <math.h>
#include "moldyn.h"
#include <math.h>
#include "moldyn.h"
@@
-1348,6
+1350,7
@@
int moldyn_integrate(t_moldyn *moldyn) {
char dir[128];
double ds;
double energy_scale;
char dir[128];
double ds;
double energy_scale;
+ struct timeval t1,t2;
//double tp;
sched=&(moldyn->schedule);
//double tp;
sched=&(moldyn->schedule);
@@
-1368,8
+1371,8
@@
int moldyn_integrate(t_moldyn *moldyn) {
moldyn->tau_square=moldyn->tau*moldyn->tau;
moldyn->cutoff_square=moldyn->cutoff*moldyn->cutoff;
moldyn->tau_square=moldyn->tau*moldyn->tau;
moldyn->cutoff_square=moldyn->cutoff*moldyn->cutoff;
- /*
energy scaling factor
*/
-
energy_scale=moldyn->count*EV
;
+ /*
get current time
*/
+
gettimeofday(&t1,NULL)
;
/* calculate initial forces */
potential_force_calc(moldyn);
/* calculate initial forces */
potential_force_calc(moldyn);
@@
-1407,6
+1410,9
@@
return 0;
moldyn->tau_square=moldyn->tau*moldyn->tau;
moldyn->time_steps=sched->runs[sched->count];
moldyn->tau_square=moldyn->tau*moldyn->tau;
moldyn->time_steps=sched->runs[sched->count];
+ /* energy scaling factor (might change!) */
+ energy_scale=moldyn->count*EV;
+
/* integration according to schedule */
for(i=0;i<moldyn->time_steps;i++) {
/* integration according to schedule */
for(i=0;i<moldyn->time_steps;i++) {
@@
-1429,7
+1435,7
@@
return 0;
/* check for log & visualization */
if(e) {
/* check for log & visualization */
if(e) {
- if(!(
i
%e))
+ if(!(
moldyn->total_steps
%e))
dprintf(moldyn->efd,
"%f %f %f %f\n",
moldyn->time,moldyn->ekin/energy_scale,
dprintf(moldyn->efd,
"%f %f %f %f\n",
moldyn->time,moldyn->ekin/energy_scale,
@@
-1437,7
+1443,7
@@
return 0;
get_total_energy(moldyn)/energy_scale);
}
if(m) {
get_total_energy(moldyn)/energy_scale);
}
if(m) {
- if(!(
i
%m)) {
+ if(!(
moldyn->total_steps
%m)) {
momentum=get_total_p(moldyn);
dprintf(moldyn->mfd,
"%f %f %f %f %f\n",moldyn->time,
momentum=get_total_p(moldyn);
dprintf(moldyn->mfd,
"%f %f %f %f %f\n",moldyn->time,
@@
-1446,7
+1452,7
@@
return 0;
}
}
if(p) {
}
}
if(p) {
- if(!(
i
%p)) {
+ if(!(
moldyn->total_steps
%p)) {
dprintf(moldyn->pfd,
"%f %f %f %f %f\n",moldyn->time,
moldyn->p/BAR,moldyn->p_avg/BAR,
dprintf(moldyn->pfd,
"%f %f %f %f %f\n",moldyn->time,
moldyn->p/BAR,moldyn->p_avg/BAR,
@@
-1454,14
+1460,14
@@
return 0;
}
}
if(t) {
}
}
if(t) {
- if(!(
i
%t)) {
+ if(!(
moldyn->total_steps
%t)) {
dprintf(moldyn->tfd,
"%f %f %f\n",
moldyn->time,moldyn->t,moldyn->t_avg);
}
}
if(s) {
dprintf(moldyn->tfd,
"%f %f %f\n",
moldyn->time,moldyn->t,moldyn->t_avg);
}
}
if(s) {
- if(!(
i
%s)) {
+ if(!(
moldyn->total_steps
%s)) {
snprintf(dir,128,"%s/s-%07.f.save",
moldyn->vlsdir,moldyn->time);
fd=open(dir,O_WRONLY|O_TRUNC|O_CREAT,
snprintf(dir,128,"%s/s-%07.f.save",
moldyn->vlsdir,moldyn->time);
fd=open(dir,O_WRONLY|O_TRUNC|O_CREAT,
@@
-1476,20
+1482,27
@@
return 0;
}
}
if(v) {
}
}
if(v) {
- if(!(
i
%v)) {
+ if(!(
moldyn->total_steps
%v)) {
visual_atoms(&(moldyn->vis),moldyn->time,
moldyn->atom,moldyn->count);
}
}
/* display progress */
visual_atoms(&(moldyn->vis),moldyn->time,
moldyn->atom,moldyn->count);
}
}
/* display progress */
- if(!(i%10)) {
- printf("\rsched:%d, steps:%d, T:%3.1f/%3.1f P:%4.1f/%4.1f V:%6.1f",
+ if(!(moldyn->total_steps%10)) {
+ /* get current time */
+ gettimeofday(&t2,NULL);
+
+ printf("\rsched:%d, steps:%d, T:%3.1f/%3.1f P:%4.1f/%4.1f V:%6.1f (%d)",
sched->count,i,
moldyn->t,moldyn->t_avg,
moldyn->p_avg/BAR,moldyn->gp_avg/BAR,
sched->count,i,
moldyn->t,moldyn->t_avg,
moldyn->p_avg/BAR,moldyn->gp_avg/BAR,
- moldyn->volume);
+ moldyn->volume,
+ (int)(t2.tv_sec-t1.tv_sec));
fflush(stdout);
fflush(stdout);
+
+ /* copy over time */
+ t1=t2;
}
/* increase absolute time */
}
/* increase absolute time */