1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;
int main () {
double Material1=0.00001, Material2=0.00004, Material3=0.000006, SpatialPoint=0, Tside, Tinitial, L, time;
double const PI = acos(-1);
double x1, x2;
double Sum, T1, T2;
int n;
double Temp1Series;
cout << "Please enter your T side value. " << "Enter a number between 20 and 25: ";
cin >> Tside;
while (Tside < 20 || Tside > 25)
{
cout << "Error ! Enter number again !: ";
cin >> Tside;
}
cout << "Please enter your T initial value. " << "Enter a number between 50 and 100: ";
cin >> Tinitial;
while (Tinitial < 50 || Tinitial > 100)
{
cout << "Error ! Enter number again !: ";
cin >> Tinitial;
}
cout << "Please enter the thickness of the circuit board (L). " << "Enter a number between 0.005 and 0.008: ";
cin >> L;
while (L < 0.005 || L > 0.008)
{
cout << "Error ! Enter number again !: ";
cin >> L;
}
cout << "Please enter the time after which you want to check the temperature. " << "Enter a number between 1 and 50: ";
cin >> time;
while (time < 1 || time > 50)
{
cout << "Error ! Enter number again!: ";
cin >> time;
}
cout << "Pi = " << PI << endl;
cout << "Please enter the number of your type of material. " << "M1 = 0.00001, M2 = 0.00004 or M3 = 0.000006?: " << endl;
cin >> Material1;
x1 = 0.0025; // this is a value that the user must enter
x2 = 0;
SpatialPoint = L/2;
for(n=1; n <= 100; n++)
{
Temp1Series = exp((-(n*PI)*(n*PI))*(Material1*time)/(L*L))*((1.0-cos(n*PI))/(n*PI))*sin((n*PI*x1)/L);
cout << "Temp1Series = " << Temp1Series << endl;
{ Sum = Sum + Temp1Series;
} cout << "Sum = " << Sum << endl;
T1 = Tside + ((2*(Tinitial - Tside))*(Sum));
T2 = Tside + (2*(Tinitial - Tside))*0;
}
cout << "The final temperature for T(L/2,t) = " << T1 << endl;
cout << "The final temperature for T(0,t) = " << T2 << endl;
return 0;}
|