def Delvry_Pass(self): print("========================Delvry_Pass start=====================") self.pu_prf = mathuty.Clamp(self.pu_prf_tgt, self.penv.d["pu_prf_env_min"][7], self.penv.d["pu_prf_env_max"][7]) print("pu_prf") print(self.pu_prf) # bspare = self.Limit_PU_Prf(self.pu_prf) self.ef_en_pu_prf = self.pu_prf for std in self.std_vec[:-1]: self.ef_en_pu_prf = mathuty.Clamp( self.ef_en_pu_prf, self.penv.d["ef_pu_prf_env_min"][std], self.penv.d["ef_pu_prf_env_max"][std]) self.std_ex_strn_buf = self.lrg.calc(7, "Std_Ex_Strn5")(self.ef_en_pu_prf, self.pu_prf) self.std_ex_strn = mathuty.Clamp(self.std_ex_strn_buf, self.lpce.d["crit_bckl_lim_cb"][7], self.lpce.d["crit_bckl_lim_we"][7]) print("std_ex_strn") print(self.std_ex_strn) if self.std_ex_strn_buf != self.std_ex_strn: self.ef_en_pu_prf = self.lrg.calc(7, "Ef_En_PU_Prf5")( self.std_ex_strn, self.pu_prf) self.ufd_pu_prf_buf = self.lrg.calc(7, "UFD_PU_Prf1")(self.ef_en_pu_prf, self.std_ex_strn) self.ufd_pu_prf = mathuty.Clamp(self.ufd_pu_prf_buf, self.penv.d["ufd_pu_prf_env_min"][7], self.penv.d["ufd_pu_prf_env_max"][7]) print("ufd_pu_prf_buf", self.ufd_pu_prf_buf) print("ufd_pu_prf", self.ufd_pu_prf) if self.ufd_pu_prf_buf != self.ufd_pu_prf: self.std_ex_strn = self.lrg.calc(7, "Std_Ex_Strn6")(self.ufd_pu_prf, self.pu_prf) self.ef_en_pu_prf = self.lrg.calc(7, "Ef_En_PU_Prf1")( self.ufd_pu_prf, self.std_ex_strn) self.ef_ex_pu_prf = self.lrg.calc(7, "Ef_Ex_PU_Prf3")(self.ef_en_pu_prf, self.ufd_pu_prf) self.istd_ex_strn = self.lrg.calc(7, "Istd_Ex_Strn2")(self.std_ex_strn) print("ef_en_pu_prf", self.ef_en_pu_prf) print("ef_ex_pu_prf", self.ef_ex_pu_prf) print("istd_ex_strn", self.istd_ex_strn) print("======================Delvry_Pass end========================") return self.ef_en_pu_prf, self.ef_ex_pu_prf, self.istd_ex_strn
def Pass_Mill_Targ(self, std): ef_en_pu_prf = 0 ef_pu_prf_buf = 0 std_ex_strn = 0 std_ex_strn_buf = 0 ufd_pu_prf = 0 ufd_pu_prf = self.ufd.Prf( std, self.alc.d["force_pu_wid"][std], self.fsstd.d["force_bnd"][std], self.crlc.d["pce_wr_cr"][std], self.crlc.d["wr_br_cr"][std]) / self.alc.d["thick"][std] ef_pu_prf = self.Ef_PU_Prf_Aim(std) ef_en_pu_prf = self.lrg.calc(std, "Ef_En_PU_Prf3")(ufd_pu_prf, ef_pu_prf, 0) ef_en_pu_prf = mathuty.Clamp(ef_en_pu_prf, self.penv.d["ef_pu_prf_env_min"][std - 1], self.penv.d["ef_pu_prf_env_max"][std - 1]) std_ex_strn_buf = self.lrg.calc(std, "Std_Ex_Strn1")(ef_en_pu_prf, ufd_pu_prf) std_ex_strn = mathuty.Clamp(std_ex_strn_buf, self.lpce.d["crit_bckl_lim_cb"][std], self.lpce.d["crit_bckl_lim_we"][std]) if std_ex_strn != std_ex_strn_buf: ef_en_pu_prf = self.lrg.calc(std, "Ef_En_PU_Prf1")(ufd_pu_prf, std_ex_strn) ef_pu_prf = self.lrg.calc(std, "Ef_Ex_PU_Prf3")(ef_en_pu_prf, ufd_pu_prf) ef_pu_prf = mathuty.Clamp(ef_pu_prf, self.penv.d["ef_pu_prf_env_min"][std], self.penv.d["ef_pu_prf_env_max"][std]) while std != 7 & std >= 0: std = std + 1 ef_pu_prf_buf = self.Ef_PU_Prf_Aim(std) if ef_pu_prf > ef_pu_prf_buf: ef_pu_prf = ef_pu_prf + self.lrg.d["ef_pu_prf_chg_cb"][std] ef_pu_prf = max(ef_pu_prf, ef_pu_prf_buf) else: ef_pu_prf = ef_pu_prf + self.lrg.d["ef_pu_prf_chg_we"][std] ef_pu_prf = min(ef_pu_prf, ef_pu_prf_buf) ef_pu_prf = mathuty.Clamp(ef_pu_prf, self.penv.d["ef_pu_prf_env_min"][std], self.penv.d["ef_pu_prf_env_max"][std]) return ef_pu_prf
def Limit_PU_Prf(self, pu_prf_buf): self.pu_prf = mathuty.Clamp(pu_prf_buf, self.pu_prf_lim_min, self.pu_prf_lim_max) self.targ_same = self.pu_prf == self.pu_prf_old self.pu_prf_old = self.pu_prf return self.targ_same
def Eval_Ef_En_PU_Prf(self, ef_ex_pu_prf, ef_pu_prf_chg_cb, ef_pu_prf_chg_we, ef_pu_prf_env_min, ef_pu_prf_env_max, ef_en_pu_prf): self.ef_en_pu_prf = mathuty.Clamp(ef_en_pu_prf, ef_pu_prf_env_min, ef_pu_prf_env_max) if (self.ef_en_pu_prf + ef_pu_prf_chg_we) < ef_ex_pu_prf: self.ef_en_pu_prf = ef_ex_pu_prf - ef_pu_prf_chg_we elif (self.ef_en_pu_prf + ef_pu_prf_chg_cb) > ef_ex_pu_prf: self.ef_en_pu_prf = ef_ex_pu_prf - ef_pu_prf_chg_cb return self.ef_en_pu_prf
def Ef_PU_Prf_Aim(self, std): ef_pu_prf_buf = 0 ef_pu_prf_buf = self.pu_prf - self.istd_ex_strn buf_pass = 7 while buf_pass >= 1 & buf_pass <= 7: ef_pu_prf_buf = mathuty.Clamp( ef_pu_prf_buf, self.penv.d["ef_pu_prf_env_min"][buf_pass], self.penv.d["ef_pu_prf_env_max"][buf_pass]) if buf_pass == std: break else: buf_pass = buf_pass - 1 return ef_pu_prf_buf
def Bnd_Frc(self, std, ufd_prf, force_pu_wid, pce_wr_crn, wr_br_crn, force_bnd_lim_min, force_bnd_lim_max): """ 不包括限幅,直接返回force_bnd_des """ b_cof = self.b_cof[std] force_bnd_des = ( (ufd_prf / self.ufd_modifier(std) - b_cof[0] * force_pu_wid - b_cof[1] * pow(force_pu_wid, 1.5) - b_cof[2] * pce_wr_crn - b_cof[3] * wr_br_crn * force_pu_wid - b_cof[4] * wr_br_crn * pow(force_pu_wid, 1.5) - b_cof[8] * wr_br_crn - b_cof[9] * force_pu_wid - b_cof[11] * force_pu_wid - b_cof[12] * pow(force_pu_wid, 1.5) - b_cof[14] * pce_wr_crn - b_cof[15] * pce_wr_crn - b_cof[16] - b_cof[17]) / (b_cof[5] + b_cof[6] * force_pu_wid + b_cof[7] * pow(force_pu_wid, 2) + b_cof[10] + b_cof[13])) force_bnd = mathuty.Clamp(force_bnd_des, force_bnd_lim_min, force_bnd_lim_max) return force_bnd, force_bnd_des
def Calculate(self): PceIZFSPass = 0 CritFSPass = 7 self.d.loc[0, "thick"] = self.fsstd.d.loc[1, "en_thick"] for std in self.std_vec: self.d.loc[std, "force_pu_wid"] = ( self.fsstd.d.loc[std, "force_strip"] / self.fsstd.d.loc[std, "en_width"]) self.d.loc[std, "thick"] = self.fsstd.d.loc[std, "ex_thick"] # *pcFSPassD->pcAlcD->pcRollbite = # *pcFSPassD->pcFSStdD[ iter ]->pcRollbite; if self.lrg.d.loc[std, "pce_infl_cof"] <= 0: PceIZFSPass = std # if redrft_perm: Frc_Chg_Limits pu_prf_change_sum = 0 for std in self.std_vec[:-1]: if ((self.fsstd.d.loc[std, "dummied"] != "T") & (self.lrg.d.loc[std, "pce_infl_cof"] > 0)): pass else: raise Exception("pce_infl_cof <= 0") if self.lpce.d.loc[std, "strn_rlf_cof"] == 0: pu_prf_change_sum += (1 / self.lrg.d.loc[std, "pce_infl_cof"]) else: pu_prf_change_sum += (self.lpce.d.loc[std, "strn_rlf_cof"] / (self.lrg.d.loc[std, "pce_infl_cof"] * self.lpce.d.loc[std, "elas_modu"])) print("pu_prf_change_sum", std) print(pu_prf_change_sum) self.targt = Target(self.fsstd, self.lpce, self.lrg, self.ufd, self.crlc, self.penv, self) ef_en_pu_prf, ef_ex_pu_prf, istd_ex_strn = self.targt.Delvry_Pass() std = 7 while std != 0: # 在alcd对象中这里的stdd局部对象实际就为当前机架道次的fsstd对象 pce_wr_crn, wr_br_crn = self.crlc.Crns( std, self.fsstd.d.loc[std, "wr_shft"]) print("pce_wr_crn by crlc crns before actrtyp_shft", std) print(pce_wr_crn) # print(" wr_br_crn by crlc crns before actrtyp_shft", std) # print(wr_br_crn) if self.fsstd.d.loc[std, "dummied"] == "T": self.d.loc[std - 1, "thick"] = self.d.loc[std, "thick"] self.d.loc[std, "ufd_pu_prf"] = 0 else: # 925-1775 line else # self.rollbite.Calculate() # if redrft_perm: cAlcD::Eval_Frc_PU_Wid flt_ok = True if std < PceIZFSPass: self.d.loc[std, "ufd_pu_prf"] = self.ufd.Prf( self.d.loc[std, "force_pu_wid"], self.fsstd.d.loc[std, "force_bnd"], pce_wr_crn, wr_br_crn) / self.d.loc[std, "thick"] else: self.d.loc[std, "ufd_pu_prf"] = self.lrg.calc( std, "UFD_PU_Prf3")(ef_en_pu_prf, ef_ex_pu_prf) print("pass{}".format(std)) print("ef_en_pu_prf: {}".format(ef_en_pu_prf)) print("ef_ex_pu_prf: {}".format(ef_ex_pu_prf)) pce_wr_crn, wr_br_crn = self.actrtyp_shift( std, pce_wr_crn, wr_br_crn) print("pce_wr_crn after actrtyp_shft", std) print(pce_wr_crn) # print(" wr_br_crn after actrtyp_shft", std) # print(wr_br_crn) self.actrtyp_bend(std, pce_wr_crn, wr_br_crn) self.lpce.d.loc[std, "ufd_pu_prf"] = self.ufd.Prf( std, self.d["force_pu_wid"][std], self.fsstd.d["force_bnd"][std], pce_wr_crn, wr_br_crn) / self.d.loc[std, "thick"] # end if down stream stand influence is 0 ufd_pu_prf_tol = 0.0001 alc_lim = (abs(self.d.loc[std, "ufd_pu_prf"] - self.lpce.d.loc[std, "ufd_pu_prf"]) > ufd_pu_prf_tol) print(" alc ufd_pu_prf {}".format(std)) print(self.d.loc[std, "ufd_pu_prf"]) print(" lpce ufd_pu_prf {}".format(std)) print(self.lpce.d.loc[std, "ufd_pu_prf"]) print("alc_lim", alc_lim) redrft_lim = False # redrft_lim = false; if( redrft_perm ) 1183-1475line if alc_lim | redrft_lim: # 1481-1734 alc_lim check ufd_pu_prf = self.ufd.Prf(std, self.d["force_pu_wid"][std], self.fsstd.d["force_bnd"][std], pce_wr_crn, wr_br_crn) / self.d["thick"][std] print("local ufd_pu_prf", std) print(self.lpce.d.loc[std, "ufd_pu_prf"]) ef_en_pu_prf_buf = self.lrg.calc(std, "Ef_En_PU_Prf3")( ufd_pu_prf, ef_en_pu_prf, ef_ex_pu_prf) if ((ef_en_pu_prf_buf > self.penv.d["ef_pu_prf_env_max"][std - 1]) | (ef_en_pu_prf_buf < self.penv.d["ef_pu_prf_env_min"][std - 1])): if ef_en_pu_prf < ef_ex_pu_prf: if ef_en_pu_prf_buf > ef_ex_pu_prf: ef_en_pu_prf_buf = ef_ex_pu_prf else: if ef_en_pu_prf_buf < ef_ex_pu_prf: ef_en_pu_prf_buf = ef_ex_pu_prf ef_en_pu_prf = ef_en_pu_prf_buf std_ex_strn = self.lrg.calc(std, "Std_Ex_Strn1")(ef_en_pu_prf, ufd_pu_prf) ef_ex_pu_prf = self.lrg.calc(std, "Ef_Ex_PU_Prf3")(ef_en_pu_prf, ufd_pu_prf) if std < 7: # Calculate the stand exit differential strain # relative to the next non-dummied pass. std_ex_strn_dn = self.lrg.calc( std + 1, "Std_Ex_Strn4")(ef_ex_pu_prf, self.lpce.d.loc[std + 1, "ef_pu_prf"]) flt_idx_list = ["we", "cb"] bckl_lim_dn = {} for flt_idx in flt_idx_list: bckl_lim_dn[flt_idx] = (self.lpce.d.loc[ std + 1, "crit_bckl_lim_{}".format(flt_idx)]) if std == 7: flt_ok = ((std_ex_strn <= self.lpce.d.loc[std, "crit_bckl_lim_we"]) & (std_ex_strn >= self.lpce.d.loc[std, "crit_bckl_lim_cb"])) else: flt_ok = ((std_ex_strn <= self.lpce.d.loc[std, "crit_bckl_lim_we"]) & (std_ex_strn >= self.lpce.d.loc[std, "crit_bckl_lim_cb"]) & (std_ex_strn_dn <= bckl_lim_dn["we"]) & (std_ex_strn_dn >= bckl_lim_dn["cb"])) if not flt_ok: if std != 7: flt_ok = ((std_ex_strn_dn <= bckl_lim_dn["we"]) & (std_ex_strn_dn >= bckl_lim_dn["cb"])) # Re-target the per unit profile if ((not flt_ok) & (self.loop_count <= self.loop_count_lim) & (std <= CritFSPass)): ef_pu_prf_alt = self.targt.Pass_Mill_Targ(std) std_ex_strn = self.lrg.calc( std, "Std_Ex_Strn2")(istd_ex_strn) pu_prf = self.lrg.calc(std, "Istd_Ex_PU_Prf0")( std_ex_strn, ef_pu_prf_alt) pu_prf = mathuty.Clamp( pu_prf, self.penv.d.loc[7, "pu_prf_env_min"], self.penv.d.loc[7, "pu_prf_env_max"]) pu_prf_same = self.targt.Limit_PU_Prf(pu_prf) CritFSPass = std if not pu_prf_same: self.start_over = True # end of alc_lim check self.lpce.d.loc[std, "ufd_pu_prf"] = self.ufd.Prf( std, self.d["force_pu_wid"][std], self.fsstd.d["force_bnd"][std], pce_wr_crn, wr_br_crn) / self.d["thick"][std] self.lpce.d.loc[std, "ef_pu_prf"] = self.lrg.calc( std, "Ef_Ex_PU_Prf3")(ef_en_pu_prf, self.lpce.d.loc[std, "ufd_pu_prf"]) self.lpce.d.loc[std, "strn"] = self.lrg.calc( std, "Std_Ex_Strn4")(ef_en_pu_prf, self.lpce.d.loc[std, "ef_pu_prf"]) self.lpce.d.loc[std, "prf"] = self.lrg.calc( std, "Istd_Ex_PU_Prf0")( self.lpce.d.loc[std, "strn"], self.lpce.d.loc[std, "ef_pu_prf"]) * self.d["thick"][std] # end of pass not dummied if self.start_over: self.loop_count = self.loop_count + 1 if self.loop_count > self.loop_count_lim: raise Exception( "Calculate: loop counter exceeded configured limit") self.start_over = False std = 7 # pcFSPassD = pcLstFSPassD; # if ( redrft_perm ): cAlcD::Frc_Chg_Limits tmp = self.targt.Delvry_Pass() ef_en_pu_prf = tmp[0] ef_ex_pu_prf = tmp[1] istd_ex_strn = tmp[2] self.lpce.d.loc[7, "ef_pu_prf"] = ef_ex_pu_prf else: if std == 1: break else: std = std - 1 ef_ex_pu_prf = ef_en_pu_prf ef_en_pu_prf = mathuty.Clamp( ef_ex_pu_prf, self.penv.d["ef_pu_prf_env_min"][PceIZFSPass], self.penv.d["ef_pu_prf_env_max"][PceIZFSPass]) ef_pu_prf_sum = 0 buf_pass = PceIZFSPass + 1 while (buf_pass <= 7) & (buf_pass > 0): self.d.loc[buf_pass, "ef_pu_prf_dlt_min"] = max( self.lrg.d.loc[buf_pass, "ef_pu_prf_chg_cb"], max(ef_ex_pu_prf, self.penv.d.loc[buf_pass, "ef_pu_prf_env_min"]) - min(ef_en_pu_prf, self.penv.d.loc[buf_pass - 1, "ef_pu_prf_env_max"])) self.d.loc[buf_pass, "ef_pu_prf_dlt_max"] = min( self.lrg.d.loc[buf_pass, "ef_pu_prf_chg_we"], min(ef_ex_pu_prf, self.penv.d.loc[buf_pass, "ef_pu_prf_env_max"]) - max(ef_en_pu_prf, self.penv.d.loc[buf_pass - 1, "ef_pu_prf_env_min"])) if ef_en_pu_prf <= ef_ex_pu_prf: ef_pu_prf_sum = ( ef_pu_prf_sum + self.d.loc[buf_pass, "ef_pu_prf_dlt_max"]) if buf_pass == std: if ef_pu_prf_sum <= 0.000001: ef_en_pu_prf = ef_ex_pu_prf else: ef_en_pu_prf = ( ef_ex_pu_prf - self.d.loc[buf_pass, "ef_pu_prf_dlt_max"] * (ef_ex_pu_prf - ef_en_pu_prf) / ef_pu_prf_sum) else: if (self.penv.d.loc[buf_pass, "ef_pu_prf_env_max"] <= ef_en_pu_prf): ef_en_pu_prf = self.penv.d.loc[ buf_pass, "ef_pu_prf_env_max"] ef_pu_prf_sum = 0 if (self.penv.d.loc[buf_pass, "ef_pu_prf_env_min"] >= ef_ex_pu_prf): ef_en_pu_prf = self.penv.d.loc[ buf_pass, "ef_pu_prf_env_min"] ef_pu_prf_sum = 0 else: ef_pu_prf_sum = ( ef_pu_prf_sum + self.d.loc[buf_pass, "ef_pu_prf_dlt_min"]) if buf_pass == std: if ef_pu_prf_sum >= -0.000001: ef_en_pu_prf = ef_ex_pu_prf else: ef_en_pu_prf = ( ef_ex_pu_prf - self.d.loc[buf_pass, "ef_pu_prf_dlt_min"] * (ef_ex_pu_prf - ef_en_pu_prf) / ef_pu_prf_sum) else: if (self.penv.d.loc[buf_pass, "ef_pu_prf_env_min"] >= ef_en_pu_prf): ef_en_pu_prf = self.penv.d.loc[ buf_pass, "ef_pu_prf_env_min"] ef_pu_prf_sum = 0 if (self.penv.d.loc[buf_pass, "ef_pu_prf_env_max"] <= ef_ex_pu_prf): ef_en_pu_prf = self.penv.d.loc[ buf_pass, "ef_pu_prf_env_max"] ef_pu_prf_sum = 0 if buf_pass == std: break else: buf_pass = buf_pass + 1 # Calculate initial entry pu profile if self.lpce.d["strn_rlf_cof"][std] == 0: self.d.loc[std, "pu_prf_change"] = ( 1 / self.lrg.d.loc[std, "pce_infl_cof"] / pu_prf_change_sum) else: self.d.loc[std, "pu_prf_change"] = ( self.lpce.d["strn_rlf_cof"][std] / (self.lrg.d.loc[std, "pce_infl_cof"] * self.lpce.d["elas_modu"][std]) / pu_prf_change_sum) ef_en_pu_prf_dft = ( ef_ex_pu_prf + (self.targt.en_pu_prf - self.targt.pu_prf) * self.d.loc[std, "pu_prf_change"]) if (((ef_en_pu_prf_dft > ef_ex_pu_prf) & (ef_en_pu_prf_dft < ef_en_pu_prf)) | ((ef_en_pu_prf_dft < ef_ex_pu_prf) & (ef_en_pu_prf_dft > ef_en_pu_prf))): ef_en_pu_prf = ef_en_pu_prf_dft ef_en_pu_prf = self.targt.Eval_Ef_En_PU_Prf( ef_ex_pu_prf, self.lrg.d["ef_pu_prf_chg_cb"][std], self.lrg.d["ef_pu_prf_chg_we"][std], self.penv.d["ef_pu_prf_env_min"][std - 1], self.penv.d["ef_pu_prf_env_max"][std - 1], ef_en_pu_prf) # end of start_over not true # end of while loop print("PceIZFSPass", PceIZFSPass) self.redrfted = False if self.redrft_perm: pass else: for std in self.std_vec: self.fsstd.d.loc[std, "force_ssu"] = 0
def Calculate(self): # logging.info(self.fsstd.lim) # lim的max/min与env中的min/max对应上 self.d = pd.DataFrame(index=self.pass_vec) self.d["force_bnd_env_min"] = self.fsstd.lim["force_bnd_lim_max"] self.d["force_bnd_env_max"] = self.fsstd.lim["force_bnd_lim_min"] self.d["pos_shft_env_min"] = self.fsstd.lim["wr_shft_lim_max"] self.d["pos_shft_env_max"] = self.fsstd.lim["wr_shft_lim_min"] for std in self.std_vec: tmp = self.crlc.Crns(std, self.fsstd.lim["wr_shft_lim_min"][std]) self.d.loc[std, "pce_wr_crn_lim_min"] = tmp[0] self.d.loc[std, "wr_br_crn_lim_min"] = tmp[1] tmp = self.crlc.Crns(std, self.fsstd.lim["wr_shft_lim_max"][std]) self.d.loc[std, "pce_wr_crn_lim_max"] = tmp[0] self.d.loc[std, "wr_br_crn_lim_max"] = tmp[1] # 678-679 line self.d["force_pu_wid"] = (self.fsstd.d["force_strip"] / self.fsstd.d["en_width"]) self.d["force_pu_wid_lim_min"] = self.d["force_pu_wid"] self.d["force_pu_wid_lim_max"] = self.d["force_pu_wid"] for std in self.std_vec: # 此时的pce_wr_crn和wr_br_crn是用wr_shft_nom求得的 self.d.loc[std, "pce_wr_crn"], self.d.loc[std, "wr_br_crn"] = ( self.crlc.Crns(std, self.fsstd.lim["wr_shft_nom"][std])) for std in self.std_vec: self.func.loc[std, "dprf_dfrcw"] = self.ufd.Dprf_Dfrcw( std, self.d["force_pu_wid"][std], self.fsstd.lim["force_bnd_nom"][std], self.d["pce_wr_crn"][std], # 此时仍然对应nom self.d["wr_br_crn"][std] # 此时仍然对应nom ) if self.func.loc[std, "dprf_dfrcw"] >= 0: self.d.loc[std, "force_pu_wid_env_min"] = ( self.d.loc[std, "force_pu_wid_lim_min"]) self.d.loc[std, "force_pu_wid_env_max"] = ( self.d.loc[std, "force_pu_wid_lim_max"]) else: self.d.loc[std, "force_pu_wid_env_min"] = ( self.d.loc[std, "force_pu_wid_lim_max"]) self.d.loc[std, "force_pu_wid_env_max"] = ( self.d.loc[std, "force_pu_wid_lim_min"]) self.d["pce_wr_crn_env_min"] = self.d["pce_wr_crn_lim_max"] self.d["wr_br_crn_env_min"] = self.d["wr_br_crn_lim_max"] self.d["pce_wr_crn_env_max"] = self.d["pce_wr_crn_lim_min"] self.d["wr_br_crn_env_max"] = self.d["wr_br_crn_lim_min"] # logging.info(self.d) for m in ["min", "max"]: for std in self.std_vec: self.d.loc[std, "ufd_pu_prf_env_{}".format(m)] = ( self.ufd.Prf(std, self.d["force_pu_wid_env_{}".format(m)][std], self.d["force_bnd_env_{}".format(m)][std], self.d["pce_wr_crn_env_{}".format(m)][std], self.d["wr_br_crn_env_{}".format(m)][std]) / self.fsstd.d["ex_thick"][std]) # 至此前段非空过部分结束 bckl_list = ["we", "cb"] for bckl in bckl_list: self.d["std_ex_strn_lim_{}".format(bckl)] = ( self.lpce.d["crit_bckl_lim_{}".format(bckl)]) # 计算各机架入口有效单位凸度极限范围 # 忽略带钢影响系数小于0的情况(pce_infl_cof<pce_infl_cof_mn)直接计算 # 后期用cLRGD::Ef_En_PU_Prf1(..)替换这个计算过程 for std in self.std_vec: self.d.loc[std - 1, "ef_pu_prf_lim_min"] = self.lrg.calc( std, "Ef_En_PU_Prf1")(self.d.loc[std, "ufd_pu_prf_env_min"], self.d.loc[std, "std_ex_strn_lim_we"]) self.d.loc[std - 1, "ef_pu_prf_lim_max"] = self.lrg.calc( std, "Ef_En_PU_Prf1")(self.d.loc[std, "ufd_pu_prf_env_max"], self.d.loc[std, "std_ex_strn_lim_cb"]) self.d.loc[7, "ef_pu_prf_lim_min"] = -1 self.d.loc[7, "ef_pu_prf_lim_max"] = 1 # mean指的意思是都一样的, 初始化中间坯的ef_pu_prf_env为 self.d.loc[0, "ef_pu_prf_env_min"] = self.fsstd.d["pu_prf_pass0"][1] self.d.loc[0, "ef_pu_prf_env_max"] = self.fsstd.d["pu_prf_pass0"][1] # 包络线对应的极限机架号 # pas_env_lim_min = 0 # pas_env_lim_max = 0 # ========================= 协调单位凸度包络线 ================================ loop_count = 0 std = 1 while (std >= 1) & (std <= 7): print("协调机架", std) # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # --------------- 计算各机架出口有效单位凸度包络线下限 ------------------- # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! move_prv_min = False # 注意入口有效单位凸度包络线为上道次有效单位凸度包络线 self.d.loc[std, "ef_pu_prf_env_min"] = self.lrg.calc( std, "Ef_Ex_PU_Prf3")(self.d["ef_pu_prf_env_min"][std - 1], self.d["ufd_pu_prf_env_min"][std]) # print(self.d.loc[std, "ef_pu_prf_env_min"]) # print(self.d.loc[std, "ef_pu_prf_lim_max"]) # 若出口有效单位凸度包络线下限小于极限值下限,修正出口有效单位凸度包络线下限 if (self.d["ef_pu_prf_env_min"][std] < self.d["ef_pu_prf_lim_min"][std]): print("进行了修正min") # pas_env_lim的mathuty.max处理 # 将有效比例凸度极限的最小值作为新的目标,之后进行重新计算ufd_pu_prf ef_ex_pu_prf = self.d["ef_pu_prf_lim_min"][std] # 重新计算ufd_pu_prf # 注意入口有效单位凸度包络线为上道次有效单位凸度包络线 ufd_pu_prf = self.lrg.calc(std, "UFD_PU_Prf3")( self.d["ef_pu_prf_env_min"][std - 1], ef_ex_pu_prf) # ufd状态异常,对>force_pu_wid_lim做偏移量为10的修正,在这里忽略 # 从force_chg_clmp判定的条件分支开始 istd_ex_pu_prf = self.lrg.calc(std, "Istd_Ex_PU_Prf0")( self.d["std_ex_strn_lim_we"][std], ef_ex_pu_prf) ef_en_pu_prf = self.lrg.calc(std, "Ef_En_PU_Prf5")( self.d["std_ex_strn_lim_we"][std], istd_ex_pu_prf) # 利用上一道次的ef_pu_prf_env来Clamp获得ef_en_pu_prf_buf # (注意是否要提前定义这个ef_en_pu_prf_buf) ef_en_pu_prf_buf = mathuty.Clamp( ef_en_pu_prf, self.d["ef_pu_prf_env_min"][std - 1], self.d["ef_pu_prf_env_max"][std - 1]) # 更新move_prv标记 move_prv_min = ( (ef_en_pu_prf_buf != self.d["ef_pu_prf_env_min"][std - 1]) & (self.d["ef_pu_prf_env_min"][std - 1] != self.d["ef_pu_prf_env_max"][std - 1])) # 更新上一道次或入口有效单位凸度极限的最小值,注意是极限 self.d.loc[std - 1, "ef_pu_prf_lim_min"] = ef_en_pu_prf_buf # 如果不能前移,则将入口有效包络线的下限赋值给ef_en_pu_prf_buf if not move_prv_min: ef_en_pu_prf_buf = self.d["ef_pu_prf_env_min"][std - 1] # --- force_chg_clmp判定的条件分支结束 --- # 输出后计算ufd单位凸度 ufd_pu_prf = self.lrg.calc(std, "UFD_PU_Prf3")(ef_en_pu_prf_buf, ef_ex_pu_prf) # 之后是窜辊和弯辊力介入调整计算辊系凸度 # 注意pce_wr_crn和wr_br_crn为两个变化中的状态量 tmp = self.ufd.Crns(std, ufd_pu_prf * self.fsstd.d["ex_thick"][std], self.d["force_pu_wid_env_min"][std], self.d["force_bnd_env_min"][std], self.d["pce_wr_crn"][std], self.d["wr_br_crn"][std]) self.d.loc[std, "pce_wr_crn"] = tmp[0] self.d.loc[std, "wr_br_crn"] = tmp[1] # 窜辊位置包络线下限更新 self.d.loc[std, "pos_shft_env_min"] = self.crlc.Shft_Pos( std, self.d["pce_wr_crn"][std], self.fsstd.lim["wr_shft_lim_min"][std], self.fsstd.lim["wr_shft_lim_max"][std], self.d["pos_shft_env_min"][std]) # 根据上面的窜辊位置重计算更新综合辊系凸度 tmp = self.crlc.Crns(std, self.d["pos_shft_env_min"][std]) self.d.loc[std, "pce_wr_crn_env_min"] = tmp[0] self.d.loc[std, "wr_br_crn_env_min"] = tmp[1] # 用ufd.Pce_WR_Crn(..)计算pce_wr_crn self.d.loc[std, "pce_wr_crn"] = self.ufd.Pce_WR_Crn( std, ufd_pu_prf * self.fsstd.d["ex_thick"][std], self.d["force_pu_wid_env_min"][std], self.d["force_bnd_env_min"][std], self.d["wr_br_crn_env_min"][std]) # Re-calculate the following composite roll stack crown # 再次更新计算pce_wr_crn和wr_br_crn之后才能更新计算弯辊力下限 tmp = self.crlc.Crns(std, self.d["pos_shft_env_min"][std]) self.d.loc[std, "pce_wr_crn_env_min"] = tmp[0] self.d.loc[std, "wr_br_crn_env_min"] = tmp[1] # 更新弯辊力包络线的下限 tmp = self.ufd.Bnd_Frc( std, ufd_pu_prf * self.fsstd.d["ex_thick"][std], self.d["force_pu_wid_env_min"][std], self.d["pce_wr_crn_env_min"][std], self.d["wr_br_crn_env_min"][std], self.fsstd.lim["force_bnd_lim_min"][std], self.fsstd.lim["force_bnd_lim_max"][std]) self.d.loc[std, "force_bnd_env_min"] = tmp[0] force_bnd_des = tmp[1] # 弯辊力计算值和原值是否相等的指示器 force_bnd_clmp = (force_bnd_des != self.d["force_bnd_env_min"][std]) # 计算均载辊缝单位凸度包络线下限 self.d.loc[std, "ufd_pu_prf_env_min"] = ( self.ufd.Prf(std, self.d["force_pu_wid_env_min"][std], self.d["force_bnd_env_min"][std], self.d["pce_wr_crn_env_min"][std], self.d["wr_br_crn_env_min"][std]) / self.fsstd.d["ex_thick"][std]) # force_bnd_clmp判断以及处理有效单位凸度,忽略了带钢影响系数的判断 if force_bnd_clmp: force_bnd_clmp = False ef_en_pu_prf = self.lrg.calc(std, "Ef_En_PU_Prf3")( self.d["ufd_pu_prf_env_min"][std], ef_ex_pu_prf) # 对入口有效单位凸度进行限幅 ef_en_pu_prf_buf = mathuty.Clamp( ef_en_pu_prf, self.d["ef_pu_prf_env_min"][std - 1], self.d["ef_pu_prf_env_max"][std - 1]) # move_prv指示器更新 move_prv_min = move_prv_min | ( (ef_en_pu_prf_buf != self.d["ef_pu_prf_lim_min"][std - 1]) & (self.d["ef_pu_prf_env_min"][std - 1] != self.d["ef_pu_prf_env_max"][std - 1])) self.d.loc[std - 1, "ef_pu_prf_lim_min"] = ef_en_pu_prf_buf # ---------------------------------------------------- # ----------------- 浪形失稳条件判断 ----------------- # ---------------------------------------------------- if not move_prv_min: std_ex_strn = self.lrg.calc( std, "Std_Ex_Strn1")(self.d["ef_pu_prf_env_min"][std - 1], self.d["ufd_pu_prf_env_min"][std]) # std_ex_strn低于出口应变差中浪极限 # 被 1 < 0 掐掉 # std_ex_strn高于出口应变差边浪极限 # 被 1 < 0 掐掉 # ++++++++++++++++ 最终计算有效单位凸度下限(算是更新) +++++++++++++++++++ self.d.loc[std, "ef_pu_prf_env_min"] = self.lrg.calc( std, "Ef_Ex_PU_Prf3")(self.d["ef_pu_prf_env_min"][std - 1], self.d["ufd_pu_prf_env_min"][std]) # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # --------------- 计算各机架出口有效单位凸度包络线上限 ------------------- # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # 注意入口有效单位凸度包络线为上道次有效单位凸度包络线 move_prv_max = False # 注意入口有效单位凸度包络线为上道次有效单位凸度包络线 self.d.loc[std, "ef_pu_prf_env_max"] = self.lrg.calc( std, "Ef_Ex_PU_Prf3")(self.d["ef_pu_prf_env_max"][std - 1], self.d["ufd_pu_prf_env_max"][std]) # print(self.d.loc[std, "ef_pu_prf_env_max"]) # print(self.d.loc[std, "ef_pu_prf_lim_max"]) # 若出口有效单位凸度包络线下限小于极限值下限,修正出口有效单位凸度包络线下限 if (self.d["ef_pu_prf_env_max"][std] > self.d["ef_pu_prf_lim_max"][std]): print("进行了修正max") # pas_env_lim的mathuty.max处理 # 将有效比例凸度极限的最小值作为新的目标,之后进行重新计算ufd_pu_prf ef_ex_pu_prf = self.d["ef_pu_prf_lim_max"][std] # 重新计算ufd_pu_prf # 注意入口有效单位凸度包络线为上道次有效单位凸度包络线 ufd_pu_prf = self.lrg.calc(std, "UFD_PU_Prf3")( self.d["ef_pu_prf_env_max"][std - 1], ef_ex_pu_prf) # ufd状态异常,对>force_pu_wid_lim做偏移量为10的修正,在这里忽略 # 从force_chg_clmp判定的条件分支开始 istd_ex_pu_prf = self.lrg.calc(std, "Istd_Ex_PU_Prf0")( self.d["std_ex_strn_lim_cb"][std], ef_ex_pu_prf) ef_en_pu_prf = self.lrg.calc(std, "Ef_En_PU_Prf5")( self.d["std_ex_strn_lim_cb"][std], istd_ex_pu_prf) # 利用上一道次的ef_pu_prf_env来Clamp获得ef_en_pu_prf_buf # (注意是否要提前定义这个ef_en_pu_prf_buf) ef_en_pu_prf_buf = mathuty.Clamp( ef_en_pu_prf, self.d["ef_pu_prf_env_max"][std - 1], self.d["ef_pu_prf_env_max"][std - 1]) # 更新move_prv标记 move_prv_max = ( (ef_en_pu_prf_buf != self.d["ef_pu_prf_env_max"][std - 1]) & (self.d["ef_pu_prf_env_max"][std - 1] != self.d["ef_pu_prf_env_max"][std - 1])) # 更新上一道次或入口有效单位凸度极限的最小值,注意是极限 self.d.loc[std - 1, "ef_pu_prf_lim_max"] = ef_en_pu_prf_buf # 如果不能前移,则将入口有效包络线的下限赋值给ef_en_pu_prf_buf if not move_prv_max: ef_en_pu_prf_buf = self.d["ef_pu_prf_env_max"][std - 1] # --- force_chg_clmp判定的条件分支结束 --- # 输出后计算ufd单位凸度 ufd_pu_prf = self.lrg.calc(std, "UFD_PU_Prf3")(ef_en_pu_prf_buf, ef_ex_pu_prf) # 之后是窜辊和弯辊力介入调整计算辊系凸度 # 注意pce_wr_crn和wr_br_crn为两个变化中的状态量 tmp = self.ufd.Crns(std, ufd_pu_prf * self.fsstd.d["ex_thick"][std], self.d["force_pu_wid_env_max"][std], self.d["force_bnd_env_max"][std], self.d["pce_wr_crn"][std], self.d["wr_br_crn"][std]) self.d.loc[std, "pce_wr_crn"] = tmp[0] self.d.loc[std, "wr_br_crn"] = tmp[1] # 窜辊位置包络线下限更新 self.d.loc[std, "pos_shft_env_max"] = self.crlc.Shft_Pos( std, self.d["pce_wr_crn"][std], self.fsstd.lim["wr_shft_lim_min"][std], self.fsstd.lim["wr_shft_lim_max"][std], self.d["pos_shft_env_max"][std]) # 根据上面的窜辊位置重计算更新综合辊系凸度 tmp = self.crlc.Crns(std, self.d["pos_shft_env_max"][std]) self.d.loc[std, "pce_wr_crn_env_max"] = tmp[0] self.d.loc[std, "wr_br_crn_env_max"] = tmp[1] # 用ufd.Pce_WR_Crn(..)计算pce_wr_crn self.d.loc[std, "pce_wr_crn"] = self.ufd.Pce_WR_Crn( std, ufd_pu_prf * self.fsstd.d["ex_thick"][std], self.d["force_pu_wid_env_max"][std], self.d["force_bnd_env_max"][std], self.d["wr_br_crn_env_max"][std]) # Re-calculate the following composite roll stack crown # 再次更新计算pce_wr_crn和wr_br_crn之后才能更新计算弯辊力下限 tmp = self.crlc.Crns(std, self.d["pos_shft_env_max"][std]) self.d.loc[std, "pce_wr_crn_env_max"] = tmp[0] self.d.loc[std, "wr_br_crn_env_max"] = tmp[1] # 更新弯辊力包络线的下限 tmp = self.ufd.Bnd_Frc( std, ufd_pu_prf * self.fsstd.d["ex_thick"][std], self.d["force_pu_wid_env_max"][std], self.d["pce_wr_crn_env_max"][std], self.d["wr_br_crn_env_max"][std], self.fsstd.lim["force_bnd_lim_min"][std], self.fsstd.lim["force_bnd_lim_max"][std]) self.d.loc[std, "force_bnd_env_max"] = tmp[0] force_bnd_des = tmp[1] # 弯辊力计算值和原值是否相等的指示器 force_bnd_clmp = (force_bnd_des != self.d["force_bnd_env_max"][std]) # 计算均载辊缝单位凸度包络线下限 self.d.loc[std, "ufd_pu_prf_env_max"] = ( self.ufd.Prf(std, self.d["force_pu_wid_env_max"][std], self.d["force_bnd_env_max"][std], self.d["pce_wr_crn_env_max"][std], self.d["wr_br_crn_env_max"][std]) / self.fsstd.d["ex_thick"][std]) # force_bnd_clmp判断以及处理有效单位凸度,忽略了带钢影响系数的判断 if force_bnd_clmp: force_bnd_clmp = False ef_en_pu_prf = self.lrg.calc(std, "Ef_En_PU_Prf3")( self.d["ufd_pu_prf_env_max"][std], ef_ex_pu_prf, ef_en_pu_prf) # 对入口有效单位凸度进行限幅 ef_en_pu_prf_buf = mathuty.Clamp( ef_en_pu_prf, self.d["ef_pu_prf_env_max"][std - 1], self.d["ef_pu_prf_env_max"][std - 1]) # move_prv指示器更新 move_prv_max = move_prv_max | ( (ef_en_pu_prf_buf != self.d["ef_pu_prf_lim_max"][std - 1]) & (self.d["ef_pu_prf_env_max"][std - 1] != self.d["ef_pu_prf_env_max"][std - 1])) self.d.loc[std - 1, "ef_pu_prf_lim_max"] = ef_en_pu_prf_buf # ---------------------------------------------------- # ----------------- 浪形失稳条件判断 ----------------- # ---------------------------------------------------- if not move_prv_max: std_ex_strn = self.lrg.calc( std, "Std_Ex_Strn1")(self.d["ef_pu_prf_env_max"][std - 1], self.d["ufd_pu_prf_env_max"][std]) # std_ex_strn低于出口应变差中浪极限 # 被 1 < 0 掐掉 # std_ex_strn高于出口应变差边浪极限 # 被 1 < 0 掐掉 # ++++++++++++++++ 最终计算有效单位凸度下限(算是更新) +++++++++++++++++++ self.d.loc[std, "ef_pu_prf_env_max"] = self.lrg.calc( std, "Ef_Ex_PU_Prf3")(self.d["ef_pu_prf_env_max"][std - 1], self.d["ufd_pu_prf_env_max"][std]) # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # ------------------------ 每个循环周期末的迭代处理 ---------------------- # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if move_prv_min | move_prv_max: loop_count = loop_count + 1 if loop_count > pow(self.pass_vec[-1] - 1, 2): if 7 == std: break else: std = std + 1 else: std = std - 1 else: if 7 == std: break else: std = std + 1 # 结束--计算各机架出口有效单位凸度包络线下限和上限,在循环中进行 # loop_count计数器 超出极限的监控 if loop_count > pow(self.pass_vec[-1] - 2, 2): print("loop counter exceeded limit") logging.info("loop counter exceeded limit") # =============== 最后一波计算以及检查确认工作 =================== std = 1 while std > 0: mxx_list = ["max", "min"] for m__ in mxx_list: self.d.loc[std, "ufd_pu_prf_env_{}".format(m__)] = ( self.ufd.Prf( std, self.d["force_pu_wid_env_{}".format(m__)][std], self.d["force_bnd_env_{}".format(m__)][std], self.d["pce_wr_crn_env_{}".format(m__)][std], self.d["wr_br_crn_env_{}".format(m__)][std]) / self.fsstd.d["ex_thick"][std]) self.d.loc[std, "ef_pu_prf_env_{}".format(m__)] = ( self.lrg.calc(std, "Ef_Ex_PU_Prf3")( self.d["ef_pu_prf_env_{}".format(m__)][std - 1], self.d["ufd_pu_prf_env_{}".format(m__)][std])) std_ex_strn = self.lrg.calc(std, "Std_Ex_Strn1")( self.d["ef_pu_prf_env_{}".format(m__)][std], self.d["ufd_pu_prf_env_{}".format(m__)][std]) # 计算比例凸度包络线上下限 self.d.loc[std, "pu_prf_env_{}".format(m__)] = (self.lrg.calc( std, "Istd_Ex_PU_Prf0")( std_ex_strn, self.d["ef_pu_prf_env_{}".format(m__)][std])) # 检查确认 parameter_list = [ "pu_prf_env", "ef_pu_prf_env", "ufd_pu_prf_env", "force_pu_wid_env" ] for para in parameter_list: scratch = max(self.d["{}_min".format(para)][std], self.d["{}_max".format(para)][std]) self.d["{}_min".format(para)][std] = min( self.d["{}_min".format(para)][std], self.d["{}_max".format(para)][std]) self.d["{}_max".format(para)][std] = scratch # 迭代计数器处理 if 7 == std: break else: std = std + 1
def Shft_Pos(self, std, pce_wr_cr_req, pos_shft_lim_buf_min, pos_shft_lim_buf_max, pos_shft_org): print("now in Shft_Pos(..) std{}".format(std)) # 注意这里的wr_grn_cr为单辊 wr_grn_cr = self.wr_grn_crn_single(std, pos_shft_org) # pce_wr_cr局部变量为前一卷带钢的带钢-工作辊辊系凸度值 # 修改 # pce_wr_cr = self.fsstd.d["pce_wr_crn_org"][std] pce_wr_cr, wr_br_cr = self.Crns(std, self.fsstd.d["wr_shft_last"][std]) # 因为这里的凸度为轧辊的凸度,所以负向为带钢的正向, # 所以dlt仍为负值,说明带钢凸度朝着增大的方向,窜辊负移 # 如果dlt仍为正值,说明带钢凸度朝着减小的方向,窜辊正移 pce_wr_cr_dlt = pce_wr_cr_req - pce_wr_cr wr_grn_cr_req = wr_grn_cr + (pce_wr_cr_dlt / 2) pos_shft = ((wr_grn_cr_req - ( (self.d["cvc_crn_wid_min"][std] + self.d["cvc_crn_wid_max"][std]) / 2)) * 2 * self.cvc_Sm) / (self.d["cvc_crn_wid_max"][std] - self.d["cvc_crn_wid_min"][std]) print("pos_shft by wr_grn_cr_req") print(pos_shft) pos_shft = mathuty.Clamp(pos_shft, pos_shft_lim_buf_min, pos_shft_lim_buf_max) print("pos_shft by wr_grn_cr_req with clamp") print(pos_shft) pce_wr_cr_buf1, wr_br_cr_buf1 = self.Crns(std, pos_shft) print("first pce_wr_cr_buf1") print(pce_wr_cr_buf1) # pos_shft_lim和pos_shft_lim_buf不是一个东西 # pos_shft_lim的意义是当你窜辊窜动方向确定下来后的极限约束 # 接下来为pos_shft_lim的赋值计算 if pce_wr_cr_dlt > 0: pos_shft_lim_min = pos_shft_org pos_shft_lim_max = pos_shft_lim_buf_max else: pos_shft_lim_min = pos_shft_lim_buf_min pos_shft_lim_max = pos_shft_org # 窜辊位置限幅标志位设定 # 正常情况下软极限空间足够的话,pce_wr_cr_buf1要等于pce_wr_cr_req # pce_wr_cr_buf1大于pce_wr_cr_req说明被正向限幅了,反之亦然 # 这里的语句意思是是再把pos_shft_lim范围缩小一点 # pos_shft_clmp_min指的是吧pos_shft_lim的下限约束了一下 if pce_wr_cr_buf1 > pce_wr_cr_req: pos_shft_lim_max = pos_shft pos_shft_clmp_max = True pos_shft_clmp_min = False else: pos_shft_lim_min = pos_shft pos_shft_clmp_min = True pos_shft_clmp_max = False # --- 迭代计算 --- status = "nonconvgnt" iter_mx = 15 pce_wr_cr_tol = 0.0000001 for i in range(1, iter_mx + 1): pos_shft_dlt = 2 if (pos_shft + pos_shft_dlt) > pos_shft_lim_buf_max: pos_shft_dlt = -pos_shft_dlt pce_wr_cr_buf2, wr_br_cr_buf2 = self.Crns(std, pos_shft + pos_shft_dlt) if (((pos_shft_dlt >= 0) & (pce_wr_cr_buf2 <= pce_wr_cr_buf1)) | ((pos_shft_dlt < 0) & (pce_wr_cr_buf2 >= pce_wr_cr_buf1))): if pce_wr_cr_req > pce_wr_cr_buf1: pos_shft = pos_shft + pos_shft_dlt # pos_shft = pos_shft + 2 else: pos_shft = pos_shft - pos_shft_dlt # pos_shft = pos_shft - 2 else: pos_shft = (pos_shft + (pce_wr_cr_req - pce_wr_cr_buf1) * pos_shft_dlt / (pce_wr_cr_buf2 - pce_wr_cr_buf1)) if ((pos_shft_clmp_min & (pos_shft >= pos_shft_lim_max)) | (pos_shft_clmp_max & (pos_shft <= pos_shft_lim_min))): pos_shft = (pos_shft_lim_min + pos_shft_lim_max) / 2 pos_shft_clmp_min = False pos_shft_clmp_max = False if pos_shft < pos_shft_lim_min: pos_shft = pos_shft_lim_min pos_shft_clmp_min = True if pos_shft > pos_shft_lim_max: pos_shft = pos_shft_lim_max pos_shft_clmp_max = True pce_wr_cr_buf1, wr_br_cr_buf = self.Crns(std, pos_shft) print("iter", i, pce_wr_cr_buf1) # 确认是否达到收敛精度 if (abs(pce_wr_cr_req - pce_wr_cr_buf1) <= pce_wr_cr_tol): status = "valid" break if (pce_wr_cr_buf1 > pce_wr_cr_req): if pos_shft_clmp_min: status = "outofbounds pce_wr_cr_buf1 > pce_wr_cr_req" break else: pos_shft_lim_max = pos_shft else: if pos_shft_clmp_max: status = "outofbounds pce_wr_cr_buf1 < pce_wr_cr_req" break else: pos_shft_lim_min = pos_shft pos_shft = mathuty.Clamp(pos_shft, pos_shft_lim_min, pos_shft_lim_max) pce_wr_cr_buf1, wr_br_cr_buf = self.Crns(std, pos_shft) print(status) return pos_shft