// Calculation program for displaying saeshore wave by simple simulation 1, Jan. 29 (Sat.), 2009
// y=sin(x-yt)
// file name: wave1.c
#include< stdio.h>
#include< math.h>
void main(void)
{
double pi;// the value of the pi
double x,y,dx,time;// x is the phase, y indicates the wave form, dx is the minute increment of x, and time is the normalized time by wave number.
double xmin,xmax;// the minimum and maximum values of x respectively
double c;// c indicates the degree of an influence of viscousity
int i,imax;
double xx[10001],yy[10001];// Take care of the upper limit of storage memory capacitance.
FILE *fp;
// Setting of the constants
pi=3.14159265;
c=1.;
// Setting of the other parameters
xmin=-2*pi;
xmax=2*pi;
dx=(xmax-xmin)/10000;
// Setting of the normalized time
time=1.25;// the normalized time by wave number
// execution of calculation
i=0;
for(x=xmin+dx;x< xmax;x=x+dx)
{
i++;
y=sin(x);
xx[i]=x+y*time;
yy[i]=y;
printf("i=%d,x=%f,y=%f\n",i,xx[i],yy[i]);
}
imax=i;
// writing the calculated coordinates data (expressed in (x,y) coordinates) into a textfile named "wave1.txt"
fp=fopen("wave1.txt","w");
if(fp==NULL)
{
printf("FILE OPEN ERROR\n");
}
else
{
for(i=1;i<=imax;i++)
{
fprintf(fp,"%f,%f\n",xx[i],yy[i]);
}
fflush(fp);
fclose(fp);
}
printf("end\n");
}// the end of the program
RETURN