void Look_traj() { //make_plot_crd_diff 110 1605 0 vector<double> X; Load_traj(110, 1605, 0, X); int szX = X.size(); if (szX == 0) return; vector<double> diffX(szX-1); for (int i = 0; i < szX-1; ++i) { diffX[i] = X[i+1] - X[i]; } { //------------------------------------------------------------------ char filter[] = TEXT("Plot Text File (*.txt)\0*.txt\0") TEXT("All Files (*.*)\0*.*\0"); char outfile_name[1048]; sprintf(outfile_name, "\0"); DWORD nFilterIndex; if (SaveFileDlg(0, outfile_name, filter, nFilterIndex) == S_OK) { cout << "now saving file " << outfile_name << endl; ofstream ofile; ofile.open(outfile_name, ios::out); for (int i = 0; i < szX-1; ++i) { ofile << X[i] << "," << diffX[i] << endl; } ofile.close(); } } for (int N = 10; N < 100; N += 5) Statistika (diffX, "diffX", N, calcMathOzh); for (int N = 10; N < 100; N += 5) Statistika (X, "linearTrendParameterA", N, calcLinearTrendParameterA); }
int main(int argc, char ** argv) { print_lib_intro_notice(cout); print_copyright_notice(cout); cout << endl; // example #2: open a file, run a geometry optimization, and save a file. // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ char infile_name[1048]; char outfile_name[1048]; DWORD nFilterIndex; if (OpenFileDlg(0, "Ghemical Project File (*.gpr)\0*.gpr\0All files \0*.*\0", infile_name, nFilterIndex) != S_OK) { return -1; } // check that we have got both file names from the command line. /*if (argc != 3) { cout << "usage : example2 infile.gpr outfile.gpr" << endl; exit(1); } char * infile_name = argv[1]; char * outfile_name = argv[2]; */ // create a model object, and read in a file. model * mdl = new model(); cout << "trying to open a file " << infile_name << " ; "; ifstream ifile; ifile.open(infile_name, ios::in); if (ifile.fail()) { cout << "failed!!!" << endl; ifile.close(); delete mdl; return -1; } cout << "ok!!!" << endl; ReadGPR(* mdl, ifile, false, false); ifile.close(); printf( "mdl->use_periodic_boundary_conditions = %d\n", mdl->use_periodic_boundary_conditions); printf( "mdl->periodic_box_HALFdim[0] = %f\n", mdl->periodic_box_HALFdim[0]); printf( "mdl->periodic_box_HALFdim[1] = %f\n", mdl->periodic_box_HALFdim[1]); printf( "mdl->periodic_box_HALFdim[2] = %f\n", mdl->periodic_box_HALFdim[2]); // if everything went fine, then create a computation engine object, initialize it, // and create a geometry optimizer object using the computation engine object. engine * eng = mdl->GetCurrentSetup()->CreateEngineByIDNumber(CURRENT_ENG1_MM); // engine * eng = mdl->GetCurrentSetup()->CreateEngineByIDNumber(ENG1_MM_TRIPOS52); // engine * eng = mdl->GetCurrentSetup()->CreateEngineByIDNumber(ENG1_MM_DEFAULT); // eng_pbc != NULL if we will use a system with periodic boundary conditions... // engine_pbc * eng_pbc = dynamic_cast<engine_pbc *>(eng); #if USE_ENGINE_PBC_TST engine_pbc_tst * eng_pbc = dynamic_cast<engine_pbc_tst *>(eng); #else engine_pbc * eng_pbc = dynamic_cast<engine_pbc *>(eng); #endif /*USE_ENGINE_PBC_TST*/ CopyCRD(mdl, eng, 0); CopyLockedCRD(mdl, eng, 0); printf("\n%f %f %f %f %f %f\n", mdl->maxCRD[0], mdl->minCRD[0], mdl->maxCRD[1], mdl->minCRD[1], mdl->maxCRD[2], mdl->minCRD[2]); mdl->periodic_box_HALFdim[0] = (mdl->maxCRD[0] - mdl->minCRD[0]+0.14) / 2.; mdl->periodic_box_HALFdim[1] = (mdl->maxCRD[1] - mdl->minCRD[1]+0.12) / 2.; mdl->periodic_box_HALFdim[0] = (mdl->maxCRD[0] - mdl->minCRD[0]) / 2. + 0.14; mdl->periodic_box_HALFdim[1] = (mdl->maxCRD[1] - mdl->minCRD[1]) / 2. + 0.12; printf( "mdl->use_periodic_boundary_conditions = %d\n", mdl->use_periodic_boundary_conditions); printf( "mdl->periodic_box_HALFdim[0] = %f\n", mdl->periodic_box_HALFdim[0]); printf( "mdl->periodic_box_HALFdim[1] = %f\n", mdl->periodic_box_HALFdim[1]); printf( "mdl->periodic_box_HALFdim[2] = %f\n", mdl->periodic_box_HALFdim[2]); geomopt * opt = new geomopt(eng, 100, 0.025, 10.0); // then take 100 geometry optimization steps, and print out some data about progess. for (int n1 = 0;n1 < 100;n1++) { opt->TakeCGStep(conjugate_gradient::Newton2An); eng_pbc->CheckLocations(); cout << "step = " << (n1 + 1) << " "; cout << "energy = " << opt->optval << " "; cout << "step length = " << opt->optstp << endl; } // now copy the optimized coordinates back to the model object, and save the file. CopyCRD(eng, mdl, 0); delete opt; opt = NULL; delete eng; eng = NULL; //------------------------------------------------------------------ TCHAR filter[] = TEXT("Ghemical Project File (*.gpr)\0*.gpr\0") TEXT("All Files (*.*)\0*.*\0"); sprintf(outfile_name, "\0"); if (SaveFileDlg(0, outfile_name, filter, nFilterIndex) == S_OK) { cout << "now saving file " << outfile_name << endl; ofstream ofile; ofile.open(outfile_name, ios::out); WriteGPR_v100(* mdl, ofile); ofile.close(); } // finally release all allocated memory and leave. delete mdl; mdl = NULL; return 0; }
BOOL CALLBACK DlgProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) { static HWND previewWnd; switch (msg) { case WM_INITDIALOG: { if (!(previewWnd = FindWindowEx(wnd, NULL, TEXT("FontPreview"), NULL))) { goto Exit; } return TRUE; } case WM_CLOSE: { Exit: EndDialog(wnd, 0); PostQuitMessage(0); return TRUE; } case WM_COMMAND: { int notifyCode = HIWORD(wParam); int id = LOWORD(wParam); HWND wndCtl = (HWND)lParam; switch (id) { case IDC_FONTLIST: { if (notifyCode != LBN_SELCHANGE) break; SendDlgItemMessage(wnd, IDC_FONTPREVIEW, WM_USER, 0, 0); return FALSE; } case IDC_FONTSIZELIST: { if (notifyCode != LBN_SELCHANGE) break; SendDlgItemMessage(wnd, IDC_FONTPREVIEW, WM_USER, 0, 0); return FALSE; } case IDC_CHKBOLD: { if (notifyCode != BN_CLICKED) break; SendDlgItemMessage(wnd, IDC_FONTPREVIEW, WM_USER, 0, 0); return FALSE; } case IDC_CHKITALIC: { if (notifyCode != BN_CLICKED) break; SendDlgItemMessage(wnd, IDC_FONTPREVIEW, WM_USER, 0, 0); return FALSE; } case IDC_BTNSAVE: { static const TCHAR* gbaExtWithDot = TEXT(".gbafont"); static const TCHAR* saveFileDlgFilter [] = {TEXT("gbafont"), NULL}; TCHAR filePath[512]; FILE* gbaFontFile; if (!SaveFileDlg(filePath, TEXT("GBA Font"), saveFileDlgFilter, wnd)) return FALSE; if (!wcsstr(filePath, saveFileDlgFilter[0])) wcscat(filePath, gbaExtWithDot); gbaFontFile = _wfopen(filePath, L"w"); SendDlgItemMessage(wnd, IDC_FONTPREVIEW, WM_USER + 1, (WPARAM)gbaFontFile, 0); fclose(gbaFontFile); return FALSE; } } } } return FALSE; }