Skip to content

Commit

Permalink
thermal tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
gtheler committed Nov 25, 2023
1 parent ea8516c commit ed229d2
Show file tree
Hide file tree
Showing 12 changed files with 323 additions and 8 deletions.
3 changes: 3 additions & 0 deletions doc/tutorials/120-mazes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ number-sections: true
toc: true
prev_link: ../110-tensile-test
prev_title: \#1 Tensile test
next_link: ../320-thermal
next_title: \#3 Heat conduction

...


Expand Down
3 changes: 3 additions & 0 deletions doc/tutorials/320-thermal/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
README.pdf
*.vtk
*.msh
164 changes: 164 additions & 0 deletions doc/tutorials/320-thermal/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# FeenoX Tutorial \#3: Heat conduction

- [<span class="toc-section-number">1</span> Foreword][]
- [<span class="toc-section-number">1.1</span> Summary][]
- [<span class="toc-section-number">2</span> Linear steady-state
problems][]
- [<span class="toc-section-number">2.1</span> Temperature
conditions][]
- [<span class="toc-section-number">2.1.1</span> Single-material
slab][]
- [<span class="toc-section-number">2.1.2</span> Two-material
slab][]
- [<span class="toc-section-number">2.2</span> Heat flux conditions][]
- [<span class="toc-section-number">2.3</span> Convection
conditions][]
- [<span class="toc-section-number">2.4</span> Volumetric heat
sources][]
- [<span class="toc-section-number">2.5</span> Space-dependent
properties: manufactured solution][]
- [<span class="toc-section-number">3</span> Non-linear state-state
problems][]
- [<span class="toc-section-number">3.1</span> Temperature-dependent
heat flux: radiation][]
- [<span class="toc-section-number">3.2</span> Temperature-dependent
conductivity][]
- [<span class="toc-section-number">3.3</span> Temperature-dependent
sources][]
- [<span class="toc-section-number">4</span> Transient problems][]
- [<span class="toc-section-number">4.1</span> From an arbitrary
initial condition][]
- [<span class="toc-section-number">4.2</span> From a steady state][]

[<span class="toc-section-number">1</span> Foreword]: #sec:foreword
[<span class="toc-section-number">1.1</span> Summary]: #summary
[<span class="toc-section-number">2</span> Linear steady-state problems]:
#linear-steady-state-problems
[<span class="toc-section-number">2.1</span> Temperature conditions]: #temperature-conditions
[<span class="toc-section-number">2.1.1</span> Single-material slab]: #single-material-slab
[<span class="toc-section-number">2.1.2</span> Two-material slab]: #two-material-slab
[<span class="toc-section-number">2.2</span> Heat flux conditions]: #heat-flux-conditions
[<span class="toc-section-number">2.3</span> Convection conditions]: #convection-conditions
[<span class="toc-section-number">2.4</span> Volumetric heat sources]:
#volumetric-heat-sources
[<span class="toc-section-number">2.5</span> Space-dependent properties: manufactured solution]:
#space-dependent-properties-manufactured-solution
[<span class="toc-section-number">3</span> Non-linear state-state problems]:
#non-linear-state-state-problems
[<span class="toc-section-number">3.1</span> Temperature-dependent heat flux: radiation]:
#temperature-dependent-heat-flux-radiation
[<span class="toc-section-number">3.2</span> Temperature-dependent conductivity]:
#temperature-dependent-conductivity
[<span class="toc-section-number">3.3</span> Temperature-dependent sources]:
#temperature-dependent-sources
[<span class="toc-section-number">4</span> Transient problems]: #transient-problems
[<span class="toc-section-number">4.1</span> From an arbitrary initial condition]:
#from-an-arbitrary-initial-condition
[<span class="toc-section-number">4.2</span> From a steady state]: #from-a-steady-state

# Foreword

Welcome to **FeenoX’s tutorial number three**. Here you will learn how
to solve the heat conduction equation with FeenoX in all of its flavors:
linear and non-linear, static and transient.

## Summary

- We start solving steady-state problems. As long as neither of the

1. material properties, nor
2. sources

depend on the temperature $T(\vec{x})$ and

3. the boundary conditions do not depend or depend linearly
on $T(\vec{x})$

