From a2fcf7383bde47f67391ef92f317916001d6460b Mon Sep 17 00:00:00 2001 From: Aloma Blanch Date: Fri, 17 Jul 2020 08:44:29 -0500 Subject: [PATCH] Added Outlet Boundary Conditions --- functions.py | 16 ++++++++++++++-- generatePDF.py | 27 +++++++++++++++++++++++++-- main.py | 7 +++++-- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/functions.py b/functions.py index 33bd9a5..74d5e5a 100644 --- a/functions.py +++ b/functions.py @@ -82,8 +82,7 @@ def periodicity(project,folder,dt,T_cyc,n_cyc,save_path): 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])) - # 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 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])] + 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])] return txt def pressure(folder,N_ts,T_cyc,dt,n_cyc,save_path): @@ -171,5 +170,18 @@ def inlet_flow_waveform(project_folder,t_btw_rst,N_ts,dt,T_cyc,n_cyc,save_path): txt = '{0} time steps saved, available to visualize in ParaView.'.format(np.unique(np.round(t_pts,3)).shape[0]) 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 \ No newline at end of file diff --git a/generatePDF.py b/generatePDF.py index bce0ee1..d70e596 100644 --- a/generatePDF.py +++ b/generatePDF.py @@ -7,7 +7,7 @@ Created on Fri Jul 17 05:34:59 2020 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): def header(self): # Arial bold 15 @@ -78,7 +78,7 @@ def generatePDF(save_path,project,DBP,MBP,SBP,PP,Q_avg,txt1,txt2): self.add_page() self.section_title(num, title) - title = 'Project name: '+ project + title = 'Simulation Job name: '+ project pdf = PDF() pdf.set_title(title) 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.set_font('Arial', '', 10) 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') \ No newline at end of file diff --git a/main.py b/main.py index b2a7820..786845d 100644 --- a/main.py +++ b/main.py @@ -20,7 +20,7 @@ import os.path # 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 @@ -53,6 +53,9 @@ rc = float(mylines[26][18:-1]) # Imesteps between Restarts - idx 6 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 error_plot(folder,dt,rc,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) # 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)