Skip to content

Instantly share code, notes, and snippets.

@vit1-irk
Created November 23, 2019 02:52
Show Gist options
  • Save vit1-irk/74d99ccaebaac88505770d60bf6b1928 to your computer and use it in GitHub Desktop.
Save vit1-irk/74d99ccaebaac88505770d60bf6b1928 to your computer and use it in GitHub Desktop.
Not fully working?
#include <complex.h>
#include <math.h>
#include <stdio.h>
int main()
{
double a,m,u0,e,h,x,hh;
complex double c1,c2,b,d,g, w,k;
FILE *f;
h=5;
hh=0.001;
m=1;
a=1.5;
u0=2;
f=fopen("f.txt","w");
//for (e=M_PI/(a*a*2*m)+u0-2*h;e<=M_PI/(a*a*2*m)+u0+2*h;e+=h) {
e=M_PI/(a*a*2*m)+u0+2*h;
w=csqrt(2*m*(e-u0));
k=csqrt(2*m*e);
c1=(ccos(w*a)-I*csin(w*a))*(1+k/w)/(2*ccos(w*a)+I*csin(w*a)*(k/w+w/k));
c2=(ccos(w*a)+I*csin(w*a))*(1-k/w)/(2*ccos(w*a)+I*csin(w*a)*(k/w+w/k));
b=(k/w-w/k)*I*csin(w*a)/(2*ccos(w*a)+I*csin(w*a)*(k/w+w/k));
d=2*(ccos(k*a)-I*csin(k*a))/(2*ccos(w*a)+I*csin(w*a)*(k/w+w/k));
for (x=-a;x<=0;x+=hh) {
g=ccos(k*x)*(1+b)+I*csin(k*x)*(1-b);
fprintf(f,"%lf %lf\n",x,cabs(g)*cabs(g));
}
for (x=0;x<=a;x+=hh) {
g=ccos(w*x)*(c1+c2)+I*csin(k*w)*(c1-c2);
fprintf(f,"%lf %lf\n",x,cabs(g)*cabs(g));
}
for (x=a;x<=2*a;x+=hh) {
g=ccos(k*x)*d+csin(k*x)*d;
fprintf(f,"%lf %lf\n",x,cabs(g)*cabs(g));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment