pKaTool/pKa_system_micro.py
def determine_pkhalf(self,charges,acid_base):
        """from a list of [pH,charge] determine two pKa values that define the population"""
        import copy
        #
        # First find out if there are one or two pKa values
        #
        pkas=self.determine_pkhalf_simple(charges,acid_base)
        if len(pkas)==2:
            #
            # Function for two pKa values
            #
            self.funktion="(1.0/(math.pow(10,-pH)/math.pow(10,-pKa1)+1+math.pow(10,-pKa2)/math.pow(10,-pH)))"
            self.funktion=self.funktion.replace('pKa1','self.pkvars[0][1]')
            self.funktion=self.funktion.replace('pKa2','self.pkvars[1][1]')
            self.pkvars=[[4.0,4.0],[6.0,6.0]]
        else:
            if charges[0][1]>0.2:
                
                self.funktion="(1.0-(1.0/(1.0+math.pow(10,pKa1-pH))))"
            else:
                self.funktion="(1.0/(1.0+math.pow(10,pKa1-pH)))"
            self.funktion=self.funktion.replace('pKa1','self.pkvars[0][1]')
            self.pkvars=[[4.0,4.0]]
        #
        # Fit the function
        #
        old_diff=10000
        for x in range(200):
            self.fit_LM_micro(charges)
            #
            # Check convergence
            # 
            now_diff=self.calc_sq_diff_micro(charges)
            if (abs(now_diff-old_diff)/old_diff)<0.0001:
                break
            else:
                old_diff=now_diff
        #
        # Compile the results
        #
        rets=[]
        for pka in self.pkvars:
            rets.append(pka[1])

        return rets
from a list of [pH,charge] determine two pKa values that define the population
from a list of [pH,charge] determine two pKa values that define the population
from a list of [ pH charge ] determine two pKa values that define the population
def determine_pkhalf(self,charges,acid_base):
        import copy
         First find out if there are one or two pKa values
        pkas=self.determine_pkhalf_simple(charges,acid_base)
        if len(pkas)==2:
             Function for two pKa values
            self.funktion="(1.0/(math.pow(10,-pH)/math.pow(10,-pKa1)+1+math.pow(10,-pKa2)/math.pow(10,-pH)))"
            self.funktion=self.funktion.replace('pKa1','self.pkvars[0][1]')
            self.funktion=self.funktion.replace('pKa2','self.pkvars[1][1]')
            self.pkvars=[[4.0,4.0],[6.0,6.0]]
        else:
            if charges[0][1]>0.2:
                self.funktion="(1.0-(1.0/(1.0+math.pow(10,pKa1-pH))))"
            else:
                self.funktion="(1.0/(1.0+math.pow(10,pKa1-pH)))"
            self.funktion=self.funktion.replace('pKa1','self.pkvars[0][1]')
            self.pkvars=[[4.0,4.0]]
         Fit the function
        old_diff=10000
        for x in range(200):
            self.fit_LM_micro(charges)
             Check convergence
            now_diff=self.calc_sq_diff_micro(charges)
            if (abs(now_diff-old_diff)/old_diff)<0.0001:
                break
            else:
                old_diff=now_diff
         Compile the results
        rets=[]
        for pka in self.pkvars:
            rets.append(pka[1])
        return rets
def determine_pkhalf ( self , charges , acid_base ) : import copy pkas = self . determine_pkhalf_simple ( charges , acid_base ) if len ( pkas ) == 2 : self . funktion = "(1.0/(math.pow(10,-pH)/math.pow(10,-pKa1)+1+math.pow(10,-pKa2)/math.pow(10,-pH)))" self . funktion = self . funktion . replace ( 'pKa1' , 'self.pkvars[0][1]' ) self . funktion = self . funktion . replace ( 'pKa2' , 'self.pkvars[1][1]' ) self . pkvars = [ [ 4.0 , 4.0 ] , [ 6.0 , 6.0 ] ] else : if charges [ 0 ] [ 1 ] > 0.2 : self . funktion = "(1.0-(1.0/(1.0+math.pow(10,pKa1-pH))))" else : self . funktion = "(1.0/(1.0+math.pow(10,pKa1-pH)))" self . funktion = self . funktion . replace ( 'pKa1' , 'self.pkvars[0][1]' ) self . pkvars = [ [ 4.0 , 4.0 ] ] old_diff = 10000 for x in range ( 200 ) : self . fit_LM_micro ( charges ) now_diff = self . calc_sq_diff_micro ( charges ) if ( abs ( now_diff - old_diff ) / old_diff ) < 0.0001 : break else : old_diff = now_diff rets = [ ] for pka in self . pkvars : rets . append ( pka [ 1 ] ) return rets
from a list of [pH,charge] determine two pKa values that define the population
from a list of [ pH charge ] determine two pKa values that define the population
"""from a list of [pH,charge] determine two pKa values that define the population""" # # First find out if there are one or two pKa values # # # Function for two pKa values # # # Fit the function # # # Check convergence #  # # Compile the results #
self
charges
acid_base