14 const double pi = std::numbers::pi;
15 const double L = phys.
L_cm;
16 const double D = phys.
D_cm2h;
19 const int max_k = 200;
21 for (
int k = 0; k < max_k; ++k)
23 double term_k = 2.0 * k + 1.0;
24 double lambda = (term_k * pi) / L;
26 double sine_term = std::sin(lambda * x);
27 double exp_term = std::exp(-D * lambda * lambda * t);
29 sum += (1.0 / term_k) * sine_term * exp_term;
33 return phys.
Tsur + (phys.
Tin - phys.
Tsur) * (4.0 / pi) * sum;
39 std::vector<double> T(x_grid.size());
40 for (
size_t i = 0; i < x_grid.size(); ++i)
43 if (i == 0 || i == x_grid.size() - 1)
49 T[i] =
solve(t, x_grid[i], phys);
static std::vector< double > get_profile(double t, const std::vector< double > &x_grid, const PhysParams &phys)
Generate a full temperature profile for a set of grid points.
static double solve(double t, double x, const PhysParams &phys)
Compute the exact temperature at a given time and position.
Physical parameters of the wall heat conduction problem.
double Tin
Initial temperature [°C].
double D_cm2h
Thermal diffusivity [cm^2/h].
double L_cm
Wall thickness [cm].
double Tsur
Surface (Dirichlet) temperature [°C].