From: hackbard Date: Sun, 17 Feb 2008 13:33:15 +0000 (+0100) Subject: start of diffusion calc function X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fposic.git;a=commitdiff_plain;h=9b3b22db2ac62d0fc45a072749bdb4ad70d10f99 start of diffusion calc function --- diff --git a/moldyn.c b/moldyn.c index 80cf572..93c72da 100644 --- a/moldyn.c +++ b/moldyn.c @@ -2322,6 +2322,42 @@ int pair_correlation_init(t_moldyn *moldyn,double dr) { return 0; } +int calculate_diffusion_coefficient(t_moldyn *moldyn,double *dc) { + + int i; + t_atom *atom; + t_3dvec dist; + double d2; + int a_cnt; + int b_cnt; + + atom=moldyn->atom; + dc[0]=0; + dc[1]=0; + dc[2]=0; + a_cnt=0; + b_cnt=0; + + for(i=0;icount;i++) { + + v3_sub(&dist,&(atom[i].r),&(atom[i].r_0)); + check_per_bound(moldyn,&dist); + d2=v3_absolute_square(&dist); + + if(atom[i].brand) { + b_cnt+=1; + dc[1]+=d2; + } + else { + a_cnt+=1; + } + + dc[2]+=d2; + } + + return 0; +} + int calculate_pair_correlation(t_moldyn *moldyn,double dr,void *ptr) { int slots;