Heat
Heat transfer: diffusion of heat on lattices and meshes, and cooling towards the surroundings.
CoffeeCupElement(label, visual=None, *, T=90.0, room=20.0, k=0.1)
Bases: Element
Cup of coffee at the temperature T in a room at the temperature room, exchanging heat at the rate k.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the cup. |
required |
visual
|
VisualSpec | None
|
How the cup is drawn, or |
None
|
T
|
Annotated[float, StateSpec()]
|
The initial temperature of the coffee. |
90.0
|
room
|
Annotated[float, ParameterSpec()]
|
The temperature of the room. |
20.0
|
k
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate of heat exchange. |
0.1
|
Examples:
>>> from skcomplex.models.physics.heat import CoffeeCupElement
>>> CoffeeCupElement('coffee', k=0.2).k
0.2
Source code in src/skcomplex/models/physics/heat/_cooling.py
43 44 45 46 47 48 49 50 51 52 53 54 55 | |
HeatElement(label, visual=None, *, u=0.0, D=1.0)
Bases: Element
Site of a plate, with the temperature u and the diffusion coefficient D of heat.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the site. |
required |
visual
|
VisualSpec | None
|
How the site is drawn, or |
None
|
u
|
Annotated[float, StateSpec()]
|
The initial temperature. |
0.0
|
D
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The diffusion coefficient. |
1.0
|
Examples:
>>> from skcomplex.models.physics.heat import HeatElement
>>> HeatElement('site', D=0.5).D
0.5
Source code in src/skcomplex/models/physics/heat/_heat.py
46 47 48 49 50 51 52 53 54 55 56 | |
cooling_coffee(T=90.0, *, room=20.0, k=0.1)
Return a cup of coffee whose temperature relaxes to that of the room, T' = -k (T - T_room).
The heat flow is proportional to the discrepancy between the coffee and the room, a balancing feedback loop, so
hot coffee cools and iced coffee warms, both exponentially with the time constant 1 / k.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
T
|
float
|
The initial temperature of the coffee. |
90.0
|
room
|
float
|
The temperature of the room. |
20.0
|
k
|
float
|
The rate of heat exchange. |
0.1
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the temperature |
Examples:
>>> from skcomplex.models.physics.heat import cooling_coffee
>>> cooling_coffee(T=5.0).elements[0].T
5.0
Source code in src/skcomplex/models/physics/heat/_cooling.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
harmonic(x, y)
Return the harmonic function exp(x) sin(y), a steady temperature known in closed form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
The first coordinates. |
required |
y
|
Array
|
The second coordinates. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
values |
Array
|
The temperatures. |
Examples:
>>> from skcomplex.models.physics.heat import harmonic
>>> float(harmonic(0.0, 0.0))
0.0
Source code in src/skcomplex/models/physics/heat/_heat.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
heat_diffusion(shape=(64, 64), *, D=1.0, spacing=1.0, boundary='zero-flux')
Return heat diffusing on a plate from a hot square in its middle, du/dt = D laplacian(u).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
The number of sites along every dimension. |
(64, 64)
|
D
|
float
|
The diffusion coefficient. |
1.0
|
spacing
|
float
|
The distance between sites. |
1.0
|
boundary
|
str
|
|
'zero-flux'
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the temperature |
Examples:
>>> from skcomplex.models.physics.heat import heat_diffusion
>>> heat_diffusion((10, 10)).elements[0].check().prepare().size_
100
Source code in src/skcomplex/models/physics/heat/_heat.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
heat_l_shape(refine=3, *, D=1.0, temperature=harmonic)
Return heat on the L-shaped domain with fixed boundary temperatures, discretised by linear finite elements.
The plate starts cold inside, and its temperature relaxes to the solution of Laplace's equation with the boundary temperatures. The default boundary temperature is harmonic, so the steady state is known.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
refine
|
int
|
The number of uniform refinements of the mesh. |
3
|
D
|
float
|
The diffusion coefficient. |
1.0
|
temperature
|
Callable[[Array, Array], Array] | float
|
The boundary temperature, a number or a function of the coordinates. |
harmonic
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the temperature |
Examples:
>>> from skcomplex.models.physics.heat import heat_l_shape
>>> heat_l_shape(1).elements[0].check().prepare().size_
21
Source code in src/skcomplex/models/physics/heat/_heat.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |