X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fcomputational_physics.git;a=blobdiff_plain;f=zentral.c;fp=zentral.c;h=cf071cd699b56a59a62f71240c71a2cbe70eaa78;hp=0000000000000000000000000000000000000000;hb=5df96c501847a0db33e17ab397aa180b538c7ad9;hpb=cede22b7d2a4006a212670776d0395c750f711de diff --git a/zentral.c b/zentral.c new file mode 100644 index 0000000..cf071cd --- /dev/null +++ b/zentral.c @@ -0,0 +1,70 @@ +/* + * zentral.c - teilchen im zentralfeld + * + * usag: ./zentral + * + */ + + +#include +#include +#include +#include +#include "g_plot.h" + +int main(int argc,char **argv) { + double x_p,x,y_p,y,r_3; /* ortsvektor */ + double vx_p,vx,vy_p,vy; /* geschwindigkeitsvektor */ + int steps,i,j; + double tau; + double alpha,f_x,f_y; + int fd; + char filename[64]; + double *buf; + + if(argc!=7) { + printf("usage: %s \n",argv[0]); + return -1; + } + + /* init + starting conditions */ + x_p=atof(argv[1]); y_p=atof(argv[2]); + vx_p=atof(argv[3]); vy_p=atof(argv[4]); + steps=atoi(argv[5]); alpha=atof(argv[6]); + tau=2*M_PI/steps; + sprintf(filename,"zentral_%f_%f_%f_%f_%d_%f.plot",x_p,y_p,vx_p,vy_p,steps,alpha); + fd=gp_init(filename); + + /* allocate memory for data buffer */ + if((buf=(double *)malloc(5*steps*sizeof(double)))==NULL) { + puts("malloc failed!"); + return -1; + } + buf[0]=0; + buf[1]=x_p; buf[2]=y_p; + buf[3]=vx_p; buf[4]=vy_p; + + /* loop */ + for(i=0;i