CalculatorUI.py
UI框架基于tkinter
# !/usr/bin/python
# -*- coding: UTF-8 -*-
'''
@Time: 2022/1/6 10:10
@User: dell
@IDE: PyCharm
@Author: George
@File: CalculatorUI.py
e-mail:gaoxin_hit@163.com
'''
import tgd02 as t2
import tgd03 as t3
import tgd04 as t4
import tkinter as tk
import tkinter.messagebox
from tkinter.filedialog import (askopenfilename,
askopenfilenames,
askdirectory,
asksaveasfilename)
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.pack()
self.window_init()
self.CreatWidgets()
def window_init(self):
self.master.title('Welcome To CalculateFoundation !')
# width, height = self.master.maxsize()
width, height = 600, 220
self.master.geometry("{}x{}".format(width, height))
def CreatWidgets(self): # 测试entry中拿取文件路径的逻辑
self.geofilePath_en = tk.Entry(self, width=60)
self.geofilePath_en.grid(row=0, column=1, columnspan=3, sticky=tk.E, padx=5, pady=5)
self.geofilePath_en.delete(0, "end")
self.geofilePath_en.insert(0, "请选择塔筒几何参数文件")
self.fm1 = tk.Frame(self) # 塔筒几何参数文件输入
self.chooseButton1 = tk.Button(self.fm1, text='选择塔筒几何参数文件', command=self.ChooseGeoFileFrame)
self.fm1.grid(row=0, sticky=tk.W, padx=5, pady=5)
self.chooseButton1.grid(row=0, sticky=tk.W, padx=5, pady=5)
self.materialfilePath_en = tk.Entry(self, width=60)
self.materialfilePath_en.grid(row=1, column=1, columnspan=3, sticky=tk.E, padx=5, pady=5)
self.materialfilePath_en.delete(0, "end")
self.materialfilePath_en.insert(0, "请选择塔筒材料参数文件")
self.fm2 = tk.Frame(self) # 塔筒材料属性文件输入
self.chooseButton2 = tk.Button(self.fm2, text='选择塔筒材料参数文件', command=self.ChooseMaterialFileFrame)
self.chooseButton2.grid(row=1, column=0, sticky=tk.W, padx=5, pady=5)
self.fm2.grid(row=1, column=0, sticky=tk.W, padx=5, pady=5)
self.savedir_en = tk.Entry(self, width=60)
self.savedir_en.grid(row=2, column=1, columnspan=3, sticky=tk.E, padx=5, pady=5)
self.savedir_en.delete(0, "end")
self.savedir_en.insert(0, "计算结果文件存储路径")
self.fm3 = tk.Frame(self) # 计算结果存储路径
self.chooseButton3 = tk.Button(self.fm3, text='选择计算结果存储路径', command=self.ChooseSaveDir)
self.fm3.grid(row=2, column=0, sticky=tk.W, padx=5, pady=5)
self.chooseButton3.grid(row=2, column=0, sticky=tk.W, padx=5, pady=5)
self.fm4 = tk.Frame(self) # 添加确认计算的按钮
self.chooseButton4 = tk.Button(self.fm4, text='计 算', width=10, command=self.Calculation)
self.fm4.grid(row=3, column=3, sticky=tk.E, padx=5, pady=5)
self.chooseButton4.grid(row=3, column=3, sticky=tk.E, padx=5, pady=5)
self.fm5 = tk.Frame(self) # 添加退出计算的按钮
self.chooseButton5 = tk.Button(self.fm4, text='退 出', width=10, command=self.Quit)
self.fm5.grid(row=3, column=0, sticky=tk.E, padx=5, pady=5)
self.chooseButton5.grid(row=3, column=0, sticky=tk.E, padx=5, pady=5)
def ChooseGeoFileFrame(self):
# 弹出选择文件夹的界面,选择相应的输入文件,点击确定,完成输入并且对文件进行检查
# ?这个弹出窗口是否可以复用到其他任何需要选择输入文件的地方????
# !应该不好弄,如果需要在弹出窗口的时候就指定文件后缀名的话,是否会产生不良影响呢?
filepath = askopenfilenames(title='请选择文件',
initialdir='/', filetypes=[('Python source file', '*.xlsx')])
self.geofilePath_en.delete(0, "end")
self.geofilePath_en.insert(0, filepath)
def ChooseMaterialFileFrame(self):
filepath = askopenfilenames(title='请选择文件',
initialdir='/', filetypes=[('Python source file', '*.xlsx')])
self.materialfilePath_en.delete(0, "end")
self.materialfilePath_en.insert(0, filepath)
def ChooseSaveDir(self):
savedir = askdirectory()
self.savedir_en.delete(0, "end")
self.savedir_en.insert(0, savedir)
def Calculation(self):
geo_path = self.geofilePath_en.get()
material_path = self.materialfilePath_en.get()
Tower_geo = t3.get_Tower_geo(geo_path)
load_data_A = t3.get_load_data_A(material_path) # 这里先用材料文件路径做个测试
savedir = self.savedir_en.get()
result = []
for i, item in enumerate(Tower_geo):
ans = t2.calcu_Aear_force(item[1], item[2], load_data_A[i])
result.append((Tower_geo[i][0], ans[0], ans[1]))
t4.save_result(savedir, result)
tkinter.messagebox.showinfo("提示", "计算完成!")
def Quit(self):
quit = tk.messagebox.askokcancel("提示", "是否要退出?")
if quit == True:
self.master.destroy()
if __name__ == '__main__':
app = Application()
app.mainloop()
CalcuPart.py
计算核心,主要包括提取材料常数的部分
# !/usr/bin/python
# -*- coding: UTF-8 -*-
'''
@Time: 2022/1/7 15:34
@User: dell
@IDE: PyCharm
@Author: George
@File: CalcuPart.py
e-mail:gaoxin_hit@163.com
'''
import MaterialLib as ML
class SectionCheck():
def __init__(self, conc_str_deg, steel_str_deg, pre_steel_str_deg,
outer_dia, inner_dia, outer_bar_dia, inner_bar_dia, n, sigma_con,
bar_num_per_hole):
# "C60": (fck_GB, ftk_GB, fc_GB, ft_GB, Ec, fck_MC, alpha_1, ftk_0k05)
# 获取混凝土材料属性
concrete_material_cell = ML.return_concrete_material_attr(conc_str_deg)
self.fck_GB = concrete_material_cell["fck_GB"]
self.ftk_GB = concrete_material_cell["ftk_GB"]
self.fc_GB = concrete_material_cell["fc_GB"]
self.Ec = concrete_material_cell["Ec"]
self.fck_MC = concrete_material_cell["fck_MC"]
self.alpha_1 = concrete_material_cell["alpha_1"]
self.ftk_0k05 = concrete_material_cell["ftk_0k05"]
# "HRB400": (fyk, fstk, fy, fy_p, Es)
# 获取钢筋材料属性
steel_material_cell = ML.return_steel_material_attr(steel_str_deg)
self.fyk = steel_material_cell["fyk"]
self.fstk = steel_material_cell["fstk"]
self.fy = steel_material_cell["fy"]
self.fy_p = steel_material_cell["fy_p"]
self.Es = steel_material_cell["Es"]
# "1860": (fptk, fpy, fpy_p, Ep)
# 获取预应力筋材料属性
pre_steel_material_cell = ML.return_presteel_material_attr(pre_steel_str_deg)
self.fptk = pre_steel_material_cell["fptk"]
self.fpy = pre_steel_material_cell["fpy"]
self.fpy_p = pre_steel_material_cell["fpy_p"]
self.Ep = pre_steel_material_cell["Ep"]
self.A_phi = pre_steel_material_cell["A_phi"]
self.sigma_con = sigma_con
self.An = 3.1416/4*(outer_dia**2 - inner_dia**2)
def calcu_press_loss(self, a, l, x_b, x_t, theta_b, theta_t, k, miu, As, As_p):
sigma_l1 = a * self.Ep / l
mid_para_b = k*x_b + miu*theta_b
mid_para_t = k*x_t + miu*theta_t
sigma_l2_b = mid_para_b * self.sigma_con
sigma_l2_t = mid_para_t * self.sigma_con
sigma_l2 = 0.5 * (sigma_l2_b + sigma_l2_t)
contr_para = self.sigma_con/self.fptk
if contr_para <= 0.7:
sigma_l4 = 0.125*(contr_para-0.5)*self.sigma_con
else:
sigma_l4 = 0.2*(contr_para-0.575)*self.sigma_con
sigma_pc = None
MaterialLib.py
材料常数库代码
# !/usr/bin/python
# -*- coding: UTF-8 -*-
'''
@Time: 2022/1/6 11:43
@User: dell
@IDE: PyCharm
@Author: George
@File: MaterialLib.py
e-mail:gaoxin_hit@163.com
'''
# 创建材料属性列表,后期只需要指定材料代号,其他数据可以直接使用
# 混凝土材料属性
# "C60": (fck_GB, ftk_GB, fc_GB, ft_GB, Ec, fck_MC, alpha_1, ftk_0k05)
Concrete_materialLib = {"C15": (10.0, 1.27, 7.20, 0.91, 2.20*10**4, 12.00, 1.00, 1.1),
"C20": (13.4, 1.54, 9.60, 1.10, 2.55*10**4, 16.00, 1.00, 1.3),
"C25": (16.7, 1.78, 11.9, 1.27, 2.80*10**4, 20.00, 1.00, 1.5),
"C30": (20.1, 2.01, 14.3, 1.43, 3.00*10**4, 25.00, 1.00, 1.8),
"C35": (23.4, 2.20, 16.7, 1.57, 3.15*10**4, 28.57, 1.00, 1.94),
"C40": (26.8, 2.39, 19.1, 1.71, 3.25*10**4, 31.87, 1.00, 2.07),
"C45": (29.6, 2.51, 21.1, 1.80, 3.35*10**4, 35.00, 1.00, 2.2),
"C50": (32.4, 2.64, 23.1, 1.89, 3.45*10**4, 40.00, 1.00, 2.5),
"C55": (35.5, 2.74, 25.3, 1.96, 3.55*10**4, 45.00, 0.99, 2.7),
"C60": (38.5, 2.85, 27.5, 2.04, 3.60*10**4, 50.00, 0.98, 2.9),
"C65": (41.5, 2.93, 29.7, 2.09, 3.65*10**4, 53.57, 0.97, 2.97),
"C70": (44.5, 2.99, 31.8, 2.14, 3.70*10**4, 56.87, 0.96, 3.03),
"C75": (47.4, 3.05, 33.8, 2.18, 3.75*10**4, 60.00, 0.95, 3.1),
"C80": (50.2, 3.11, 35.9, 2.22, 3.80*10**4, 65.00, 0.94, 3.15)
}
def return_concrete_material_attr(str_deg):
material_set = {"C15", "C20", "C25", "C30", "C35", "C40", "C45",
"C50", "C55", "C60", "C65", "C70", "C75", "C80"}
if str_deg in material_set:
concrete_material_cell = {"fck_GB": Concrete_materialLib[str_deg][0],
"ftk_GB": Concrete_materialLib[str_deg][1],
"fc_GB": Concrete_materialLib[str_deg][2],
"ft_GB": Concrete_materialLib[str_deg][3],
"Ec": Concrete_materialLib[str_deg][4],
"fck_MC": Concrete_materialLib[str_deg][5],
"alpha_1": Concrete_materialLib[str_deg][6],
"ftk_0k05": Concrete_materialLib[str_deg][7]}
else:
pass # 提示材料强度等级输入错误!
return concrete_material_cell
# 钢筋材料属性
# "HRB400": (fyk, fstk, fy, fy_p, Es)
steel_materialLib = {"HPB300": (300, 420, 270, 270, 2.1*10**5),
"HRB335": (335, 455, 300, 300, 2.0*10**5),
"HRB400": (400, 540, 360, 360, 2.0*10**5),
"HRB500": (500, 630, 435, 410, 2.0*10**5),
"HRBF335": (335, 455, 300, 300, 2.0*10**5),
"HRBF400": (400, 540, 360, 360, 2.0*10**5),
"HRBF500": (500, 630, 435, 410, 2.0*10**5),
"RRB400": (400, 540, 360, 360, 2.0*10**5)}
# "HRB400": (fyk, fstk, fy, fy_p, Es)
def return_steel_material_attr(str_deg):
material_set = {"HPB300", "HRB335", "HRB400", "HRB500", "HRBF335", "HRBF400", "HRBF500", "RRB400"}
if str_deg in material_set:
steel_material_cell = {"fyk": steel_materialLib[str_deg][0],
"fstk": steel_materialLib[str_deg][1],
"fy": steel_materialLib[str_deg][2],
"fy_p": steel_materialLib[str_deg][3],
"Es": steel_materialLib[str_deg][4]}
else:
pass # 提示材料强度等级输入错误!
return steel_material_cell
# 预应力筋材料属性
# 目前仅考虑纳入国标中钢绞线的数据
# "1860": (fptk, fpy, fpy_p, Ep, A_phi)
# A_phi ——> 单根钢绞线截面面积,mm^2
pre_steel_materialLib = {"1570": (1570, 1110, 390, 1.95*10**5, 140),
"1720": (1720, 1220, 390, 1.95*10**5, 140),
"1860": (1860, 1320, 390, 1.95*10**5, 140),
"1960": (1960, 1390, 390, 1.95*10**5, 140)}
def return_presteel_material_attr(str_deg):
material_set = {"1570", "1720", "1860", "1960"}
if str_deg in material_set:
steel_material_cell = {"fptk": pre_steel_materialLib[str_deg][0],
"fpy": pre_steel_materialLib[str_deg][1],
"fpy_p": pre_steel_materialLib[str_deg][2],
"Ep": pre_steel_materialLib[str_deg][3],
"A_phi": pre_steel_materialLib[str_deg][4]}