pandoc xelatex
This commit is contained in:
1 parent
96a3da2869
commit
6e738980af
2 files changed
+34
-40
No files matched your search
+34
-40
@@ -10,20 +10,19 @@ $$
|
|||||||
\rho c_p \frac{\partial T}{\partial t} = \lambda \left( \frac{\partial^2 T}{\partial x^2} + \frac{\partial^2 T}{\partial y^2} + \frac{\partial^2 T}{\partial z^2} \right)
|
\rho c_p \frac{\partial T}{\partial t} = \lambda \left( \frac{\partial^2 T}{\partial x^2} + \frac{\partial^2 T}{\partial y^2} + \frac{\partial^2 T}{\partial z^2} \right)
|
||||||
$$
|
$$
|
||||||
|
|
||||||
|
|
||||||
Where:
|
Where:
|
||||||
|
|
||||||
* $T$: Temperature ($^{\circ}C$)
|
- $T$: Temperature ($^{\circ}C$)
|
||||||
|
|
||||||
* $\rho$: Mass density ($kg/m^3$)
|
- $\rho$: Mass density ($kg/m^3$)
|
||||||
|
|
||||||
* $c_p$: Specific heat capacity ($J/(kg \cdot ^{\circ}C)$)
|
- $c_p$: Specific heat capacity ($J/(kg \cdot ^{\circ}C)$)
|
||||||
|
|
||||||
* $\lambda$: Thermal conductivity ($W/(m \cdot ^{\circ}C)$)
|
- $\lambda$: Thermal conductivity ($W/(m \cdot ^{\circ}C)$)
|
||||||
|
|
||||||
* $x, y, z$: Spatial dimensions (m)
|
- $x, y, z$: Spatial dimensions (m)
|
||||||
|
|
||||||
* $t$: Time (s)
|
- $t$: Time (s)
|
||||||
|
|
||||||
For a 1D bar, assuming homogeneous and isotropic material and insulated sides (except for the ends), the equation simplifies to:
|
For a 1D bar, assuming homogeneous and isotropic material and insulated sides (except for the ends), the equation simplifies to:
|
||||||
|
|
||||||
@@ -31,7 +30,6 @@ $$
|
|||||||
\rho c_p \frac{\partial T}{\partial t} = \lambda \frac{\partial^2 T}{\partial x^2}
|
\rho c_p \frac{\partial T}{\partial t} = \lambda \frac{\partial^2 T}{\partial x^2}
|
||||||
$$
|
$$
|
||||||
|
|
||||||
|
|
||||||
This can be rewritten using thermal diffusivity $\alpha = \frac{\lambda}{\rho c_p}$:
|
This can be rewritten using thermal diffusivity $\alpha = \frac{\lambda}{\rho c_p}$:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
@@ -42,7 +40,7 @@ $$
|
|||||||
|
|
||||||
The following sections address the specific questions posed in the project document.
|
The following sections address the specific questions posed in the project document.
|
||||||
|
|
||||||
### Question 1: Express the left term of the equation (\*) using numerical differentiation.
|
### Question 1: Express the left term of the equation (\*) using numerical differentiation
|
||||||
|
|
||||||
The left term is the first partial derivative of temperature with respect to time, $\frac{\partial T}{\partial t}$.
|
The left term is the first partial derivative of temperature with respect to time, $\frac{\partial T}{\partial t}$.
|
||||||
Using a forward finite difference approximation for the time derivative at node $i$ and time step $n$:
|
Using a forward finite difference approximation for the time derivative at node $i$ and time step $n$:
|
||||||
@@ -51,10 +49,9 @@ $$
|
|||||||
\frac{\partial T}{\partial t} \approx \frac{T_i^{n+1} - T_i^n}{\Delta t}
|
\frac{\partial T}{\partial t} \approx \frac{T_i^{n+1} - T_i^n}{\Delta t}
|
||||||
$$
|
$$
|
||||||
|
|
||||||
|
|
||||||
This approximates the rate of temperature change at a specific spatial point $i$ from time $t_n$ to $t_{n+1}$.
|
This approximates the rate of temperature change at a specific spatial point $i$ from time $t_n$ to $t_{n+1}$.
|
||||||
|
|
||||||
### Question 2: Express the right term of the equation (\*) using numerical differentiation.
|
### Question 2: Express the right term of the equation (\*) using numerical differentiation
|
||||||
|
|
||||||
The right term is the second partial derivative of temperature with respect to space, $\frac{\partial^2 T}{\partial x^2}$.
|
The right term is the second partial derivative of temperature with respect to space, $\frac{\partial^2 T}{\partial x^2}$.
|
||||||
Using a central finite difference approximation for the second spatial derivative at node $i$ and time step $n$:
|
Using a central finite difference approximation for the second spatial derivative at node $i$ and time step $n$:
|
||||||
@@ -63,10 +60,9 @@ $$
|
|||||||
\frac{\partial^2 T}{\partial x^2} \approx \frac{T_{i+1}^n - 2T_i^n + T_{i-1}^n}{(\Delta x)^2}
|
\frac{\partial^2 T}{\partial x^2} \approx \frac{T_{i+1}^n - 2T_i^n + T_{i-1}^n}{(\Delta x)^2}
|
||||||
$$
|
$$
|
||||||
|
|
||||||
|
|
||||||
This relates the curvature of the temperature profile at node $i$ to the temperatures of its immediate neighbors at the current time step.
|
This relates the curvature of the temperature profile at node $i$ to the temperatures of its immediate neighbors at the current time step.
|
||||||
|
|
||||||
### Question 3: Reformulate the equation (\*) using the results of Question 1 and 2.
|
### Question 3: Reformulate the equation (\*) using the results of Question 1 and 2
|
||||||
|
|
||||||
Substitute the finite difference approximations into the 1D Heat Equation:
|
Substitute the finite difference approximations into the 1D Heat Equation:
|
||||||
|
|
||||||
@@ -74,10 +70,9 @@ $$
|
|||||||
\frac{T_i^{n+1} - T_i^n}{\Delta t} = \alpha \frac{T_{i+1}^n - 2T_i^n + T_{i-1}^n}{(\Delta x)^2}
|
\frac{T_i^{n+1} - T_i^n}{\Delta t} = \alpha \frac{T_{i+1}^n - 2T_i^n + T_{i-1}^n}{(\Delta x)^2}
|
||||||
$$
|
$$
|
||||||
|
|
||||||
|
|
||||||
Where $\alpha = \frac{\lambda}{\rho c_p}$ is the thermal diffusivity.
|
Where $\alpha = \frac{\lambda}{\rho c_p}$ is the thermal diffusivity.
|
||||||
|
|
||||||
### Question 4: From the new formula of the equation, express $T_i^{n+1}$.
|
### Question 4: From the new formula of the equation, express $T_i^{n+1}$
|
||||||
|
|
||||||
Rearranging the reformulated equation to explicitly solve for the temperature at the next time step $T_i^{n+1}$:
|
Rearranging the reformulated equation to explicitly solve for the temperature at the next time step $T_i^{n+1}$:
|
||||||
|
|
||||||
@@ -85,7 +80,6 @@ $$
|
|||||||
T_i^{n+1} = T_i^n + \alpha \frac{\Delta t}{(\Delta x)^2} (T_{i+1}^n - 2T_i^n + T_{i-1}^n)
|
T_i^{n+1} = T_i^n + \alpha \frac{\Delta t}{(\Delta x)^2} (T_{i+1}^n - 2T_i^n + T_{i-1}^n)
|
||||||
$$
|
$$
|
||||||
|
|
||||||
|
|
||||||
This is the core update equation for each interior node.
|
This is the core update equation for each interior node.
|
||||||
|
|
||||||
For convenience, we define the Fourier number (or numerical stability parameter) $r$:
|
For convenience, we define the Fourier number (or numerical stability parameter) $r$:
|
||||||
@@ -94,7 +88,6 @@ $$
|
|||||||
r = \alpha \frac{\Delta t}{(\Delta x)^2}
|
r = \alpha \frac{\Delta t}{(\Delta x)^2}
|
||||||
$$
|
$$
|
||||||
|
|
||||||
|
|
||||||
So the update equation becomes:
|
So the update equation becomes:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
@@ -112,10 +105,10 @@ The temperature at the right end of the bar ($x=L$) is a fixed boundary conditio
|
|||||||
This means $T_{N_x}^n = 50^{\circ}C$ for all time steps $n$.
|
This means $T_{N_x}^n = 50^{\circ}C$ for all time steps $n$.
|
||||||
|
|
||||||
c. **Initial temperature** $T_0$**:**
|
c. **Initial temperature** $T_0$**:**
|
||||||
The initial temperature of the *internal* nodes of the bar (at time $t=0$) is $T_0 = 0^{\circ}C$.
|
The initial temperature of the _internal_ nodes of the bar (at time $t=0$) is $T_0 = 0^{\circ}C$.
|
||||||
This means $T_i^0 = 0^{\circ}C$ for all internal nodes $i$.
|
This means $T_i^0 = 0^{\circ}C$ for all internal nodes $i$.
|
||||||
|
|
||||||
### Question 6: Write the algorithm to calculate all temperatures at each point of the bar and at any time.
|
### Question 6: Write the algorithm to calculate all temperatures at each point of the bar and at any time
|
||||||
|
|
||||||
The algorithm to solve the 1D Heat Equation using the Explicit Finite Difference Method involves these steps:
|
The algorithm to solve the 1D Heat Equation using the Explicit Finite Difference Method involves these steps:
|
||||||
|
|
||||||
@@ -131,51 +124,52 @@ The algorithm to solve the 1D Heat Equation using the Explicit Finite Difference
|
|||||||
|
|
||||||
6. **Set Up Time Loop:**
|
6. **Set Up Time Loop:**
|
||||||
|
|
||||||
* Create a `time_vector` from `0` to `t_final_s_sim` with step `dt`.
|
- Create a `time_vector` from `0` to `t_final_s_sim` with step `dt`.
|
||||||
|
|
||||||
* Initialize storage for `T_midpoint_over_time` (temperature at the bar's midpoint over all time) and `all_profiles`/`all_profile_times` (full spatial profiles at specific time points for plotting).
|
- Initialize storage for `T_midpoint_over_time` (temperature at the bar's midpoint over all time) and `all_profiles`/`all_profile_times` (full spatial profiles at specific time points for plotting).
|
||||||
|
|
||||||
* Capture the initial profile (`t=0`) if it's one of the `plot_time_points`.
|
- Capture the initial profile (`t=0`) if it's one of the `plot_time_points`.
|
||||||
|
|
||||||
7. **Main Time-Stepping Loop:**
|
7. **Main Time-Stepping Loop:**
|
||||||
|
|
||||||
* Iterate for each time step `n` from the start to `t_final_s_sim`.
|
- Iterate for each time step `n` from the start to `t_final_s_sim`.
|
||||||
|
|
||||||
* **Create `T_next`:** Initialize `T_next` by copying `T_current`. This implicitly carries over the fixed boundary conditions.
|
- **Create `T_next`:** Initialize `T_next` by copying `T_current`. This implicitly carries over the fixed boundary conditions.
|
||||||
|
|
||||||
* **Apply Finite Difference Equation:** For each *internal* node `i` (from index 2 to `Nx-1`), calculate `T_next(i)` using the formula derived in Question 4: `T_next(i) = T_current(i) + r * (T_current(i+1) - 2*T_current(i) + T_current(i-1))`.
|
- **Apply Finite Difference Equation:** For each _internal_ node `i` (from index 2 to `Nx-1`), calculate `T_next(i)` using the formula derived in Question 4: `T_next(i) = T_current(i) + r * (T_current(i+1) - 2*T_current(i) + T_current(i-1))`.
|
||||||
|
|
||||||
* **Update `T_current`:** Set `T_current = T_next` for the next iteration.
|
- **Update `T_current`:** Set `T_current = T_next` for the next iteration.
|
||||||
|
|
||||||
* **Store Data:** Record `T_current(mid_index)` into `T_midpoint_over_time`. If the current time matches a `plot_time_point` (using `ismembertol` with absolute tolerance), store the full `T_current` profile into `all_profiles`.
|
- **Store Data:** Record `T_current(mid_index)` into `T_midpoint_over_time`. If the current time matches a `plot_time_point` (using `ismembertol` with absolute tolerance), store the full `T_current` profile into `all_profiles`.
|
||||||
|
|
||||||
### Question 7: Use MATLAB to solve the equation.
|
### Question 7: Use MATLAB to solve the equation
|
||||||
|
|
||||||
The MATLAB code implements the algorithm described in Question 6 using the specified numerical values for parameters and material properties. The `fprintf` statements provide real-time output of derived constants (thermal diffusivity, Fourier number) and simulation progress.
|
The MATLAB code implements the algorithm described in Question 6 using the specified numerical values for parameters and material properties. The `fprintf` statements provide real-time output of derived constants (thermal diffusivity, Fourier number) and simulation progress.
|
||||||
|
|
||||||
**Key Features of the MATLAB Implementation:**
|
**Key Features of the MATLAB Implementation:**
|
||||||
|
|
||||||
* **Parameter Definition:** All physical and numerical parameters are clearly defined at the beginning of the script.
|
- **Parameter Definition:** All physical and numerical parameters are clearly defined at the beginning of the script.
|
||||||
|
|
||||||
* **Stability Check:** The Fourier number (`r`) is calculated, and a warning is issued if it exceeds `0.5`, indicating potential numerical instability.
|
- **Stability Check:** The Fourier number (`r`) is calculated, and a warning is issued if it exceeds `0.5`, indicating potential numerical instability.
|
||||||
|
|
||||||
* **Grid Initialization:** Spatial and temporal grids are set up, and the initial temperature profile is established with the specified boundary conditions.
|
- **Grid Initialization:** Spatial and temporal grids are set up, and the initial temperature profile is established with the specified boundary conditions.
|
||||||
|
|
||||||
* **Iterative Solution:** A `for` loop efficiently advances the temperature solution through time, updating each internal node based on its neighbors' temperatures from the previous time step.
|
- **Iterative Solution:** A `for` loop efficiently advances the temperature solution through time, updating each internal node based on its neighbors' temperatures from the previous time step.
|
||||||
|
|
||||||
* **Profile Capture:** Specific `plot_time_points` are strategically chosen to capture the temperature profiles during critical phases of heat transfer (early transient, middle, and approaching steady-state). The `unique()` function ensures these points are sorted and distinct.
|
- **Profile Capture:** Specific `plot_time_points` are strategically chosen to capture the temperature profiles during critical phases of heat transfer (early transient, middle, and approaching steady-state). The `unique()` function ensures these points are sorted and distinct.
|
||||||
|
|
||||||
* **Robust Data Storage:** `ismembertol` with an explicit absolute tolerance (`dt/2`, `'DataScale', 1`) is used to accurately match simulation times with `plot_time_points` for storing profiles, avoiding floating-point comparison issues.
|
- **Robust Data Storage:** `ismembertol` with an explicit absolute tolerance (`dt/2`, `'DataScale', 1`) is used to accurately match simulation times with `plot_time_points` for storing profiles, avoiding floating-point comparison issues.
|
||||||
|
|
||||||
* **Visualization:** The results are presented in a two-panel figure:
|
- **Visualization:** The results are presented in a two-panel figure:
|
||||||
|
|
||||||
* The left panel displays multiple **temperature profiles across the bar (Temperature vs. Position)** at the selected `plot_time_points`, illustrating the evolution of the temperature distribution.
|
- The left panel displays multiple **temperature profiles across the bar (Temperature vs. Position)** at the selected `plot_time_points`, illustrating the evolution of the temperature distribution.
|
||||||
|
|
||||||
* The right panel shows the **temperature at the bar's midpoint as a function of time (Temperature vs. Time)**, providing a clear view of how a specific point heats up and approaches equilibrium.
|
- The right panel shows the **temperature at the bar's midpoint as a function of time (Temperature vs. Time)**, providing a clear view of how a specific point heats up and approaches equilibrium.
|
||||||
|
|
||||||
* **Conditional Legend:** A conditional check prevents the legend from being displayed if too many lines are plotted, improving readability.
|
- **Conditional Legend:** A conditional check prevents the legend from being displayed if too many lines are plotted, improving readability.
|
||||||
|
|
||||||
* **Figure Output:** The figure provides a comprehensive visualization of the simulation, demonstrating how the temperature profile changes over time until it reaches a steady-state (linear) distribution between the fixed boundary temperatures.
|
- **Figure Output:** The figure provides a comprehensive visualization of the simulation, demonstrating how the temperature profile changes over time until it reaches a steady-state (linear) distribution between the fixed boundary temperatures.
|
||||||
|
|
||||||
An example of the generated figure (`Figure_1.png`) would be:
|
An example of the generated figure (`Figure_1.png`) would be:
|
||||||

|
|
||||||
|

|
||||||
Binary file not shown.
Reference in new issue
Block a user