asd
This commit is contained in:
parent
2d3873605d
commit
b7d7695faf
940
codes/CS.py
940
codes/CS.py
File diff suppressed because it is too large
Load Diff
@ -586,25 +586,15 @@ def CenterComparison(A,B,C,R,center):
|
|||||||
|
|
||||||
def VelocityChannel(M,repeat,recorder):
|
def VelocityChannel(M,repeat,recorder):
|
||||||
[row,col,numt2] = M.shape
|
[row,col,numt2] = M.shape
|
||||||
|
|
||||||
|
|
||||||
[X,Y] = np.meshgrid(np.linspace(0,col,col),np.linspace(0,row,row))
|
[X,Y] = np.meshgrid(np.linspace(0,col,col),np.linspace(0,row,row))
|
||||||
|
|
||||||
plt.ion()
|
plt.ion()
|
||||||
|
|
||||||
rown = row*6/row
|
rown = row*6/row
|
||||||
coln = col*6/row
|
coln = col*6/row
|
||||||
|
|
||||||
fig = plt.figure()#figsize=(4, 6) , dpi=200)
|
fig = plt.figure()#figsize=(4, 6) , dpi=200)
|
||||||
ax = fig.add_subplot(111, projection='3d')
|
ax = fig.add_subplot(111, projection='3d')
|
||||||
|
|
||||||
|
|
||||||
for rr in range(-1,repeat):
|
for rr in range(-1,repeat):
|
||||||
|
|
||||||
for t in range(numt2):
|
for t in range(numt2):
|
||||||
|
|
||||||
V = M[:,:,t]
|
V = M[:,:,t]
|
||||||
|
|
||||||
#ax.plot_surface(X, Y, V, cmap=plt.cm.magma, vmin=-30, vmax=50, linewidth=0, antialiased=False)
|
#ax.plot_surface(X, Y, V, cmap=plt.cm.magma, vmin=-30, vmax=50, linewidth=0, antialiased=False)
|
||||||
#ax.plot_wireframe(X, Y, V,rcount=20,ccount=20,linewidth=0.5)
|
#ax.plot_wireframe(X, Y, V,rcount=20,ccount=20,linewidth=0.5)
|
||||||
ax.plot_surface(X, Y, V,cmap='magma',vmin=-30, vmax=100, linewidth=0, antialiased=False)
|
ax.plot_surface(X, Y, V,cmap='magma',vmin=-30, vmax=100, linewidth=0, antialiased=False)
|
||||||
@ -615,7 +605,6 @@ def VelocityChannel(M,repeat,recorder):
|
|||||||
ax.set_xlabel('$x$')
|
ax.set_xlabel('$x$')
|
||||||
ax.set_ylabel('$y$')
|
ax.set_ylabel('$y$')
|
||||||
ax.set_zlabel('$v(r)$')
|
ax.set_zlabel('$v(r)$')
|
||||||
|
|
||||||
ax.set_title('phase ' + str(t))
|
ax.set_title('phase ' + str(t))
|
||||||
plt.pause(0.001)
|
plt.pause(0.001)
|
||||||
plt.draw()
|
plt.draw()
|
||||||
@ -634,116 +623,7 @@ def PlotTri(tri,pos,p):
|
|||||||
#ax.plot_trisurf(pos[:,0], pos[:,1], pos[:,2], triangles=tri.simplices, cmap=plt.cm.Spectral,linewidth=0.1,edgecolors='k')
|
#ax.plot_trisurf(pos[:,0], pos[:,1], pos[:,2], triangles=tri.simplices, cmap=plt.cm.Spectral,linewidth=0.1,edgecolors='k')
|
||||||
#ax.tripcolor(pos[:,0], pos[:,1], pos[:,2], triangles=tri.simplices, facecolors=p2.T, edgecolor='black')
|
#ax.tripcolor(pos[:,0], pos[:,1], pos[:,2], triangles=tri.simplices, facecolors=p2.T, edgecolor='black')
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
def PlotPressureDrop(mode):
|
|
||||||
|
|
||||||
barye2mmHg = 1/1333.22387415
|
|
||||||
|
|
||||||
CT = np.loadtxt('Pressure/DROPS/pd_NS_coarse.txt')
|
|
||||||
CT2 = np.loadtxt('Pressure/DROPS/pd_NS_coarse2.txt')
|
|
||||||
|
|
||||||
ref_ao = np.loadtxt('Pressure/DROPS2/refPPE1_coarse.txt')
|
|
||||||
ref = np.loadtxt('Pressure/DROPS2/refPPE1_coarse_leo1.txt')
|
|
||||||
CS2 = np.loadtxt('Pressure/DROPS2/CSPPE2_coarse_leo1.txt')
|
|
||||||
|
|
||||||
|
|
||||||
PPE_CT = np.loadtxt('Pressure/DROPS/pd_PPE_NS_coarse.txt')
|
|
||||||
PPE_CT_leo = np.loadtxt('Pressure/DROPS/pd_PPE_NS_coarse_leo1.txt')
|
|
||||||
|
|
||||||
|
|
||||||
STE_CT = np.loadtxt('Pressure/DROPS/test_STE_R1_coarse.txt')
|
|
||||||
test_STE_CT = np.loadtxt('Pressure/DROPS/test2_STE_R1_coarse_leo1.txt')
|
|
||||||
|
|
||||||
STEint_CT = np.loadtxt('Pressure/DROPS/test_STEint_R1_coarse.txt')
|
|
||||||
test_STEint_CT = np.loadtxt('Pressure/DROPS/test2_STEint_R1_coarse_leo1.txt')
|
|
||||||
|
|
||||||
|
|
||||||
# UNDERSAMPLING
|
|
||||||
PPE_R1_leo1 = np.loadtxt('Pressure/DROPS/test_PPE_R1_coarse_leo1.txt')
|
|
||||||
|
|
||||||
PPE_KT_R2_leo1 = np.loadtxt('Pressure/DROPS/KT_PPE_R2_coarse_leo1.txt')
|
|
||||||
PPE_KT_R4_leo1 = np.loadtxt('Pressure/DROPS/KT_PPE_R4_coarse_leo1.txt')
|
|
||||||
PPE_KT_R8_leo1 = np.loadtxt('Pressure/DROPS/KT_PPE_R8_coarse_leo1.txt')
|
|
||||||
PPE_KT_R12_leo1 = np.loadtxt('Pressure/DROPS/KT_PPE_R12_coarse_leo1.txt')
|
|
||||||
PPE_KT_R20_leo1 = np.loadtxt('Pressure/DROPS/KT_PPE_R20_coarse_leo1.txt')
|
|
||||||
|
|
||||||
PPE_CS_R2_leo1 = np.loadtxt('Pressure/DROPS/CS_PPE_R2_coarse_leo1.txt')
|
|
||||||
PPE_CS_R4_leo1 = np.loadtxt('Pressure/DROPS/CS_PPE_R4_coarse_leo1.txt')
|
|
||||||
PPE_CS_R8_leo1 = np.loadtxt('Pressure/DROPS/CS_PPE_R8_coarse_leo1.txt')
|
|
||||||
PPE_CS_R12_leo1 = np.loadtxt('Pressure/DROPS/CS_PPE_R12_coarse_leo1.txt')
|
|
||||||
PPE_CS_R20_leo1 = np.loadtxt('Pressure/DROPS/CS_PPE_R20_coarse_leo1.txt')
|
|
||||||
|
|
||||||
#CT_fine = np.loadtxt('Pressure/DROPS/pd_NS_fine.txt')
|
|
||||||
#CT_fine_T = np.loadtxt('Pressure/DROPS/pd_NS_fine_T.txt')
|
|
||||||
#PPE_CT_fine = np.loadtxt('Pressure/DROPS/pd_PPE_NS_fine.txt')
|
|
||||||
#PPE_CT_fine_leo3 = np.loadtxt('Pressure/DROPS/pd_PPE_NS_fine_leo3.txt')
|
|
||||||
|
|
||||||
|
|
||||||
tvec2 = np.linspace(0, 2.5 ,PPE_CT_leo.size)
|
|
||||||
tvec = np.linspace(tvec2[1]*0.5 ,2.5+tvec2[1]*0.5 , CT.size)
|
|
||||||
#tvec_T = np.linspace(0,2.5,CT_fine_T.size)
|
|
||||||
|
|
||||||
fig = plt.figure()
|
|
||||||
|
|
||||||
if mode=='KT':
|
|
||||||
plt.plot(tvec,CT,'-k',linewidth=2,label='$ref$')
|
|
||||||
plt.plot(tvec2,PPE_R1_leo1,'xkcd:red',linewidth=2,linestyle='-' , label='$R = 1$')
|
|
||||||
plt.plot(tvec2,PPE_KT_R2_leo1,'xkcd:blue',linewidth=2,linestyle='-' ,label='$R = 2$')
|
|
||||||
plt.plot(tvec2,PPE_KT_R4_leo1,'xkcd:green',linewidth=2,linestyle='-',label='$R = 4$')
|
|
||||||
plt.plot(tvec2,PPE_KT_R8_leo1,'xkcd:orange',linewidth=2,linestyle='-',label='$R = 8$')
|
|
||||||
plt.plot(tvec2,PPE_KT_R20_leo1,'xkcd:magenta',linewidth=2,linestyle='-', label='$R = 20$')
|
|
||||||
plt.title('$kt-BLAST$',fontsize=20)
|
|
||||||
|
|
||||||
if mode=='CS':
|
|
||||||
plt.plot(tvec,CT,'-k',linewidth=2,label='$ref$')
|
|
||||||
plt.plot(tvec2,ref_ao,'xkcd:red',linewidth=2,linestyle='--' , label='$aorta$')
|
|
||||||
plt.plot(tvec2,ref,'xkcd:red',linewidth=2,linestyle='-' , label='$leo$')
|
|
||||||
plt.plot(tvec2,CS2,'xkcd:blue',linewidth=2,linestyle='-' ,label='$R = 2$')
|
|
||||||
|
|
||||||
#plt.plot(tvec2,PPE_R1_leo1,'xkcd:red',linewidth=2,linestyle='-' , label='$R = 1$')
|
|
||||||
#plt.plot(tvec2,PPE_CS_R2_leo1,'xkcd:blue',linewidth=2,linestyle='-' ,label='$R = 2$')
|
|
||||||
#plt.plot(tvec2,PPE_CS_R4_leo1,'xkcd:green',linewidth=2,linestyle='-',label='$R = 4$')
|
|
||||||
#plt.plot(tvec2,PPE_CS_R8_leo1,'xkcd:orange',linewidth=2,linestyle='-',label='$R = 8$')
|
|
||||||
#plt.plot(tvec2,PPE_CS_R20_leo1,'xkcd:magenta',linewidth=2,linestyle='-', label='$R = 20$')
|
|
||||||
plt.title('$Compressed \ \ Sensing$',fontsize=20)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if mode=='STE':
|
|
||||||
plt.plot(tvec,CT,'-k',linewidth=2,label='$ref$')
|
|
||||||
plt.plot(tvec2,STE_CT , 'xkcd:purple' , label='STE-CT aorta')
|
|
||||||
plt.plot(tvec2,test_STE_CT , 'xkcd:purple' , linestyle='--', marker='o', label='STE-CT leo')
|
|
||||||
|
|
||||||
|
|
||||||
if mode=='STEint':
|
|
||||||
plt.plot(tvec,CT,'-k',linewidth=2,label='$ref$')
|
|
||||||
plt.plot(tvec2,STEint_CT, 'xkcd:aquamarine', label='STEint-CT aorta')
|
|
||||||
plt.plot(tvec2,test_STEint_CT, 'xkcd:aquamarine', linestyle='--', marker='o',label='STEint-CT aorta')
|
|
||||||
|
|
||||||
|
|
||||||
plt.ylim([-2,7])
|
|
||||||
plt.xlabel(r'$time \ \ \ (s)$',fontsize=20)
|
|
||||||
plt.ylabel(r'$\delta p \ \ \ (mmHg) $',fontsize=20)
|
|
||||||
plt.legend(fontsize=16)
|
|
||||||
##############################################################################################################################
|
|
||||||
|
|
||||||
|
|
||||||
#fig = plt.figure()
|
|
||||||
#plt.plot(tvec2,CT_fine,'-ok',label='CT')
|
|
||||||
##plt.plot(tvec_T,CT_fine_T,'--k',label='CT T')
|
|
||||||
#plt.plot(tvec2 ,PPE_CT_fine ,'-om',label='PPE-CT aorta')
|
|
||||||
#plt.plot(tvec2 ,PPE_CT_fine_leo3,'-oc',label='PPE-CT leo3')
|
|
||||||
#plt.title('aorta fine')
|
|
||||||
#plt.xlabel(r'$time \ \ (s) $',fontsize=20)
|
|
||||||
#plt.ylabel(r'$\delta p \ \ \ (mmHg) $',fontsize=20)
|
|
||||||
#plt.legend(fontsize=14)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
def Plot_flux(masterpath,meshpath,options,mode,R):
|
def Plot_flux(masterpath,meshpath,options,mode,R):
|
||||||
|
|
||||||
mesh = Mesh()
|
mesh = Mesh()
|
||||||
@ -1090,8 +970,7 @@ def Plot_dP(masterpath,options,mode,R):
|
|||||||
tcat[l-2] = float(row[0])
|
tcat[l-2] = float(row[0])
|
||||||
tcat = tcat+shift_t
|
tcat = tcat+shift_t
|
||||||
ax.plot(tcat[cstar[0]:tcat.size-cstar[1]],catheter[cstar[0]:tcat.size-cstar[1]],'white',linewidth=linesize,linestyle='--',label='$catheter$')
|
ax.plot(tcat[cstar[0]:tcat.size-cstar[1]],catheter[cstar[0]:tcat.size-cstar[1]],'white',linewidth=linesize,linestyle='--',label='$catheter$')
|
||||||
|
|
||||||
|
|
||||||
tm = np.linspace(0,Dt*tend,tend)
|
tm = np.linspace(0,Dt*tend,tend)
|
||||||
ax.set_xlim([-0.05,0.81])
|
ax.set_xlim([-0.05,0.81])
|
||||||
|
|
||||||
@ -1131,226 +1010,7 @@ def Plot_dP(masterpath,options,mode,R):
|
|||||||
|
|
||||||
|
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
def Plot_peaksystole(datapath,options,meshes,dt,R):
|
|
||||||
import pickle
|
|
||||||
barye2mmHg = 1/1333.22387415
|
|
||||||
|
|
||||||
|
|
||||||
for mesh_size in meshes:
|
|
||||||
t_star = 6
|
|
||||||
|
|
||||||
|
|
||||||
PPE_MEAN = np.zeros([len(R)])
|
|
||||||
PPE_STD = np.zeros([len(R)])
|
|
||||||
STE_MEAN = np.zeros([len(R)])
|
|
||||||
STE_STD = np.zeros([len(R)])
|
|
||||||
V_MEAN = np.zeros([len(R)])
|
|
||||||
V_STD = np.zeros([len(R)])
|
|
||||||
|
|
||||||
ref_P = 0
|
|
||||||
ref_V = 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if mesh_size=='Ucoarse':
|
|
||||||
ref_V = 326.95828118309191
|
|
||||||
if mesh_size=='Ufine':
|
|
||||||
ref_V = 232.95021682714497
|
|
||||||
if mesh_size=='Uffine':
|
|
||||||
ref_V = 234.66445211879045
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for l in range(len(R)):
|
|
||||||
if R[l]==0:
|
|
||||||
ref = np.loadtxt('/home/yeye/N_MRI/codes/pressure_drop/'+mesh_size+'/dt' + str(dt) + '/ref_'+mesh_size+'.txt')
|
|
||||||
PPE0_raw = open('/home/yeye/N_MRI/codes/pressure_drop/'+mesh_size+'/dt' + str(dt) + '/R0/pdrop_PPE_impl_stan.dat','rb')
|
|
||||||
STE0_raw = open('/home/yeye/N_MRI/codes/pressure_drop/'+mesh_size+'/dt' + str(dt) + '/R0/pdrop_STE_impl_stan.dat','rb')
|
|
||||||
PPE0 = pickle.load(PPE0_raw)['pdrop']*(-barye2mmHg)
|
|
||||||
STE0 = pickle.load(STE0_raw)['pdrop']*(-barye2mmHg)
|
|
||||||
|
|
||||||
curpath = datapath + 'sequences/aorta_'+mesh_size+'.npz'
|
|
||||||
p = np.load(curpath)
|
|
||||||
px = p['x']
|
|
||||||
py = p['y']
|
|
||||||
pz = p['z']
|
|
||||||
v = np.sqrt(px[:,:,:,t_star]**2 + py[:,:,:,t_star]**2 + pz[:,:,:,t_star]**2)
|
|
||||||
max0 = np.where(v==np.max(v))
|
|
||||||
|
|
||||||
ref_P = ref[6]
|
|
||||||
V_MEAN[l] = ref_V
|
|
||||||
V_STD[l] = 0
|
|
||||||
PPE_MEAN[l] = PPE0[6]
|
|
||||||
PPE_STD[l] = 0
|
|
||||||
STE_MEAN[l] = STE0[6]
|
|
||||||
STE_STD[l] = 0
|
|
||||||
else:
|
|
||||||
PPE_MEAN[l] = np.loadtxt(datapath + 'maxpv/'+mesh_size + '/ppemean_R'+ str(R[l]) +'.txt')
|
|
||||||
PPE_STD[l] = np.loadtxt(datapath + 'maxpv/'+mesh_size + '/ppestd_R'+ str(R[l]) +'.txt')
|
|
||||||
STE_MEAN[l] = np.loadtxt(datapath + 'maxpv/'+mesh_size + '/stemean_R'+ str(R[l]) +'.txt')
|
|
||||||
STE_STD[l] = np.loadtxt(datapath + 'maxpv/'+mesh_size + '/stestd_R'+ str(R[l]) +'.txt')
|
|
||||||
V_MEAN[l] = np.loadtxt(datapath + 'maxpv/'+mesh_size + '/vmean_R'+ str(R[l]) +'.txt')
|
|
||||||
V_STD[l] = np.loadtxt(datapath + 'maxpv/'+mesh_size + '/vstd_R'+ str(R[l]) +'.txt')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
plt.figure(figsize=(10, 6), dpi=100)
|
|
||||||
Rvec = np.linspace(-10,R[-1]+5,100)
|
|
||||||
hline = Rvec*0+ref_P
|
|
||||||
plt.subplot(1,2,1)
|
|
||||||
plt.plot([0],[ref_P],color='k',marker='o',label= '$ref$')
|
|
||||||
plt.plot(Rvec,hline,color='k',linestyle='--')
|
|
||||||
plt.errorbar(R,PPE_MEAN, yerr=PPE_STD,color=options['ppecol'],marker='o',label= '$PPE$')
|
|
||||||
plt.errorbar(R,STE_MEAN, yerr=STE_STD,color=options['stecol'],marker='o',label= '$STE$')
|
|
||||||
plt.xlim([-2,R[-1]+5])
|
|
||||||
plt.ylim([-7,18])
|
|
||||||
plt.xlabel(r'$R$',fontsize=20)
|
|
||||||
plt.title('$Peak \ Systole \ pressure$',fontsize=18)
|
|
||||||
plt.ylabel(r'$ max \ \big ( \delta P \big ) \ \ mmHg$',fontsize=16)
|
|
||||||
|
|
||||||
|
|
||||||
plt.subplot(1,2,2)
|
|
||||||
#plt.plot([0],[ref_V],color='k',marker='o',label= '$ref$')
|
|
||||||
Rvec = np.linspace(-10,R[-1]+5,100)
|
|
||||||
hline = Rvec*0+ref_V
|
|
||||||
plt.plot(Rvec,hline,color='k',linestyle='--')
|
|
||||||
plt.errorbar(R,V_MEAN, yerr=V_STD,color='royalblue',marker='o',label= '$' + mesh_size + '$')
|
|
||||||
plt.xlim([-2,R[-1]+5])
|
|
||||||
plt.ylim([0,350])
|
|
||||||
plt.xlabel(r'$R$',fontsize=20)
|
|
||||||
plt.ylabel(r'$ max \ \big ( v \big ) \ \ cm/s$',fontsize=16)
|
|
||||||
plt.title('$Peak \ Systole \ velocity$',fontsize=18)
|
|
||||||
#plt.legend(fontsize=15)
|
|
||||||
|
|
||||||
plt.annotate('$'+mesh_size+'$', xy=(-0.2, 1.1), xycoords='axes fraction',fontsize=15)
|
|
||||||
|
|
||||||
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
def Plot_peaksystole_flux(datapath,options,meshes,dt,R):
|
|
||||||
import pickle
|
|
||||||
barye2mmHg = 1/1333.22387415
|
|
||||||
|
|
||||||
|
|
||||||
for mesh_size in meshes:
|
|
||||||
t_star = 6
|
|
||||||
PPE_MEAN = np.zeros([len(R)])
|
|
||||||
PPE_STD = np.zeros([len(R)])
|
|
||||||
STE_MEAN = np.zeros([len(R)])
|
|
||||||
STE_STD = np.zeros([len(R)])
|
|
||||||
V_MEAN = np.zeros([len(R)])
|
|
||||||
V_STD = np.zeros([len(R)])
|
|
||||||
Q_MEAN = np.zeros([len(R)])
|
|
||||||
Q_STD = np.zeros([len(R)])
|
|
||||||
|
|
||||||
ref_V = 0
|
|
||||||
|
|
||||||
if mesh_size=='Ucoarse':
|
|
||||||
ref_V = 326.95828118309191
|
|
||||||
if mesh_size=='Ufine':
|
|
||||||
ref_V = 232.95021682714497
|
|
||||||
if 'Uffine' in mesh_size:
|
|
||||||
ref_V = 226.93523675462458
|
|
||||||
maxv1 = 184.05091675316763
|
|
||||||
ref_Q = 454.77517472437495
|
|
||||||
maxq1 = 429.01393994253556
|
|
||||||
|
|
||||||
|
|
||||||
for l in range(len(R)):
|
|
||||||
if R[l]==0:
|
|
||||||
ref = np.loadtxt('/home/yeye/N_MRI/codes/pressure_drop/'+mesh_size+'/dt' + str(dt) + '/ref_'+mesh_size+'.txt')
|
|
||||||
PPE0_raw = open('/home/yeye/N_MRI/codes/pressure_drop/'+mesh_size+'/dt' + str(dt) + '/R0/pdrop_PPE_impl_stan.dat','rb')
|
|
||||||
STE0_raw = open('/home/yeye/N_MRI/codes/pressure_drop/'+mesh_size+'/dt' + str(dt) + '/R0/pdrop_STE_impl_stan.dat','rb')
|
|
||||||
PPE0 = pickle.load(PPE0_raw)['pdrop']*(-barye2mmHg)
|
|
||||||
STE0 = pickle.load(STE0_raw)['pdrop']*(-barye2mmHg)
|
|
||||||
|
|
||||||
curpath = datapath + 'sequences/aorta_'+mesh_size+'.npz'
|
|
||||||
p = np.load(curpath)
|
|
||||||
px = p['x']
|
|
||||||
py = p['y']
|
|
||||||
pz = p['z']
|
|
||||||
v = np.sqrt(px[:,:,:,t_star]**2 + py[:,:,:,t_star]**2 + pz[:,:,:,t_star]**2)
|
|
||||||
max0 = np.where(v==np.max(v))
|
|
||||||
V_MEAN[l] = ref_V
|
|
||||||
V_STD[l] = 0
|
|
||||||
PPE_MEAN[l] = PPE0[6]
|
|
||||||
PPE_STD[l] = 0
|
|
||||||
STE_MEAN[l] = STE0[6]
|
|
||||||
STE_STD[l] = 0
|
|
||||||
elif R[l]==1:
|
|
||||||
PPE_MEAN[l] = 0
|
|
||||||
PPE_STD[l] = 0
|
|
||||||
STE_MEAN[l] = 0
|
|
||||||
STE_STD[l] = 0
|
|
||||||
V_MEAN[l] = maxv1
|
|
||||||
V_STD[l] = 0
|
|
||||||
Q_MEAN[l] = maxq1
|
|
||||||
Q_STD[l] = 0
|
|
||||||
|
|
||||||
else:
|
|
||||||
PPE_MEAN[l] = np.loadtxt(datapath + 'maxpv/'+mesh_size + '/ppemean_R'+ str(R[l]) +'.txt')
|
|
||||||
PPE_STD[l] = np.loadtxt(datapath + 'maxpv/'+mesh_size + '/ppestd_R'+ str(R[l]) +'.txt')
|
|
||||||
STE_MEAN[l] = np.loadtxt(datapath + 'maxpv/'+mesh_size + '/stemean_R'+ str(R[l]) +'.txt')
|
|
||||||
STE_STD[l] = np.loadtxt(datapath + 'maxpv/'+mesh_size + '/stestd_R'+ str(R[l]) +'.txt')
|
|
||||||
V_MEAN[l] = np.loadtxt(datapath + 'maxpv/'+mesh_size + '/vmean_R'+ str(R[l]) +'.txt')
|
|
||||||
V_STD[l] = np.loadtxt(datapath + 'maxpv/'+mesh_size + '/vstd_R'+ str(R[l]) +'.txt')
|
|
||||||
Q_MEAN[l] = -np.loadtxt(datapath + 'maxpv/'+mesh_size + '/Q2_R'+ str(R[l]) +'.txt')
|
|
||||||
Q_STD[l] = -np.loadtxt(datapath + 'maxpv/'+mesh_size + '/Qstd2_R'+ str(R[l]) +'.txt')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
plt.figure(figsize=(15, 5), dpi=100)
|
|
||||||
plt.annotate('$'+mesh_size+'$', xy=(-0.2, 1.1), xycoords='axes fraction',fontsize=15)
|
|
||||||
|
|
||||||
|
|
||||||
Rvec = np.linspace(-10,R[-1]+5,100)
|
|
||||||
plt.subplot(1,3,1)
|
|
||||||
#plt.plot(Rvec,hline,color='k',linestyle='--')
|
|
||||||
plt.errorbar(R,PPE_MEAN, yerr=PPE_STD,color=options['ppecol'],marker='o',label= '$PPE$')
|
|
||||||
plt.errorbar(R,STE_MEAN, yerr=STE_STD,color=options['stecol'],marker='o',label= '$STE$')
|
|
||||||
plt.xlim([-2,R[-1]+5])
|
|
||||||
plt.ylim([-0.1,2.0])
|
|
||||||
plt.xlabel(r'$R$',fontsize=20)
|
|
||||||
plt.legend(fontsize=12,loc=2)
|
|
||||||
plt.title('$ l_2 \ error \ in \ Peak \ pressure$',fontsize=16)
|
|
||||||
plt.xticks(R)
|
|
||||||
plt.ylabel(r'$ || p - p^{ref} ||/|| p^{ref} ||_{l2} $',fontsize=16)
|
|
||||||
|
|
||||||
|
|
||||||
plt.subplot(1,3,2)
|
|
||||||
#plt.plot([0],[ref_V],color='k',marker='o',label= '$ref$')
|
|
||||||
Rvec = np.linspace(-10,R[-1]+7,100)
|
|
||||||
hline = Rvec*0+ref_V
|
|
||||||
plt.plot(Rvec,hline,color='royalblue',linestyle='--')
|
|
||||||
plt.errorbar(R,V_MEAN, yerr=V_STD,color='royalblue',marker='o',label= '$' + mesh_size + '$')
|
|
||||||
plt.xlim([-2,R[-1]+5])
|
|
||||||
plt.ylim([0,350])
|
|
||||||
plt.xlabel(r'$R$',fontsize=20)
|
|
||||||
plt.ylabel(r'$ v \ \ cm/s$',fontsize=16)
|
|
||||||
plt.xticks(R)
|
|
||||||
plt.title('$Peak \ velocity$',fontsize=16)
|
|
||||||
#plt.legend(fontsize=15)
|
|
||||||
|
|
||||||
plt.subplot(1,3,3)
|
|
||||||
Rvec = np.linspace(-10,R[-1]+7,100)
|
|
||||||
hline = Rvec*0+ref_Q
|
|
||||||
plt.plot(Rvec,hline,color='mediumvioletred',linestyle='--')
|
|
||||||
plt.errorbar(R,Q_MEAN, yerr=Q_STD,color='mediumvioletred',marker='o',label= '$' + mesh_size + '$')
|
|
||||||
plt.xlim([-2,R[-1]+5])
|
|
||||||
plt.xlabel(r'$R$',fontsize=20)
|
|
||||||
plt.ylabel(r'$ Q \ \ ml/s$',fontsize=16)
|
|
||||||
plt.xticks(R)
|
|
||||||
plt.ylim([150,550])
|
|
||||||
plt.title('$Peak \ Flux $',fontsize=16)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
def CLOCK(t1, t2):
|
def CLOCK(t1, t2):
|
||||||
tot_time = np.round(t2 - t1, 2)
|
tot_time = np.round(t2 - t1, 2)
|
||||||
if tot_time < 60:
|
if tot_time < 60:
|
||||||
@ -1411,6 +1071,9 @@ def ROUTINE(options):
|
|||||||
if options['Error-curves']['apply']:
|
if options['Error-curves']['apply']:
|
||||||
print('--- Error-curves analysis ---')
|
print('--- Error-curves analysis ---')
|
||||||
ratio = False
|
ratio = False
|
||||||
|
fac=1
|
||||||
|
if '11mm' in options['Error-curves']['subfolders']:
|
||||||
|
fac=100
|
||||||
for types in options['Error-curves']['type']:
|
for types in options['Error-curves']['type']:
|
||||||
if types=='mean_ratio':
|
if types=='mean_ratio':
|
||||||
types = 'mean'
|
types = 'mean'
|
||||||
@ -1418,6 +1081,9 @@ def ROUTINE(options):
|
|||||||
if types=='max_ratio':
|
if types=='max_ratio':
|
||||||
types = 'max'
|
types = 'max'
|
||||||
ratio = True
|
ratio = True
|
||||||
|
if types=='norm2_m':
|
||||||
|
types='norm2'
|
||||||
|
meas=True
|
||||||
nc = 0
|
nc = 0
|
||||||
if len(options['Error-curves']['subfolders'])==0:
|
if len(options['Error-curves']['subfolders'])==0:
|
||||||
ucomp = []
|
ucomp = []
|
||||||
@ -1445,46 +1111,262 @@ def ROUTINE(options):
|
|||||||
for subf in options['Error-curves']['subfolders']:
|
for subf in options['Error-curves']['subfolders']:
|
||||||
ucomp = []
|
ucomp = []
|
||||||
wcomp = []
|
wcomp = []
|
||||||
colorset = options['Error-curves']['colors']
|
if 'colors' in options['Error-curves']:
|
||||||
|
print('colors setted...')
|
||||||
|
colorset = options['Error-curves']['colors']
|
||||||
|
colorsetted = True
|
||||||
|
else:
|
||||||
|
colorsetted = False
|
||||||
|
styles = options['Error-curves']['styles']
|
||||||
labelset = options['Error-curves']['labels']
|
labelset = options['Error-curves']['labels']
|
||||||
path = options['Error-curves']['folder'] + subf + '/'
|
path = options['Error-curves']['folder'] + subf + '/'
|
||||||
try:
|
wcomp = np.loadtxt(path + 'w'+types+'.txt')
|
||||||
ucomp = np.loadtxt(path + '/u'+types+'.txt')
|
times = np.loadtxt(path + 'times.txt')
|
||||||
wcomp = np.loadtxt(path + '/w'+types+'.txt')
|
if types != 'grad':
|
||||||
times = np.loadtxt(path + '/times.txt')
|
ucomp = np.loadtxt(path + 'u'+types+'.txt')
|
||||||
except IOError:
|
|
||||||
print('no cError-curves for ' + subf)
|
|
||||||
|
|
||||||
if not ratio:
|
|
||||||
plt.plot(
|
|
||||||
times, ucomp, color=colorset[nc], linestyle='-', label= '$u'+ subf +'$' )
|
|
||||||
|
|
||||||
plt.plot(
|
if colorsetted:
|
||||||
times, wcomp, color=colorset[nc], linestyle='--', label='$w'+subf+'$')
|
if not ratio:
|
||||||
|
if types not in ['grad']:
|
||||||
|
if meas:
|
||||||
|
plt.plot(times, fac*ucomp, color=colorset[nc], linestyle='--', label= '$ u \ '+ labelset[nc] +'$',linewidth=2.5 )
|
||||||
|
plt.plot(times, fac*wcomp, color=colorset[nc], linestyle=styles[nc], label= '$ w \ '+ labelset[nc] +'$',linewidth=2.5)
|
||||||
|
else:
|
||||||
|
wu = wcomp/ucomp
|
||||||
|
plt.plot(
|
||||||
|
times, wu, color=colorset[nc], linestyle=styles[nc], label= '$'+ labelset[nc] +'$' )
|
||||||
|
nc +=1
|
||||||
else:
|
else:
|
||||||
wu = wcomp/ucomp
|
if not ratio:
|
||||||
plt.plot(
|
if types not in ['grad']:
|
||||||
times, wu, color=colorset[nc], linestyle='-', label= '$'+ labelset[nc] +'$' )
|
if meas:
|
||||||
nc +=1
|
plt.plot(times, fac*ucomp, linestyle='--', label= '$'+ labelset[nc] +'$' )
|
||||||
|
else:
|
||||||
|
plt.plot(times, fac*ucomp, linestyle='--', label= '$'+ labelset[nc] +'$' )
|
||||||
|
plt.plot(
|
||||||
|
times, fac*wcomp, linestyle=styles[nc], label= '$'+ labelset[nc] +'$')
|
||||||
|
else:
|
||||||
|
wu = wcomp/ucomp
|
||||||
|
plt.plot(
|
||||||
|
times, wu, linestyle=styles[nc], label= '$'+ labelset[nc] +'$' )
|
||||||
|
nc +=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#plt.ylim([0, 170])
|
|
||||||
plt.xlabel('$time \ \ (s)$', fontsize=18)
|
plt.xlabel('$time \ \ (s)$', fontsize=18)
|
||||||
plt.legend(fontsize=16)
|
plt.legend(fontsize=14)
|
||||||
if options['Error-curves']['title']:
|
if options['Error-curves']['title']:
|
||||||
plt.title(options['Error-curves']['title'], fontsize=18)
|
plt.title(options['Error-curves']['title'], fontsize=18)
|
||||||
|
|
||||||
if not ratio:
|
if not ratio:
|
||||||
plt.ylabel('$velocity \ \ (cm/s)$', fontsize=18)
|
if types == 'grad':
|
||||||
|
plt.ylim([0, 230])
|
||||||
|
plt.ylabel('$ |grad(w)|_2 \ \ (1/s)$', fontsize=18)
|
||||||
|
elif types == 'norm2':
|
||||||
|
plt.ylim([0, 52])
|
||||||
|
plt.ylabel('$ |w|_2 \ \ (cm/s)$', fontsize=18)
|
||||||
|
else:
|
||||||
|
plt.ylabel('$velocity \ \ (cm/s)$', fontsize=18)
|
||||||
plt.savefig(options['Error-curves']['outpath'] + types + '.png', dpi=500, bbox_inches='tight')
|
plt.savefig(options['Error-curves']['outpath'] + types + '.png', dpi=500, bbox_inches='tight')
|
||||||
else:
|
else:
|
||||||
plt.ylabel('$w/u$', fontsize=18)
|
plt.ylabel('$|w/u|$', fontsize=18)
|
||||||
if 'max' in types:
|
#if 'max' in types:
|
||||||
plt.ylim([0, 1.8])
|
#plt.ylim([0, 1.8])
|
||||||
plt.savefig(options['Error-curves']['outpath'] + types + '_ratio.png', dpi=500, bbox_inches='tight')
|
plt.savefig(options['Error-curves']['outpath'] + types + '_ratio.png', dpi=500, bbox_inches='tight')
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
if 'Histograms_checkpoint' in options:
|
||||||
|
if options['Histograms_checkpoint']['apply']:
|
||||||
|
print('--- Histograms ---')
|
||||||
|
path = options['Histograms_checkpoint']['path']
|
||||||
|
freq = np.loadtxt(path + 'hist_freq.txt')
|
||||||
|
edges = np.loadtxt(path + 'hist_edges.txt')
|
||||||
|
fig, ax = plt.subplots()
|
||||||
|
#ax.bar(edges[:-1], freq, width=np.diff(edges), edgecolor="black", align="edge")
|
||||||
|
ax.bar(edges[:-1], freq, width=np.diff(edges), align="edge")
|
||||||
|
plt.title(options['Histograms_checkpoint']['title'], fontsize=18)
|
||||||
|
plt.xlim([0 , 50])
|
||||||
|
plt.ylim([0 , 1.8])
|
||||||
|
plt.savefig(path + 'hist.png', dpi=500, bbox_inches='tight')
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
if 'Pressure_drops' in options:
|
||||||
|
if options['Pressure_drops']['apply']:
|
||||||
|
print('--- Pressure_drops ---')
|
||||||
|
import pickle
|
||||||
|
nc = 0
|
||||||
|
tommhg = options['Pressure_drops']['convertor']
|
||||||
|
|
||||||
|
for subf in options['Pressure_drops']['subfolders']:
|
||||||
|
ucomp = []
|
||||||
|
wcomp = []
|
||||||
|
if 'colors' in options['Pressure_drops']:
|
||||||
|
colorset = options['Pressure_drops']['colors']
|
||||||
|
colorsetted = True
|
||||||
|
else:
|
||||||
|
colorsetted = False
|
||||||
|
styles = options['Pressure_drops']['styles']
|
||||||
|
labelset = options['Pressure_drops']['labels']
|
||||||
|
path = options['Pressure_drops']['folder'] + subf + '/'
|
||||||
|
dataname = 'pdrop_COR_impl_stan.dat'
|
||||||
|
if 'STE' in path:
|
||||||
|
dataname = 'pdrop_STE_impl_stan.dat'
|
||||||
|
if labelset[nc]=='ref':
|
||||||
|
dataname = 'pdrop.dat'
|
||||||
|
data = open(path+dataname, 'rb')
|
||||||
|
p_drop = pickle.load(data)['pdrop']/tommhg
|
||||||
|
data = open(path+dataname, 'rb')
|
||||||
|
times = pickle.load(data)['time']
|
||||||
|
|
||||||
|
if labelset[nc] == 'ref':
|
||||||
|
plt.plot(times, p_drop,color='black', linestyle='-', label= '$ref$' )
|
||||||
|
else:
|
||||||
|
|
||||||
|
if colorsetted:
|
||||||
|
plt.plot(
|
||||||
|
times, p_drop, color=colorset[nc], linestyle=styles[nc], label= '$'+ labelset[nc] +'$' )
|
||||||
|
else:
|
||||||
|
plt.plot(times, p_drop, linestyle=styles[nc], label= '$'+ labelset[nc] +'$' )
|
||||||
|
|
||||||
|
if options['Pressure_drops']['catheter']:
|
||||||
|
|
||||||
|
c_path = '/home/yeye/Desktop/PhD/MEDICAL_DATA/Study_David/catheter_data/catheter_'+ labelset[nc]+'_rest_stats.csv'
|
||||||
|
|
||||||
|
|
||||||
|
with open(c_path, 'r') as csvfile:
|
||||||
|
mylist = [row[0] for row in csv.reader(csvfile, delimiter=';')]
|
||||||
|
|
||||||
|
Values = np.array(mylist)
|
||||||
|
catheter = np.zeros([len(Values)-2])
|
||||||
|
tcat = np.zeros([len(Values)-2])
|
||||||
|
for l in range(2,len(Values)):
|
||||||
|
row = Values[l].split(',')
|
||||||
|
catheter[l-2] = float(row[5])
|
||||||
|
tcat[l-2] = float(row[0])
|
||||||
|
|
||||||
|
|
||||||
|
if '11mm' in subf:
|
||||||
|
tdelay = 0.015
|
||||||
|
elif '9mm' in subf:
|
||||||
|
tdelay = -0.12
|
||||||
|
elif '13mm' in subf:
|
||||||
|
tdelay = 0.1
|
||||||
|
elif 'Normal' in subf:
|
||||||
|
tdelay = -0.01
|
||||||
|
|
||||||
|
plt.plot(tcat+tdelay,catheter,color=colorset[nc],linestyle='--')# ,label='$cat' + subf + '$')
|
||||||
|
|
||||||
|
nc +=1
|
||||||
|
|
||||||
|
|
||||||
|
#plt.ylim([0, 170])
|
||||||
|
plt.xlabel('$time \ \ (s)$', fontsize=18)
|
||||||
|
plt.legend(fontsize=14)
|
||||||
|
if options['Pressure_drops']['title']:
|
||||||
|
plt.title(options['Pressure_drops']['title'], fontsize=18)
|
||||||
|
plt.ylabel('$ \delta P \ \ (mmHg)$', fontsize=18)
|
||||||
|
plt.savefig(options['Pressure_drops']['outpath'] + 'pressure_drops.png', dpi=500, bbox_inches='tight')
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
if 'l2_comp' in options:
|
||||||
|
if options['l2_comp']['apply']:
|
||||||
|
print('--- L2 component analysis ---')
|
||||||
|
fig, ax = plt.subplots()
|
||||||
|
for subf in options['l2_comp']['subfolder']:
|
||||||
|
path = options['l2_comp']['folder'] + subf + '/'
|
||||||
|
colors = options['l2_comp']['colors']
|
||||||
|
mode = options['l2_comp']['mode']['type']
|
||||||
|
|
||||||
|
if mode in ['gain','gain_compressed']:
|
||||||
|
gain = True
|
||||||
|
path_to_comp = options['l2_comp']['mode']['comp']
|
||||||
|
wx = np.loadtxt(path_to_comp + '/wx.txt')
|
||||||
|
wy = np.loadtxt(path_to_comp + '/wy.txt')
|
||||||
|
wz = np.loadtxt(path_to_comp + '/wz.txt')
|
||||||
|
else:
|
||||||
|
gain = False
|
||||||
|
wx = np.loadtxt(path + '/wx.txt')
|
||||||
|
wy = np.loadtxt(path + '/wy.txt')
|
||||||
|
wz = np.loadtxt(path + '/wz.txt')
|
||||||
|
|
||||||
|
times = np.loadtxt(path + '/times.txt')
|
||||||
|
if subf != 'SNRinfV120' and gain:
|
||||||
|
varux = np.loadtxt(path + '/varux.txt')
|
||||||
|
varuy = np.loadtxt(path + '/varuy.txt')
|
||||||
|
varuz = np.loadtxt(path + '/varuz.txt')
|
||||||
|
if 'SNRinfV120' in subf:
|
||||||
|
lsty = '--'
|
||||||
|
labels = ['','','','','']
|
||||||
|
else:
|
||||||
|
lsty = '-'
|
||||||
|
lsty2 = '--'
|
||||||
|
labels = ['$wx$','$wy$','$wz$','$div$']
|
||||||
|
labels2 = ['$\delta u_x$','$\delta u_y$','$\delta u_z$']
|
||||||
|
labels3 = ['$x$','$y$','$z$']
|
||||||
|
|
||||||
|
if mode == 'gain':
|
||||||
|
plt.plot(times, varux, color = colors[0], linestyle=lsty2 , label= labels2[0] )
|
||||||
|
plt.plot(times, varuy, color = colors[1], linestyle=lsty2 , label= labels2[1] )
|
||||||
|
plt.plot(times, varuz, color = colors[2], linestyle=lsty2 , label= labels2[2] )
|
||||||
|
plt.plot(times, wx, color = colors[0], linestyle=lsty, label= labels[0] )
|
||||||
|
plt.plot(times, wy, color = colors[1], linestyle=lsty, label= labels[1] )
|
||||||
|
plt.plot(times, wz, color = colors[2], linestyle=lsty, label= labels[2] )
|
||||||
|
elif mode == 'gain_compressed':
|
||||||
|
plt.plot(times, varux-wx, color = colors[0], linestyle=lsty, label= labels3[0] )
|
||||||
|
plt.plot(times, varuy-wy, color = colors[1], linestyle=lsty, label= labels3[1] )
|
||||||
|
plt.plot(times, varuz-wz, color = colors[2], linestyle=lsty, label= labels3[2] )
|
||||||
|
else:
|
||||||
|
plt.plot(times, wx, color = colors[0], linestyle=lsty, label= labels[0] )
|
||||||
|
plt.plot(times, wy, color = colors[1], linestyle=lsty, label= labels[1] )
|
||||||
|
plt.plot(times, wz, color = colors[2], linestyle=lsty, label= labels[2] )
|
||||||
|
|
||||||
|
plt.xlabel('$time \ \ (s)$', fontsize=18)
|
||||||
|
|
||||||
|
if options['l2_comp']['div']:
|
||||||
|
div = np.loadtxt(path + 'div.txt')
|
||||||
|
div_rescaled = div*0.01
|
||||||
|
div_rescaled = div_rescaled + 0.1
|
||||||
|
plt.plot(times, div_rescaled, color = 'indigo', linestyle=lsty, label= labels[3] )
|
||||||
|
|
||||||
|
if 'title' in options['l2_comp']:
|
||||||
|
if options['l2_comp']['title']:
|
||||||
|
plt.title(options['l2_comp']['title'], fontsize=18)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if options['l2_comp']['aliasing']:
|
||||||
|
if 'Poiseuille' in options['l2_comp']['folder']:
|
||||||
|
print('adding alaising color in Poiseuille')
|
||||||
|
import matplotlib.transforms as mtransforms
|
||||||
|
trans = mtransforms.blended_transform_factory(ax.transData, ax.transAxes)
|
||||||
|
if 'SNR10' in subf:
|
||||||
|
time_al = [0.15,0.78]
|
||||||
|
elif 'SNRinf' in subf:
|
||||||
|
time_al = [0.21,0.78]
|
||||||
|
pm_al = 0.5*(time_al[1] + time_al[0])
|
||||||
|
r_al = 0.5*(time_al[1] - time_al[0])
|
||||||
|
ax.fill_between(times, 0, 1, where=np.abs(times -pm_al)<= r_al ,facecolor='gold', alpha=0.4, transform=trans)
|
||||||
|
if mode == 'gain_compressed':
|
||||||
|
ax.text(pm_al/times[-1], 0.55, '$aliasing$', horizontalalignment='center',verticalalignment='center', transform=ax.transAxes,fontsize=17)
|
||||||
|
else:
|
||||||
|
ax.text(pm_al/times[-1], 0.82, '$aliasing$', horizontalalignment='center',verticalalignment='center', transform=ax.transAxes,fontsize=17)
|
||||||
|
|
||||||
|
leg = plt.legend(fancybox=True,fontsize=16)
|
||||||
|
leg.get_frame().set_linewidth(0.0)
|
||||||
|
ax.tick_params(axis='both', which='major', labelsize=14)
|
||||||
|
#plt.ylim([-0.005 , 0.235])
|
||||||
|
|
||||||
|
if mode == 'gain_compressed':
|
||||||
|
plt.ylim([-0.25 , 1.75])
|
||||||
|
plt.ylabel('$|| \delta u ||_{L2} - || w ||_{L2}$', fontsize=18)
|
||||||
|
if not gain:
|
||||||
|
plt.ylim([-0.005 , 0.5])
|
||||||
|
plt.ylabel('$ \sqrt{\int w^2 dx /| \Omega|}/ venc$', fontsize=18)
|
||||||
|
|
||||||
|
plt.savefig(options['l2_comp']['folder'] + options['l2_comp']['name'] + '.png', dpi=500, bbox_inches='tight')
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
191
codes/MRI.py
191
codes/MRI.py
@ -3,13 +3,10 @@
|
|||||||
# Workspace for MRI analysis of the 4Dflow data
|
# Workspace for MRI analysis of the 4Dflow data
|
||||||
#
|
#
|
||||||
# written by Jeremias Garay L: j.e.garay.labra@rug.nl
|
# written by Jeremias Garay L: j.e.garay.labra@rug.nl
|
||||||
# Fernanda te amo
|
|
||||||
# for autoreload in ipython3
|
# for autoreload in ipython3
|
||||||
# %load_ext autoreload
|
# %load_ext autoreload
|
||||||
# %autoreload 2
|
# %autoreload 2
|
||||||
################################################################
|
################################################################
|
||||||
import h5py
|
|
||||||
from dPdirectestim.dPdirectestim import *
|
|
||||||
from dolfin import *
|
from dolfin import *
|
||||||
import dolfin
|
import dolfin
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -999,14 +996,8 @@ def CLOCK(rank,t1,t2):
|
|||||||
print('Total time: ' + str(time_hour) + ' hrs, ' + str(time_min) + ' min, ' + str(time_sec) + ' s')
|
print('Total time: ' + str(time_hour) + ' hrs, ' + str(time_min) + ' min, ' + str(time_sec) + ' s')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def SCANNER(options):
|
def SCANNER(options):
|
||||||
|
|
||||||
########################################
|
|
||||||
#
|
|
||||||
# Basic Tools
|
|
||||||
#
|
|
||||||
########################################
|
|
||||||
if 'kspace_cib' in options:
|
if 'kspace_cib' in options:
|
||||||
if options['kspace_cib']['apply']:
|
if options['kspace_cib']['apply']:
|
||||||
print('--- kspace from CIB data ---')
|
print('--- kspace from CIB data ---')
|
||||||
@ -1416,24 +1407,18 @@ def SCANNER(options):
|
|||||||
else:
|
else:
|
||||||
CIBtoH5(path_to_cib,times,dt,outpath,flip=flip)
|
CIBtoH5(path_to_cib,times,dt,outpath,flip=flip)
|
||||||
|
|
||||||
########################################
|
|
||||||
#
|
|
||||||
# Undersampling
|
|
||||||
#
|
|
||||||
########################################
|
|
||||||
if 'cs' in options:
|
if 'cs' in options:
|
||||||
if options['cs']['apply']:
|
if options['cs']['apply']:
|
||||||
if rank==0:
|
if rank==0:
|
||||||
print('Applying Compressed Sensing')
|
print('Applying Compressed Sensing')
|
||||||
|
|
||||||
|
|
||||||
[Sqx, Sqy, Sqz] = LOADsequences(options['cs']['seqpath'])
|
[Sqx, Sqy, Sqz] = LOADsequences(options['cs']['seqpath'])
|
||||||
|
|
||||||
|
|
||||||
import CS
|
import CS
|
||||||
if options['cs']['short']:
|
if 'short' in options['cs']:
|
||||||
[Mx,My,Mz] = LOADsequences(options['cs']['Mpath'])
|
if options['cs']['short']:
|
||||||
CS.undersampling_short(Mx,My,Mz,options)
|
[Mx,My,Mz] = LOADsequences(options['cs']['Mpath'])
|
||||||
|
CS.undersampling_short(Mx,My,Mz,options)
|
||||||
else:
|
else:
|
||||||
CS.undersampling(Sqx,Sqy,Sqz,options,options['cs']['savepath'])
|
CS.undersampling(Sqx,Sqy,Sqz,options,options['cs']['savepath'])
|
||||||
|
|
||||||
@ -1457,12 +1442,6 @@ def SCANNER(options):
|
|||||||
print('saving the sequences' + options['SENSE']['savepath'])
|
print('saving the sequences' + options['SENSE']['savepath'])
|
||||||
np.savez_compressed(options['SENSE']['savepath'], x=MxS,y=MyS,z=MzS)
|
np.savez_compressed(options['SENSE']['savepath'], x=MxS,y=MyS,z=MzS)
|
||||||
|
|
||||||
########################################
|
|
||||||
#
|
|
||||||
# Writing Checkpoint from Sequence
|
|
||||||
#
|
|
||||||
########################################
|
|
||||||
|
|
||||||
if 'create_checkpoint' in options:
|
if 'create_checkpoint' in options:
|
||||||
if options['create_checkpoint']['apply']:
|
if options['create_checkpoint']['apply']:
|
||||||
print('--- Create Checkpoint ---')
|
print('--- Create Checkpoint ---')
|
||||||
@ -1529,7 +1508,7 @@ def SCANNER(options):
|
|||||||
comm = MESH['mesh'].mpi_comm()
|
comm = MESH['mesh'].mpi_comm()
|
||||||
dt = options['create_checkpoint']['dt']
|
dt = options['create_checkpoint']['dt']
|
||||||
if options['create_checkpoint']['xdmf']:
|
if options['create_checkpoint']['xdmf']:
|
||||||
xdmf_u = XDMFFile(options['create_checkpoint']['savepath']+'u.xdmf')
|
xdmf_u = XDMFFile(options['create_checkpoint']['savepath']+ 'R' + str(r) + '/u.xdmf')
|
||||||
|
|
||||||
for l in range(len(vel_seq)):
|
for l in range(len(vel_seq)):
|
||||||
if rank == 0:
|
if rank == 0:
|
||||||
@ -1545,11 +1524,6 @@ def SCANNER(options):
|
|||||||
inout.write_HDF5_data(
|
inout.write_HDF5_data(
|
||||||
comm, path + '/u.h5', vel_seq[l], '/u', t=l*dt)
|
comm, path + '/u.h5', vel_seq[l], '/u', t=l*dt)
|
||||||
|
|
||||||
########################################
|
|
||||||
#
|
|
||||||
# Relative Pressure Estimators
|
|
||||||
#
|
|
||||||
########################################
|
|
||||||
if 'reference' in options:
|
if 'reference' in options:
|
||||||
if options['reference']['apply']:
|
if options['reference']['apply']:
|
||||||
if rank == 0:
|
if rank == 0:
|
||||||
@ -1688,157 +1662,6 @@ def SCANNER(options):
|
|||||||
if rank==0:
|
if rank==0:
|
||||||
print(' ')
|
print(' ')
|
||||||
|
|
||||||
if 'peak_pv' in options:
|
|
||||||
|
|
||||||
if options['peak_pv']['apply']:
|
|
||||||
import CS
|
|
||||||
import pickle
|
|
||||||
import sys
|
|
||||||
import logging
|
|
||||||
# DPestim
|
|
||||||
logging.getLogger().setLevel(logging.INFO)
|
|
||||||
parameters['form_compiler']['optimize'] = True
|
|
||||||
parameters['form_compiler']['cpp_optimize'] = True
|
|
||||||
parameters['form_compiler']['cpp_optimize_flags'] = '-O3 -ffast-math -march=native'
|
|
||||||
infile_dp = options['peak_pv']['infile_dp']
|
|
||||||
estimator = DPDirectEstim(infile_dp)
|
|
||||||
|
|
||||||
barye2mmHg = 1/1333.22387415
|
|
||||||
t_star = 0.185
|
|
||||||
if rank==0:
|
|
||||||
print('Computing Velocity and Pressure at Peak Systole')
|
|
||||||
print('The inlet max occurs at ' + str(t_star) + ' sec')
|
|
||||||
|
|
||||||
|
|
||||||
[BOX,AORTA,LEO] = CREATEmeshes(options)
|
|
||||||
|
|
||||||
if options['peak_pv']['mesh_into']=='leo':
|
|
||||||
MESH = LEO
|
|
||||||
del AORTA
|
|
||||||
if options['peak_pv']['mesh_into']=='aorta':
|
|
||||||
MESH = AORTA
|
|
||||||
del LEO
|
|
||||||
|
|
||||||
if options['peak_pv']['p_comp']=='error':
|
|
||||||
if rank==0:
|
|
||||||
print('Reading Pressure Reference')
|
|
||||||
P0_PPE = READcheckpoint(MESH,'p',options,options['checkpoint_path'],'p_PPE_impl_stan')
|
|
||||||
P0_STE = READcheckpoint(MESH,'p',options,options['checkpoint_path'],'p_STE_impl_stan')
|
|
||||||
|
|
||||||
[Sqx,Sqy,Sqz] = LOADsequences(options['peak_pv']['orig_seq'])
|
|
||||||
Nite = options['peak_pv']['N_CS']
|
|
||||||
[row,col,dep,numt] = Sqz.shape
|
|
||||||
frms_num = 3
|
|
||||||
peakslice = options['peak_pv']['peak_slice']
|
|
||||||
R = options['peak_pv']['R']
|
|
||||||
|
|
||||||
v0 = np.sqrt(Sqx[:,:,:,peakslice]**2 + Sqy[:,:,:,peakslice]**2 + Sqz[:,:,:,peakslice]**2)
|
|
||||||
max0 = np.where(v0==np.max(v0))
|
|
||||||
|
|
||||||
qqvec = {}
|
|
||||||
for ss in options['peak_pv']['flux_bnd']:
|
|
||||||
qqvec[ss] = np.zeros([Nite])
|
|
||||||
|
|
||||||
ppemax = np.zeros([Nite])
|
|
||||||
stemax = np.zeros([Nite])
|
|
||||||
vmax = np.zeros([Nite])
|
|
||||||
slrdmax = peakslice
|
|
||||||
# Selecting around the max only
|
|
||||||
slrdmax = 1
|
|
||||||
Sqx = Sqx[:,:,:,peakslice-1:peakslice+2]
|
|
||||||
Sqy = Sqy[:,:,:,peakslice-1:peakslice+2]
|
|
||||||
Sqz = Sqz[:,:,:,peakslice-1:peakslice+2]
|
|
||||||
|
|
||||||
for l in range(len(R)):
|
|
||||||
if rank==0:
|
|
||||||
print('Peak Systole velocity and pressure at R = ' + str(R[l]))
|
|
||||||
|
|
||||||
sx_cs = np.zeros([row,col,dep,frms_num,Nite])
|
|
||||||
sy_cs = np.zeros([row,col,dep,frms_num,Nite])
|
|
||||||
sz_cs = np.zeros([row,col,dep,frms_num,Nite])
|
|
||||||
|
|
||||||
for k in range(Nite):
|
|
||||||
if rank==0:
|
|
||||||
print('CS iteration number ' + str(k+1))
|
|
||||||
[xcs,ycs,zcs] = CS.undersampling_peakpv(Sqx,Sqy,Sqz,options,R[l])
|
|
||||||
sx_cs[:,:,:,:,k] = xcs
|
|
||||||
sy_cs[:,:,:,:,k] = ycs
|
|
||||||
sz_cs[:,:,:,:,k] = zcs
|
|
||||||
vk = np.sqrt(sx_cs[:,:,:,1,k]**2 + sy_cs[:,:,:,1,k]**2 + sz_cs[:,:,:,1,k]**2)
|
|
||||||
vmax[k] = vk[max0]
|
|
||||||
|
|
||||||
if rank==0:
|
|
||||||
print('\n CS done')
|
|
||||||
|
|
||||||
# To write the checkpoints
|
|
||||||
vel_seq = SqtoH5(BOX,MESH,sx_cs[:,:,:,:,k],sy_cs[:,:,:,:,k],sz_cs[:,:,:,:,k])
|
|
||||||
comm = MESH['mesh'].mpi_comm()
|
|
||||||
|
|
||||||
# Computing the Fluxes
|
|
||||||
if rank==0:
|
|
||||||
print('\n Computing the Flux')
|
|
||||||
QQ = Fluxes(MESH,vel_seq,options,options['peak_pv']['flux_bnd'])
|
|
||||||
|
|
||||||
for ss in options['peak_pv']['flux_bnd']:
|
|
||||||
qqvec[ss][k] = QQ[ss][slrdmax]
|
|
||||||
|
|
||||||
if rank==0:
|
|
||||||
print('\n Writing checkpoints')
|
|
||||||
|
|
||||||
for ns in range(len(vel_seq)):
|
|
||||||
pathss = options['peak_pv']['savepath'] + 'H5/checkpoint/{i}/'.format(i=ns)
|
|
||||||
if l<10 and l>0:
|
|
||||||
pathss = options['peak_pv']['savepath'] + 'H5/checkpoint/0{i}/'.format(i=ns)
|
|
||||||
inout.write_HDF5_data(comm, pathss + '/u.h5', vel_seq[ns], '/u', t=0)
|
|
||||||
if rank==0:
|
|
||||||
print('\n The checkpoints were wrote')
|
|
||||||
|
|
||||||
# Computing the Pressure Drop
|
|
||||||
estimator.estimate()
|
|
||||||
# Reading the results
|
|
||||||
if options['peak_pv']['p_comp']=='peak':
|
|
||||||
ppe_raw = open(options['peak_pv']['savepath'] + '/H5/pdrop_PPE_impl_stan.dat','rb')
|
|
||||||
ste_raw = open(options['peak_pv']['savepath'] + '/H5/pdrop_STE_impl_stan.dat','rb')
|
|
||||||
ppe = pickle.load(ppe_raw)['pdrop']*(-barye2mmHg)
|
|
||||||
ste = pickle.load(ste_raw)['pdrop']*(-barye2mmHg)
|
|
||||||
p1max[k] = ppe[slrdmax]
|
|
||||||
p2max[k] = ste[slrdmax]
|
|
||||||
elif options['peak_pv']['p_comp']=='error':
|
|
||||||
PPE = READcheckpoint(MESH,'p',options,options['peak_pv']['savepath']+'H5/checkpoint/','p_PPE_impl_stan')
|
|
||||||
STE = READcheckpoint(MESH,'p',options,options['peak_pv']['savepath']+'H5/checkpoint/','p_STE_impl_stan')
|
|
||||||
ppe_vec_0 = P0_PPE[peakslice].vector().get_local() - P0_PPE[peakslice].vector().get_local()[0]
|
|
||||||
ppe_vec = PPE[slrdmax].vector().get_local() - PPE[slrdmax].vector().get_local()[0]
|
|
||||||
ste_vec_0 = P0_STE[peakslice].vector().get_local() - P0_STE[peakslice].vector().get_local()[0]
|
|
||||||
ste_vec = STE[slrdmax].vector().get_local() - STE[slrdmax].vector().get_local()[0]
|
|
||||||
ppemax[k] = np.linalg.norm(ppe_vec_0 - ppe_vec)/np.linalg.norm(ppe_vec_0)
|
|
||||||
stemax[k] = np.linalg.norm(ste_vec_0 - ste_vec)/np.linalg.norm(ste_vec_0)
|
|
||||||
else:
|
|
||||||
raise Exception('Pressure computation not recognize!')
|
|
||||||
|
|
||||||
|
|
||||||
# VELOCITIES
|
|
||||||
vmean = np.mean(vmax)
|
|
||||||
vstd = np.std(vmax)
|
|
||||||
# PRESSURES
|
|
||||||
ppemean = np.mean(ppemax)
|
|
||||||
stemean = np.mean(stemax)
|
|
||||||
ppestd = np.std(ppemax)
|
|
||||||
stestd = np.std(stemax)
|
|
||||||
|
|
||||||
|
|
||||||
if options['peak_pv']['save']:
|
|
||||||
if rank==0:
|
|
||||||
print('\n saving the files in ' + options['peak_pv']['savepath'])
|
|
||||||
for ss in options['peak_pv']['flux_bnd']:
|
|
||||||
np.savetxt( options['peak_pv']['savepath'] + 'Q'+str(ss) +'_R'+str(R[l])+'.txt', [np.mean(qqvec[ss])])
|
|
||||||
np.savetxt( options['peak_pv']['savepath'] + 'Qstd'+str(ss) +'_R'+str(R[l])+'.txt', [np.std(qqvec[ss])])
|
|
||||||
np.savetxt( options['peak_pv']['savepath'] + 'ppemean_R'+str(R[l])+'.txt', [ppemean] )
|
|
||||||
np.savetxt( options['peak_pv']['savepath'] + 'stemean_R'+str(R[l])+'.txt', [stemean] )
|
|
||||||
np.savetxt( options['peak_pv']['savepath'] + 'vmean_R'+str(R[l])+'.txt', [vmean] )
|
|
||||||
np.savetxt( options['peak_pv']['savepath'] + 'ppestd_R'+str(R[l])+'.txt', [ppestd] )
|
|
||||||
np.savetxt( options['peak_pv']['savepath'] + 'stestd_R'+str(R[l])+'.txt', [stestd] )
|
|
||||||
np.savetxt( options['peak_pv']['savepath'] + 'vstd_R'+str(R[l])+'.txt', [vstd] )
|
|
||||||
|
|
||||||
if 'change_mesh' in options:
|
if 'change_mesh' in options:
|
||||||
if options['change_mesh']['apply']:
|
if options['change_mesh']['apply']:
|
||||||
if rank == 0:
|
if rank == 0:
|
||||||
@ -1861,9 +1684,9 @@ def SCANNER(options):
|
|||||||
changed = {}
|
changed = {}
|
||||||
#W = LEO['FEM'].sub(0).collapse()
|
#W = LEO['FEM'].sub(0).collapse()
|
||||||
comm = MESH_out['mesh'].mpi_comm()
|
comm = MESH_out['mesh'].mpi_comm()
|
||||||
v2 = Function(MESH_out['FEM'])
|
|
||||||
|
|
||||||
for k in range(len(list(origin))):
|
for k in range(len(list(origin))):
|
||||||
|
v2 = Function(MESH_out['FEM'])
|
||||||
if rank == 0:
|
if rank == 0:
|
||||||
print('CHANGING: index', k)
|
print('CHANGING: index', k)
|
||||||
LagrangeInterpolator.interpolate(v2, origin[k])
|
LagrangeInterpolator.interpolate(v2, origin[k])
|
||||||
@ -1878,7 +1701,7 @@ def SCANNER(options):
|
|||||||
if rank == 0:
|
if rank == 0:
|
||||||
print('saving checkpoint', l)
|
print('saving checkpoint', l)
|
||||||
path = options['change_mesh']['savepath'] + \
|
path = options['change_mesh']['savepath'] + \
|
||||||
'R1/checkpoint/{i}/'.format(i=l)
|
'checkpoint/{i}/'.format(i=l)
|
||||||
writepath = path + '/'+options['change_mesh']['mode']+'.h5'
|
writepath = path + '/'+options['change_mesh']['mode']+'.h5'
|
||||||
inout.write_HDF5_data(
|
inout.write_HDF5_data(
|
||||||
comm, writepath, changed[l] ,'/'+options['change_mesh']['mode'], t=l*dt)
|
comm, writepath, changed[l] ,'/'+options['change_mesh']['mode'], t=l*dt)
|
||||||
|
@ -109,14 +109,10 @@ def WORKcheck(MESH, mode, output_path, checkpoint_path, filename, outname, optio
|
|||||||
|
|
||||||
if mode == 'p' or mode == 'p_cib':
|
if mode == 'p' or mode == 'p_cib':
|
||||||
xdmf_p = XDMFFile(output_path+outname+'.xdmf')
|
xdmf_p = XDMFFile(output_path+outname+'.xdmf')
|
||||||
for k in range(0, len(indexes), 1):
|
dt = options['Pressure']['dt']
|
||||||
|
for k in range(0, len(indexes), options['Pressure']['undersampling']):
|
||||||
|
te = k*dt
|
||||||
path = checkpoint_path + str(indexes[k]) + '/'+filename+'.h5'
|
path = checkpoint_path + str(indexes[k]) + '/'+filename+'.h5'
|
||||||
|
|
||||||
if filename == 'p':
|
|
||||||
if k < 10 and k > 0:
|
|
||||||
path = checkpoint_path + '0' + \
|
|
||||||
str(indexes[k]) + '/'+filename+'.h5'
|
|
||||||
|
|
||||||
p = Function(W)
|
p = Function(W)
|
||||||
if mode == 'p':
|
if mode == 'p':
|
||||||
barye2mmHg = 1/1333.22387415
|
barye2mmHg = 1/1333.22387415
|
||||||
@ -126,36 +122,10 @@ def WORKcheck(MESH, mode, output_path, checkpoint_path, filename, outname, optio
|
|||||||
hdf = HDF5File(MESH['mesh'].mpi_comm(), path, 'r')
|
hdf = HDF5File(MESH['mesh'].mpi_comm(), path, 'r')
|
||||||
hdf.read(p, 'p/vector_0')
|
hdf.read(p, 'p/vector_0')
|
||||||
hdf.close()
|
hdf.close()
|
||||||
|
|
||||||
p1vec = p.vector().get_local()
|
p1vec = p.vector().get_local()
|
||||||
p1vec = p1vec - np.mean(p1vec)
|
#p1vec = p1vec - np.mean(p1vec)
|
||||||
p.vector()[:] = p1vec*barye2mmHg
|
p.vector()[:] = p1vec*barye2mmHg
|
||||||
xdmf_p.write(p, te)
|
xdmf_p.write(p, te)
|
||||||
te = te + dt
|
|
||||||
numt = numt + 1
|
|
||||||
|
|
||||||
if mode == 'divu':
|
|
||||||
xdmf_u = XDMFFile(output_path+outname+'.xdmf')
|
|
||||||
for k in range(0, len(indexes), 1):
|
|
||||||
path = checkpoint_path + str(indexes[k]) + '/'+filename+'.h5'
|
|
||||||
|
|
||||||
if indexes[k] < 10 and indexes[k] > 0:
|
|
||||||
path = checkpoint_path + '0' + \
|
|
||||||
str(indexes[k]) + '/'+filename+'.h5'
|
|
||||||
|
|
||||||
v = Function(V)
|
|
||||||
dv = Function(W)
|
|
||||||
|
|
||||||
dv.rename('div', outname)
|
|
||||||
comm = MPI.COMM_WORLD
|
|
||||||
hdf = HDF5File(MESH['mesh'].mpi_comm(), path, 'r')
|
|
||||||
hdf.read(v, 'u/vector_0')
|
|
||||||
|
|
||||||
hdf.close()
|
|
||||||
dv.assign(project(div(v), W))
|
|
||||||
xdmf_u.write(dv, te)
|
|
||||||
te = te + dt
|
|
||||||
numt = numt + 1
|
|
||||||
|
|
||||||
def READcheckpoint(MESH, mode, output_path, checkpoint_path, filename, outname, options, flow=False, bnds=None):
|
def READcheckpoint(MESH, mode, output_path, checkpoint_path, filename, outname, options, flow=False, bnds=None):
|
||||||
|
|
||||||
@ -203,7 +173,7 @@ def READcheckpoint(MESH, mode, output_path, checkpoint_path, filename, outname,
|
|||||||
freq,edges = np.histogram(ValuesPeak, bins=80, density=True)
|
freq,edges = np.histogram(ValuesPeak, bins=80, density=True)
|
||||||
#Saving the histogram
|
#Saving the histogram
|
||||||
print('Saving at ' + output_path)
|
print('Saving at ' + output_path)
|
||||||
np.savetxt(output_path + 'hist_frew.txt', freq)
|
np.savetxt(output_path + 'hist_freq.txt', freq)
|
||||||
np.savetxt(output_path + 'hist_edges.txt', edges)
|
np.savetxt(output_path + 'hist_edges.txt', edges)
|
||||||
|
|
||||||
if mode == 'perturbation':
|
if mode == 'perturbation':
|
||||||
@ -235,6 +205,20 @@ def READcheckpoint(MESH, mode, output_path, checkpoint_path, filename, outname,
|
|||||||
|
|
||||||
noise_in_coil = options['Perturbation']['type']['coil']
|
noise_in_coil = options['Perturbation']['type']['coil']
|
||||||
|
|
||||||
|
umaxima = []
|
||||||
|
for k in indexes:
|
||||||
|
path = checkpoint_path + str(k) + '/'+filename+'.h5'
|
||||||
|
hdf = HDF5File(MESH['mesh'].mpi_comm(), path, 'r')
|
||||||
|
hdf.read(u, 'u/vector_0')
|
||||||
|
time = hdf.attributes('u/vector_0').to_dict()['timestamp']
|
||||||
|
hdf.close()
|
||||||
|
uvec = u.vector().get_local()
|
||||||
|
umaxima.append(np.max(uvec))
|
||||||
|
|
||||||
|
ufactor = options['Perturbation']['type']['phase_contrast']/100
|
||||||
|
VENC = np.floor(np.ceil(np.max(umaxima))*ufactor)
|
||||||
|
print('VENC chosen = ',VENC)
|
||||||
|
|
||||||
for k in indexes:
|
for k in indexes:
|
||||||
path = checkpoint_path + str(k) + '/'+filename+'.h5'
|
path = checkpoint_path + str(k) + '/'+filename+'.h5'
|
||||||
hdf = HDF5File(MESH['mesh'].mpi_comm(), path, 'r')
|
hdf = HDF5File(MESH['mesh'].mpi_comm(), path, 'r')
|
||||||
@ -244,9 +228,7 @@ def READcheckpoint(MESH, mode, output_path, checkpoint_path, filename, outname,
|
|||||||
uvec = u.vector().get_local()
|
uvec = u.vector().get_local()
|
||||||
|
|
||||||
if Phase_Contrast:
|
if Phase_Contrast:
|
||||||
ufactor = options['Perturbation']['type']['phase_contrast']/100
|
#gamma = 267.513e6 # rad/Tesla/sec Gyromagnetic ratio for H nuclei
|
||||||
VENC = np.max(np.abs(uvec))*ufactor
|
|
||||||
gamma = 267.513e6 # rad/Tesla/sec Gyromagnetic ratio for H nuclei
|
|
||||||
B0 = 1.5 # Tesla Magnetic Field Strenght
|
B0 = 1.5 # Tesla Magnetic Field Strenght
|
||||||
TE = 5e-3 # Echo-time
|
TE = 5e-3 # Echo-time
|
||||||
Phi1 = 1*B0*TE + 0*uvec
|
Phi1 = 1*B0*TE + 0*uvec
|
||||||
@ -474,7 +456,11 @@ def ERRORmap(MESH, mode, outpath, reference_path, checkpoint_path, refname,comna
|
|||||||
|
|
||||||
from dolfin import HDF5File
|
from dolfin import HDF5File
|
||||||
V = MESH['FEM']
|
V = MESH['FEM']
|
||||||
|
V1 = MESH['FEM'].sub(1).collapse()
|
||||||
W = MESH['FEM'].sub(0).collapse()
|
W = MESH['FEM'].sub(0).collapse()
|
||||||
|
DGs = FunctionSpace( MESH['mesh'], 'DG',0)
|
||||||
|
cellv = CellVolume(MESH['mesh'])
|
||||||
|
h = CellDiameter(MESH['mesh'])
|
||||||
unsort_indexes = os.listdir(checkpoint_path)
|
unsort_indexes = os.listdir(checkpoint_path)
|
||||||
indexes = [int(x) for x in unsort_indexes]
|
indexes = [int(x) for x in unsort_indexes]
|
||||||
indexes.sort()
|
indexes.sort()
|
||||||
@ -486,6 +472,80 @@ def ERRORmap(MESH, mode, outpath, reference_path, checkpoint_path, refname,comna
|
|||||||
if len(indexes)!=len(indexes0):
|
if len(indexes)!=len(indexes0):
|
||||||
raise Exception('The lengh of the checkpoints are not the same!')
|
raise Exception('The lengh of the checkpoints are not the same!')
|
||||||
|
|
||||||
|
if mode == 'algebra':
|
||||||
|
outname = options['Algebra']['outname']
|
||||||
|
output = XDMFFile(outpath+outname+'.xdmf')
|
||||||
|
checkpoint = options['Algebra']['checkpoint']
|
||||||
|
v1 = Function(W)
|
||||||
|
v2 = Function(W)
|
||||||
|
vout = Function(W)
|
||||||
|
vout.rename('velocity','velocity')
|
||||||
|
vout_vec = np.zeros(vout.vector().get_local().size)
|
||||||
|
times_vec = np.zeros(len(indexes0))
|
||||||
|
vdict1 = {}
|
||||||
|
vdict2 = {}
|
||||||
|
if options['Algebra']['mode'] == 'aliasing':
|
||||||
|
print('Assuming the corrector in the second path entered')
|
||||||
|
|
||||||
|
# Reading all the timestamps first
|
||||||
|
for k in range(len(indexes)):
|
||||||
|
path_v1 = reference_path + str(indexes0[k]) + '/'+refname+'.h5'
|
||||||
|
path_v2 = checkpoint_path + str(indexes[k]) + '/'+comname+'.h5'
|
||||||
|
hdf_v1 = HDF5File(MESH['mesh'].mpi_comm(), path_v1, 'r')
|
||||||
|
|
||||||
|
if 'w' in refname:
|
||||||
|
hdf_v1.read(v1, 'w/vector_0')
|
||||||
|
time = hdf_v1.attributes('w/vector_0').to_dict()['timestamp']
|
||||||
|
else:
|
||||||
|
hdf_v1.read(v1, 'u/vector_0')
|
||||||
|
time = hdf_v1.attributes('u/vector_0').to_dict()['timestamp']
|
||||||
|
times_vec[k] = time
|
||||||
|
hdf_v2 = HDF5File(MESH['mesh'].mpi_comm(), path_v2, 'r')
|
||||||
|
if 'w' in comname:
|
||||||
|
hdf_v2.read(v2, 'w/vector_0')
|
||||||
|
else:
|
||||||
|
hdf_v2.read(v2, 'u/vector_0')
|
||||||
|
|
||||||
|
print('computing algebra for the time',time)
|
||||||
|
hdf_v1.close()
|
||||||
|
hdf_v2.close()
|
||||||
|
vdict1[k] = v1.vector().get_local()
|
||||||
|
vdict2[k] = v2.vector().get_local()
|
||||||
|
|
||||||
|
|
||||||
|
for k in range(len(indexes)):
|
||||||
|
if options['Algebra']['mode'] == '+':
|
||||||
|
vout.vector()[:] = vdict1[k] + vdict2[k]
|
||||||
|
elif options['Algebra']['mode'] == '-':
|
||||||
|
vout.vector()[:] = vdict1[k] - vdict2[k]
|
||||||
|
elif options['Algebra']['mode'] == 'aliasing':
|
||||||
|
VENC = options['Algebra']['VENC']
|
||||||
|
aliasing = False
|
||||||
|
for l in range(len(vout_vec)):
|
||||||
|
if k>0:
|
||||||
|
#mean1 = abs(np.mean(vdict2[0][:]))
|
||||||
|
#mean2 = abs(np.mean(vdict2[1][:]))
|
||||||
|
#mean3 = abs(np.mean(vdict2[2][:]))
|
||||||
|
#treshold = 10*max(mean1,mean2,mean3)
|
||||||
|
#if abs(np.mean(vdict2[k][:]))>treshold:
|
||||||
|
# vout_vec[l] = 0
|
||||||
|
if vdict1[k][l]-vdict1[k-1][l] < -VENC:
|
||||||
|
vdict1[k][l] = vdict1[k][l] + 2*VENC
|
||||||
|
vout_vec[l] = vdict1[k][l]
|
||||||
|
else:
|
||||||
|
vout_vec[l] = vdict1[k][l]
|
||||||
|
else:
|
||||||
|
vout_vec[l] = vdict1[k][l] # first case is suppouse to be aliasing-free
|
||||||
|
|
||||||
|
vout.vector()[:] = vout_vec
|
||||||
|
else:
|
||||||
|
raise Exception('Not supported operation between vectors!')
|
||||||
|
|
||||||
|
output.write(vout, times_vec[k])
|
||||||
|
if checkpoint:
|
||||||
|
path = outpath + 'checkpoint/' + str(indexes[k]) + '/' + 'u.h5'
|
||||||
|
inout.write_HDF5_data(MESH['mesh'].mpi_comm(), path , vout, '/u', t=times_vec[k])
|
||||||
|
|
||||||
if mode =='curves':
|
if mode =='curves':
|
||||||
|
|
||||||
if options['Error-curves']['undersampling']>1:
|
if options['Error-curves']['undersampling']>1:
|
||||||
@ -495,27 +555,54 @@ def ERRORmap(MESH, mode, outpath, reference_path, checkpoint_path, refname,comna
|
|||||||
|
|
||||||
u = Function(W)
|
u = Function(W)
|
||||||
w = Function(W)
|
w = Function(W)
|
||||||
|
ones = interpolate(Constant(1), V.sub(1).collapse())
|
||||||
|
L_sys = assemble(ones*dx)
|
||||||
|
VENC = options['Error-curves']['VENC']
|
||||||
|
|
||||||
for typs in options['Error-curves']['type']:
|
for typs in options['Error-curves']['type']:
|
||||||
ucomp = []
|
ucomp = []
|
||||||
wcomp = []
|
wcomp = []
|
||||||
|
div_array = []
|
||||||
|
varu = []
|
||||||
times = []
|
times = []
|
||||||
dt = options['Error-curves']['dt']
|
|
||||||
for k in range(1,len(indexes)):
|
if typs == 'l2_comp':
|
||||||
path_w = checkpoint_path + str(indexes[k]) + '/'+comname+'.h5'
|
wy = Function(V1)
|
||||||
path_u = reference_path + str(indexes0[k]) + '/'+refname+'.h5'
|
wz = Function(V1)
|
||||||
|
comname2 = comname
|
||||||
|
wx_array = []
|
||||||
|
wy_array = []
|
||||||
|
wz_array = []
|
||||||
|
|
||||||
|
if typs == 'utrue-uobs':
|
||||||
|
u_path = options['Error-curves']['true_check'] + 'checkpoint/'
|
||||||
|
w_path = options['Error-curves']['ref_check'] + 'checkpoint/'
|
||||||
|
comname2 = 'u'
|
||||||
|
varux_array = []
|
||||||
|
varuy_array = []
|
||||||
|
varuz_array = []
|
||||||
|
else:
|
||||||
|
u_path = reference_path
|
||||||
|
w_path = checkpoint_path
|
||||||
|
|
||||||
|
dt = options['Error-curves']['dt']
|
||||||
|
|
||||||
|
for k in range(1,len(indexes)):
|
||||||
|
path_w = w_path + str(indexes[k]) + '/'+comname2+'.h5'
|
||||||
|
path_u = u_path + str(indexes0[k]) + '/'+refname+'.h5'
|
||||||
u.rename('meas', 'meas')
|
u.rename('meas', 'meas')
|
||||||
w.rename('w', 'w')
|
w.rename('w', 'w')
|
||||||
hdf_w = HDF5File(MESH['mesh'].mpi_comm(),path_w,'r')
|
hdf_w = HDF5File(MESH['mesh'].mpi_comm(),path_w,'r')
|
||||||
if 'w' in comname:
|
if 'w' in comname2:
|
||||||
hdf_w.read(w, 'w/vector_0')
|
hdf_w.read(w, 'w/vector_0')
|
||||||
else:
|
else:
|
||||||
hdf_w.read(w, 'u/vector_0')
|
hdf_w.read(w, 'u/vector_0')
|
||||||
hdf_u = HDF5File(MESH['mesh'].mpi_comm(), path_u, 'r')
|
if typs != 'l2_comp':
|
||||||
hdf_u.read(u, 'u/vector_0')
|
hdf_u = HDF5File(MESH['mesh'].mpi_comm(), path_u, 'r')
|
||||||
hdf_u.close()
|
hdf_u.read(u, 'u/vector_0')
|
||||||
|
hdf_u.close()
|
||||||
|
u_vec = u.vector().get_local()
|
||||||
hdf_w.close()
|
hdf_w.close()
|
||||||
u_vec = u.vector().get_local()
|
|
||||||
w_vec = w.vector().get_local()
|
w_vec = w.vector().get_local()
|
||||||
print('computing error in timestep numer',k)
|
print('computing error in timestep numer',k)
|
||||||
|
|
||||||
@ -525,59 +612,53 @@ def ERRORmap(MESH, mode, outpath, reference_path, checkpoint_path, refname,comna
|
|||||||
elif typs == 'max':
|
elif typs == 'max':
|
||||||
ucomp.append(np.max(abs(u_vec)))
|
ucomp.append(np.max(abs(u_vec)))
|
||||||
wcomp.append(np.max(abs(w_vec)))
|
wcomp.append(np.max(abs(w_vec)))
|
||||||
|
elif typs == 'norm2':
|
||||||
|
ucomp.append(np.sqrt(assemble(dot(u,u)*dx)/L_sys))
|
||||||
|
wcomp.append(np.sqrt(assemble(dot(w,w)*dx)/L_sys))
|
||||||
|
elif typs == 'grad':
|
||||||
|
wcomp.append(np.sqrt(assemble(inner(grad(w),grad(w))*dx)/L_sys))
|
||||||
|
elif typs == 'l2_comp':
|
||||||
|
wx = w.sub(0,deepcopy=True)
|
||||||
|
wy = w.sub(1,deepcopy=True)
|
||||||
|
wz = w.sub(2,deepcopy=True)
|
||||||
|
wx_array.append(np.sqrt(assemble(wx*wx*dx)/L_sys)/VENC)
|
||||||
|
wy_array.append(np.sqrt(assemble(wy*wy*dx)/L_sys)/VENC)
|
||||||
|
wz_array.append(np.sqrt(assemble(wz*wz*dx)/L_sys)/VENC)
|
||||||
|
elif typs == 'div':
|
||||||
|
div_array.append(np.sqrt(assemble(div(u)**2/h*dx)/L_sys)/VENC)
|
||||||
|
elif typs == 'utrue-uobs':
|
||||||
|
wx = w.sub(0,deepcopy=True)
|
||||||
|
wy = w.sub(1,deepcopy=True)
|
||||||
|
wz = w.sub(2,deepcopy=True)
|
||||||
|
ux = u.sub(0,deepcopy=True)
|
||||||
|
uy = u.sub(1,deepcopy=True)
|
||||||
|
uz = u.sub(2,deepcopy=True)
|
||||||
|
varux_array.append(np.sqrt(assemble((ux-wx)**2*dx)/L_sys)/VENC)
|
||||||
|
varuy_array.append(np.sqrt(assemble((uy-wy)**2*dx)/L_sys)/VENC)
|
||||||
|
varuz_array.append(np.sqrt(assemble((uz-wz)**2*dx)/L_sys)/VENC)
|
||||||
else:
|
else:
|
||||||
raise Exception('No defined type for curve printing!')
|
raise Exception('No defined type for curve printing!')
|
||||||
|
|
||||||
times.append(k*dt)
|
times.append(k*dt)
|
||||||
|
|
||||||
np.savetxt(outpath+'u' +typs+'.txt',ucomp)
|
if typs == 'grad':
|
||||||
np.savetxt(outpath+'w' +typs+'.txt',wcomp)
|
np.savetxt(outpath+'w' +typs+'.txt',wcomp)
|
||||||
|
elif typs == 'l2_comp':
|
||||||
|
np.savetxt(outpath+'wx.txt',wx_array)
|
||||||
|
np.savetxt(outpath+'wy.txt',wy_array)
|
||||||
|
np.savetxt(outpath+'wz.txt',wz_array)
|
||||||
|
elif typs == 'div':
|
||||||
|
np.savetxt(outpath+'div.txt',div_array)
|
||||||
|
elif typs == 'utrue-uobs':
|
||||||
|
np.savetxt(outpath+'varux.txt',varux_array)
|
||||||
|
np.savetxt(outpath+'varuy.txt',varuy_array)
|
||||||
|
np.savetxt(outpath+'varuz.txt',varuz_array)
|
||||||
|
else:
|
||||||
|
np.savetxt(outpath+'u' +typs+'.txt',ucomp)
|
||||||
|
np.savetxt(outpath+'w' +typs+'.txt',wcomp)
|
||||||
|
|
||||||
np.savetxt(outpath+'times.txt',times)
|
np.savetxt(outpath+'times.txt',times)
|
||||||
|
|
||||||
if mode == 'histogram':
|
|
||||||
from pathlib import Path
|
|
||||||
import pickle
|
|
||||||
u = Function(V)
|
|
||||||
w = Function(V)
|
|
||||||
errors = {}
|
|
||||||
|
|
||||||
for k in range(len(indexes)):
|
|
||||||
path_w = checkpoint_path + str(indexes[k]) + '/'+comname+'.h5'
|
|
||||||
path_u = reference_path + str(indexes0[k]) + '/'+refname+'.h5'
|
|
||||||
|
|
||||||
if indexes0[k] < 10:
|
|
||||||
path_u = reference_path + '0' + \
|
|
||||||
str(indexes0[k]) + '/'+refname+'.h5'
|
|
||||||
|
|
||||||
u.rename('meas', 'meas')
|
|
||||||
w.rename('w', 'w')
|
|
||||||
hdf_w = HDF5File(MESH['mesh'].mpi_comm(),path_w,'r')
|
|
||||||
hdf_w.read(w, 'w/vector_0')
|
|
||||||
hdf_u = HDF5File(MESH['mesh'].mpi_comm(), path_u, 'r')
|
|
||||||
hdf_u.read(u, 'u/vector_0')
|
|
||||||
hdf_u.close()
|
|
||||||
hdf_w.close()
|
|
||||||
|
|
||||||
u_vec = u.vector().get_local()
|
|
||||||
w_vec = w.vector().get_local()
|
|
||||||
errors[k] = np.zeros(u_vec.size)
|
|
||||||
|
|
||||||
for l in range(len(errors[k])):
|
|
||||||
#errors[k][l] = np.nan
|
|
||||||
if u_vec[l]<1e-9:
|
|
||||||
errors[k][l] = -1
|
|
||||||
else:
|
|
||||||
eta = np.abs(w_vec[l]/u_vec[l])
|
|
||||||
if np.abs(eta)>50:
|
|
||||||
errors[k][l] = -1
|
|
||||||
else:
|
|
||||||
errors[k][l] = eta
|
|
||||||
|
|
||||||
|
|
||||||
write_path = Path(outpath)
|
|
||||||
fpath = write_path.joinpath('errors.dat')
|
|
||||||
pickle.dump(errors, fpath.open('wb'))
|
|
||||||
|
|
||||||
if mode == 'h5':
|
if mode == 'h5':
|
||||||
xdmf_u = XDMFFile(outpath+'meas.xdmf')
|
xdmf_u = XDMFFile(outpath+'meas.xdmf')
|
||||||
#xdmf_ucor = XDMFFile(output_path+'ucor.xdmf')
|
#xdmf_ucor = XDMFFile(output_path+'ucor.xdmf')
|
||||||
@ -592,10 +673,6 @@ def ERRORmap(MESH, mode, outpath, reference_path, checkpoint_path, refname,comna
|
|||||||
path_w = checkpoint_path + str(indexes[k]) + '/'+comname+'.h5'
|
path_w = checkpoint_path + str(indexes[k]) + '/'+comname+'.h5'
|
||||||
path_u = reference_path + str(indexes0[k]) + '/'+refname+'.h5'
|
path_u = reference_path + str(indexes0[k]) + '/'+refname+'.h5'
|
||||||
|
|
||||||
if indexes0[k] < 10:
|
|
||||||
path_u = reference_path + '0' + \
|
|
||||||
str(indexes0[k]) + '/'+refname+'.h5'
|
|
||||||
|
|
||||||
u.rename('meas', 'meas')
|
u.rename('meas', 'meas')
|
||||||
w.rename('w', 'w')
|
w.rename('w', 'w')
|
||||||
#ucor.rename('ucor', 'ucor')
|
#ucor.rename('ucor', 'ucor')
|
||||||
@ -612,34 +689,173 @@ def ERRORmap(MESH, mode, outpath, reference_path, checkpoint_path, refname,comna
|
|||||||
#ucor.vector()[:] = u_vec + w_vec
|
#ucor.vector()[:] = u_vec + w_vec
|
||||||
|
|
||||||
xdmf_u.write(u, k)
|
xdmf_u.write(u, k)
|
||||||
#xdmf_ucor.write(ucor, k)
|
|
||||||
xdmf_w.write(w, k)
|
xdmf_w.write(w, k)
|
||||||
|
|
||||||
if mode == 'colormap':
|
if mode == 'u':
|
||||||
colormap = XDMFFile(outpath+'colormap.xdmf')
|
colormap = XDMFFile(outpath+'u.xdmf')
|
||||||
|
#ds = Measure("ds", subdomain_data=MESH['boundaries'])
|
||||||
|
u = Function(W)
|
||||||
|
#P2 = FunctionSpace( MESH['mesh'], 'P',1)
|
||||||
|
cm = Function(DGs)
|
||||||
|
vs = TestFunction(DGs)
|
||||||
|
|
||||||
|
for k in range(len(indexes)):
|
||||||
|
path_u = reference_path + str(indexes0[k]) + '/'+refname+'.h5'
|
||||||
|
u.rename('meas', 'meas')
|
||||||
|
cm.rename('vel','vel')
|
||||||
|
hdf_u = HDF5File(MESH['mesh'].mpi_comm(), path_u, 'r')
|
||||||
|
hdf_u.read(u, 'u/vector_0')
|
||||||
|
time = hdf_u.attributes('u/vector_0').to_dict()['timestamp']
|
||||||
|
print('making the colormap in the time',time)
|
||||||
|
hdf_u.close()
|
||||||
|
r = assemble(dot(u,u)*vs/cellv*dx).get_local()
|
||||||
|
cm.vector()[:] = np.sqrt(np.abs(r))
|
||||||
|
#cm.vector()[:] = np.sqrt(r)
|
||||||
|
colormap.write(cm, time)
|
||||||
|
|
||||||
|
if mode == 'w':
|
||||||
|
colormap = XDMFFile(outpath+'w.xdmf')
|
||||||
|
#ds = Measure("ds", subdomain_data=MESH['boundaries'])
|
||||||
|
w = Function(W)
|
||||||
|
#P2 = FunctionSpace( MESH['mesh'], 'P',2)
|
||||||
|
cm = Function(DGs)
|
||||||
|
vs = TestFunction(DGs)
|
||||||
|
|
||||||
|
for k in range(len(indexes)):
|
||||||
|
path_w = checkpoint_path + str(indexes0[k]) + '/'+comname+'.h5'
|
||||||
|
w.rename('cor', 'cor')
|
||||||
|
cm.rename('w','w')
|
||||||
|
hdf_w = HDF5File(MESH['mesh'].mpi_comm(), path_w, 'r')
|
||||||
|
hdf_w.read(w, 'w/vector_0')
|
||||||
|
time = hdf_w.attributes('w/vector_0').to_dict()['timestamp']
|
||||||
|
print('making the colormap in the time',time)
|
||||||
|
hdf_w.close()
|
||||||
|
r = assemble(dot(w,w)*vs/cellv*dx).get_local()
|
||||||
|
cm.vector()[:] = np.sqrt(np.abs(r))
|
||||||
|
colormap.write(cm, time)
|
||||||
|
|
||||||
|
if mode == 'w/u':
|
||||||
|
colormap = XDMFFile(outpath+'w_u.xdmf')
|
||||||
#ds = Measure("ds", subdomain_data=MESH['boundaries'])
|
#ds = Measure("ds", subdomain_data=MESH['boundaries'])
|
||||||
u = Function(W)
|
u = Function(W)
|
||||||
w = Function(W)
|
w = Function(W)
|
||||||
cm = Function(W)
|
cm = Function(DGs)
|
||||||
dt = options['Corrector']['dt']
|
vs = TestFunction(DGs)
|
||||||
|
|
||||||
for k in range(len(indexes)):
|
for k in range(len(indexes)):
|
||||||
print('making the colormap in the time',np.round(k*dt,2))
|
|
||||||
path_w = checkpoint_path + str(indexes[k]) + '/'+comname+'.h5'
|
path_w = checkpoint_path + str(indexes[k]) + '/'+comname+'.h5'
|
||||||
path_u = reference_path + str(indexes0[k]) + '/'+refname+'.h5'
|
path_u = reference_path + str(indexes0[k]) + '/'+refname+'.h5'
|
||||||
u.rename('meas', 'meas')
|
u.rename('meas', 'meas')
|
||||||
w.rename('w', 'w')
|
w.rename('w', 'w')
|
||||||
cm.rename('color','color')
|
cm.rename('w_u','w_u')
|
||||||
hdf_w = HDF5File(MESH['mesh'].mpi_comm(),path_w,'r')
|
hdf_w = HDF5File(MESH['mesh'].mpi_comm(),path_w,'r')
|
||||||
hdf_w.read(w, 'w/vector_0')
|
hdf_w.read(w, 'w/vector_0')
|
||||||
hdf_u = HDF5File(MESH['mesh'].mpi_comm(), path_u, 'r')
|
hdf_u = HDF5File(MESH['mesh'].mpi_comm(), path_u, 'r')
|
||||||
hdf_u.read(u, 'u/vector_0')
|
hdf_u.read(u, 'u/vector_0')
|
||||||
|
time = hdf_u.attributes('u/vector_0').to_dict()['timestamp']
|
||||||
|
print('making the colormap in the time',time)
|
||||||
hdf_u.close()
|
hdf_u.close()
|
||||||
hdf_w.close()
|
hdf_w.close()
|
||||||
uvec = u.vector().get_local()
|
rw = assemble(dot(w,w)*vs/cellv*dx).get_local()
|
||||||
wvec = w.vector().get_local()
|
ru = assemble(dot(u,u)*vs/cellv*dx).get_local()
|
||||||
cm.vector()[:] = np.sqrt((uvec - wvec)**2)
|
cm.vector()[:] = np.sqrt(rw)/np.sqrt(ru)
|
||||||
colormap.write(cm, k*dt)
|
colormap.write(cm, time)
|
||||||
|
|
||||||
|
if mode == 'dot':
|
||||||
|
colormap = XDMFFile(outpath+'dot.xdmf')
|
||||||
|
#ds = Measure("ds", subdomain_data=MESH['boundaries'])
|
||||||
|
u = Function(W)
|
||||||
|
w = Function(W)
|
||||||
|
cm = Function(V1)
|
||||||
|
u.rename('meas', 'meas')
|
||||||
|
w.rename('w', 'w')
|
||||||
|
|
||||||
|
for k in range(len(indexes)):
|
||||||
|
path_w = checkpoint_path + str(indexes[k]) + '/'+comname+'.h5'
|
||||||
|
path_u = reference_path + str(indexes0[k]) + '/'+refname+'.h5'
|
||||||
|
hdf_w = HDF5File(MESH['mesh'].mpi_comm(),path_w,'r')
|
||||||
|
hdf_w.read(w, 'w/vector_0')
|
||||||
|
hdf_u = HDF5File(MESH['mesh'].mpi_comm(), path_u, 'r')
|
||||||
|
hdf_u.read(u, 'u/vector_0')
|
||||||
|
time = hdf_u.attributes('u/vector_0').to_dict()['timestamp']
|
||||||
|
print('making the colormap in the time',time)
|
||||||
|
hdf_u.close()
|
||||||
|
hdf_w.close()
|
||||||
|
cm = project(inner(u,w),V1)
|
||||||
|
cm.rename('dot','dot')
|
||||||
|
colormap.write(cm, time)
|
||||||
|
|
||||||
|
if mode == 'div(u)':
|
||||||
|
|
||||||
|
colormap = XDMFFile(outpath+'divu.xdmf')
|
||||||
|
#ds = Measure("ds", subdomain_data=MESH['boundaries'])
|
||||||
|
u = Function(W)
|
||||||
|
cm = Function(DGs)
|
||||||
|
vs = TestFunction(DGs)
|
||||||
|
|
||||||
|
for k in range(len(indexes)):
|
||||||
|
path_u = reference_path + str(indexes0[k]) + '/'+refname+'.h5'
|
||||||
|
u.rename('meas', 'meas')
|
||||||
|
cm.rename('divu','divu')
|
||||||
|
hdf_u = HDF5File(MESH['mesh'].mpi_comm(), path_u, 'r')
|
||||||
|
hdf_u.read(u, 'u/vector_0')
|
||||||
|
time = hdf_u.attributes('u/vector_0').to_dict()['timestamp']
|
||||||
|
print('making the colormap in the time',time)
|
||||||
|
hdf_u.close()
|
||||||
|
r = assemble(div(u)**2*vs/cellv*dx).get_local()
|
||||||
|
cm.vector()[:] = np.sqrt(r)
|
||||||
|
colormap.write(cm, time)
|
||||||
|
|
||||||
|
if mode == 'div(u)/u':
|
||||||
|
|
||||||
|
colormap = XDMFFile(outpath+'divu_u.xdmf')
|
||||||
|
#ds = Measure("ds", subdomain_data=MESH['boundaries'])
|
||||||
|
u = Function(W)
|
||||||
|
cm = Function(DGs)
|
||||||
|
vs = TestFunction(DGs)
|
||||||
|
|
||||||
|
surface = np.zeros(cm.vector().get_local().size)
|
||||||
|
volume = np.zeros(cm.vector().get_local().size)
|
||||||
|
Cells = MESH['mesh'].cells()
|
||||||
|
Points = MESH['mesh'].coordinates()
|
||||||
|
for k in range(MESH['mesh'].num_cells()):
|
||||||
|
A = Points[Cells[k]][0]
|
||||||
|
B = Points[Cells[k]][1]
|
||||||
|
C = Points[Cells[k]][2]
|
||||||
|
D = Points[Cells[k]][3]
|
||||||
|
# volume
|
||||||
|
Vol = 1/6*np.abs(np.inner(A-D, np.cross(B-D, C-D)))
|
||||||
|
volume[k] = Vol
|
||||||
|
# surface area
|
||||||
|
SA = 0
|
||||||
|
for l in range(4):
|
||||||
|
if l == 0:
|
||||||
|
[P1, P2, P3, P4] = [A, B, C, D]
|
||||||
|
if l == 1:
|
||||||
|
[P1, P2, P3, P4] = [D, A, B, C]
|
||||||
|
if l == 2:
|
||||||
|
[P1, P2, P3, P4] = [C, D, A, B]
|
||||||
|
if l == 3:
|
||||||
|
[P1, P2, P3, P4] = [B, C, D, A]
|
||||||
|
|
||||||
|
SA += 0.5*np.linalg.norm(np.cross(P2-P1, P3-P1))
|
||||||
|
surface[k] = SA
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for k in range(len(indexes)):
|
||||||
|
path_u = reference_path + str(indexes0[k]) + '/'+refname+'.h5'
|
||||||
|
u.rename('meas', 'meas')
|
||||||
|
cm.rename('divu','divu')
|
||||||
|
hdf_u = HDF5File(MESH['mesh'].mpi_comm(), path_u, 'r')
|
||||||
|
hdf_u.read(u, 'u/vector_0')
|
||||||
|
time = hdf_u.attributes('u/vector_0').to_dict()['timestamp']
|
||||||
|
print('making the colormap in the time',time)
|
||||||
|
hdf_u.close()
|
||||||
|
rdiv = assemble(div(u)**2*vs*dx).get_local()
|
||||||
|
ru = assemble(dot(u,u)*vs*dx).get_local()
|
||||||
|
cm.vector()[:] = np.sqrt(rdiv)/np.sqrt(ru)*volume/surface/np.sqrt(120)
|
||||||
|
colormap.write(cm, time)
|
||||||
|
|
||||||
if mode == 'error_u':
|
if mode == 'error_u':
|
||||||
xdmf_u = XDMFFile(output_path+'error_u.xdmf')
|
xdmf_u = XDMFFile(output_path+'error_u.xdmf')
|
||||||
@ -874,6 +1090,11 @@ def ESTIMpressure(MESH, outpath, checkpoint_path, filename, options):
|
|||||||
#from dolfin import HDF5File
|
#from dolfin import HDF5File
|
||||||
V = MESH['FEM']
|
V = MESH['FEM']
|
||||||
W = MESH['FEM'].sub(1).collapse()
|
W = MESH['FEM'].sub(1).collapse()
|
||||||
|
p = Function(W)
|
||||||
|
one_mesh = interpolate(Constant(1), W)
|
||||||
|
dt = options['Estim_Pressure']['dt']
|
||||||
|
p_drop_lst = []
|
||||||
|
time_ = []
|
||||||
# Checkpoints folders
|
# Checkpoints folders
|
||||||
unsort_indexes = os.listdir(checkpoint_path)
|
unsort_indexes = os.listdir(checkpoint_path)
|
||||||
indexes = [int(x) for x in unsort_indexes]
|
indexes = [int(x) for x in unsort_indexes]
|
||||||
@ -897,22 +1118,25 @@ def ESTIMpressure(MESH, outpath, checkpoint_path, filename, options):
|
|||||||
sphere1 = mshr.Sphere(x1, radius1)
|
sphere1 = mshr.Sphere(x1, radius1)
|
||||||
mesh_s1 = mshr.generate_mesh(sphere0, Npts0)
|
mesh_s1 = mshr.generate_mesh(sphere0, Npts0)
|
||||||
mesh_s2 = mshr.generate_mesh(sphere1, Npts1)
|
mesh_s2 = mshr.generate_mesh(sphere1, Npts1)
|
||||||
|
# New elements
|
||||||
|
VS1 = FunctionSpace(mesh_s1, FiniteElement('P', mesh_s1.ufl_cell(), 1))
|
||||||
|
VS2 = FunctionSpace(mesh_s2, FiniteElement('P', mesh_s2.ufl_cell(), 1))
|
||||||
|
s1 = Function(VS1)
|
||||||
|
s2 = Function(VS2)
|
||||||
|
LagrangeInterpolator.interpolate(s1, one_mesh)
|
||||||
|
LagrangeInterpolator.interpolate(s2, one_mesh)
|
||||||
|
vol1 = assemble(s1*dx)
|
||||||
|
vol2 = assemble(s1*dx)
|
||||||
|
|
||||||
VS1 = FunctionSpace(mesh_s1, FiniteElement('P', mesh_s1.ufl_cell(), 1))
|
if options['Estim_Pressure']['method'] == 'boundaries':
|
||||||
VS2 = FunctionSpace(mesh_s2, FiniteElement('P', mesh_s2.ufl_cell(), 1))
|
boundaries = MESH['boundaries']
|
||||||
s1 = Function(VS1)
|
ds = Measure("ds", subdomain_data=boundaries)
|
||||||
s2 = Function(VS2)
|
bnd1 = options['Estim_Pressure']['boundaries'][0]
|
||||||
p = Function(W)
|
bnd2 = options['Estim_Pressure']['boundaries'][1]
|
||||||
|
area1 = assemble(one_mesh*ds(bnd1))
|
||||||
one_mesh = interpolate(Constant(1), W)
|
area2 = assemble(one_mesh*ds(bnd2))
|
||||||
LagrangeInterpolator.interpolate(s1, one_mesh)
|
|
||||||
LagrangeInterpolator.interpolate(s2, one_mesh)
|
|
||||||
vol1 = assemble(s1*dx)
|
|
||||||
vol2 = assemble(s1*dx)
|
|
||||||
|
|
||||||
dt = options['Estim_Pressure']['dt']
|
|
||||||
p_drop_lst = []
|
|
||||||
time_ = []
|
|
||||||
|
|
||||||
for k in range(0, len(indexes)):
|
for k in range(0, len(indexes)):
|
||||||
path = checkpoint_path + str(indexes[k]) + '/'+filename+'.h5'
|
path = checkpoint_path + str(indexes[k]) + '/'+filename+'.h5'
|
||||||
@ -920,11 +1144,14 @@ def ESTIMpressure(MESH, outpath, checkpoint_path, filename, options):
|
|||||||
hdf.read(p, 'p/vector_0')
|
hdf.read(p, 'p/vector_0')
|
||||||
hdf.close()
|
hdf.close()
|
||||||
|
|
||||||
LagrangeInterpolator.interpolate(s1, p)
|
if options['Estim_Pressure']['method'] == 'spheres':
|
||||||
LagrangeInterpolator.interpolate(s2, p)
|
LagrangeInterpolator.interpolate(s1, p)
|
||||||
|
LagrangeInterpolator.interpolate(s2, p)
|
||||||
P1 = assemble(s1*dx)/vol1
|
P1 = assemble(s1*dx)/vol1
|
||||||
P2 = assemble(s2*dx)/vol2
|
P2 = assemble(s2*dx)/vol2
|
||||||
|
if options['Estim_Pressure']['method'] == 'boundaries':
|
||||||
|
P1 = assemble(p*ds(bnd1))/area1
|
||||||
|
P2 = assemble(p*ds(bnd2))/area2
|
||||||
|
|
||||||
p_drop_lst.append(P2-P1)
|
p_drop_lst.append(P2-P1)
|
||||||
time_.append(k*dt)
|
time_.append(k*dt)
|
||||||
@ -1012,41 +1239,60 @@ def OUTLETwind(MESH, output_path, checkpoint_path, filename, bnds):
|
|||||||
|
|
||||||
def ROUTINE(options):
|
def ROUTINE(options):
|
||||||
|
|
||||||
|
if 'Algebra' in options:
|
||||||
|
if options['Algebra']['apply']:
|
||||||
|
|
||||||
|
if rank == 0:
|
||||||
|
print('Applying Algebra')
|
||||||
|
print('Choosen mode: ' + options['Algebra']['mode'])
|
||||||
|
|
||||||
|
MESH = LOADmesh(options['Algebra']['meshpath'])
|
||||||
|
v1path = options['Algebra']['v1']['path'] + 'checkpoint/'
|
||||||
|
v1name = options['Algebra']['v1']['name']
|
||||||
|
v2path = options['Algebra']['v2']['path'] + 'checkpoint/'
|
||||||
|
v2name = options['Algebra']['v2']['name']
|
||||||
|
outpath = options['Algebra']['outpath']
|
||||||
|
|
||||||
|
ERRORmap(MESH, 'algebra', outpath, v1path,
|
||||||
|
v2path, v1name, v2name, options)
|
||||||
|
|
||||||
if 'Outlet_Wind' in options:
|
if 'Outlet_Wind' in options:
|
||||||
if options['Outlet_Wind']['apply']:
|
if options['Outlet_Wind']['apply']:
|
||||||
if rank == 0:
|
if rank == 0:
|
||||||
print('--- Outlet Windkessel ---')
|
print('--- Outlet Windkessel ---')
|
||||||
|
|
||||||
mesh_path = options['Outlet_Wind']['mesh_path']
|
meshpath = options['Outlet_Wind']['meshpath']
|
||||||
out_path = options['Outlet_Wind']['out_path']
|
out_path = options['Outlet_Wind']['out_path']
|
||||||
filename = options['Outlet_Wind']['filename']
|
filename = options['Outlet_Wind']['filename']
|
||||||
checkpoint = options['Outlet_Wind']['checkpoint'] + 'checkpoint/'
|
checkpoint = options['Outlet_Wind']['checkpoint'] + 'checkpoint/'
|
||||||
bnds = options['Outlet_Wind']['bnds']
|
bnds = options['Outlet_Wind']['bnds']
|
||||||
MESH = LOADmesh(mesh_path)
|
MESH = LOADmesh(meshpath)
|
||||||
OUTLETwind(MESH, out_path, checkpoint, filename, bnds)
|
OUTLETwind(MESH, out_path, checkpoint, filename, bnds)
|
||||||
|
|
||||||
if 'Corrector' in options:
|
if 'Colormap' in options:
|
||||||
if options['Corrector']['apply']:
|
if options['Colormap']['apply']:
|
||||||
if rank == 0:
|
|
||||||
print('Applying Corrector')
|
|
||||||
|
|
||||||
MESH = LOADmesh(options['Corrector']['mesh_path'])
|
for mode in options['Colormap']['mode']:
|
||||||
u_path = options['Corrector']['u_path'] + 'checkpoint/'
|
if rank == 0:
|
||||||
w_path = options['Corrector']['w_path'] + 'checkpoint/'
|
print('Applying Colormap')
|
||||||
wname = options['Corrector']['wname']
|
print('Choosen mode: ' + mode)
|
||||||
uname = options['Corrector']['uname']
|
|
||||||
mode = options['Corrector']['mode']
|
|
||||||
outpath = options['Corrector']['outpath']
|
|
||||||
|
|
||||||
ERRORmap(MESH, mode, outpath, u_path,
|
MESH = LOADmesh(options['Colormap']['meshpath'])
|
||||||
w_path, uname, wname, options)
|
upath = options['Colormap']['upath'] + 'checkpoint/'
|
||||||
|
wpath = options['Colormap']['wpath'] + 'checkpoint/'
|
||||||
|
wname = options['Colormap']['wname']
|
||||||
|
uname = options['Colormap']['uname']
|
||||||
|
outpath = options['Colormap']['outpath']
|
||||||
|
|
||||||
|
ERRORmap(MESH, mode, outpath, upath,
|
||||||
|
wpath, uname, wname, options)
|
||||||
|
|
||||||
if 'Velocity' in options:
|
if 'Velocity' in options:
|
||||||
if options['Velocity']['apply']:
|
if options['Velocity']['apply']:
|
||||||
if rank == 0:
|
if rank == 0:
|
||||||
print('--- Reading Velocity ---')
|
print('--- Reading Velocity ---')
|
||||||
|
|
||||||
MESH = LOADmesh(options['Velocity']['mesh_path'])
|
MESH = LOADmesh(options['Velocity']['meshpath'])
|
||||||
filename = options['Velocity']['filename']
|
filename = options['Velocity']['filename']
|
||||||
checkpoint_path = options['Velocity']['checkpoint'] + 'checkpoint/'
|
checkpoint_path = options['Velocity']['checkpoint'] + 'checkpoint/'
|
||||||
outpath = options['Velocity']['checkpoint']
|
outpath = options['Velocity']['checkpoint']
|
||||||
@ -1067,7 +1313,7 @@ def ROUTINE(options):
|
|||||||
if options['W_map']['apply']:
|
if options['W_map']['apply']:
|
||||||
if rank == 0:
|
if rank == 0:
|
||||||
print('Applying W--MAP')
|
print('Applying W--MAP')
|
||||||
MESH = LOADmesh(options['mesh_path'])
|
MESH = LOADmesh(options['meshpath'])
|
||||||
filename = options['W_map']['filename']
|
filename = options['W_map']['filename']
|
||||||
outname = options['W_map']['out_name']
|
outname = options['W_map']['out_name']
|
||||||
mode = 'w'
|
mode = 'w'
|
||||||
@ -1078,7 +1324,7 @@ def ROUTINE(options):
|
|||||||
if options['GradW_map']['apply']:
|
if options['GradW_map']['apply']:
|
||||||
if rank == 0:
|
if rank == 0:
|
||||||
print('Applying Grad W--MAP')
|
print('Applying Grad W--MAP')
|
||||||
MESH = LOADmesh(options['mesh_path'])
|
MESH = LOADmesh(options['meshpath'])
|
||||||
filename = options['GradW_map']['filename']
|
filename = options['GradW_map']['filename']
|
||||||
outname = options['GradW_map']['out_name']
|
outname = options['GradW_map']['out_name']
|
||||||
mode = 'gradw'
|
mode = 'gradw'
|
||||||
@ -1088,21 +1334,21 @@ def ROUTINE(options):
|
|||||||
if 'Pressure' in options:
|
if 'Pressure' in options:
|
||||||
if options['Pressure']['apply']:
|
if options['Pressure']['apply']:
|
||||||
if rank == 0:
|
if rank == 0:
|
||||||
print('Applying Pressure-MAP')
|
print('---Applying Pressure---')
|
||||||
|
|
||||||
MESH = LOADmesh(options['mesh_path'])
|
MESH = LOADmesh(options['meshpath'])
|
||||||
|
outpath = options['Pressure']['checkpoint']
|
||||||
|
checkpoint_path = options['Pressure']['checkpoint'] + 'checkpoint/'
|
||||||
filename = options['Pressure']['filename']
|
filename = options['Pressure']['filename']
|
||||||
outname = options['Pressure']['out_name']
|
WORKcheck(MESH, 'p', outpath, checkpoint_path,
|
||||||
mode = 'p'
|
filename, filename, options)
|
||||||
WORKcheck(MESH, mode, output_path, checkpoint_path,
|
|
||||||
filename, outname, options)
|
|
||||||
|
|
||||||
if 'Error_P' in options:
|
if 'Error_P' in options:
|
||||||
if options['Error_P']['apply']:
|
if options['Error_P']['apply']:
|
||||||
if rank == 0:
|
if rank == 0:
|
||||||
print('Applying L2 error to Pressure')
|
print('Applying L2 error to Pressure')
|
||||||
|
|
||||||
MESH = LOADmesh(options['mesh_path'])
|
MESH = LOADmesh(options['meshpath'])
|
||||||
refname = options['Error_P']['refname']
|
refname = options['Error_P']['refname']
|
||||||
reference_path = options['Error_P']['refpath']
|
reference_path = options['Error_P']['refpath']
|
||||||
filename = options['Error_P']['filename']
|
filename = options['Error_P']['filename']
|
||||||
@ -1115,10 +1361,13 @@ def ROUTINE(options):
|
|||||||
if options['Estim_Pressure']['apply']:
|
if options['Estim_Pressure']['apply']:
|
||||||
if rank == 0:
|
if rank == 0:
|
||||||
print('Applying Pressure Estimator')
|
print('Applying Pressure Estimator')
|
||||||
|
print('Method choosed: '+options['Estim_Pressure']['method'])
|
||||||
|
|
||||||
MESH = LOADmesh(options['mesh_path'])
|
MESH = LOADmesh(options['Estim_Pressure']['meshpath'])
|
||||||
filename = options['Estim_Pressure']['filename']
|
filename = options['Estim_Pressure']['filename']
|
||||||
outpath = options['Estim_Pressure']['outpath']
|
outpath = options['Estim_Pressure']['checkpath']
|
||||||
|
checkpoint_path = options['Estim_Pressure']['checkpath'] + 'checkpoint/'
|
||||||
|
|
||||||
ESTIMpressure(MESH, outpath, checkpoint_path, filename, options)
|
ESTIMpressure(MESH, outpath, checkpoint_path, filename, options)
|
||||||
|
|
||||||
if 'Error-curves' in options:
|
if 'Error-curves' in options:
|
||||||
@ -1162,7 +1411,11 @@ def ROUTINE(options):
|
|||||||
|
|
||||||
MESH = LOADmesh(options['Perturbation']['meshpath'])
|
MESH = LOADmesh(options['Perturbation']['meshpath'])
|
||||||
checkpath = options['Perturbation']['checkpath'] + 'checkpoint/'
|
checkpath = options['Perturbation']['checkpath'] + 'checkpoint/'
|
||||||
name_folder = 'SNR' +options['Perturbation']['type']['SNR'] + 'V' + str(options['Perturbation']['type']['phase_contrast'])
|
if type(options['Perturbation']['type']['SNR'])=='str':
|
||||||
|
name_folder = 'SNR' +options['Perturbation']['type']['SNR'] + 'V' + str(options['Perturbation']['type']['phase_contrast'])
|
||||||
|
else:
|
||||||
|
name_folder = 'SNR' +str(options['Perturbation']['type']['SNR']) + 'V' + str(options['Perturbation']['type']['phase_contrast'])
|
||||||
|
|
||||||
out_check = options['Perturbation']['checkpath'] + name_folder + '/'
|
out_check = options['Perturbation']['checkpath'] + name_folder + '/'
|
||||||
READcheckpoint(MESH,'perturbation', out_check,checkpath,'u','u',options)
|
READcheckpoint(MESH,'perturbation', out_check,checkpath,'u','u',options)
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -1,5 +1,4 @@
|
|||||||
from dolfin import *
|
from dolfin import *
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from common import inout
|
from common import inout
|
||||||
from mpi4py import MPI
|
from mpi4py import MPI
|
||||||
@ -23,7 +22,6 @@ def solv_NavierStokes(options):
|
|||||||
theta = Constant(options['theta'])
|
theta = Constant(options['theta'])
|
||||||
Tf = options['Tf']
|
Tf = options['Tf']
|
||||||
dt = options['dt']
|
dt = options['dt']
|
||||||
dt_w = options['dt_write']
|
|
||||||
|
|
||||||
# CREATING THE FILES
|
# CREATING THE FILES
|
||||||
xdmf_u = XDMFFile(options['savepath']+'u.xdmf')
|
xdmf_u = XDMFFile(options['savepath']+'u.xdmf')
|
||||||
@ -53,7 +51,6 @@ def solv_NavierStokes(options):
|
|||||||
BCS = []
|
BCS = []
|
||||||
bc = options['boundary_conditions']
|
bc = options['boundary_conditions']
|
||||||
# For Windkessel implementation
|
# For Windkessel implementation
|
||||||
flows = {}
|
|
||||||
pii0 = {}
|
pii0 = {}
|
||||||
pii = {}
|
pii = {}
|
||||||
press = {}
|
press = {}
|
||||||
@ -63,6 +60,23 @@ def solv_NavierStokes(options):
|
|||||||
Windkvar = {}
|
Windkvar = {}
|
||||||
windkessel = False
|
windkessel = False
|
||||||
|
|
||||||
|
u, p = TrialFunctions(W)
|
||||||
|
w = Function(W)
|
||||||
|
h = CellDiameter(mesh)
|
||||||
|
|
||||||
|
u0, p0 = w.split()
|
||||||
|
u_ = theta*u + otheta*u0
|
||||||
|
p_ = theta*p + otheta*p0
|
||||||
|
# The variational formulation
|
||||||
|
# Mass matrix
|
||||||
|
F = (
|
||||||
|
(rho/dt)*dot(u - u0, v)*dx
|
||||||
|
+ mu*inner(grad(u_), grad(v))*dx
|
||||||
|
- p_*div(v)*dx + q*div(u)*dx
|
||||||
|
+ rho*dot(grad(u_)*u0, v)*dx
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
for nbc in range(len(bc)):
|
for nbc in range(len(bc)):
|
||||||
nid = bc[nbc]['id']
|
nid = bc[nbc]['id']
|
||||||
if bc[nbc]['type'] == 'dirichlet':
|
if bc[nbc]['type'] == 'dirichlet':
|
||||||
@ -82,43 +96,27 @@ def solv_NavierStokes(options):
|
|||||||
windkessel = True
|
windkessel = True
|
||||||
if rank==0:
|
if rank==0:
|
||||||
print('Adding Windkessel BC at boundary ',nid)
|
print('Adding Windkessel BC at boundary ',nid)
|
||||||
[R_p,C,R_d] = bc[nbc]['value']
|
[R_p,R_d,C] = bc[nbc]['value']
|
||||||
# coeficients
|
# coeficients
|
||||||
alpha[nid] = R_d*C/(R_d*C + dt)
|
alpha[nid] = R_d*C/(R_d*C + dt)
|
||||||
beta[nid] = R_d*(1-alpha[nid])
|
beta[nid] = R_d*(1-alpha[nid])
|
||||||
gamma[nid] = R_p + beta[nid]
|
gamma[nid] = R_p + beta[nid]
|
||||||
# dynamical terms
|
# dynamical terms
|
||||||
if C ==0:
|
if C ==0:
|
||||||
flows[nid] = Constant(0)
|
print('no capacitance C for boundary',nid)
|
||||||
press[nid] = Constant(R_p*0)
|
press[nid] = Constant(0)
|
||||||
else:
|
else:
|
||||||
flows[nid] = Constant(0)
|
|
||||||
pii0[nid] = Constant(bc[nbc]['p0'][0]*bc[nbc]['p0'][1])
|
pii0[nid] = Constant(bc[nbc]['p0'][0]*bc[nbc]['p0'][1])
|
||||||
pii[nid] = Constant(alpha[nid]*pii0[nid] + beta[nid]*flows[nid])
|
pii[nid] = Constant(bc[nbc]['p0'][0]*bc[nbc]['p0'][1])
|
||||||
press[nid] = Constant(gamma[nid]*flows[nid] + alpha[nid]*pii0[nid])
|
press[nid] = Constant(bc[nbc]['p0'][0]*bc[nbc]['p0'][1])
|
||||||
|
|
||||||
Windkvar[nid] = dt*press[nid]*dot(v,n)*ds(nid)
|
Windkvar[nid] = press[nid]*dot(v,n)*ds(nid)
|
||||||
|
|
||||||
u, p = TrialFunctions(W)
|
|
||||||
w = Function(W)
|
|
||||||
h = CellDiameter(mesh)
|
|
||||||
|
|
||||||
u0, p0 = w.split()
|
|
||||||
u_ = theta*u + otheta*u0
|
|
||||||
p_ = theta*p + otheta*p0
|
|
||||||
# The variational formulation
|
|
||||||
# Mass matrix
|
|
||||||
F = (
|
|
||||||
(rho/dt)*dot(u - u0, v)*dx
|
|
||||||
+ mu*inner(grad(u_), grad(v))*dx
|
|
||||||
- p_*div(v)*dx + q*div(u)*dx
|
|
||||||
+ rho*dot(grad(u_)*u0, v)*dx
|
|
||||||
)
|
|
||||||
|
|
||||||
# Stabilization Terms
|
# Stabilization Terms
|
||||||
if options['stabilization']['temam']:
|
if options['stabilization']['temam']:
|
||||||
if rank==0:
|
if rank==0:
|
||||||
print('Addint Temam stabilization term')
|
print('Adding Temam stabilization term')
|
||||||
F += 0.5*rho*div(u0)*dot(u_, v)*dx
|
F += 0.5*rho*div(u0)*dot(u_, v)*dx
|
||||||
|
|
||||||
if pspg:
|
if pspg:
|
||||||
@ -132,7 +130,7 @@ def solv_NavierStokes(options):
|
|||||||
for nid in options['stabilization']['forced_normal']['boundaries']:
|
for nid in options['stabilization']['forced_normal']['boundaries']:
|
||||||
if rank==0:
|
if rank==0:
|
||||||
print('Forcing normal velocity in border ', nid)
|
print('Forcing normal velocity in border ', nid)
|
||||||
ut = u - n*dot(u,n)
|
ut = u - n*dot(u0,n)
|
||||||
vt = v - n*dot(v,n)
|
vt = v - n*dot(v,n)
|
||||||
F += gparam*dot(ut,vt)*ds(nid)
|
F += gparam*dot(ut,vt)*ds(nid)
|
||||||
|
|
||||||
@ -145,52 +143,67 @@ def solv_NavierStokes(options):
|
|||||||
print('adding backflow stabilization in border number:' + str(nk))
|
print('adding backflow stabilization in border number:' + str(nk))
|
||||||
F -= 0.5*rho*abs_n(dot(u0, n))*dot(u_, v)*ds(nk)
|
F -= 0.5*rho*abs_n(dot(u0, n))*dot(u_, v)*ds(nk)
|
||||||
|
|
||||||
a = lhs(F)
|
|
||||||
L = rhs(F)
|
|
||||||
|
|
||||||
if windkessel:
|
if windkessel:
|
||||||
for nid in Windkvar.keys():
|
for nid in Windkvar.keys():
|
||||||
L = L - Windkvar[nid]
|
F += Windkvar[nid]
|
||||||
|
|
||||||
|
a = lhs(F)
|
||||||
|
L = rhs(F)
|
||||||
|
|
||||||
# The static part of the matrix
|
# The static part of the matrix
|
||||||
A = assemble(a)
|
A = assemble(a)
|
||||||
u, p = w.split()
|
u, p = w.split()
|
||||||
|
uwrite = Function(W.sub(0).collapse())
|
||||||
|
pwrite = Function(W.sub(1).collapse())
|
||||||
|
uwrite.rename('velocity', 'u')
|
||||||
|
pwrite.rename('pressure', 'p')
|
||||||
u.rename('velocity', 'u')
|
u.rename('velocity', 'u')
|
||||||
p.rename('pressure', 'p')
|
p.rename('pressure', 'p')
|
||||||
ind = 0
|
ind = 0
|
||||||
t = dt
|
t = dt
|
||||||
checkcicle = int(options['checkpoint_dt']/options['dt'])
|
checkcicle = int(options['checkpoint_dt']/options['dt'])
|
||||||
writecicle = int(options['checkpoint_dt']/options['dt_write'])
|
writecicle = int(options['xdmf_dt']/options['dt'])
|
||||||
|
|
||||||
while t<=Tf+dt:
|
while t<=Tf+dt:
|
||||||
if windkessel:
|
|
||||||
for k in flows.keys():
|
|
||||||
flows[k].assign(assemble(dot(u0,n)*ds(k)))
|
|
||||||
pii0[k].assign(pii[k])
|
|
||||||
pii[k].assign(alpha[k]*pii0[k] + beta[k]*flows[k])
|
|
||||||
press[k].assign(gamma[k]*flows[k] + alpha[k]*pii0[k])
|
|
||||||
|
|
||||||
# To solve
|
# To solve
|
||||||
assemble(a, tensor=A)
|
assemble(a, tensor=A)
|
||||||
b = assemble(L)
|
b = assemble(L)
|
||||||
[bcs.apply(A, b) for bcs in BCS]
|
[bcs.apply(A, b) for bcs in BCS]
|
||||||
solve(A, w.vector(), b , 'lu')
|
print('solving for t = ' + str(np.round(t,4)))
|
||||||
|
solve(A, w.vector(), b )
|
||||||
ind += 1
|
ind += 1
|
||||||
|
|
||||||
if options['write_xdmf']:
|
if options['write_xdmf']:
|
||||||
if np.mod(ind,writecicle)<0.1 or ind==1:
|
if np.mod(ind,writecicle)<0.1 or ind==1:
|
||||||
xdmf_u.write(u, t)
|
xdmf_u.write(u, t)
|
||||||
xdmf_p.write(p, t)
|
xdmf_p.write(p, t)
|
||||||
|
|
||||||
|
assign(uwrite, w.sub(0))
|
||||||
|
assign(pwrite, w.sub(1))
|
||||||
|
|
||||||
if np.mod(ind,checkcicle)<0.1 or ind==1:
|
if np.mod(ind,checkcicle)<0.1 or ind==1:
|
||||||
if options['write_checkpoint']:
|
if options['write_checkpoint']:
|
||||||
checkpath = options['savepath'] +'checkpoint/{i}/'.format(i=ind)
|
checkpath = options['savepath'] +'checkpoint/{i}/'.format(i=ind)
|
||||||
comm = u.function_space().mesh().mpi_comm()
|
comm = uwrite.function_space().mesh().mpi_comm()
|
||||||
inout.write_HDF5_data(comm, checkpath + '/u.h5', u, '/u', t=t)
|
inout.write_HDF5_data(comm, checkpath + '/u.h5', uwrite, '/u', t=t)
|
||||||
inout.write_HDF5_data(comm, checkpath + '/p.h5', p, '/p', t=t)
|
inout.write_HDF5_data(comm, checkpath + '/p.h5', pwrite, '/p', t=t)
|
||||||
|
|
||||||
inflow.t = t
|
|
||||||
t += dt
|
t += dt
|
||||||
|
inflow.t = t
|
||||||
assign(u0, w.sub(0))
|
assign(u0, w.sub(0))
|
||||||
|
|
||||||
|
if windkessel:
|
||||||
|
for nid in Windkvar.keys():
|
||||||
|
qq = assemble(dot(u0,n)*ds(nid))
|
||||||
|
pii0[nid].assign(pii[nid])
|
||||||
|
pii[nid].assign(Constant(alpha[nid]*float(pii0[nid]) + beta[nid]*qq))
|
||||||
|
pp = Constant(gamma[nid]*qq + alpha[nid]*float(pii0[nid]))
|
||||||
|
press[nid].assign(pp)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -3,12 +3,6 @@
|
|||||||
# Input file for Graphics
|
# Input file for Graphics
|
||||||
#
|
#
|
||||||
#################################################
|
#################################################
|
||||||
ppecol: 'coral'
|
|
||||||
stecol: 'yellowgreen'
|
|
||||||
daecol: 'cyan'
|
|
||||||
corcol: 'indigo'
|
|
||||||
refcol: 'black'
|
|
||||||
|
|
||||||
dP:
|
dP:
|
||||||
apply: false
|
apply: false
|
||||||
data: '/home/yeye/Desktop/dP/results/11AoCoPhantomRest2/R1/testBF/'
|
data: '/home/yeye/Desktop/dP/results/11AoCoPhantomRest2/R1/testBF/'
|
||||||
@ -23,7 +17,7 @@ dP:
|
|||||||
save: True
|
save: True
|
||||||
name: '/home/yeye/Desktop/11AoCoPhantomRest2_BF.png'
|
name: '/home/yeye/Desktop/11AoCoPhantomRest2_BF.png'
|
||||||
|
|
||||||
Histograms:
|
Histograms_meshes:
|
||||||
apply: false
|
apply: false
|
||||||
outpath: '/home/yeye/Desktop/'
|
outpath: '/home/yeye/Desktop/'
|
||||||
colors:
|
colors:
|
||||||
@ -44,20 +38,45 @@ HistCorrector:
|
|||||||
errors: '/home/yeye/Desktop/testH/H2/errors.dat'
|
errors: '/home/yeye/Desktop/testH/H2/errors.dat'
|
||||||
outpath: '/home/yeye/Desktop/h2_160.png'
|
outpath: '/home/yeye/Desktop/h2_160.png'
|
||||||
|
|
||||||
|
Histograms_checkpoint:
|
||||||
|
apply: false
|
||||||
|
path: '/home/yeye/Desktop/Corrector_2019/mono2/dt10ms_SUPGcon/'
|
||||||
|
title: '$dt = 10 \ ms$'
|
||||||
|
|
||||||
Error-curves:
|
Error-curves:
|
||||||
apply: false
|
apply: false
|
||||||
norm: 2
|
folder: '/home/yeye/Desktop/Corrector_2019/Perturbation/'
|
||||||
folder: '/home/yeye/Desktop/First/'
|
type: ['norm2_m']
|
||||||
resol: ['H2']
|
subfolders: ['SNRinfV120','SNR10V120','SNRinfV80','SNR10V80']
|
||||||
mode: ['meas','corrs']
|
labels: ['SNRinfV120','SNR10V120','SNRinfV80','SNR10V80']
|
||||||
times: ['30ms']
|
#subfolders: ['BA_p2p1','BAA','BBA']
|
||||||
colors: ['orangered','lime','dodgerblue']
|
#labels: ['BA_{P2P1}','BAA','BBA']
|
||||||
outpath: '/home/yeye/Desktop/'
|
colors: ['indigo','limegreen','dodgerblue','orangered','yellow']
|
||||||
|
styles: ['-','-','-','-','-','-','-','-']
|
||||||
|
title: '$leo2.0$'
|
||||||
|
outpath: '/home/yeye/Desktop/Corrector_2019/Perturbation/'
|
||||||
|
|
||||||
Components:
|
Pressure_drops:
|
||||||
|
apply: false
|
||||||
|
folder: '/home/yeye/Desktop/Corrector_2019/Perturbation/STE/'
|
||||||
|
convertor: -1333.22387415
|
||||||
|
#convertor: -133.322
|
||||||
|
catheter: false
|
||||||
|
subfolders: ['SNRinfV120','SNR15V120','SNRinfV80','SNR15V80','dt10ms']
|
||||||
|
labels: ['SNRinfV120','SNR15V120','SNRinfV80','SNR15V80','ref']
|
||||||
|
colors: ['indigo','limegreen','dodgerblue','orangered','yellow']
|
||||||
|
styles: ['-','-','-','-','-','-','-','-','-','-']
|
||||||
|
title: '$STE \ leo2.0$'
|
||||||
|
outpath: '/home/yeye/Desktop/Corrector_2019/Perturbation/STE/'
|
||||||
|
|
||||||
|
l2_comp:
|
||||||
apply: True
|
apply: True
|
||||||
folder: '/home/yeye/Desktop/Corrector_2019/figures/Errorcurves/'
|
colors: ['dodgerblue','orangered','limegreen']
|
||||||
subfolders: ['11mm','13mm','Normal']
|
div: false
|
||||||
type: ['mean','max']
|
aliasing: false
|
||||||
colors: ['orangered','lime','dodgerblue']
|
folder: '/home/yeye/Desktop/Poiseuille/curves/'
|
||||||
outpath: '/home/yeye/Desktop/'
|
subfolder: ['SNR10V80']
|
||||||
|
name: 'SNR10V120_gain'
|
||||||
|
mode:
|
||||||
|
type: 'gain_compressed'
|
||||||
|
comp: '/home/yeye/Desktop/Poiseuille/curves/SNR10V120/'
|
@ -3,63 +3,95 @@
|
|||||||
# Input file for the checkpoint postprocessing
|
# Input file for the checkpoint postprocessing
|
||||||
#
|
#
|
||||||
#################################################
|
#################################################
|
||||||
Corrector:
|
Algebra:
|
||||||
apply: false
|
apply: false
|
||||||
mode: 'colormap' # h5 , histogram, colormap
|
mode: '+'
|
||||||
outpath: '/home/yeye/Desktop/Corrector_2019/figure3/11mm/'
|
VENC: 97
|
||||||
mesh_path: '/home/yeye/Desktop/Corrector_2019/meshes/11AoCoPhantomRest2.h5'
|
outname: 'ucor'
|
||||||
u_path: '/home/yeye/Desktop/Corrector_2019/First/meas/11mmAoCo2/'
|
outpath: '/home/yeye/Desktop/Corrector_2019/Perturbation/gain/SNR10V60/'
|
||||||
w_path: '/home/yeye/Desktop/Corrector_2019/First/corrector/11mmAoCo2/'
|
checkpoint: true
|
||||||
wname: 'w_COR_impl_stan'
|
#meshpath: '/home/yeye/Desktop/Poiseuille/Meas_leo/poiseuille.h5'
|
||||||
|
meshpath: '/home/yeye/Desktop/Corrector_2019/Meshes/leoH3_2.0.h5'
|
||||||
|
v1:
|
||||||
|
name: 'u'
|
||||||
|
path: '/home/yeye/Desktop/Corrector_2019/Perturbation/Meas/SNR10V60/'
|
||||||
|
v2:
|
||||||
|
name: 'w_COR_impl_stan'
|
||||||
|
path: '/home/yeye/Desktop/Corrector_2019/Perturbation/COR/SNR10V60/'
|
||||||
|
|
||||||
|
Colormap:
|
||||||
|
apply: false
|
||||||
|
#mode: ['u','w','w/u','div(u)','div(u)/u']
|
||||||
|
mode: ['dot']
|
||||||
|
outpath: '/home/yeye/Desktop/Poiseuille/H5/leo2mm/SNRinfV80/'
|
||||||
|
meshpath: '/home/yeye/Desktop/Poiseuille/Meas_leo/poiseuille.h5'
|
||||||
|
upath: '/home/yeye/Desktop/Poiseuille/Meas_leo/SNRinfV80/'
|
||||||
|
wpath: '/home/yeye/Desktop/Poiseuille/Corrector/leo2mm/SNRinfV80/'
|
||||||
uname: 'u'
|
uname: 'u'
|
||||||
dt: 0.03072
|
wname: 'w_COR_impl_stan'
|
||||||
|
|
||||||
Velocity:
|
Velocity:
|
||||||
apply: false
|
apply: false
|
||||||
mesh_path: '/home/yeye/Desktop/Corrector_2019/meshes/NormalAoCoPhantomRest2.h5'
|
meshpath: '/home/yeye/Desktop/Corrector_2019/Poiseuille/poiseuille.h5'
|
||||||
checkpoint: '/home/yeye/Desktop/Corrector_2019/First/meas/NormalAoCo2/'
|
checkpoint: '/home/yeye/Desktop/Corrector_2019/Poiseuille/COR/SNR15V120/'
|
||||||
undersampling: 1
|
undersampling: 1
|
||||||
dt: 0.03072
|
dt: 0.03
|
||||||
filename: 'u'
|
filename: 'w_COR_impl_stan'
|
||||||
|
|
||||||
Estim_Pressure:
|
Estim_Pressure:
|
||||||
apply: false
|
apply: false
|
||||||
|
meshpath: '/home/yeye/Desktop/Corrector_2019/Meshes/9mmRest2.0.h5'
|
||||||
filename: 'p_COR_impl_stan'
|
filename: 'p_COR_impl_stan'
|
||||||
outpath: '/home/yeye/Desktop/dP/results/11AoCoPhantomRest2/R1/testBF/'
|
checkpath: '/home/yeye/Desktop/Corrector_2019/AoCo/9mm_pspg/'
|
||||||
method: spheres # slices, boundaries, spheres
|
method: spheres # slices, boundaries, spheres
|
||||||
dt: 0.03072
|
dt: 0.03072
|
||||||
boundaries: [2,3]
|
boundaries: [2,3]
|
||||||
spheres:
|
spheres:
|
||||||
- center: [0.09, 0.093, 0.08] # 11mm
|
- center: [0.0980092, 0.0909768, 0.0802258] # 9mm
|
||||||
#- center : [0.08, 0.09, 0.08]
|
#- center: [0.110266, 0.086805, 0.0794744] # 11mm
|
||||||
#- center : [0.093, 0.09, 0.085] # Normal
|
#- center : [0.0940797, 0.0766444, 0.080433] #13mm
|
||||||
|
#- center: [0.0870168, 0.0901715, 0.0883529] # Normal
|
||||||
radius: 0.005
|
radius: 0.005
|
||||||
Npts: 32
|
Npts: 32
|
||||||
- center: [0.134, 0.135, 0.026] # 11mm
|
- center: [0.0980092, 0.135047, 0.0252659] # 9mm
|
||||||
#- center : [0.125, 0.135, 0.025] # 13 mm
|
#- center: [0.110266, 0.133002, 0.0263899] # 11mm
|
||||||
#- center : [0.13, 0.14, 0.03] # Normal
|
#- center : [0.0940573, 0.123321, 0.0260755] # 13 mm
|
||||||
|
#- center: [0.0869949, 0.12838, 0.0269889] # Normal
|
||||||
radius: 0.005
|
radius: 0.005
|
||||||
Npts: 32
|
Npts: 32
|
||||||
|
|
||||||
Outlet_Wind:
|
Outlet_Wind:
|
||||||
apply: false
|
apply: false
|
||||||
mesh_path: '/home/yeye/NavierStokes/examples/meshes/aorta.h5'
|
mesh_path: '/home/yeye/Desktop/aorta/mesh/aorta_coarse_marked.h5'
|
||||||
checkpoint: '/home/yeye/NavierStokes/examples/results/aorta/'
|
checkpoint: '/home/yeye/Desktop/aorta/results/mono/'
|
||||||
filename: ['u','p']
|
filename: ['u','p']
|
||||||
bnds: [3,4,5,6]
|
bnds: [3,4,5,6]
|
||||||
out_path: '/home/yeye/NavierStokes/examples/results/aorta/'
|
out_path: '/home/yeye/Desktop/aorta/results/mono/'
|
||||||
|
|
||||||
Error-curves:
|
Error-curves:
|
||||||
apply: true
|
apply: true
|
||||||
dt: 0.03072
|
dt: 0.03
|
||||||
type: ['mean','max']
|
VENC: 204 #194/129/113/97 for aorta(120,80,70,60)/ 204/136
|
||||||
meshpath: '/home/yeye/Desktop/Corrector_2019/meshes/NormalAoCoPhantomRest1.4.h5'
|
type: ['utrue-uobs']
|
||||||
ref_check: '/home/yeye/Desktop/Corrector_2019/I/meas/NormalRest1.4/R1/'
|
#type: ['l2_comp','div']
|
||||||
|
meshpath: '/home/yeye/Desktop/Poiseuille/Meas_leo/poiseuille.h5'
|
||||||
|
#meshpath: '/home/yeye/Desktop/Corrector_2019/Meshes/leoH3_2.0.h5'
|
||||||
|
true_check: '/home/yeye/Desktop/Poiseuille/Meas_leo/SNRinfV120/'
|
||||||
|
true_name: 'u'
|
||||||
|
ref_check: '/home/yeye/Desktop/Poiseuille/Meas_leo/SNR10V120/'
|
||||||
ref_name: 'u'
|
ref_name: 'u'
|
||||||
undersampling: 1
|
undersampling: 1
|
||||||
com_check: '/home/yeye/Desktop/Corrector_2019/I/corrector/NormalRest1.4/'
|
com_check: '/home/yeye/Desktop/Poiseuille/Corrector/leo2mm/SNR10V120/'
|
||||||
com_name: 'w_COR_impl_stan'
|
com_name: 'w_COR_impl_stan'
|
||||||
outpath: '/home/yeye/Desktop/Corrector_2019/figures/Errorcurves/Normal/'
|
outpath: '/home/yeye/Desktop/Poiseuille/curves/SNR10V120/'
|
||||||
|
|
||||||
|
Histograms:
|
||||||
|
apply: false
|
||||||
|
type: ['normal','grad']
|
||||||
|
meshpath: '/home/yeye/Desktop/Corrector_2019/meshes/11AoCoPhantomRest1.4.h5'
|
||||||
|
checkpath: '/home/yeye/Desktop/Corrector_2019/I/corrector/11mmRest1.4/'
|
||||||
|
field_name: 'w_COR_impl_stan'
|
||||||
|
outpath: '/home/yeye/Desktop/Corrector_2019/I/corrector/11mmRest1.4/'
|
||||||
|
|
||||||
Temporal-Average:
|
Temporal-Average:
|
||||||
apply: false
|
apply: false
|
||||||
@ -77,4 +109,15 @@ Temporal-Interpolation:
|
|||||||
xdmf: true
|
xdmf: true
|
||||||
dt: 0.03072
|
dt: 0.03072
|
||||||
dt_new: 0.015
|
dt_new: 0.015
|
||||||
out_check: '/home/yeye/Desktop/Corrector_2019/I/meas/11mmRest1.4/dt15ms/'
|
out_check: '/home/yeye/Desktop/Corrector_2019/I/meas/11mmRest1.4/dt15ms/'
|
||||||
|
|
||||||
|
Perturbation:
|
||||||
|
apply: false
|
||||||
|
undersampling: 1
|
||||||
|
type:
|
||||||
|
SNR: 10 # dB signal to noise ratio
|
||||||
|
coil: true
|
||||||
|
phase_contrast: 80 # venc % respect u max
|
||||||
|
meshpath: '/home/yeye/Desktop/Poiseuille/Meas_leo/poiseuille.h5'
|
||||||
|
checkpath: '/home/yeye/Desktop/Poiseuille/Meas_leo/original/'
|
||||||
|
xdmf: true
|
@ -1,50 +0,0 @@
|
|||||||
#################################################
|
|
||||||
#
|
|
||||||
# Input file for CFD Monolithic Solver
|
|
||||||
#
|
|
||||||
#################################################
|
|
||||||
mesh_path : '/home/p283370/Desktop/PhD/AORTA/MESH/aorta_fine/aorta_fine_marked.h5'
|
|
||||||
write_xdmf : False
|
|
||||||
savepath : '/home/yeye/Desktop/PhD/AORTA/DATA/monolithic/'
|
|
||||||
write_checkpoint : False
|
|
||||||
checkpoint_path : '/home/yeye/Desktop/PhD/AORTA/DATA/monolithic/checkpoint/'
|
|
||||||
write_outlets : False
|
|
||||||
outlets_path : '/home/yeye/Desktop/PhD/AORTA/DATA/monolithic/outlets/'
|
|
||||||
|
|
||||||
Tf : 0.9 # seg
|
|
||||||
density : 1.2 # gr/cm3
|
|
||||||
dynamic_viscosity : 0.035
|
|
||||||
dt : 0.005
|
|
||||||
dt_write : 0.01
|
|
||||||
checkpoint_dt : 0.02
|
|
||||||
|
|
||||||
|
|
||||||
stab:
|
|
||||||
pspg : 1
|
|
||||||
epsilon : 0.01
|
|
||||||
backflow : 1
|
|
||||||
back_id : [3,4,5,6]
|
|
||||||
temam : 1
|
|
||||||
supg : 0
|
|
||||||
pssu : 0
|
|
||||||
|
|
||||||
param:
|
|
||||||
U : 60
|
|
||||||
period : 0.7
|
|
||||||
Nvel : 1
|
|
||||||
Npress : 1
|
|
||||||
theta : 1
|
|
||||||
|
|
||||||
windkessel:
|
|
||||||
id : [3,4,5,6]
|
|
||||||
R_p : {'3':100 , '4':250, '5':250 , '6':250 }
|
|
||||||
R_d : {'3':1000, '4':8000, '5':8000 , '6':8000}
|
|
||||||
C : {'3':0.01, '4':0.0001, '5':0.00001, '6':0.0001}
|
|
||||||
alpha : {'3':0 , '4':0 , '5':0 , '6':0}
|
|
||||||
beta : {'3':0 , '4':0 , '5':0 , '6':0}
|
|
||||||
gamma : {'3':0 , '4':0 , '5':0 , '6':0}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -5,42 +5,43 @@
|
|||||||
#################################################
|
#################################################
|
||||||
|
|
||||||
phase_contrast:
|
phase_contrast:
|
||||||
apply : False
|
apply: False
|
||||||
dealiased : True
|
dealiased: True
|
||||||
VENC : 400
|
VENC: 400
|
||||||
meas0 : '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/9AoCoPhantom0.9/Mag9AoCo0.90.npz'
|
meas0: '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/9AoCoPhantom0.9/Mag9AoCo0.90.npz'
|
||||||
measG : '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/9AoCoPhantom0.9/Mag9AoCo0.9G.npz'
|
measG: '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/9AoCoPhantom0.9/Mag9AoCo0.9G.npz'
|
||||||
output : '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/9AoCoPhantom0.9/u_R1.npz'
|
output: '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/9AoCoPhantom0.9/u_R1.npz'
|
||||||
|
|
||||||
resize:
|
resize:
|
||||||
apply : False
|
apply: False
|
||||||
dim : [120,120,84]
|
dim: [120,120,84]
|
||||||
loadseq : '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/Uffine/aoreal.npz'
|
loadseq: '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/Uffine/aoreal.npz'
|
||||||
save : True
|
save: True
|
||||||
savepath : '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/Uffine/aoreal_rs.npz'
|
savepath: '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/Uffine/aoreal_rs.npz'
|
||||||
|
|
||||||
magnetization_CIB:
|
magnetization_CIB:
|
||||||
apply : False
|
apply: False
|
||||||
loadpath : '/home/yeye/Desktop/PhD/MEDICAL_DATA/Phantom/With_AoCo_9mm/MATLAB_FILES/'
|
loadpath: '/home/yeye/Desktop/PhD/MEDICAL_DATA/Phantom/With_AoCo_9mm/MATLAB_FILES/'
|
||||||
savepath : '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/9AoCoPhantom0.9/Mag9AoCo0.9.npz'
|
savepath: '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/9AoCoPhantom0.9/Mag9AoCo0.9.npz'
|
||||||
|
|
||||||
magnetization:
|
magnetization:
|
||||||
apply : False
|
apply: False
|
||||||
loadseq : '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/Uffine/aoreal.npz'
|
loadseq: '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/Uffine/aoreal.npz'
|
||||||
VENC : 250
|
VENC: 250
|
||||||
save : True
|
save: True
|
||||||
savepath : '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/MAG/Mag9AoCoE1.npz'
|
savepath: '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/MAG/Mag9AoCoE1.npz'
|
||||||
|
|
||||||
sequence:
|
sequence:
|
||||||
apply: False
|
apply: false
|
||||||
checkpoint_path: '/home/yeye/Desktop/First/H1/dt5ms/coaorta/'
|
checkpoint_path: '/home/yeye/Desktop/Poiseuille/Meas/'
|
||||||
meshpath: '/home/yeye/Desktop/PhD/AORTA/MESH/coaorta/H1/coaortaH1.h5'
|
meshpath: '/home/yeye/Desktop/Poiseuille/Meas/poiseuille.h5'
|
||||||
sampling_rate: 1
|
sampling_rate: 1
|
||||||
boxtype: 'fix_resolution'
|
boxtype: 'fix_resolution'
|
||||||
ranges: {'x': [10.8,21] , 'y': [13,19] , 'z': [-0.1,11.5] }
|
#ranges: {'x': [10.8,21] , 'y': [13,19] , 'z': [-0.1,11.5] }
|
||||||
resol: [0.14,0.14,0.14]
|
ranges: {'x': [-1,1] , 'y': [-1,1] , 'z': [0,6] }
|
||||||
boxsize: [80,80,80]
|
resol: [0.2,0.2,0.2]
|
||||||
name: 'SH1_5ms'
|
boxsize: [100,100,100]
|
||||||
|
name: 'seq'
|
||||||
|
|
||||||
cs:
|
cs:
|
||||||
apply: false
|
apply: false
|
||||||
@ -54,14 +55,14 @@ cs:
|
|||||||
name: 'ucs'
|
name: 'ucs'
|
||||||
|
|
||||||
kt-BLAST:
|
kt-BLAST:
|
||||||
apply : False
|
apply: False
|
||||||
VENC : 3.5 # cm/s
|
VENC: 3.5 # cm/s
|
||||||
mode : 'kxky'
|
mode: 'kxky'
|
||||||
R : [4] # Acceleration factors
|
R: [4] # Acceleration factors
|
||||||
noise : False
|
noise: False
|
||||||
save : True
|
save: True
|
||||||
savepath : '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/9AoCoPhantomRest2E1/'
|
savepath: '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/9AoCoPhantomRest2E1/'
|
||||||
name : 'KT_kxky'
|
name: 'KT_kxky'
|
||||||
|
|
||||||
reference:
|
reference:
|
||||||
apply : False
|
apply : False
|
||||||
@ -76,11 +77,6 @@ reference:
|
|||||||
save : True
|
save : True
|
||||||
name : 'ref'
|
name : 'ref'
|
||||||
|
|
||||||
norms:
|
|
||||||
apply : False
|
|
||||||
field_path : '/home/yeye/Desktop/PhD/AORTA/DATA/ct/aorta_coarse/'
|
|
||||||
plot : True
|
|
||||||
|
|
||||||
create_checkpoint:
|
create_checkpoint:
|
||||||
apply: false
|
apply: false
|
||||||
loadseq: '/home/yeye/Desktop/Corrector_2019/Second/Vol2/dicom/mod/'
|
loadseq: '/home/yeye/Desktop/Corrector_2019/Second/Vol2/dicom/mod/'
|
||||||
@ -100,28 +96,15 @@ create_checkpoint:
|
|||||||
savepath: '/home/yeye/Desktop/Corrector_2019/Second/Vol2/dicom/'
|
savepath: '/home/yeye/Desktop/Corrector_2019/Second/Vol2/dicom/'
|
||||||
xdmf: true
|
xdmf: true
|
||||||
|
|
||||||
peak_pv:
|
|
||||||
apply : False
|
|
||||||
orig_seq : '/home/yeye/Desktop/PhD/AORTA/DATA/sequences/aorta_Ucoarse.npz'
|
|
||||||
peak_slice : 6
|
|
||||||
R : [1,2]
|
|
||||||
p_comp : 'error' # 'peak' or 'error'
|
|
||||||
flux_bnd : [2]
|
|
||||||
N_CS : 1
|
|
||||||
mesh_into : 'leo'
|
|
||||||
save : True
|
|
||||||
savepath : '/home/yeye/Desktop/PhD/AORTA/DATA/maxpv/Ucoarse_test/'
|
|
||||||
infile_dp : '/home/yeye/Desktop/dP/input/all_points.yaml'
|
|
||||||
|
|
||||||
change_mesh:
|
change_mesh:
|
||||||
apply: false
|
apply: false
|
||||||
mode: 'u'
|
mode: 'u'
|
||||||
dt: 0.005
|
dt: 0.03
|
||||||
checkpoint_path: '/home/yeye/Desktop/R1/checkpoint/'
|
checkpoint_path: '/home/yeye/Desktop/Poiseuille/Meas/checkpoint/'
|
||||||
under_rate: 1
|
under_rate: 1
|
||||||
mesh_in: '/home/yeye/Desktop/PhD/AORTA/MESH/coaorta/H1/coaortaH1.h5'
|
mesh_in: '/home/yeye/Desktop/Poiseuille/Meas/poiseuille.h5'
|
||||||
mesh_out: '/home/yeye/Desktop/meshes/leo_1.42.h5'
|
mesh_out: '/home/yeye/Desktop/Poiseuille/Meas_leo/poiseuille.h5'
|
||||||
savepath: '/home/yeye/Desktop/test/'
|
savepath: '/home/yeye/Desktop/Poiseuille/Meas_leo/'
|
||||||
xdmf: True
|
xdmf: True
|
||||||
|
|
||||||
SENSE:
|
SENSE:
|
||||||
@ -133,8 +116,9 @@ SENSE:
|
|||||||
|
|
||||||
create_leo:
|
create_leo:
|
||||||
apply: false
|
apply: false
|
||||||
velseq: '/home/yeye/Desktop/Corrector_2019/Second/Vol2/dicom/mod_nocoro/u_R1.mat'
|
velseq: '/home/yeye/Desktop/Corrector_2019/Meshes/SH3_2.0_R1.npz'
|
||||||
resol: [0.09,0.09,0.09]
|
resol: [0.2,0.2,0.2]
|
||||||
|
#ranges: {'x': [-1.2,1.2] , 'y': [-1.2,1.2] , 'z': [-0.2,6.2] }
|
||||||
ranges: {'x': [10.8,21] , 'y': [13,19] , 'z': [-0.1,11.5] }
|
ranges: {'x': [10.8,21] , 'y': [13,19] , 'z': [-0.1,11.5] }
|
||||||
masked: false
|
masked: false
|
||||||
segmentation: '/home/yeye/Desktop/PhD/MEDICAL_DATA/Phantom/With_AoCo_9mm/MATLAB_FILES/Segmented_Aorta.mat'
|
segmentation: '/home/yeye/Desktop/PhD/MEDICAL_DATA/Phantom/With_AoCo_9mm/MATLAB_FILES/Segmented_Aorta.mat'
|
||||||
@ -148,13 +132,13 @@ kspace_cib:
|
|||||||
|
|
||||||
CIBtoH5:
|
CIBtoH5:
|
||||||
apply: false
|
apply: false
|
||||||
data_path: '/home/yeye/Desktop/PhD/MEDICAL_DATA/AoCo/9AoCoPhantomRest0.9/'
|
data_path: '/home/yeye/Desktop/PhD/MEDICAL_DATA/Study_David/Patients/Study_14_GM/velmesh_from_velmat/'
|
||||||
interpolate: true
|
interpolate: false
|
||||||
flip: false
|
flip: false # Set it True for AoCo = 13mm
|
||||||
dt: 0.03072
|
dt: 0.03831417624521074
|
||||||
mesh_path: '/home/yeye/Desktop/PhD/MEDICAL_DATA/AoCo/9AoCoPhantomRest1.4/'
|
mesh_path: '/home/yeye/Desktop/PhD/MEDICAL_DATA/Study_David/Patients/Study_14_GM/velmesh_from_velmat/'
|
||||||
times: [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]
|
times: [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]
|
||||||
outpath: '/home/yeye/Desktop/9mmRest1.4/R1/'
|
outpath: '/home/yeye/Desktop/Patient_GM/'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user