1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <stdio.h>
void InitialValues(double *ptr_total_force,double *ptr_chain_r, double *ptr_chain_v, double sigma,const int N, const int DI
M){
double randomaux;
for (int i=0;i<N;i++){
for (int d=0;d<DIM;d++){
// vector force
ptr_total_force[i*DIM+d]=0;
// vector positions and velocities
ptr_chain_r[i*DIM+d] = 0.0;
ptr_chain_v[i*DIM+d] = 0.0;
if (d==0){
randomaux = 0.001*i*d; //gsl_rng_uniform_pos(r1);
ptr_chain_r[i*DIM+d] = randomaux;
// vector velocities
randomaux = 0.5*(i-d);//(2*gsl_ran_gaussian(r2,sigma) - 1);
ptr_chain_v[i*DIM+d] = randomaux;
}
}
ptr_chain_r[i*DIM+0] += sigma*i;
printf("%f\t%f\n",ptr_chain_r[i*DIM+0],ptr_chain_v[i*DIM+0]);
}
}
int main(){
const int N=4;
const int DIM=3;
double total_force[N][DIM];
double total_force_old[N][DIM];
double chain_r[N][DIM]; // monomer positions
double chain_v[N][DIM]; // monomer velocities
double sigma = 1.0; // diametro
InitialValues(total_force[0],chain_r[0], chain_v[0],sigma, N, DIM);
printf("-------------\n");
for (int i=0;i<N;i++){
printf("%f\t%f\n",chain_r[i][0],chain_v[i][0]);
}
}
|
0.000000 0.000000
1.000000 0.500000
2.000000 1.000000
3.000000 1.500000
-------------
0.000000 0.000000
1.000000 0.500000
2.000000 1.000000
3.000000 1.500000 |