pKaTool/pKa_system_file_menu.py
def fit(self, silent=0):
        """Do 10000 rounds of fitting, or until converged"""
        #
        # Set damper
        #
        self.LM_damper = DoubleVar()
        self.LM_damper.set(0.1)
        #
        # Open the window
        #
        if not silent == 1:
            self.count_win=Toplevel()
            self.count_win.geometry('100x100+200+200')
            self.count_win.title('Fit in progress')
            self.count=IntVar()
            self.count.set(0)
            Label(self.count_win,text='Iteration #').grid(row=0,column=0)
            Label(self.count_win,textvariable=self.count).grid(row=0,column=1)
            #
            # Keep track of number of pKa calcs
            #
            self.pka_count=IntVar()
            self.pka_count.set(0)
            Label(self.count_win,text='pKa calc #').grid(row=1,column=0)
            Label(self.count_win,textvariable=self.pka_count).grid(row=1,column=1)
            #
            Button(self.count_win,text='Stop fit',command=self.stop_fit).grid(row=2,column=0,columnspan=2)
            self.count_win.update_idletasks()
        self.keep_running=1
        #
        # Make copies of all the variables
        #
        self.vars=[]
        for group in self.groups:
            self.vars.append(self.groups[group].intpka)
            for group2 in self.groups[group].intenes.keys():
                self.vars.append(self.groups[group].intenes[group2])
        #
        # Set up the loaded curves
        #
        self.exp_data=titration_curve(self.titration_data)
        #
        # Start iterating
        #
        old_diff=0.0
        status = 'MI'
        if not silent == 1:
            print 'Step    Diff   LM_damper'
        for x in range(1,1000):#1000

            if not self.keep_running:
                break
            self.fit_LM(silent=silent)
            #
            # Update more stuff
            #
            if not silent==1:
                self.count.set(self.count.get()+1)
                self.count_win.update()
            self.update_scales_from_fit()
            self.titwin.update()
            #self.master.update_idletasks()
            now_diff=self.eval(silent=silent)-self.exp_data
            #
            # Check convergence
            #
            if not silent == 1:
                print '%5d  %6.4f  %6.4f' %(x, now_diff, self.LM_damper.get())

            if abs(now_diff-old_diff)<0.00005:
                status = 'C'
                if not silent == 1:
                    print 'Converged',now_diff
                break
            else:
                old_diff=now_diff


        if not silent==1:
            self.count_win.destroy()
        self.update_pkasystem_curves()
        return status
Do 10000 rounds of fitting, or until converged
Do 10000 rounds of fitting, or until converged
Do 10000 rounds of fitting or until converged
def fit(self, silent=0):
         Set damper
        self.LM_damper = DoubleVar()
        self.LM_damper.set(0.1)
         Open the window
        if not silent == 1:
            self.count_win=Toplevel()
            self.count_win.geometry('100x100+200+200')
            self.count_win.title('Fit in progress')
            self.count=IntVar()
            self.count.set(0)
            Label(self.count_win,text='Iteration ').grid(row=0,column=0)
            Label(self.count_win,textvariable=self.count).grid(row=0,column=1)
             Keep track of number of pKa calcs
            self.pka_count=IntVar()
            self.pka_count.set(0)
            Label(self.count_win,text='pKa calc ').grid(row=1,column=0)
            Label(self.count_win,textvariable=self.pka_count).grid(row=1,column=1)
            Button(self.count_win,text='Stop fit',command=self.stop_fit).grid(row=2,column=0,columnspan=2)
            self.count_win.update_idletasks()
        self.keep_running=1
         Make copies of all the variables
        self.vars=[]
        for group in self.groups:
            self.vars.append(self.groups[group].intpka)
            for group2 in self.groups[group].intenes.keys():
                self.vars.append(self.groups[group].intenes[group2])
         Set up the loaded curves
        self.exp_data=titration_curve(self.titration_data)
         Start iterating
        old_diff=0.0
        status = 'MI'
        if not silent == 1:
            print 'Step    Diff   LM_damper'
        for x in range(1,1000):1000
            if not self.keep_running:
                break
            self.fit_LM(silent=silent)
             Update more stuff
            if not silent==1:
                self.count.set(self.count.get()+1)
                self.count_win.update()
            self.update_scales_from_fit()
            self.titwin.update()
            self.master.update_idletasks()
            now_diff=self.eval(silent=silent)-self.exp_data
             Check convergence
            if not silent == 1:
                print '%5d  %6.4f  %6.4f' %(x, now_diff, self.LM_damper.get())
            if abs(now_diff-old_diff)<0.00005:
                status = 'C'
                if not silent == 1:
                    print 'Converged',now_diff
                break
            else:
                old_diff=now_diff
        if not silent==1:
            self.count_win.destroy()
        self.update_pkasystem_curves()
        return status
def fit ( self , silent = 0 ) : self . LM_damper = DoubleVar ( ) self . LM_damper . set ( 0.1 ) if not silent == 1 : self . count_win = Toplevel ( ) self . count_win . geometry ( '100x100+200+200' ) self . count_win . title ( 'Fit in progress' ) self . count = IntVar ( ) self . count . set ( 0 ) Label ( self . count_win , text = 'Iteration #' ) . grid ( row = 0 , column = 0 ) Label ( self . count_win , textvariable = self . count ) . grid ( row = 0 , column = 1 ) self . pka_count = IntVar ( ) self . pka_count . set ( 0 ) Label ( self . count_win , text = 'pKa calc #' ) . grid ( row = 1 , column = 0 ) Label ( self . count_win , textvariable = self . pka_count ) . grid ( row = 1 , column = 1 ) Button ( self . count_win , text = 'Stop fit' , command = self . stop_fit ) . grid ( row = 2 , column = 0 , columnspan = 2 ) self . count_win . update_idletasks ( ) self . keep_running = 1 self . vars = [ ] for group in self . groups : self . vars . append ( self . groups [ group ] . intpka ) for group2 in self . groups [ group ] . intenes . keys ( ) : self . vars . append ( self . groups [ group ] . intenes [ group2 ] ) self . exp_data = titration_curve ( self . titration_data ) old_diff = 0.0 status = 'MI' if not silent == 1 : print 'Step    Diff   LM_damper' for x in range ( 1 , 1000 ) : if not self . keep_running : break self . fit_LM ( silent = silent ) if not silent == 1 : self . count . set ( self . count . get ( ) + 1 ) self . count_win . update ( ) self . update_scales_from_fit ( ) self . titwin . update ( ) now_diff = self . eval ( silent = silent ) - self . exp_data if not silent == 1 : print '%5d  %6.4f  %6.4f' % ( x , now_diff , self . LM_damper . get ( ) ) if abs ( now_diff - old_diff ) < 0.00005 : status = 'C' if not silent == 1 : print 'Converged' , now_diff break else : old_diff = now_diff if not silent == 1 : self . count_win . destroy ( ) self . update_pkasystem_curves ( ) return status
Do 10000 rounds of fitting, or until converged
Do 10000 rounds of fitting or until converged
"""Do 10000 rounds of fitting, or until converged""" # # Set damper # # # Open the window # # # Keep track of number of pKa calcs # # # # Make copies of all the variables # # # Set up the loaded curves # # # Start iterating # #1000 # # Update more stuff # #self.master.update_idletasks() # # Check convergence #
self
silent