From: hackbard Date: Wed, 29 Mar 2006 16:44:28 +0000 (+0000) Subject: started potentials X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eceebe3ee412aa8cea3e6a7f0038883707f78460;p=physik%2Fposic.git started potentials --- diff --git a/Makefile b/Makefile index ff3fbe3..854b5e6 100644 --- a/Makefile +++ b/Makefile @@ -9,4 +9,4 @@ posic: moldyn.o $(OBJS) $(CC) $(CFLAGS) -lm -o $@ $(OBJS) $(LIBS) posic.c clean: - rm -f *.o posic + rm -f *.o posic */*.o diff --git a/moldyn.c b/moldyn.c index b507d65..ecba8ba 100644 --- a/moldyn.c +++ b/moldyn.c @@ -87,25 +87,26 @@ int thermal_init(t_atom *atom,t_random *random,int count,double t) { /* gaussian distribution of velocities */ v3_zero(&p_total); for(i=0;iatom; + count=moldyn->count; + eps=params->epsilon; + sig6=params->sigma6; + sig12=params->sigma12; + + u=0.0; + for(i=0;ib_ptr==random->buffer+RAND_BUFSIZE) { if(random->status&RAND_STAT_VERBOSE) dprintf(random->logfd, "[random] getting new random numbers\n"); - random->b_ptr=random->buffer; if(!(random->status&RAND_STAT_UDEV)) { lseek(random->fd,0,SEEK_SET); dprintf(random->logfd, "[random] warning, rereading random file\n"); } - read(random->fd,random->b_ptr, - RAND_BUFSIZE*sizeof(unsigned int)); + left=RAND_BUFSIZE*sizeof(unsigned int); + while(left) { + left-=read(random->fd, + random->buffer+\ + RAND_BUFSIZE*sizeof(unsigned int)-left, + left); + } if(random->status&RAND_STAT_VERBOSE) dprintf(random->logfd, "[random] got new random numbers\n"); + random->b_ptr=random->buffer; } return(*(random->b_ptr++)); @@ -84,7 +91,7 @@ unsigned int rand_get(t_random *random) { double rand_get_double(t_random *random) { - return(1.0*rand_get(random)/(double)(URAND_MAX+1)); + return(1.0*rand_get(random)/((long long unsigned int)URAND_MAX+1)); } double rand_get_double_linear(t_random *random,double a,double b) { diff --git a/random/random.h b/random/random.h index 8a21276..35d5706 100644 --- a/random/random.h +++ b/random/random.h @@ -26,7 +26,7 @@ typedef struct s_random { #define RAND_STAT_UDEV 0x04 #define RAND_STAT_GAUSS 0x08 -#define RAND_BUFSIZE (1024) /* 16 mega byte */ +#define RAND_BUFSIZE (1024) /* 4 k byte */ #define URAND_MAX 0xffffffff #define URAND_MAX_PLUS_ONE 0x100000000