Пример #1
0
def curvature_coupling_loader_membrane(data, **kwargs):
    """
	Receive the undulation data and prepare the meshes for the curvature coupling calculation.
	"""
    #---point heights into "memory"
    status('populating memory', tag='load')
    midplane_method = kwargs.pop('midplane_method', 'flat')
    if kwargs: raise Exception('unprocessed kwargs: %s' % kwargs)
    memory = {}
    for sn in data['undulations'].keys():
        if (sn, 'hqs') not in memory:
            dat = data['undulations'][sn]['data']
            vecs = dat['vecs']
            mesh = dat['mesh']
            midplane = mesh.mean(axis=0)
            #---assume the average structure is a flat bilayer at the vertical center of the bilayer
            if midplane_method == 'flat':
                zmeans = midplane.reshape((midplane.shape[0], -1)).mean(axis=1)
                midplane = np.array(
                    [i - zmeans[ii] for ii, i in enumerate(midplane)])
            #---assume the average structure is the average height profile of the bilayer
            elif midplane_method == 'average':
                zmean = midplane.mean(axis=0)
                midplane -= zmean
            else:
                raise Exception('invalid midplane method %s' % midplane_method)
            hqs = fft_field(midplane)
            memory[(sn, 'hqs')] = hqs
            memory[(sn, 'vecs')] = vecs
    return memory
			def objective(args):
				"""
				Fit parameters are defined in sequence for the optimizer.
				They are: kappa,gamma,vibe,*curvatures-per-dimple.
				"""
				kappa,gamma,vibe = args[:3]
				curvatures = args[3:]
				composite = self.curvature_sum(cfs,curvatures,method=curvature_sum_method)
				cqs = cctools.fft_field(composite)
				termlist = [multipliers(x,y) for x,y in [(hqs,hqs),(hqs,cqs),(cqs,hqs),(cqs,cqs)]]
				termlist = [np.reshape(np.mean(k,axis=0),-1)[1:] for k in termlist]
				#---skipping assertion and dropping imaginary
				termlist = [np.real(k) for k in termlist]
				hel = (kappa*area*(termlist[0]*q_raw**4+signterm*termlist[1]*q_raw**2
					+signterm*termlist[2]*q_raw**2+termlist[3])
					+gamma*area*(termlist[0]*q_raw**2))
				ratio = hel/((vibe*q_raw+machine_eps)/(np.exp(vibe*q_raw)-1)+machine_eps)
				return residual(ratio[band])
Пример #3
0
            def objective(args, mode='residual'):
                """
				Fit parameters are defined in sequence for the optimizer.
				They are: kappa,gamma,vibe,*curvatures-per-dimple.
				"""
                kappa, gamma, vibe = args[:3]
                #---uniform curvatures
                if ndrops_uniform != 0:
                    curvatures = [args[3] for i in range(ndrops_uniform)]
                    #---one curvature per field
                else:
                    curvatures = args[3:]
                composite = self.curvature_sum(cfs,
                                               curvatures,
                                               method=curvature_sum_method)
                cqs = cctools.fft_field(composite)
                termlist = [
                    multipliers(x, y)
                    for x, y in [(hqs, hqs), (hqs, cqs), (cqs, hqs), (cqs,
                                                                      cqs)]
                ]
                termlist = [
                    np.reshape(np.mean(k, axis=0), -1)[1:] for k in termlist
                ]
                #---skipping assertion and dropping imaginary
                termlist = [np.real(k) for k in termlist]
                hel = (
                    kappa / 2.0 * area *
                    (termlist[0] * q_raw**4 + signterm * termlist[1] * q_raw**2
                     + signterm * termlist[2] * q_raw**2 + termlist[3]) +
                    gamma * area * (termlist[0] * q_raw**2))
                ratio = hel / ((vibe * q_raw + machine_eps) /
                               (np.exp(vibe * q_raw) - 1) + machine_eps)
                if mode == 'residual': return residual(ratio[band])
                elif mode == 'ratio': return ratio
                else: raise Exception('invalid mode %s' % mode)