From: hackbard Date: Fri, 24 Oct 2003 00:45:27 +0000 (+0000) Subject: aded zentral.c X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5df96c501847a0db33e17ab397aa180b538c7ad9;p=physik%2Fcomputational_physics.git aded zentral.c --- diff --git a/.cvsignore b/.cvsignore index 7c417c0..4d09784 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,3 +1,4 @@ *.o -newton *.plot +newton +zentral diff --git a/Makefile b/Makefile index c65ab86..4efb3bd 100644 --- a/Makefile +++ b/Makefile @@ -5,13 +5,16 @@ CFLAGS = -O3 -Wall LIBS = -L/usr/lib -lm API = g_plot.o -OBJS = newton +OBJS = newton zentral all: $(OBJS) newton: $(API) $(CC) $(CFLAGS) -o $@ $(API) $(LIBS) newton.c +zentral: $(API) + $(CC) $(CFLAGS) -o $@ $(API) $(LIBS) zentral.c + clean: rm $(API) $(OBJS) diff --git a/newton.c b/newton.c index ee74b6e..068d892 100644 --- a/newton.c +++ b/newton.c @@ -18,7 +18,7 @@ int main(int argc,char **argv) { int i,j,steps; int fd; /* data file */ double *buf; - char filename[32]; + char filename[64]; if(argc!=5) { printf("usage: %s \n",argv[0]); 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