-
Notifications
You must be signed in to change notification settings - Fork 2
/
Heat3Dplot.py
37 lines (28 loc) · 889 Bytes
/
Heat3Dplot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 31 20:23:24 2018
@author: mathemacode
3D Plot of the exact solution
of the parabolic heat equation problem, just for
refernce and comparison to estimations.
"""
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
def exact(): # 3D plotting of solution for reference
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = np.arange(0, 1, 0.1)
t = np.arange(0, 0.1, 0.005)
t, x = np.meshgrid(t, x)
z = np.exp((-(np.pi)**2)*t) * np.sin(np.pi*x*0.1)
# Format 3D plot itself
ax.plot_surface(t, x, z, cmap=cm.coolwarm, linewidth=0, antialiased=False)
# Additional settings
ax.set_zlim(0, 0.35)
plt.title("Exact Solution")
plt.xlabel("t")
plt.ylabel("x")
plt.show()