3232from ui .win_export import Ui_win_export
3333from ui .win_about import Ui_win_about
3434from ui .win_terminal import Ui_win_terminal
35+ from ui .win_scale import Ui_win_scale
3536
3637
3738SOFTWARE = '非线性多自由度时程分析软件'
38- VERSION = 'V2.0.2 '
39- DATE = '2024.08.26 '
39+ VERSION = 'V2.1.0 '
40+ DATE = '2024.10.27 '
4041TEMP_PATH = Path (os .getenv ('TEMP' )).as_posix ()
4142ROOT = Path (__file__ ).parent .parent
4243
@@ -84,6 +85,7 @@ def init_ui(self):
8485 self .ui .setupUi (self )
8586 self .setWindowTitle (f'{ SOFTWARE } { VERSION } ' )
8687 self .ui .pushButton .clicked .connect (self .open_win_select_gm )
88+ self .ui .pushButton_23 .clicked .connect (self .open_win_scale )
8789 self .ui .pushButton_2 .clicked .connect (self .open_win_select_gm1 )
8890 self .ui .pushButton_5 .clicked .connect (self .delete_seleted )
8991 self .ui .pushButton_4 .clicked .connect (self .delete_all )
@@ -157,14 +159,14 @@ def init_ui(self):
157159
158160 def init_gm_var (self ):
159161 """初始化地震动变量"""
160- self .gm = [] # 加速度序列
161- self .gm_name = []
162- self .gm_N = 0
163- self .gm_dt = []
164- self .gm_NPTS = []
165- self .gm_t = [] # 时间序列
166- self .gm_duration = [] # 持时
167- self .gm_unit = [] # 单位
162+ self .gm : list [ np . ndarray ] = [] # 加速度序列
163+ self .gm_name : list [ str ] = []
164+ self .gm_N : int = 0
165+ self .gm_dt : list [ float ] = []
166+ self .gm_NPTS : list [ int ] = []
167+ self .gm_t : list [ np . ndarray ] = [] # 时间序列
168+ self .gm_duration : list [ float ] = [] # 持时
169+ self .gm_unit : list [ Literal [ 'g' , 'cm/s^2' , 'm/s^2' , 'mm/s^2' ]] = [] # 单位
168170 self .gm_PGA = []
169171
170172 def init_var (self ):
@@ -275,6 +277,11 @@ def open_win_select_gm(self):
275277 win = Win_importGM (self )
276278 win .exec_ ()
277279
280+ def open_win_scale (self ):
281+ win = Win_scale (self )
282+ win .exec_ ()
283+ self .plot_gm (None , self .current_gm_idx )
284+
278285 def gm_list_update (self ):
279286 """更新地震动列表"""
280287 self .ui .listWidget .clear ()
@@ -358,16 +365,15 @@ def update_gm(self):
358365 self .ui .lineEdit_4 .setText ('0.00001' )
359366 if float (self .ui .lineEdit .text ()) == 0 :
360367 self .ui .lineEdit .setText ('0.00001' )
368+ target_PGA = float (self .ui .lineEdit_4 .text ())
369+ target_dt = float (self .ui .lineEdit .text ())
361370 idx = self .current_gm_idx
362- self .gm_PGA [idx ] = float (self .ui .lineEdit_4 .text ())
363- self .gm_dt [idx ] = float (self .ui .lineEdit .text ())
371+ self .gm_PGA [idx ] = target_PGA
372+ self .gm_t [idx ] *= float (self .ui .lineEdit .text ()) / self .gm_dt [idx ]
373+ self .gm_dt [idx ] = target_dt
364374 self .gm_unit [idx ] = self .ui .comboBox .currentText ()
365- self .gm_duration [idx ] = self .gm_NPTS [idx ] * float (self .ui .lineEdit .text ())
366- th_old = self .gm [idx ]
367- th = th_old / max (abs (th_old )) * float (self .ui .lineEdit_4 .text ())
368- t = np .linspace (0 , self .gm_NPTS [idx ] * float (self .ui .lineEdit .text ()), self .gm_NPTS [idx ] + 1 )
369- self .gm [idx ] = th
370- self .gm_t [idx ] = t
375+ self .gm_duration [idx ] = self .gm_NPTS [idx ] * target_dt
376+ self .gm [idx ] *= target_PGA / max (abs (self .gm [idx ]))
371377 self .ui .label_5 .setText (f'{ self .gm_name [idx ]} 已更新' )
372378 self .plot_gm (None , idx = idx )
373379
@@ -572,8 +578,8 @@ def model_is_complete(self):
572578 print ('【MyWin, model_is_complete】质量数量与层数不等' )
573579 return False
574580 print ('【MyWin, model_is_complete】模型完备!' )
575- print ('【MyWin, model_is_complete】' , self .mat_lib )
576- print ('【MyWin, model_is_complete】' , self .story_mat )
581+ print ('【MyWin, model_is_complete】材料定义: ' , self .mat_lib )
582+ print ('【MyWin, model_is_complete】楼层材料 ' , self .story_mat )
577583 return True
578584
579585 def mat_is_complete (self ):
@@ -2785,3 +2791,47 @@ def __init__(self, parent=None):
27852791 self .ui .setupUi (self )
27862792 sys .stdout = core .EmittingStream (self .ui .textEdit )
27872793 sys .stderr = core .EmittingStream (self .ui .textEdit )
2794+
2795+
2796+ class Win_scale (QDialog ):
2797+ """统一缩放地震动"""
2798+ def __init__ (self , main : MyWin , parent = None ):
2799+ super ().__init__ (parent )
2800+ self .main = main
2801+ self .ui = Ui_win_scale ()
2802+ self .ui .setupUi (self )
2803+ self .init_ui ()
2804+
2805+ def init_ui (self ):
2806+ validator = QDoubleValidator (0 , 10000 , 7 )
2807+ validator .setNotation (QDoubleValidator .StandardNotation )
2808+ self .ui .lineEdit .setValidator (validator )
2809+ self .ui .lineEdit_4 .setValidator (validator )
2810+ self .ui .pushButton .clicked .connect (self .confirmation )
2811+ self .ui .radioButton_5 .toggled .connect (lambda : self .ui .lineEdit .setEnabled (self .ui .radioButton_5 .isChecked ()))
2812+ self .ui .radioButton_6 .toggled .connect (lambda : self .ui .lineEdit_4 .setEnabled (self .ui .radioButton_6 .isChecked ()))
2813+
2814+ def confirmation (self ):
2815+ """点击确认"""
2816+ print (f'【Win_scale, confirmation】进行地震动缩放' )
2817+ if self .main .gm_N == 0 :
2818+ self .accept ()
2819+ return
2820+ if self .ui .radioButton_4 .isChecked ():
2821+ # 归一化
2822+ for idx in range (self .main .gm_N ):
2823+ self .main .gm [idx ] /= np .max (abs (self .main .gm [idx ]))
2824+ elif self .ui .radioButton_5 .isChecked ():
2825+ # 指定PGA
2826+ PGA = float (self .ui .lineEdit .text ())
2827+ for idx in range (self .main .gm_N ):
2828+ self .main .gm [idx ] *= PGA / np .max (abs (self .main .gm [idx ]))
2829+ else :
2830+ # 指定缩放系数
2831+ SF = float (self .ui .lineEdit_4 .text ())
2832+ for idx in range (self .main .gm_N ):
2833+ self .main .gm [idx ] *= SF
2834+ self .main .ui .label_5 .setText ('已统一缩放' )
2835+ self .accept ()
2836+
2837+
0 commit comments