# Source code archive - educational

(Difference between revisions)
 Revision as of 07:29, 28 March 2006 (view source)Inkant (Talk | contribs)m (One dimensional stedy state conduction with Heat generation code using C)← Older edit Revision as of 08:01, 9 June 2006 (view source)Praveen (Talk | contribs) (Removed example code; putting it in separate page.)Newer edit → Line 1: Line 1: - #include + * [[One dimensional steady state conduction with heat generation | One dimensional steady state conduction with heat generation code in C]] - #include + - + - #define MAXROWS 10000 + - + - double **GetMatrix(double, double, double, double, double, int); + - void squareoutput(double **, int); + - void nonsquareoutput(double **, int, int); + - double **triangularize(double *[MAXROWS], int, int); + - double *returnsolvector(double **c, int nrows); + - void writeoutputvector(double *p, int nrows); + - + - + - int main(int argc, char **argv) + - { + - + - /* + - Variables chosen: + - GAMMA:  Thermal Conductivity + - L : Length of the domain + - Dx : Node spacing + - */ + - + - double GAMMA, L, Dx, Ta , Tb, Area; + - int N, row; + - double **temp; + - double **aug; + - double *solvector; + - + - + - printf("\nThis program works for only simple 1-D conduction"); + - printf("Is thermal Conductivity constant?"); + - + - + - printf("\nEnter the Value for Heat conductivity"); + - scanf("%lf", &GAMMA); + - printf("\nEnter the Length of the computational domain"); + - scanf("%lf", &L); + - printf("\nEnter the cross-sectional area of the computational domain"); + - scanf("%lf", &Area); + - printf("\nEnter the temperature at the ends of the domain"); + - scanf("%lf %lf", &Ta, &Tb); + - printf("\nEnter the number of Nodes u want to be chosen for analysis"); + - scanf("%d", &N); + - + - temp=(double **) malloc(N*sizeof(double *)); + - for(row=0;row0; temp--) + - { + - if ((tri[temp]+temp)==0)continue; + - else + - { + - for(row=temp; row>0; row--) + - { + - for(k=row-1; k>=0; k--) + - { + - if( *(tri[k]+temp)==0) + - continue; + - else + - coef= (*(tri[k]+temp))/(*(tri[temp]+temp)); + - for(col=0; col