Added Outlet Boundary Conditions

This commit is contained in:
Aloma Blanch 2020-07-17 08:44:29 -05:00
parent e77d6f0d9a
commit a2fcf7383b
3 changed files with 44 additions and 6 deletions

View File

@ -82,8 +82,7 @@ def periodicity(project,folder,dt,T_cyc,n_cyc,save_path):
if (peak_Pdiff[-1]<=1): if (peak_Pdiff[-1]<=1):
print('The numerical simulation \'{0}\' has achieve periodicity!\nSystolic Blood Pressure (SBP):\nsecond-last cycle = {1:.2f} mmHg,\nlast cycle = {2:.2f} mmHg,\n\u0394mmHg = {3:.2f} mmHg'.format(project,peak_P[-2],peak_P[-1],peak_Pdiff[-1])) print('The numerical simulation \'{0}\' has achieve periodicity!\nSystolic Blood Pressure (SBP):\nsecond-last cycle = {1:.2f} mmHg,\nlast cycle = {2:.2f} mmHg,\n\u0394mmHg = {3:.2f} mmHg'.format(project,peak_P[-2],peak_P[-1],peak_Pdiff[-1]))
# txt = ['The numerical simulation \'{0}\' has achieve periodicity!'.format(project), 'Systolic Blood Pressure (SBP):', 'Second-last cycle = {0:.2f} mmHg'.format(peak_P[-2]), 'Last cycle = {0:.2f} mmHg'.format(peak_P[-1]), 'Delta_mmHg = {0:.2f} mmHg'.format(peak_Pdiff[-1])] txt = ['The numerical simulation \'{0}\' has achieved periodicity.'.format(project), 'Systolic Blood Pressure (SBP):', 'Second-last cycle = {0:.2f} mmHg'.format(peak_P[-2]), 'Last cycle = {0:.2f} mmHg'.format(peak_P[-1]), 'Delta_mmHg = {0:.2f} mmHg'.format(peak_Pdiff[-1])]
txt = ['The numerical simulation \'{0}\' has achieve periodicity!'.format(project), 'Systolic Blood Pressure (SBP):','Second-last cycle = {0:.2f} mmHg - Last cycle = {1:.2f} mmHg - Delta_mmHg = {2:.2f} mmHg'.format(peak_P[-2],peak_P[-1],peak_Pdiff[-1])]
return txt return txt
def pressure(folder,N_ts,T_cyc,dt,n_cyc,save_path): def pressure(folder,N_ts,T_cyc,dt,n_cyc,save_path):
@ -172,4 +171,17 @@ def inlet_flow_waveform(project_folder,t_btw_rst,N_ts,dt,T_cyc,n_cyc,save_path):
return txt return txt
def rcr(project_folder):
rcr_lines = []
with open (project_folder + '/rcrt.dat', "rt") as myfile:
for myline in myfile:
rcr_lines.append(myline)
n_out = int((len(rcr_lines)-1)/6)
Rc_C_Rd = np.empty([n_out,3])
for i in range(0,n_out):
Rc_C_Rd[i][0] = float(rcr_lines[2+i*6][:-1])
Rc_C_Rd[i][1] = float(rcr_lines[3+i*6][:-1])
Rc_C_Rd[i][2] = float(rcr_lines[4+i*6][:-1])
return Rc_C_Rd

View File

