-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_points.py
More file actions
100 lines (86 loc) · 2.43 KB
/
plot_points.py
File metadata and controls
100 lines (86 loc) · 2.43 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
97
98
99
100
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 4 10:09:36 2020
@author: Samuel A. Maloney
"""
import numpy as np
# import scipy.linalg as la
import matplotlib as mpl
import matplotlib.pyplot as plt
from PoissonMlsSim import PoissonMlsSim
from ConvectionDiffusionMlsSim import ConvectionDiffusionMlsSim
def g(points):
return np.zeros(len(points), dtype='float64')
def hat(points):
return np.hstack((points > 0.25, points < 0.75)).all(1).astype('float64')
N = 3
dt = 0.01
velocity = np.array([0.1, 0.0], dtype='float64')
diffusivity = np.array([[0.01, 0.],[0., 0.01]], dtype='float64')
kwargs={
'N' : N,
'g' : g,
'dt' : dt,
'u0' : hat,
'velocity' : velocity,
'diffusivity' : diffusivity,
'Nquad' : 1,
'support' : -1,
'form' : 'cubic',
'method' : 'galerkin',
'quadrature' : 'uniform',
'perturbation' : 0 }
# mls = PoissonMlsSim(**kwargs)
mls = ConvectionDiffusionMlsSim(**kwargs)
# clear the current figure, if opened, and set parameters
fig = plt.gcf()
fig.clf()
fig.set_size_inches(15,4.5)
mpl.rc('axes', titlesize='xx-large', labelsize='x-large')
mpl.rc('xtick', labelsize='large')
mpl.rc('ytick', labelsize='large')
plt.subplots_adjust(hspace = 0.3, wspace = 0.25)
plt.rc('axes', axisbelow=True)
plt.subplot(131)
plt.scatter(mls.uNodes()[:,0], mls.uNodes()[:,1], s=100)
plt.scatter(mls.quads[:,0], mls.quads[:,1])
plt.xlabel(r'$x$')
plt.ylabel(r'$y$')
plt.title('1/cell')
# plt.xlim([0.0, 1.0])
# plt.ylim([0.0, 1.0])
plt.margins(0.0)
plt.xticks(np.arange(N+1)/N)
plt.yticks(np.arange(N+1)/N)
plt.grid()
kwargs['Nquad'] = 2
# mls = PoissonMlsSim(**kwargs)
mls = ConvectionDiffusionMlsSim(**kwargs)
plt.subplot(132)
plt.scatter(mls.nodes[:,0], mls.nodes[:,1], s=100)
plt.scatter(mls.quads[:,0], mls.quads[:,1])
plt.xlabel(r'$x$')
plt.title('4/cell, uniform spacing')
# plt.xlim([0.0, 1.0])
# plt.ylim([0.0, 1.0])
plt.margins(0.0)
plt.xticks(np.arange(N+1)/N)
plt.yticks(np.arange(N+1)/N)
plt.grid()
kwargs['Nquad'] = 2
kwargs['quadrature'] = 'gaussian'
# mls = PoissonMlsSim(**kwargs)
mls = ConvectionDiffusionMlsSim(**kwargs)
plt.subplot(133)
plt.scatter(mls.nodes[:,0], mls.nodes[:,1], s=100)
plt.scatter(mls.quads[:,0], mls.quads[:,1])
plt.xlabel(r'$x$')
plt.title('4/cell, Gaussian spacing')
# plt.xlim([0.0, 1.0])
# plt.ylim([0.0, 1.0])
plt.margins(0.0)
plt.xticks(np.arange(N+1)/N)
plt.yticks(np.arange(N+1)/N)
plt.grid()
# plt.savefig("MLS_points.pdf", bbox_inches='tight', pad_inches=0)