-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransientConduction.hpp
67 lines (54 loc) · 1.55 KB
/
TransientConduction.hpp
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
#pragma once
#include <iostream>
#include <cmath>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include "cell.hpp"
#include "mesh.hpp"
#include "coef.hpp"
double z(int i){
double z0 = 0.7 + 3*(i-1);
double err = 1;
double BI = h*L/(2*K_steel);
while (abs(err)>1e-6)
{
err = (z0*tan(z0)-BI)/(tan(z0)+z0/pow(cos(z0),2));
z0 = z0 -(z0*tan(z0)-BI)/(tan(z0)+z0/pow(cos(z0),2));
}
return z0;
};
void theoritical_transient_conduction(double x, std::string datFile){
double Bi = h*L/(2*K_steel);
std::cout<<"Bi = "<<Bi<<"\n";
double Fo = 4*diffusivity_steel*t/pow(L,2);
cout<<"Fo = "<<Fo<<"\n";
double T[100];
double dt = 100;
double time = 0;
std::vector<double> Zi(10+1,0);
double Ci;
for (int i = 1; i <= 10; i++)
{
Zi.at(i) = z(i);
}
std::ofstream results;
results.open(datFile);
if(results.is_open()){
for (int i = 0; i < 1000; i++)
{
time = i*dt;
Fo = 4*diffusivity_steel*time/pow(L,2);
for (int m = 1; m <= 10; m++) ///////////////// //////////
{
Ci = 4*sin(Zi[m])/(2*Zi[m] + sin(2*Zi[m]));
T[i] += Ci*exp(-pow(Zi[m],2)*Fo)*cos(Zi[m]*(2*x-L)/L);
}
T[i] = T[i]*(T_0-T_inf) + T_inf;
if(abs(T[i]) < 1e3){
results<<time<<" "<<T[i]<<"\n";
}
}
}
};