1D Heat Equation Solver 1.0
Computational Methods Assignment 2025
Loading...
Searching...
No Matches
analytical.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "types.hpp"
4#include <vector>
5
6/**
7 * @brief Analytical solution for the 1D heat equation.
8 *
9 * Problem:
10 * dT/dt = D * d^2T/dx^2
11 * IC: T(x, 0) = Tin
12 * BC: T(0, t) = T(L, t) = Tsur
13 *
14 * Solution (Series expansion):
15 * T(x,t) = Tsur + (Tin - Tsur) * 4/pi * Sum_{k=0,1,...} [ 1/(2k+1) * sin((2k+1)*pi*x/L) *
16 * exp(-D*((2k+1)*pi/L)^2 * t) ]
17 */
19{
20 public:
21 /**
22 * @brief Compute the exact temperature at a given time and position.
23 * @param t Time [h]
24 * @param x Position [cm]
25 * @param phys Physical parameters (L, D, Tin, Tsur)
26 * @return Temperature [°C]
27 */
28 static double solve(double t, double x, const PhysParams& phys);
29
30 /**
31 * @brief Generate a full temperature profile for a set of grid points.
32 * @param t Time [h]
33 * @param x_grid Vector of positions
34 * @param phys Physical parameters
35 * @return Vector of temperatures corresponding to x_grid
36 */
37 static std::vector<double>
38 get_profile(double t, const std::vector<double>& x_grid, const PhysParams& phys);
39};
Analytical solution for the 1D heat equation.
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.
Definition analytical.cpp:6
Physical parameters of the wall heat conduction problem.
Definition types.hpp:10
Basic physical and numerical parameter types for the 1D heat problem.