You are on page 1of 2

#include <stdio.

h>
#include <math.h>
int main()
{
int i, n=200, it=0;
double t[400], tp[200], a[400][4], b[400], rb, ro, dr, Rb=0.4, h=40, k=40, e[400], maxer, mu,
m=1.58113883008, yb, s[400], tb=363, ta=303;
/*printf("Enter the base radius: ");
scanf("%lf", &rb);
printf("Enter the tip radius: ");
scanf("%lf", &ro);
printf("Enter the base thickness: ");
scanf("%lf", &yb);
printf("\nEnter the number of nodes: ");
scanf("%d", &n);
/*Rb=rb/ro;
yb=yb/2;
m=ro*pow(h/(k*yb), 0.5);*/
mu=0.3;
dr=(1-Rb)/(n-1);
for(i=2;i<=n;i++)
t[i]=0.5;
t[1]=1;
do
{
for(i=1;i<=n;i++)
tp[i]=t[i];
for(i=2;i<n;i++)
{
a[i][1]=1+tp[i]*mu-(mu*0.5*(tp[i+1]-tp[i-1]));
a[i][2]=-2+mu*(tp[i+1]-4*tp[i]+tp[i-1])-((dr*dr*m*m)/Rb)*(Rb+(i-1)*dr);
if(i==(n-1))
a[i][2]=a[i][2]+1+tp[i]*mu+(mu*0.5*(tp[i+1]-tp[i-1]));
a[i][3]=1+tp[i]*mu+(mu*0.5*(tp[i+1]-tp[i-1]));
b[i]=(tp[i]*(tp[i+1]-2*tp[i]+tp[i-1])+pow(0.5*(tp[i+1]-tp[i-1]),2))*mu;
}
b[2]=b[2]-1-tp[2]*mu+(mu*0.5*(tp[3]-tp[1]));
a[2][1]=0;
a[n-1][3]=0;
for(i=3;i<n;i++)
{
a[i][2]=a[i][2]-(a[i][1]/a[i-1][2])*a[i-1][3];
b[i]=b[i]-(a[i][1]/a[i-1][2])*b[i-1];
}
t[n-1]=b[n-1]/a[n-1][2];
for(i=n-2;i>1;i--)
t[i]=(b[i]-a[i][3]*t[i+1])/a[i][2];
t[n]=t[n-1];
maxer=0;
for(i=2;i<n;i++)
{
e[i]=fabs(t[i]-tp[i]);
if(maxer<e[i])
maxer=e[i];
}
it++;
}while(maxer>0.0001);
/*for(i=1;i<=n;i++)
printf("%lf\n", t[i]);*/
for(i=2;i<n;i++)
{
s[i]=((1.0/pow(t[i]+(ta/(tb-ta)),2))*(1+mu*t[i])*pow(t[i+1]-t[i-1],2))/(4*dr*dr);
printf("%lf\n", s[i]);
}
}

You might also like