-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeSuspensionPlot.py
83 lines (73 loc) · 3.98 KB
/
MakeSuspensionPlot.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
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
# ===============================================================================
# Copyright 2021 An-Jun Liu
# Last Modified Date: 08/24/2022
# ===============================================================================
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
CB_color_cycle = ['blue', 'cyan', 'black',
'red', 'purple', 'brown']
"""
This code is to make the plots of intrinsic and relative viscosity vs Ca and phi for suspension system.
The data is pre-calculated.
"""
MAKE_PLOT = 1
plt.rcParams['font.family'] = 'DeJavu Serif'
plt.rcParams['font.serif'] = ['Times New Roman']
data = np.load("Data/suspension_viscosity_0.5.npy")
# Parameters
phi_range = [2.3994, 2.9993, 3.4492, 3.8991, 4.9488, 5.9986]
Ca_range = [0.01, 0.02, 0.03, 0.06, 0.07, 0.08, 0.09, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2]
### vs Ca
for i in range(2): # run over iv and rv
for j in range(2): # with or wihtout errorbar
fig, ax = plt.subplots(figsize = (12, 9))
line_id = 0
for phi_index, phi in enumerate(phi_range):
phi = round(phi, 1)
if j == 0:
ax.errorbar(Ca_range, data[i, 0, phi_index, :], yerr = data[i, 1, phi_index, :], color=CB_color_cycle[line_id], marker = 's', label = r'$\phi$'+' = {}%'.format(phi), capsize = 2)
else:
ax.plot(Ca_range, data[i, 0, phi_index, :], color=CB_color_cycle[line_id], marker = 's', label = r'$\phi$'+' = {}%'.format(phi))
line_id += 1
#plt.title("{} vs Ca (suspension system)".format(r'$\eta _{int}$' if i == 0 else r'$\eta _{rel}$'), fontsize = 30)
ax.set_xlabel("Ca", fontsize = 30)
ax.set_ylabel(r'$\left[ \eta \right]$' if i == 0 else r'$\eta _{rel}$', fontsize = 30)
ax.tick_params(which='both', labelsize=22.5, width=2, length=8, direction='in')
ax.xaxis.set_major_locator(MaxNLocator(5))
ax.xaxis.set_minor_locator(MaxNLocator(10))
ax.yaxis.set_major_locator(MaxNLocator(5))
ax.yaxis.set_minor_locator(MaxNLocator(10))
ax.legend(fontsize = 20, frameon = False)
if MAKE_PLOT:
fig.savefig("./Pictures/Viscosity_vs_phi_Ca/SuspensionSystem_{}_vs_Ca_{}ErrorBar.png".format("IntrinsicViscosity" if i == 0 else "RelativeViscosity", "with" if j == 0 else "without"), dpi = 300)
plt.close()
else:
plt.show()
### vs phi
for i in range(2): # run over iv and rv
for j in range(2): # with or wihtout errorbar
fig, ax = plt.subplots(figsize = (12, 9))
line_id = 0
for Ca_index, Ca in enumerate(Ca_range):
if not Ca in [0.03, 0.06, 0.08, 0.1, 0.18]: continue
#if Ca_index % 4 != 0: continue
if j == 0:
ax.errorbar(phi_range, data[i, 0, :, Ca_index], yerr = data[i, 1, :, Ca_index], color=CB_color_cycle[line_id], marker = 's', label = 'Ca = {}'.format(Ca), capsize = 2)
else:
ax.plot(phi_range, data[i, 0, :, Ca_index], color=CB_color_cycle[line_id], marker = 's', label = 'Ca = {}'.format(Ca))
line_id += 1
#plt.title("{} vs {} (suspension system)".format(r'$\eta _{int}$' if i == 0 else r'$\eta _{rel}$', r'$\phi$'), fontsize = 30)
ax.set_xlabel("{} (%)".format(r'$\phi$'), fontsize = 30)
ax.set_ylabel(r'$\left[ \eta \right]$' if i == 0 else r'$\eta _{rel}$', fontsize = 30)
ax.tick_params(which='both', labelsize=22.5, width=2, length=8, direction='in')
ax.xaxis.set_major_locator(MaxNLocator(5))
ax.xaxis.set_minor_locator(MaxNLocator(10))
ax.yaxis.set_major_locator(MaxNLocator(5))
ax.yaxis.set_minor_locator(MaxNLocator(10))
ax.legend(fontsize = 20, frameon = False)
if MAKE_PLOT:
fig.savefig("./Pictures/Viscosity_vs_phi_Ca/SuspensionSystem_{}_vs_phi_{}ErrorBar.png".format("IntrinsicViscosity" if i == 0 else "RelativeViscosity", "with" if j == 0 else "without"), dpi = 300)
plt.close()
else:
plt.show()