2020-07-17 01:41:59 +01:00
|
|
|
#!/usr/bin/env python
|
2020-07-17 11:51:22 +01:00
|
|
|
"""
|
|
|
|
Created on Thu Jul 16 15:08:27 2020
|
|
|
|
|
|
|
|
@author: Aloma Blanch
|
|
|
|
"""
|
2020-07-17 01:41:59 +01:00
|
|
|
|
2020-07-17 12:48:51 +01:00
|
|
|
# import numpy as np
|
|
|
|
# import matplotlib.pyplot as plt
|
|
|
|
# import matplotlib.ticker as mtick
|
2020-07-17 01:41:59 +01:00
|
|
|
from tkinter import Tk
|
2020-07-17 12:48:51 +01:00
|
|
|
# from tkinter.filedialog import askopenfilename, asksaveasfile, askdirectory
|
|
|
|
from tkinter.filedialog import askdirectory
|
|
|
|
# import pandas as pd
|
|
|
|
# import tkinter as tk
|
2020-07-17 01:41:59 +01:00
|
|
|
import os.path
|
2020-07-17 12:48:51 +01:00
|
|
|
# from scipy.signal import find_peaks_cwt
|
|
|
|
# from scipy import signal
|
|
|
|
# import statistics
|
|
|
|
# from fpdf import FPDF
|
2020-07-17 01:41:59 +01:00
|
|
|
|
|
|
|
|
2020-07-17 23:10:24 +01:00
|
|
|
from functions import error_plot, periodicity, pressure, flow, inlet_flow_waveform, rcr, cycle
|
2020-07-17 11:51:22 +01:00
|
|
|
from generatePDF import generatePDF
|
|
|
|
|
|
|
|
|
2020-07-17 01:41:59 +01:00
|
|
|
# Selct dir
|
|
|
|
Tk().withdraw()
|
|
|
|
folder = askdirectory()
|
|
|
|
project_folder = os.path.dirname(folder)
|
|
|
|
project = os.path.basename(project_folder)
|
2020-07-17 05:33:48 +01:00
|
|
|
save_path = folder+'/'+project+'-report'
|
2020-07-17 07:16:04 +01:00
|
|
|
os.mkdir(save_path)
|
2020-07-17 05:33:48 +01:00
|
|
|
save_pdf = save_path + '/' + project + '-report.pdf'
|
2020-07-17 01:41:59 +01:00
|
|
|
|
|
|
|
# Read important parameters from - solver.inp file
|
|
|
|
mylines = [] # Declare an empty list named mylines.
|
|
|
|
with open (project_folder + '/solver.inp', 'rt') as myfile: # Open lorem.txt for reading text data.
|
|
|
|
for myline in myfile: # For each line, stored as myline,
|
|
|
|
mylines.append(myline) # add its contents to mylines.
|
|
|
|
# Number of Timesteps - idx 3
|
|
|
|
# Idea: remove the text to extract the number, the text part will be the same no matter the simulation
|
|
|
|
N_ts = int(mylines[3][20:-1])
|
|
|
|
# Time Step Size - idx 4
|
|
|
|
dt = float(mylines[4][16:-1])
|
|
|
|
# Residual criteria - idx 4
|
|
|
|
rc = float(mylines[26][18:-1])
|
2020-07-17 03:18:08 +01:00
|
|
|
# Imesteps between Restarts - idx 6
|
|
|
|
t_btw_rst = int(mylines[6][37:-1])
|
2020-07-17 01:41:59 +01:00
|
|
|
|
2020-07-17 14:44:29 +01:00
|
|
|
# Extracting Outlet Boundary Conditions from - rcrt.dat fle
|
|
|
|
Rc_C_Rd = rcr(project_folder)
|
2020-07-17 23:10:24 +01:00
|
|
|
|
|
|
|
# Extracting number of cycles and period of cardiac cycle
|
|
|
|
(T_cyc,n_cyc) = cycle(folder,dt,save_path)
|
2020-07-17 14:44:29 +01:00
|
|
|
|
2020-07-17 01:41:59 +01:00
|
|
|
# Cehcking convergency and periodicity
|
2020-07-17 05:33:48 +01:00
|
|
|
error_plot(folder,dt,rc,save_path)
|
|
|
|
txt1 = periodicity(project,folder,dt,T_cyc,n_cyc,save_path)
|
2020-07-17 01:41:59 +01:00
|
|
|
|
2020-07-17 03:18:08 +01:00
|
|
|
# Pressure - Outlets
|
2020-07-17 05:33:48 +01:00
|
|
|
(DBP,MBP,SBP,PP) = pressure(folder,N_ts,T_cyc,dt,n_cyc,save_path)
|
2020-07-17 01:41:59 +01:00
|
|
|
|
2020-07-17 03:18:08 +01:00
|
|
|
# Flow Rate - Outlets
|
2020-07-17 05:33:48 +01:00
|
|
|
(Q_avg) = flow(folder,N_ts,T_cyc,dt,n_cyc,save_path)
|
2020-07-17 03:18:08 +01:00
|
|
|
|
|
|
|
# Inlet Flow Rate + and t saved
|
2020-07-17 05:33:48 +01:00
|
|
|
txt2 = inlet_flow_waveform(project_folder,t_btw_rst,N_ts,dt,T_cyc,n_cyc,save_path)
|
|
|
|
|
2020-07-17 11:51:22 +01:00
|
|
|
# Create PDF report
|
2020-07-17 14:44:29 +01:00
|
|
|
generatePDF(save_path,project,DBP,MBP,SBP,PP,Q_avg,txt1,txt2,Rc_C_Rd)
|