-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeTwoCellPlot.py
90 lines (81 loc) · 4.09 KB
/
MakeTwoCellPlot.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
84
85
86
87
88
89
90
# ===============================================================================
# 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 two-cell 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/viscosity_data_0.5.npy")
# Parameters
r = 1.0
vol = 746.3163
phis =[]
for x in range(30, 41):
phi = 2*vol/(24*x**2)
#phis.append(float(str(phi*100)[:3]))
phis.append(round(phi*100, 1))
phi_range = np.array(phis)
Ca_range = np.array([i*0.01 for i in range(1, 21)])
### 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 reversed(list(enumerate(phi_range))):
if phi_index % 2 == 0:
continue
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 (two-cell 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 = 18, frameon = False)
if MAKE_PLOT:
fig.savefig("./Pictures/Viscosity_vs_phi_Ca/TwoCellSystem_{}_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 {} (two-cell 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 = 18, frameon = False)
if MAKE_PLOT:
fig.savefig("./Pictures/Viscosity_vs_phi_Ca/TwoCellSystem_{}_vs_phi_{}ErrorBar.png".format("IntrinsicViscosity" if i == 0 else "RelativeViscosity", "with" if j == 0 else "without"), dpi = 300)
plt.close()
else:
plt.show()