82 lines
2.8 KiB
Python
82 lines
2.8 KiB
Python
#!/usr/bin/env python
|
|
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
import matplotlib.ticker as mtick
|
|
from tkinter import Tk
|
|
from tkinter.filedialog import askopenfilename, asksaveasfile, askdirectory
|
|
import pandas as pd
|
|
import tkinter as tk
|
|
import os.path
|
|
from scipy.signal import find_peaks_cwt
|
|
from scipy import signal
|
|
import statistics
|
|
from fpdf import FPDF
|
|
|
|
|
|
from functions import error_plot, periodicity, pressure, flow, inlet_flow_waveform
|
|
|
|
# Selct dir
|
|
Tk().withdraw()
|
|
folder = askdirectory()
|
|
project_folder = os.path.dirname(folder)
|
|
project = os.path.basename(project_folder)
|
|
save_path = folder+'/'+project+'-report'
|
|
# os.mkdir(save_path)
|
|
save_pdf = save_path + '/' + project + '-report.pdf'
|
|
|
|
# Input parameters
|
|
T_cyc = 0.477
|
|
n_cyc = 5
|
|
|
|
|
|
# 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])
|
|
# Imesteps between Restarts - idx 6
|
|
t_btw_rst = int(mylines[6][37:-1])
|
|
|
|
# Cehcking convergency and periodicity
|
|
error_plot(folder,dt,rc,save_path)
|
|
txt1 = periodicity(project,folder,dt,T_cyc,n_cyc,save_path)
|
|
|
|
# Pressure - Outlets
|
|
(DBP,MBP,SBP,PP) = pressure(folder,N_ts,T_cyc,dt,n_cyc,save_path)
|
|
|
|
# Flow Rate - Outlets
|
|
(Q_avg) = flow(folder,N_ts,T_cyc,dt,n_cyc,save_path)
|
|
|
|
# Inlet Flow Rate + and t saved
|
|
txt2 = inlet_flow_waveform(project_folder,t_btw_rst,N_ts,dt,T_cyc,n_cyc,save_path)
|
|
|
|
|
|
# Create PDF report
|
|
pdf = FPDF('P','mm','Letter')
|
|
pdf.add_page()
|
|
pdf.set_font('Times', 'B', 18)
|
|
pdf.cell(200, 20, 'Project name: '+ project, 0, 1, 'C')
|
|
|
|
# Keep this ratio - 5.42/3.86
|
|
pdf.set_font('Times', '', 14)
|
|
pdf.cell(200, 30, 'Cehcking convergency and periodicity:', 0, 1, 'L')
|
|
pdf.image(save_path +'/Log_Last_nonlin_res_error.jpg', x = None, y = None, w = 140, h = 100, type = '', link = '')
|
|
pdf.image(save_path +'/periodicity.jpg', x = None, y = None, w = 140, h = 100, type = '', link = '')
|
|
pdf.cell(200, 20, 'Cehcking Pressures at each outlet:', 0, 1, 'L')
|
|
pdf.image(save_path +'/pressure.jpg', x = None, y = None, w = 140, h = 100, type = '', link = '')
|
|
pdf.cell(200, 20, 'Cehcking Flow Rate at each outlet:', 0, 1, 'L')
|
|
pdf.image(save_path +'/flow.jpg', x = None, y = None, w = 140, h = 100, type = '', link = '')
|
|
|
|
pdf.image(save_path +'/inlet_waveform.jpg', x = None, y = None, w = 140, h = 100, type = '', link = '')
|
|
|
|
|
|
pdf.output(save_pdf, 'F')
|