Kc_Kt_moduli.py
def tilt_modulus( leaflet, angles_in_radians, status, nbins=100,  Plot=True):
    """ 
    It will first fit a gaussian y=A exp[(x-mu)/sigma^2] to the distribution of tilts 
    to determine the fitting range then used to fit the corresponding potential of mean force (PMF).
    Different fitting ranges are used to estimate the error on the extracted tilt modulus.
    The function will calculate one tilt modulus for each lipid species and one splay modulus for each pair
    of lipid species. It will then combine these to calculate the overall tilt modulus and splay modulus (bending rigidity).
    More details about this procedure can be found in ref. [2]_ 
    """
    
    
    """ set the angles in range [0,90] degrees """
    angles_in_degree = np.degrees(angles_in_radians)   #all_tilts[disordered_indx]
    angles_first_quadrant = np.array([first_quadrant(x) for x in angles_in_degree])

    
    """ compute the distribution of tilt angles using an histogram """    
    histo, bins = np.histogram(np.radians(angles_first_quadrant), bins= nbins , density=True) #bins=len(angles_first_quadrant)
    bincenters = 0.5 * (bins[1:] + bins[:-1])
    
    if status == "disordered":
        cutoff = 30
        g_range_sa = np.where(bincenters < np.radians(cutoff))[0]
        A, mu, sigma = _FitGaussian(bincenters[g_range_sa], histo[g_range_sa])
        
    else: 
        cutoff = 30
        g_range_sa = np.where(bincenters < np.radians(cutoff))[0]
        A, mu, sigma = _FitGaussian(bincenters[g_range_sa], histo[g_range_sa])
        #plt.plot(bincenters_Lo, _gauss(bincenters_Lo, Ao, muo, sigmao ))
        
    y=np.sin(bincenters)
    Area=trapz(y, bincenters)
    sin_normalized=y/Area
    #plt.plot(bincenters_Ld, sin_normalized)    
    """ normlize the probability with the sin(theta) """
    pa2 = histo / sin_normalized  
    """ PMF in KbT units """
    PMF = -np.log(pa2)
    #plt.plot(bincenters, PMF)


    ranges = [ (max(mu - i * sigma, 0), mu + i * sigma) 
                  for i in [ 1, 1.25, 1.5, 1.75, 2.0]] 
    
    print ("Using the following ranges to fit the PMF:", ranges)
    res_list = [_FitParabole(bincenters, PMF, fitting_range)
                    for fitting_range in ranges]

    K_list = [(2. * r[1]) for r in res_list]
    DeltaK = np.std(K_list)
    K = K_list[0]
    
    
    if Plot: 
        fig, ax = plt.subplots(3, 1, sharex=True, sharey=False)
        fig.subplots_adjust(hspace=0.05, wspace=0.05)
        ax[0].fill_between(bincenters, _gauss(bincenters,A, mu, sigma), alpha=0.5)
        ax[0].plot(bincenters, histo)  
        xcoords = [mu - sigma, mu, mu + sigma]
        for xc in xcoords:
            ax[0].axvline(x=xc, linestyle='--')
    #ax[0].plot(X_plot[:, 0], _gauss(bincenters,A_test2, mu_test2, test_sigma2 ),'-')
        ax[1].plot(bincenters, pa2,'-')
        ax[2].plot(bincenters, PMF,'-')
        ax[2].plot(bincenters, _parabole(bincenters, res_list[0][0],res_list[0][1], res_list[0][2] ), 'g--', label =r'$k_t$ = %3.1f $\pm$  %3.1f [$k_BT/ nm^2$]' %(K,DeltaK ))
        ax[2].grid('True')
        plt.xlim(0,np.pi/2)
        plt.legend()
        plt.savefig('ANALYSIS/tilts_local_normals/Tilt_modulus_'+ str(leaflet)+ '_' + str(status)+ '.png', dpi=300)
        plt.savefig('ANALYSIS/tilts_local_normals/Tilt_modulus_'+ str(leaflet)+ '_' + str(status)+ '.svg')

    return K, DeltaK, K_list
 
    It will first fit a gaussian y=A exp[(x-mu)/sigma^2] to the distribution of tilts 
    to determine the fitting range then used to fit the corresponding potential of mean force (PMF).
    Different fitting ranges are used to estimate the error on the extracted tilt modulus.
    The function will calculate one tilt modulus for each lipid species and one splay modulus for each pair
    of lipid species. It will then combine these to calculate the overall tilt modulus and splay modulus (bending rigidity).
    More details about this procedure can be found in ref. [2]_ 
    
