当前位置: 首页>>代码示例>>C++>>正文


C++ CMol::FullGeometryOptimization_LBFGS_step方法代码示例

本文整理汇总了C++中CMol::FullGeometryOptimization_LBFGS_step方法的典型用法代码示例。如果您正苦于以下问题:C++ CMol::FullGeometryOptimization_LBFGS_step方法的具体用法?C++ CMol::FullGeometryOptimization_LBFGS_step怎么用?C++ CMol::FullGeometryOptimization_LBFGS_step使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CMol的用法示例。


在下文中一共展示了CMol::FullGeometryOptimization_LBFGS_step方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CalObjectiveFunction

double CalObjectiveFunction(double Para_List[], int Get_E_Rotamer)
{
	int i, j, nAtom, time_1, time_2;
	double d_E, E_Shift, w_1D;
	double Chi_SQ_Rotamer_Local;
	double E_Rotamer_MM_Local[MAX_ROTAMER];
	double E_Min_1D_MM_Mean, E_Min_1D_QM_Mean, E_Min_1D_QM_MM_Shift, Weight_Sum;

	Chi_SQ = Chi_SQ_1D = Chi_SQ_Rotamer = 0.0;
	Chi_SQ_Rotamer_Local = 0.0;

	w_1D = 1.0 - w_Rotamer;

	time_1 = time(NULL);

	Distribute_Torsion_Parameters();
	Assign_Torsion_Parameters();

	E_Shift = Para_List[10*n_Phi];

	nAtom = Mol_ESP.nAtom;
	for(i=0; i<n_Phi; i++)	{
		for(j=0; j<nScan_List[i]; j++)	{
			memcpy(Mol_ESP.x, x_Scan_list[i][j], sizeof(double)*nAtom);
			memcpy(Mol_ESP.y, y_Scan_list[i][j], sizeof(double)*nAtom);
			memcpy(Mol_ESP.z, z_Scan_list[i][j], sizeof(double)*nAtom);
			E_Scan_MM[i][j] = Mol_ESP.Cal_E(0);
		}

		E_Min_1D_MM_Mean = E_Min_1D_QM_Mean = 0.0;
		Weight_Sum = 0.0;
		for(j=0; j<nScan_List[i]; j++)	{
			Weight_Sum += w_Scan_List[i][j];
			E_Min_1D_MM_Mean += (w_Scan_List[i][j] * E_Scan_MM[i][j] );
			E_Min_1D_QM_Mean += (w_Scan_List[i][j] * E_Scan_QM[i][j] );
		}
		E_Min_1D_QM_MM_Shift = (E_Min_1D_QM_Mean - E_Min_1D_MM_Mean)/Weight_Sum;

		for(j=0; j<nScan_List[i]; j++)	{
			d_E = (E_Scan_QM[i][j] - E_Scan_MM[i][j] - E_Min_1D_QM_MM_Shift);	// fit the relative 1D energy profile
			Chi_SQ_1D += (d_E*d_E*w_Scan_List[i][j]);
		}
	}

	
	Chi_SQ_1D *= (w_1D/w_Scan_Sum);


	for(i=0; i<nRotamer; i++)	{
		E_Rotamer_MM[i] = E_Rotamer_MM_Local[i] = 0.0;
		if(i%nProc != ProgID)	{	//only proceed when i%nProc == ProgID, do job decomposition
			continue;
		}
		memcpy(Mol_ESP.x, x_Rotamer_Opt[i], sizeof(double)*nAtom);
		memcpy(Mol_ESP.y, y_Rotamer_Opt[i], sizeof(double)*nAtom);
		memcpy(Mol_ESP.z, z_Rotamer_Opt[i], sizeof(double)*nAtom);
		Mol_ESP.FullGeometryOptimization_LBFGS_step(1);
		E_Rotamer_MM_Local[i] = Mol_ESP.Cal_E(0);
		d_E = E_Rotamer_QM[i] - E_Rotamer_MM_Local[i] - E_Shift;
		Chi_SQ_Rotamer_Local += (d_E*d_E*w_rotamer_List[i]);
	}
	if(Get_E_Rotamer)	{
//eliot (from Matt Harvey)
	for( int i = 0 ; i < nRotamer; i++ ) { E_Rotamer_MM[i] += E_Rotamer_MM_Local[i]; }
                Chi_SQ_Rotamer = Chi_SQ_Rotamer_Local;

//eliot		MPI_Allreduce(E_Rotamer_MM_Local, E_Rotamer_MM, nRotamer, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
	}
//eliot	MPI_Allreduce(&Chi_SQ_Rotamer_Local, &Chi_SQ_Rotamer, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
//	MPI_Bcast(&Chi_SQ_Rotamer, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);

	printf(" w_rotamer_Sum = %f\n", w_rotamer_Sum );

	Chi_SQ_Rotamer *= (w_Rotamer/w_rotamer_Sum);

	Chi_SQ = Chi_SQ_1D + Chi_SQ_Rotamer;

//	MPI_Barrier(MPI_COMM_WORLD);
//	printf("%lf\n", Chi_SQ);
//	MPI_Finalize();

	time_2 = time(NULL);
/*
	if(ProgID == 0)	{
		FILE *fOut;
		fOut = fopen("time-rec.txt", "a+");
		fseek(fOut, 0, SEEK_END);
		fprintf(fOut, "%d\n", time_2-time_1);
		fclose(fOut);
	}
*/
	printf("Chi_SQ=%f\n", Chi_SQ );
	return Chi_SQ;
}
开发者ID:salotz,项目名称:htmd,代码行数:94,代码来源:1d_rotamer_fitting.cpp


注:本文中的CMol::FullGeometryOptimization_LBFGS_step方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。