import math
import matplotlib.pyplot as plt
# list=[0.001,0.002,0.003,0.004,0.005,0.006,0.007,0.008,0.009];
# for i in list:
# re = 1/i**2;
# print(str(i)+":"+str(re));
#
# Re=2.09*10**6;
# res =1/math.sqrt(Re);
# print(res)
#MODEL 1 2 3
#1 ISO
#2 NMIJ-2013
#3 NIM-2016
# MODEL = 3;
#test point
p1Re = 1.06*math.pow(10,6);
p2Re = 3.5*math.pow(10,6);
Cd1 = [];
Cd2 = [];
Cd3 = [];
Cd4 = [];
Cd5 = [];
stepLen = 1000;
start = math.pow(10,5);
end = math.pow(10,7);
start2 = 2.1*math.pow(10,4);
end2 = 1.2*math.pow(10,6);
count = (end - start)/stepLen; # len = 9900000 count = 9900
print("count="+str(count));
count2 = (end2 - start2)/stepLen; # len = 9900000 count = 9900
print("count2="+str(count2));
Re2 = [];
for i in range(int(count2)):
reVal = start2 + i * stepLen;
Re2.append(reVal);
a = 0.9985;
b = 3.412;
n = 0.5;
value = a - b / math.sqrt(Re2[i]); # ISO 9300-n JJG6202008 临界流文丘里喷嘴
Cd4.append(value);
Re3 = [];
start3 = 1.5*math.pow(10,4);
end3 = 2.0*math.pow(10,6);
count3 = (end3 - start3)/stepLen; # len = 9900000 count = 9900
print("count3="+str(count3));
for i in range(int(count3)):
reVal = start3 + i * stepLen;
Re3.append(reVal);
value = 1.0118 - 0.5476* math.pow(reVal,-0.2) + 5.5616 * math.pow(reVal,-0.4) - 25.795 * math.pow(reVal,-0.6);
Cd5.append(value);
for MODEL in range(1,5):
print(MODEL)
Re = [];
reVal = 0;
for i in range(int(count)):
reVal = start + i * stepLen;
Re.append(reVal);
if MODEL == 1:
a = 0.9959;
b = -2.7200;
value = a + b / math.sqrt(Re[i]); #ISO 9300-n
Cd1.append(value);
# yp11 = a + b / math.sqrt(p1Re); #ISO 9300-n
x_10664_nmi = 6.7 * math.pow(10, 5);
y_10664_nmi9300 = a + b / math.sqrt(x_10664_nmi); # ISO 9300-n
x_10664_cq = 2.09 * math.pow(10, 6);
y_10664_cq9300 = a + b / math.sqrt(x_10664_cq); # ISO 9300-n
elif MODEL == 2:
a = 0.99845;
b = -3.412;
c = -0.00255;
d = 0.692;
e = 19.3;
f = 70000;
partA = a + b / math.sqrt(Re[i]);
partB = (c+d/math.sqrt(Re[i]))/(1+math.exp(e - Re[i]/f));
value = partA+partB; #NIMJ-2013
Cd2.append(value);
partA2 = a + b / math.sqrt(p1Re);
partB2 = (c + d / math.sqrt(p1Re)) / (1 + math.exp(e - p1Re / f));
yp12 = partA2 + partB2;
partA3 = a + b / math.sqrt(p2Re);
partB3 = (c + d / math.sqrt(p2Re)) / (1 + math.exp(e - p2Re / f));
yp13 = partA3 + partB3;
x_10664_cq = 2.09*math.pow(10,6);
partA4 = a + b / math.sqrt(x_10664_cq);
partB4 = (c + d / math.sqrt(x_10664_cq)) / (1 + math.exp(e - x_10664_cq / f));
y_10664_cq_nimj = partA4 + partB4;
x_10664_nmi = 6.7*math.pow(10,5);
partA5 = a + b / math.sqrt(x_10664_nmi);
partB5 = (c + d / math.sqrt(x_10664_nmi)) / (1 + math.exp(e - x_10664_nmi / f));
y_10664_nmi_nimj = partA5 + partB5;
elif MODEL == 3:
a = 0.99982;
b = -4.45681;
c = -0.0041;
d = 1.08767;
e = 7.34612;
f = 120000;
partA = a + b / math.sqrt(Re[i]);
partB = (c + d / math.sqrt(Re[i])) / (1 + math.exp(e - Re[i] / f));
value = partA + partB; #NIM-2016
Cd3.append(value);
partA2 = a + b / math.sqrt(p1Re);
partB2 = (c + d / math.sqrt(p1Re)) / (1 + math.exp(e - p1Re / f));
yp14 = partA2 + partB2;
partA3 = a + b / math.sqrt(p2Re);
partB3 = (c + d / math.sqrt(p2Re)) / (1 + math.exp(e - p2Re / f));
yp15 = partA3 + partB3;
x_10664_cq = 2.09*math.pow(10,6);
partA4 = a + b / math.sqrt(x_10664_cq);
partB4 = (c + d / math.sqrt(x_10664_cq)) / (1 + math.exp(e - x_10664_cq / f));
y_10664_cq_nim = partA4 + partB4;
x_10664_nmi = 6.7 * math.pow(10, 5);
partA5 = a + b / math.sqrt(x_10664_nmi);
partB5 = (c + d / math.sqrt(x_10664_nmi)) / (1 + math.exp(e - x_10664_nmi / f));
y_10664_nmi_nim = partA5 + partB5;
# print(Re)
print("5.55"+str(yp12));
print("5.55"+str(yp13));
plt.plot(Re,Cd1,color="green",label = "curve 1");
plt.plot(Re,Cd2,color="purple",label = "curve 2");
plt.plot(Re,Cd3,color="orange",label = "curve 3");
plt.plot(Re2,Cd4,color="black",label = "curve 4");
plt.plot(Re3,Cd5,color="red",label = "curve 5");
x_10664_nmi = 6.7*math.pow(10,5);
y_10664_nmi = 0.9955;
plt.plot(x_10664_nmi,y_10664_nmi,'o');
x_10664_cq = 2.09*math.pow(10,6);
y_10664_cq = 0.9869;
plt.plot(x_10664_cq,y_10664_cq,'s');
plt.plot(x_10664_cq,y_10664_cq_nimj,'s',color="green");
plt.plot(x_10664_cq,y_10664_cq_nim,'s',color="green");
plt.plot(x_10664_cq,y_10664_cq9300,'s',color="gold");
plt.plot(x_10664_nmi,y_10664_nmi_nimj,'o',color="red");
plt.plot(x_10664_nmi,y_10664_nmi_nim,'o',color="red");
plt.plot(x_10664_nmi,y_10664_nmi9300,'o',color="red");
plt.plot(p1Re,yp12,'p',color="green");
plt.plot(p2Re,yp13,'D',color="green");
plt.plot(p1Re,yp14,'p',color="purple");
plt.plot(p2Re,yp15,'D',color="purple");
plt.legend(["ISO 9300-n","NIMJ-2013","NIM-2016","ISO 9300 GM","Ishibashi-t"])
plt.show();