It will first fit a gaussian y=A exp[(x-mu)/sigma^2] to the distribution of tilts
to determine the fitting range then used to fit the corresponding potential of mean force (PMF).
Different fitting ranges are used to estimate the error on the extracted tilt modulus.
The function will calculate one tilt modulus for each lipid species and one splay modulus for each pair
of lipid species. It will then combine these to calculate the overall tilt modulus and splay modulus (bending rigidity).
More details about this procedure can be found in ref. [2]_
It will first fit a gaussian y = A exp [ ( x - mu ) / sigma^2 ] to the distribution of tilts to determine the fitting range then used to fit the corresponding potential of mean force ( PMF ) . Different fitting ranges are used to estimate the error on the extracted tilt modulus . The function will calculate one tilt modulus for each lipid species and one splay modulus for each pair of lipid species . It will then combine these to calculate the overall tilt modulus and splay modulus ( bending rigidity ) . More details about this procedure can be found in ref . [ 2 ] _
def tilt_modulus( leaflet, angles_in_radians, status, nbins=100,  Plot=True):
    angles_in_degree = np.degrees(angles_in_radians)   
    angles_first_quadrant = np.array([first_quadrant(x) for x in angles_in_degree])
    histo, bins = np.histogram(np.radians(angles_first_quadrant), bins= nbins , density=True) 
    bincenters = 0.5 * (bins[1:] + bins[:-1])
    if status == "disordered":
        cutoff = 30
        g_range_sa = np.where(bincenters < np.radians(cutoff))[0]
        A, mu, sigma = _FitGaussian(bincenters[g_range_sa], histo[g_range_sa])
    else: 
        cutoff = 30
        g_range_sa = np.where(bincenters < np.radians(cutoff))[0]
        A, mu, sigma = _FitGaussian(bincenters[g_range_sa], histo[g_range_sa])
    y=np.sin(bincenters)
    Area=trapz(y, bincenters)
    sin_normalized=y/Area
    pa2 = histo / sin_normalized  
    PMF = -np.log(pa2)
    ranges = [ (max(mu - i * sigma, 0), mu + i * sigma) 
                  for i in [ 1, 1.25, 1.5, 1.75, 2.0]] 
    print ("Using the following ranges to fit the PMF:", ranges)
    res_list = [_FitParabole(bincenters, PMF, fitting_range)
                    for fitting_range in ranges]
    K_list = [(2. * r[1]) for r in res_list]
    DeltaK = np.std(K_list)
    K = K_list[0]
    if Plot: 
        fig, ax = plt.subplots(3, 1, sharex=True, sharey=False)
        fig.subplots_adjust(hspace=0.05, wspace=0.05)
        ax[0].fill_between(bincenters, _gauss(bincenters,A, mu, sigma), alpha=0.5)
        ax[0].plot(bincenters, histo)  
        xcoords = [mu - sigma, mu, mu + sigma]
        for xc in xcoords:
            ax[0].axvline(x=xc, linestyle='--')
        ax[1].plot(bincenters, pa2,'-')
        ax[2].plot(bincenters, PMF,'-')
        ax[2].plot(bincenters, _parabole(bincenters, res_list[0][0],res_list[0][1], res_list[0][2] ), 'g--', label =r'$k_t$ = %3.1f $\pm$  %3.1f [$k_BT/ nm^2$]' %(K,DeltaK ))
        ax[2].grid('True')
        plt.xlim(0,np.pi/2)
        plt.legend()
        plt.savefig('ANALYSIS/tilts_local_normals/Tilt_modulus_'+ str(leaflet)+ '_' + str(status)+ '.png', dpi=300)
        plt.savefig('ANALYSIS/tilts_local_normals/Tilt_modulus_'+ str(leaflet)+ '_' + str(status)+ '.svg')
    return K, DeltaK, K_list
