-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab6.py
More file actions
26 lines (22 loc) · 710 Bytes
/
Copy pathlab6.py
File metadata and controls
26 lines (22 loc) · 710 Bytes
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
__author__ = 'fiodar'
from numpy import exp
from pde import *
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D
phi = lambda y: exp(2*y), lambda y: exp(2*y-1)
psi = lambda x: exp(-x), lambda x: exp(2-x)
n = 10
x_bounds = 0, 1
y_bounds = 0, 1
u = dirichlet_problem_2d(x_bounds, y_bounds, phi, psi, n, n, 0.01)
x, y = np.linspace(x_bounds[0], x_bounds[1], n), np.linspace(y_bounds[0], y_bounds[1], n)
x, y = np.meshgrid(x, y)
fig = plt.figure('Dirichlet Problem')
ax = fig.gca(projection='3d')
surf = ax.plot_surface(x, y, u, rstride=2, cstride=2, cmap=cm.coolwarm)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('u')
fig.set_tight_layout(True)
plt.show()