@ -7,7 +7,7 @@ Created on Fri Jul 17 05:34:59 2020
from fpdf import FPDF from fpdf import FPDF
def generatePDF(save_path,project,DBP,MBP,SBP,PP,Q_avg,txt1,txt2): def generatePDF(save_path,project,DBP,MBP,SBP,PP,Q_avg,txt1,txt2,Rc_C_Rd):
class PDF(FPDF): class PDF(FPDF):
def header(self): def header(self):
# Arial bold 15 # Arial bold 15
@ -78,7 +78,7 @@ def generatePDF(save_path,project,DBP,MBP,SBP,PP,Q_avg,txt1,txt2):
self.add_page() self.add_page()
self.section_title(num, title) self.section_title(num, title)
title = 'Project name: '+ project title = 'Simulation Job name: '+ project
pdf = PDF() pdf = PDF()
pdf.set_title(title) pdf.set_title(title)
pdf.set_author('Aloma Blanch Granada') pdf.set_author('Aloma Blanch Granada')
@ -140,4 +140,27 @@ def generatePDF(save_path,project,DBP,MBP,SBP,PP,Q_avg,txt1,txt2):
pdf.image(save_path +'/inlet_waveform.jpg', x = 40, y = 50, w = 140, h = 100, type = '', link = '') pdf.image(save_path +'/inlet_waveform.jpg', x = 40, y = 50, w = 140, h = 100, type = '', link = '')
pdf.set_font('Arial', '', 10) pdf.set_font('Arial', '', 10)
pdf.cell(0, 5,txt2, 0, 1) pdf.cell(0, 5,txt2, 0, 1)
width_cell=[30,20,110];
pdf.print_section(5, 'Outlet Boundary Condition Applied')
pdf.set_font('Arial', '', 10)
pdf.cell(0, 10,'3-Element Windkessel model outlet boundary condition applied in SimVascular', 0, 1)
pdf.cell(0, 5,' ', 0, 1)
pdf.set_x(50)
pdf.set_font('Times', '', 10)
pdf.cell(width_cell[2],10,'3-Element Windkessel',1,1,'C') # First header column
pdf.set_x(50)
pdf.cell(width_cell[1],10,'ROI',1,0,'C') # Second header column
pdf.cell(width_cell[0],10,'Rc [g/cm^4 s]',1,0,'C') # Second header column
pdf.cell(width_cell[0],10,'C [cm^4 s^2/g]',1,0,'C') # Second header column
pdf.cell(width_cell[0],10,'Rd [g/cm^4 s]',1,1,'C') # Second header
# Rows
for i in range(0,Rc_C_Rd.shape[0]):
pdf.set_x(50)
pdf.cell(width_cell[1],10,'ROI-'+ str(i+2),1,0,'C') # First column of row 1
pdf.cell(width_cell[0],10,str(Rc_C_Rd[i][0]),1,0,'C') # Second column of row 1
pdf.cell(width_cell[0],10,str(Rc_C_Rd[i][1]),1,0,'C') # Third column of row 1
pdf.cell(width_cell[0],10,str(Rc_C_Rd[i][2]),1,1,'C') # Third column of row 1
pdf.output(save_path + '/' + project + '-report.pdf', 'F') pdf.output(save_path + '/' + project + '-report.pdf', 'F')

View File

@ -20,7 +20,7 @@ import os.path
# from fpdf import FPDF # from fpdf import FPDF
from functions import error_plot, periodicity, pressure, flow, inlet_flow_waveform from functions import error_plot, periodicity, pressure, flow, inlet_flow_waveform, rcr
from generatePDF import generatePDF from generatePDF import generatePDF
@ -53,6 +53,9 @@ rc = float(mylines[26][18:-1])
# Imesteps between Restarts - idx 6 # Imesteps between Restarts - idx 6
t_btw_rst = int(mylines[6][37:-1]) t_btw_rst = int(mylines[6][37:-1])
# Extracting Outlet Boundary Conditions from - rcrt.dat fle
Rc_C_Rd = rcr(project_folder)
# Cehcking convergency and periodicity # Cehcking convergency and periodicity
error_plot(folder,dt,rc,save_path) error_plot(folder,dt,rc,save_path)
txt1 = periodicity(project,folder,dt,T_cyc,n_cyc,save_path) txt1 = periodicity(project,folder,dt,T_cyc,n_cyc,save_path)
@ -67,4 +70,4 @@ txt1 = periodicity(project,folder,dt,T_cyc,n_cyc,save_path)
txt2 = inlet_flow_waveform(project_folder,t_btw_rst,N_ts,dt,T_cyc,n_cyc,save_path) txt2 = inlet_flow_waveform(project_folder,t_btw_rst,N_ts,dt,T_cyc,n_cyc,save_path)
# Create PDF report # Create PDF report
generatePDF(save_path,project,DBP,MBP,SBP,PP,Q_avg,txt1,txt2) generatePDF(save_path,project,DBP,MBP,SBP,PP,Q_avg,txt1,txt2,Rc_C_Rd)