then problem is linear. If these three guys depend on space $\vec{x}$
(but not on $T(\vec{x})$, the problem is still linear:

``` feenox
```

- If any of a. b. or c. do depend on the temperature $T(\vec{x})$, then
the problem is non-linear. FeenoX is able to detect this and will
switch to a non-linear solver automatically. You can check this by
passing `--snes_view` in the command line. Here, SNES means “Scalable
Non-linear Equation Solvers” in PETSc’s jargon. The `--snes_view`
option will show some details about the solver. In linear problems,
SNES is not used but the KSP (Krylov SubSpace solvers) framework is
used instead. Therefore, `--snes_view` is empty for linear problems.

- We show how to trigger non-linearities by

- adding a boundary conditions that depends on $T(\vec{x})$, such as
radiation
- having a conductivity that depends on temperature, which is the case
for most materials anyway
- using heat sources that are temperature-dependent, where
increasing $T$ decreases the source

- Finally we show how to solve transient problems, either

1. starting from an arbitrary initial temperature distribution using
constant boundary conditions
2. starting from a steady-state solution and changing the boundary
conditions over time
3. both

# Linear steady-state problems

In this section we are going to ask FeenoX to compute a temperature
distribution $T(\vec{x})$ that satisfies

$$
- \text{div} \Big[ k(\vec{x}) \cdot \text{grad} T(\vec{x}) \Big] = q(\vec{x})
$$

## Temperature conditions

### Single-material slab

### Two-material slab

## Heat flux conditions

These problems need at least one fixed-temperature (a.k.a. Dirichlet)
condition.

## Convection conditions

## Volumetric heat sources

## Space-dependent properties: manufactured solution

# Non-linear state-state problems

The initial guess is given with `T_guess(x,y,z)` (or `T_guess(x,y)` or
`T_guess(x)`).

## Temperature-dependent heat flux: radiation

Mind the units! Kelvin:

Celsius:

## Temperature-dependent conductivity

UO$_2$

## Temperature-dependent sources

[Le Chatelier’s principle][]

[Le Chatelier’s principle]: https://en.wikipedia.org/wiki/Le_Chatelier's_principle

# Transient problems

## From an arbitrary initial condition

UO$_2$

## From a steady state

Pump
108 changes: 108 additions & 0 deletions doc/tutorials/320-thermal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
title: Heat conduction
subtitle: FeenoX Tutorial \#3
titleblock: |
FeenoX Tutorial \#3: Heat conduction
====================================
lang: en-US
number-sections: true
toc: true
prev_link: ../120-mazes
prev_title: \#2 Solving mazes
...

# Summary

Welcome to **FeenoX’s tutorial number three**.
Here you will learn how to solve the heat conduction equation with FeenoX in all of its flavors: linear and non-linear, static and transient.


* We start solving steady-state problems. As long as neither of the

a. material properties, nor
b. sources

depend on the temperature $T(\vec{x})$ and

c. the boundary conditions do not depend or depend linearly on $T(\vec{x})$

then problem is linear.
If these three guys depend on space $\vec{x}$ (but not on $T(\vec{x})$), the problem is still linear no matter how complex it looks like:

```{.feenox include="manufactured.fee"}
```

* If any of a. b. or c. do depend on the temperature $T(\vec{x})$, then the problem is non-linear.
FeenoX is able to detect this and will switch to a non-linear solver automatically.
You can check this by passing `--snes_view` in the command line. Here, SNES means "Scalable Non-linear Equation Solvers" in PETSc's jargon. The `--snes_view` option will show some details about the solver. In linear problems, SNES is not used but the KSP (Krylov SubSpace solvers) framework is used instead. Therefore, `--snes_view` is empty for linear problems.

* We show how to trigger non-linearities by

- adding a boundary conditions that depends on $T(\vec{x})$, such as radiation
- having a conductivity that depends on temperature, which is the case for most materials anyway
- using heat sources that are temperature-dependent, where increasing $T$ decreases the source

* Finally we show how to solve transient problems, either

i. starting from an arbitrary initial temperature distribution using constant boundary conditions
ii. starting from a steady-state solution and changing the boundary conditions over time
iii. both

# Linear steady-state problems

In this section we are going to ask FeenoX to compute a temperature distribution $T(\vec{x})$ that satisfies

$$
- \text{div} \Big[ k(\vec{x}) \cdot \text{grad} \left[ T(\vec{x}) \right] \Big] = q(\vec{x})
$$

along with proper boundary conditions.


## Temperature conditions

### Single-material slab

### Two-material slab

## Heat flux conditions

These problems need at least one fixed-temperature (a.k.a. Dirichlet) condition.

## Convection conditions

## Volumetric heat sources

## Space-dependent properties: manufactured solution


# Non-linear state-state problems

The initial guess is given with `T_guess(x,y,z)` (or `T_guess(x,y)` or `T_guess(x)`).

## Temperature-dependent heat flux: radiation

Mind the units!
Kelvin:

Celsius:

## Temperature-dependent conductivity

UO$_2$

## Temperature-dependent sources

[Le Chatelier's principle](https://en.wikipedia.org/wiki/Le_Chatelier's_principle)


# Transient problems

## From an arbitrary initial condition

UO$_2$

## From a steady state

Pump

1 change: 1 addition & 0 deletions doc/tutorials/320-thermal/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cat .gitignore | sed '/^#.*/ d' | sed '/^\s*$/ d' | sed 's/^/rm -rf /' | grep -v mp4 | bash
20 changes: 20 additions & 0 deletions doc/tutorials/320-thermal/manufactured.fee
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
PROBLEM thermal 2D
READ_MESH square.msh

T_manufactured(x,y) = 1 + sin(2*x)^2 * cos(3*y)^2
k(x,y) = 1 + x - 0.5*y

VAR x' x'' y' y''
q(x,y) = -(derivative(k(x',y) * derivative(T_manufactured(x'',y), x'', x'), x', x) + \
derivative(k(x,y') * derivative(T_manufactured(x,y''), y'', y'), y', y))

BC left T=T_manufactured(x,y)
BC top T=T_manufactured(x,y)
BC bottom q=+(-k(x,y)*derivative(T_manufactured(x,y'),y',y))
BC right q=-(-k(x,y)*derivative(T_manufactured(x',y),x',x))

SOLVE_PROBLEM

WRITE_MESH manufactured.vtk T T_manufactured T(x,y)-T_manufactured(x,y)
INTEGRATE (T(x,y)-T_manufactured(x,y))^2 RESULT e2
PRINT e2
11 changes: 11 additions & 0 deletions doc/tutorials/320-thermal/square.geo
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SetFactory("OpenCASCADE");
Rectangle(1) = {0, 0, 0, 1, 1, 0};

Physical Surface("bulk", 1) = {1};
Physical Curve("left", 2) = {4};
Physical Curve("right", 3) = {2};
Physical Curve("bottom", 4) = {1};
Physical Curve("top", 5) = {3};

Mesh.MeshSizeMax = 1/10;

1 change: 1 addition & 0 deletions doc/tutorials/320-thermal/syntax-feenox.tex
1 change: 1 addition & 0 deletions doc/tutorials/320-thermal/syntax.tex
15 changes: 9 additions & 6 deletions doc/tutorials/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ discussed in the [documentation][], particularly in the
As such, it is a tool that in principle should be used from a
higher-level interface (e.g. a web-based UI such as \<www.caeplex.com\>)
or called from a set of automated scripts following some kind of
parametric or optimization workflow. In any case, if you want to learn
how to create your web-based interface or how to implement an
optimization workflow on your own, you will need to start running simple
cases manually and then increasing the complexity until reaching the
solve state-of-the-art capabilities.
parametric or optimization workflow.

In any case, if you want to learn how to create your web-based interface
or how to implement an optimization workflow on your own, you will need
to start running simple cases manually and then increasing the
complexity until reaching the solve state-of-the-art capabilities.

Recall by reading again the [project’s main README][], that FeenoX is—in
a certain sense—to desktop FEA programs (like [Code_Aster][] with
Expand Down Expand Up @@ -80,9 +81,11 @@ since it is [free and open source software][].
# Physics tutorials

1. The Laplace equation
2. Heat conduction
2. [Heat conduction][]
3. Linear elasticity
4. Modal analysis
5. Thermo-mechanical analysis
6. Neutron diffusion
7. Neutron transport

[Heat conduction]: 320-thermal
2 changes: 1 addition & 1 deletion doc/tutorials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ general.md
# Physics tutorials

1. The Laplace equation
2. Heat conduction
2. [Heat conduction](320-thermal)
3. Linear elasticity
4. Modal analysis
5. Thermo-mechanical analysis
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorials/make.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash -e
for i in . 000-setup 110-tensile-test 120-mazes; do
for i in . 000-setup 110-tensile-test 120-mazes 320-thermal; do
../md2.sh --pdf ${i}/README
../md2.sh --gfm ${i}/README
../md2.sh --html ${i}/README
Expand Down

0 comments on commit ed229d2

Please sign in to comment.