def tilt_modulus ( leaflet , angles_in_radians , status , nbins = 100 , Plot = True ) : """ set the angles in range [0,90] degrees """ angles_in_degree = np . degrees ( angles_in_radians ) angles_first_quadrant = np . array ( [ first_quadrant ( x ) for x in angles_in_degree ] ) """ compute the distribution of tilt angles using an histogram """ histo , bins = np . histogram ( np . radians ( angles_first_quadrant ) , bins = nbins , density = True ) bincenters = 0.5 * ( bins [ 1 : ] + bins [ : - 1 ] ) if status == "disordered" : cutoff = 30 g_range_sa = np . where ( bincenters < np . radians ( cutoff ) ) [ 0 ] A , mu , sigma = _FitGaussian ( bincenters [ g_range_sa ] , histo [ g_range_sa ] ) else : cutoff = 30 g_range_sa = np . where ( bincenters < np . radians ( cutoff ) ) [ 0 ] A , mu , sigma = _FitGaussian ( bincenters [ g_range_sa ] , histo [ g_range_sa ] ) y = np . sin ( bincenters ) Area = trapz ( y , bincenters ) sin_normalized = y / Area """ normlize the probability with the sin(theta) """ pa2 = histo / sin_normalized """ PMF in KbT units """ PMF = - np . log ( pa2 ) ranges = [ ( max ( mu - i * sigma , 0 ) , mu + i * sigma ) for i in [ 1 , 1.25 , 1.5 , 1.75 , 2.0 ] ] print ( "Using the following ranges to fit the PMF:" , ranges ) res_list = [ _FitParabole ( bincenters , PMF , fitting_range ) for fitting_range in ranges ] K_list = [ ( 2. * r [ 1 ] ) for r in res_list ] DeltaK = np . std ( K_list ) K = K_list [ 0 ] if Plot : fig , ax = plt . subplots ( 3 , 1 , sharex = True , sharey = False ) fig . subplots_adjust ( hspace = 0.05 , wspace = 0.05 ) ax [ 0 ] . fill_between ( bincenters , _gauss ( bincenters , A , mu , sigma ) , alpha = 0.5 ) ax [ 0 ] . plot ( bincenters , histo ) xcoords = [ mu - sigma , mu , mu + sigma ] for xc in xcoords : ax [ 0 ] . axvline ( x = xc , linestyle = '--' ) ax [ 1 ] . plot ( bincenters , pa2 , '-' ) ax [ 2 ] . plot ( bincenters , PMF , '-' ) ax [ 2 ] . plot ( bincenters , _parabole ( bincenters , res_list [ 0 ] [ 0 ] , res_list [ 0 ] [ 1 ] , res_list [ 0 ] [ 2 ] ) , 'g--' , label = r'$k_t$ = %3.1f $\pm$  %3.1f [$k_BT/ nm^2$]' % ( K , DeltaK ) ) ax [ 2 ] . grid ( 'True' ) plt . xlim ( 0 , np . pi / 2 ) plt . legend ( ) plt . savefig ( 'ANALYSIS/tilts_local_normals/Tilt_modulus_' + str ( leaflet ) + '_' + str ( status ) + '.png' , dpi = 300 ) plt . savefig ( 'ANALYSIS/tilts_local_normals/Tilt_modulus_' + str ( leaflet ) + '_' + str ( status ) + '.svg' ) return K , DeltaK , K_list
It will first fit a gaussian y=A exp[(x-mu)/sigma^2] to the distribution of tilts
to determine the fitting range then used to fit the corresponding potential of mean force (PMF).
It will first fit a gaussian y = A exp [ ( x - mu ) / sigma^2 ] to the distribution of tilts to determine the fitting range then used to fit the corresponding potential of mean force ( PMF ) .
""" 
    It will first fit a gaussian y=A exp[(x-mu)/sigma^2] to the distribution of tilts 
    to determine the fitting range then used to fit the corresponding potential of mean force (PMF).
    Different fitting ranges are used to estimate the error on the extracted tilt modulus.
    The function will calculate one tilt modulus for each lipid species and one splay modulus for each pair
    of lipid species. It will then combine these to calculate the overall tilt modulus and splay modulus (bending rigidity).
    More details about this procedure can be found in ref. [2]_ 
    """ """ set the angles in range [0,90] degrees """ #all_tilts[disordered_indx] """ compute the distribution of tilt angles using an histogram """ #bins=len(angles_first_quadrant) #plt.plot(bincenters_Lo, _gauss(bincenters_Lo, Ao, muo, sigmao )) #plt.plot(bincenters_Ld, sin_normalized)     """ normlize the probability with the sin(theta) """ """ PMF in KbT units """ #plt.plot(bincenters, PMF) #ax[0].plot(X_plot[:, 0], _gauss(bincenters,A_test2, mu_test2, test_sigma2 ),'-')
leaflet
angles_in_radians
status
nbins
Plot