Changeset 042f82 for src/config.cpp
- Timestamp:
- Jul 23, 2009, 2:21:57 PM (16 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 36ec71
- Parents:
- 205ccd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/config.cpp
r205ccd r042f82 163 163 config::config() 164 164 { 165 166 167 165 mainname = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: mainname"); 166 defaultpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: defaultpath"); 167 pseudopotpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: pseudopotpath"); 168 168 databasepath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: databasepath"); 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 169 configpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: configpath"); 170 configname = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: configname"); 171 strcpy(mainname,"pcp"); 172 strcpy(defaultpath,"not specified"); 173 strcpy(pseudopotpath,"not specified"); 174 configpath[0]='\0'; 175 configname[0]='\0'; 176 basis = "3-21G"; 177 178 FastParsing = false; 179 ProcPEGamma=8; 180 ProcPEPsi=1; 181 DoOutVis=0; 182 DoOutMes=1; 183 DoOutNICS=0; 184 DoOutOrbitals=0; 185 DoOutCurrent=0; 186 DoPerturbation=0; 187 DoFullCurrent=0; 188 DoWannier=0; 189 CommonWannier=0; 190 SawtoothStart=0.01; 191 VectorPlane=0; 192 VectorCut=0; 193 UseAddGramSch=1; 194 Seed=1; 195 196 MaxOuterStep=0; 197 Deltat=1; 198 OutVisStep=10; 199 OutSrcStep=5; 200 TargetTemp=0.00095004455; 201 ScaleTempStep=25; 202 MaxPsiStep=0; 203 EpsWannier=1e-7; 204 205 MaxMinStep=100; 206 RelEpsTotalEnergy=1e-7; 207 RelEpsKineticEnergy=1e-5; 208 MaxMinStopStep=1; 209 MaxMinGapStopStep=0; 210 MaxInitMinStep=100; 211 InitRelEpsTotalEnergy=1e-5; 212 InitRelEpsKineticEnergy=1e-4; 213 InitMaxMinStopStep=1; 214 InitMaxMinGapStopStep=0; 215 216 //BoxLength[NDIM*NDIM]; 217 218 ECut=128.; 219 MaxLevel=5; 220 RiemannTensor=0; 221 LevRFactor=0; 222 RiemannLevel=0; 223 Lev0Factor=2; 224 RTActualUse=0; 225 PsiType=0; 226 MaxPsiDouble=0; 227 PsiMaxNoUp=0; 228 PsiMaxNoDown=0; 229 AddPsis=0; 230 231 RCut=20.; 232 StructOpt=0; 233 IsAngstroem=1; 234 RelativeCoord=0; 235 MaxTypes=0; 236 236 }; 237 237 … … 241 241 config::~config() 242 242 { 243 244 245 243 Free((void **)&mainname, "config::~config: *mainname"); 244 Free((void **)&defaultpath, "config::~config: *defaultpath"); 245 Free((void **)&pseudopotpath, "config::~config: *pseudopotpath"); 246 246 Free((void **)&databasepath, "config::~config: *databasepath"); 247 248 247 Free((void **)&configpath, "config::~config: *configpath"); 248 Free((void **)&configname, "config::~config: *configname"); 249 249 }; 250 250 … … 255 255 void config::Edit() 256 256 { 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 // 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 // 438 // 439 // 440 // 441 // 442 // 443 // 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 257 char choice; 258 259 do { 260 cout << Verbose(0) << "===========EDIT CONFIGURATION============================" << endl; 261 cout << Verbose(0) << " A - mainname (prefix for all runtime files)" << endl; 262 cout << Verbose(0) << " B - Default path (for runtime files)" << endl; 263 cout << Verbose(0) << " C - Path of pseudopotential files" << endl; 264 cout << Verbose(0) << " D - Number of coefficient sharing processes" << endl; 265 cout << Verbose(0) << " E - Number of wave function sharing processes" << endl; 266 cout << Verbose(0) << " F - 0: Don't output density for OpenDX, 1: do" << endl; 267 cout << Verbose(0) << " G - 0: Don't output physical data, 1: do" << endl; 268 cout << Verbose(0) << " H - 0: Don't output densities of each unperturbed orbital for OpenDX, 1: do" << endl; 269 cout << Verbose(0) << " I - 0: Don't output current density for OpenDX, 1: do" << endl; 270 cout << Verbose(0) << " J - 0: Don't do the full current calculation, 1: do" << endl; 271 cout << Verbose(0) << " K - 0: Don't do perturbation calculation to obtain susceptibility and shielding, 1: do" << endl; 272 cout << Verbose(0) << " L - 0: Wannier centres as calculated, 1: common centre for all, 2: unite centres according to spread, 3: cell centre, 4: shifted to nearest grid point" << endl; 273 cout << Verbose(0) << " M - Absolute begin of unphysical sawtooth transfer for position operator within cell" << endl; 274 cout << Verbose(0) << " N - (0,1,2) x,y,z-plane to do two-dimensional current vector cut" << endl; 275 cout << Verbose(0) << " O - Absolute position along vector cut axis for cut plane" << endl; 276 cout << Verbose(0) << " P - Additional Gram-Schmidt-Orthonormalization to stabilize numerics" << endl; 277 cout << Verbose(0) << " Q - Initial integer value of random number generator" << endl; 278 cout << Verbose(0) << " R - for perturbation 0, for structure optimization defines upper limit of iterations" << endl; 279 cout << Verbose(0) << " T - Output visual after ...th step" << endl; 280 cout << Verbose(0) << " U - Output source densities of wave functions after ...th step" << endl; 281 cout << Verbose(0) << " X - minimization iterations per wave function, if unsure leave at default value 0" << endl; 282 cout << Verbose(0) << " Y - tolerance value for total spread in iterative Jacobi diagonalization" << endl; 283 cout << Verbose(0) << " Z - Maximum number of minimization iterations" << endl; 284 cout << Verbose(0) << " a - Relative change in total energy to stop min. iteration" << endl; 285 cout << Verbose(0) << " b - Relative change in kinetic energy to stop min. iteration" << endl; 286 cout << Verbose(0) << " c - Check stop conditions every ..th step during min. iteration" << endl; 287 cout << Verbose(0) << " e - Maximum number of minimization iterations during initial level" << endl; 288 cout << Verbose(0) << " f - Relative change in total energy to stop min. iteration during initial level" << endl; 289 cout << Verbose(0) << " g - Relative change in kinetic energy to stop min. iteration during initial level" << endl; 290 cout << Verbose(0) << " h - Check stop conditions every ..th step during min. iteration during initial level" << endl; 291 // cout << Verbose(0) << " j - six lower diagonal entries of matrix, defining the unit cell" << endl; 292 cout << Verbose(0) << " k - Energy cutoff of plane wave basis in Hartree" << endl; 293 cout << Verbose(0) << " l - Maximum number of levels in multi-level-ansatz" << endl; 294 cout << Verbose(0) << " m - Factor by which grid nodes increase between standard and upper level" << endl; 295 cout << Verbose(0) << " n - 0: Don't use RiemannTensor, 1: Do" << endl; 296 cout << Verbose(0) << " o - Factor by which grid nodes increase between Riemann and standard(?) level" << endl; 297 cout << Verbose(0) << " p - Number of Riemann levels" << endl; 298 cout << Verbose(0) << " r - 0: Don't Use RiemannTensor, 1: Do" << endl; 299 cout << Verbose(0) << " s - 0: Doubly occupied orbitals, 1: Up-/Down-Orbitals" << endl; 300 cout << Verbose(0) << " t - Number of orbitals (depends pn SpinType)" << endl; 301 cout << Verbose(0) << " u - Number of SpinUp orbitals (depends on SpinType)" << endl; 302 cout << Verbose(0) << " v - Number of SpinDown orbitals (depends on SpinType)" << endl; 303 cout << Verbose(0) << " w - Number of additional, unoccupied orbitals" << endl; 304 cout << Verbose(0) << " x - radial cutoff for ewald summation in Bohrradii" << endl; 305 cout << Verbose(0) << " y - 0: Don't do structure optimization beforehand, 1: Do" << endl; 306 cout << Verbose(0) << " z - 0: Units are in Bohr radii, 1: units are in Aengstrom" << endl; 307 cout << Verbose(0) << " i - 0: Coordinates given in file are absolute, 1: ... are relative to unit cell" << endl; 308 cout << Verbose(0) << "=========================================================" << endl; 309 cout << Verbose(0) << "INPUT: "; 310 cin >> choice; 311 312 switch (choice) { 313 case 'A': // mainname 314 cout << Verbose(0) << "Old: " << config::mainname << "\t new: "; 315 cin >> config::mainname; 316 break; 317 case 'B': // defaultpath 318 cout << Verbose(0) << "Old: " << config::defaultpath << "\t new: "; 319 cin >> config::defaultpath; 320 break; 321 case 'C': // pseudopotpath 322 cout << Verbose(0) << "Old: " << config::pseudopotpath << "\t new: "; 323 cin >> config::pseudopotpath; 324 break; 325 326 case 'D': // ProcPEGamma 327 cout << Verbose(0) << "Old: " << config::ProcPEGamma << "\t new: "; 328 cin >> config::ProcPEGamma; 329 break; 330 case 'E': // ProcPEPsi 331 cout << Verbose(0) << "Old: " << config::ProcPEPsi << "\t new: "; 332 cin >> config::ProcPEPsi; 333 break; 334 case 'F': // DoOutVis 335 cout << Verbose(0) << "Old: " << config::DoOutVis << "\t new: "; 336 cin >> config::DoOutVis; 337 break; 338 case 'G': // DoOutMes 339 cout << Verbose(0) << "Old: " << config::DoOutMes << "\t new: "; 340 cin >> config::DoOutMes; 341 break; 342 case 'H': // DoOutOrbitals 343 cout << Verbose(0) << "Old: " << config::DoOutOrbitals << "\t new: "; 344 cin >> config::DoOutOrbitals; 345 break; 346 case 'I': // DoOutCurrent 347 cout << Verbose(0) << "Old: " << config::DoOutCurrent << "\t new: "; 348 cin >> config::DoOutCurrent; 349 break; 350 case 'J': // DoFullCurrent 351 cout << Verbose(0) << "Old: " << config::DoFullCurrent << "\t new: "; 352 cin >> config::DoFullCurrent; 353 break; 354 case 'K': // DoPerturbation 355 cout << Verbose(0) << "Old: " << config::DoPerturbation << "\t new: "; 356 cin >> config::DoPerturbation; 357 break; 358 case 'L': // CommonWannier 359 cout << Verbose(0) << "Old: " << config::CommonWannier << "\t new: "; 360 cin >> config::CommonWannier; 361 break; 362 case 'M': // SawtoothStart 363 cout << Verbose(0) << "Old: " << config::SawtoothStart << "\t new: "; 364 cin >> config::SawtoothStart; 365 break; 366 case 'N': // VectorPlane 367 cout << Verbose(0) << "Old: " << config::VectorPlane << "\t new: "; 368 cin >> config::VectorPlane; 369 break; 370 case 'O': // VectorCut 371 cout << Verbose(0) << "Old: " << config::VectorCut << "\t new: "; 372 cin >> config::VectorCut; 373 break; 374 case 'P': // UseAddGramSch 375 cout << Verbose(0) << "Old: " << config::UseAddGramSch << "\t new: "; 376 cin >> config::UseAddGramSch; 377 break; 378 case 'Q': // Seed 379 cout << Verbose(0) << "Old: " << config::Seed << "\t new: "; 380 cin >> config::Seed; 381 break; 382 383 case 'R': // MaxOuterStep 384 cout << Verbose(0) << "Old: " << config::MaxOuterStep << "\t new: "; 385 cin >> config::MaxOuterStep; 386 break; 387 case 'T': // OutVisStep 388 cout << Verbose(0) << "Old: " << config::OutVisStep << "\t new: "; 389 cin >> config::OutVisStep; 390 break; 391 case 'U': // OutSrcStep 392 cout << Verbose(0) << "Old: " << config::OutSrcStep << "\t new: "; 393 cin >> config::OutSrcStep; 394 break; 395 case 'X': // MaxPsiStep 396 cout << Verbose(0) << "Old: " << config::MaxPsiStep << "\t new: "; 397 cin >> config::MaxPsiStep; 398 break; 399 case 'Y': // EpsWannier 400 cout << Verbose(0) << "Old: " << config::EpsWannier << "\t new: "; 401 cin >> config::EpsWannier; 402 break; 403 404 case 'Z': // MaxMinStep 405 cout << Verbose(0) << "Old: " << config::MaxMinStep << "\t new: "; 406 cin >> config::MaxMinStep; 407 break; 408 case 'a': // RelEpsTotalEnergy 409 cout << Verbose(0) << "Old: " << config::RelEpsTotalEnergy << "\t new: "; 410 cin >> config::RelEpsTotalEnergy; 411 break; 412 case 'b': // RelEpsKineticEnergy 413 cout << Verbose(0) << "Old: " << config::RelEpsKineticEnergy << "\t new: "; 414 cin >> config::RelEpsKineticEnergy; 415 break; 416 case 'c': // MaxMinStopStep 417 cout << Verbose(0) << "Old: " << config::MaxMinStopStep << "\t new: "; 418 cin >> config::MaxMinStopStep; 419 break; 420 case 'e': // MaxInitMinStep 421 cout << Verbose(0) << "Old: " << config::MaxInitMinStep << "\t new: "; 422 cin >> config::MaxInitMinStep; 423 break; 424 case 'f': // InitRelEpsTotalEnergy 425 cout << Verbose(0) << "Old: " << config::InitRelEpsTotalEnergy << "\t new: "; 426 cin >> config::InitRelEpsTotalEnergy; 427 break; 428 case 'g': // InitRelEpsKineticEnergy 429 cout << Verbose(0) << "Old: " << config::InitRelEpsKineticEnergy << "\t new: "; 430 cin >> config::InitRelEpsKineticEnergy; 431 break; 432 case 'h': // InitMaxMinStopStep 433 cout << Verbose(0) << "Old: " << config::InitMaxMinStopStep << "\t new: "; 434 cin >> config::InitMaxMinStopStep; 435 break; 436 437 // case 'j': // BoxLength 438 // cout << Verbose(0) << "enter lower triadiagonalo form of basis matrix" << endl << endl; 439 // for (int i=0;i<6;i++) { 440 // cout << Verbose(0) << "Cell size" << i << ": "; 441 // cin >> mol->cell_size[i]; 442 // } 443 // break; 444 445 case 'k': // ECut 446 cout << Verbose(0) << "Old: " << config::ECut << "\t new: "; 447 cin >> config::ECut; 448 break; 449 case 'l': // MaxLevel 450 cout << Verbose(0) << "Old: " << config::MaxLevel << "\t new: "; 451 cin >> config::MaxLevel; 452 break; 453 case 'm': // RiemannTensor 454 cout << Verbose(0) << "Old: " << config::RiemannTensor << "\t new: "; 455 cin >> config::RiemannTensor; 456 break; 457 case 'n': // LevRFactor 458 cout << Verbose(0) << "Old: " << config::LevRFactor << "\t new: "; 459 cin >> config::LevRFactor; 460 break; 461 case 'o': // RiemannLevel 462 cout << Verbose(0) << "Old: " << config::RiemannLevel << "\t new: "; 463 cin >> config::RiemannLevel; 464 break; 465 case 'p': // Lev0Factor 466 cout << Verbose(0) << "Old: " << config::Lev0Factor << "\t new: "; 467 cin >> config::Lev0Factor; 468 break; 469 case 'r': // RTActualUse 470 cout << Verbose(0) << "Old: " << config::RTActualUse << "\t new: "; 471 cin >> config::RTActualUse; 472 break; 473 case 's': // PsiType 474 cout << Verbose(0) << "Old: " << config::PsiType << "\t new: "; 475 cin >> config::PsiType; 476 break; 477 case 't': // MaxPsiDouble 478 cout << Verbose(0) << "Old: " << config::MaxPsiDouble << "\t new: "; 479 cin >> config::MaxPsiDouble; 480 break; 481 case 'u': // PsiMaxNoUp 482 cout << Verbose(0) << "Old: " << config::PsiMaxNoUp << "\t new: "; 483 cin >> config::PsiMaxNoUp; 484 break; 485 case 'v': // PsiMaxNoDown 486 cout << Verbose(0) << "Old: " << config::PsiMaxNoDown << "\t new: "; 487 cin >> config::PsiMaxNoDown; 488 break; 489 case 'w': // AddPsis 490 cout << Verbose(0) << "Old: " << config::AddPsis << "\t new: "; 491 cin >> config::AddPsis; 492 break; 493 494 case 'x': // RCut 495 cout << Verbose(0) << "Old: " << config::RCut << "\t new: "; 496 cin >> config::RCut; 497 break; 498 case 'y': // StructOpt 499 cout << Verbose(0) << "Old: " << config::StructOpt << "\t new: "; 500 cin >> config::StructOpt; 501 break; 502 case 'z': // IsAngstroem 503 cout << Verbose(0) << "Old: " << config::IsAngstroem << "\t new: "; 504 cin >> config::IsAngstroem; 505 break; 506 case 'i': // RelativeCoord 507 cout << Verbose(0) << "Old: " << config::RelativeCoord << "\t new: "; 508 cin >> config::RelativeCoord; 509 break; 510 }; 511 } while (choice != 'q'); 512 512 }; 513 513 … … 520 520 int config::TestSyntax(char *filename, periodentafel *periode, molecule *mol) 521 521 { 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 522 int test; 523 ifstream file(filename); 524 525 // search file for keyword: ProcPEGamma (new syntax) 526 if (ParseForParameter(1,&file,"ProcPEGamma", 0, 1, 1, int_type, &test, 1, optional)) { 527 file.close(); 528 return 1; 529 } 530 // search file for keyword: ProcsGammaPsi (old syntax) 531 if (ParseForParameter(1,&file,"ProcsGammaPsi", 0, 1, 1, int_type, &test, 1, optional)) { 532 file.close(); 533 return 0; 534 } 535 file.close(); 536 return -1; 537 537 } 538 538 … … 542 542 bool config::GetIsAngstroem() const 543 543 { 544 544 return (IsAngstroem == 1); 545 545 }; 546 546 … … 550 550 char * config::GetDefaultPath() const 551 551 { 552 552 return defaultpath; 553 553 }; 554 554 … … 559 559 void config::SetDefaultPath(const char *path) 560 560 { 561 561 strcpy(defaultpath, path); 562 562 }; 563 563 … … 567 567 void config::RetrieveConfigPathAndName(string filename) 568 568 { 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 569 char *ptr = NULL; 570 char *buffer = new char[MAXSTRINGSIZE]; 571 strncpy(buffer, filename.c_str(), MAXSTRINGSIZE); 572 int last = -1; 573 for(last=MAXSTRINGSIZE;last--;) { 574 if (buffer[last] == '/') 575 break; 576 } 577 if (last == -1) { // no path in front, set to local directory. 578 strcpy(configpath, "./"); 579 ptr = buffer; 580 } else { 581 strncpy(configpath, buffer, last+1); 582 ptr = &buffer[last+1]; 583 if (last < 254) 584 configpath[last+1]='\0'; 585 } 586 strcpy(configname, ptr); 587 cout << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl; 588 delete[](buffer); 589 589 }; 590 590 … … 597 597 void config::Load(char *filename, periodentafel *periode, molecule *mol) 598 598 { 599 600 601 599 RetrieveConfigPathAndName(filename); 600 601 // ParseParameterFile 602 602 struct ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename); 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 603 FileBuffer->InitMapping(); 604 605 /* Oeffne Hauptparameterdatei */ 606 int di; 607 double BoxLength[9]; 608 string zeile; 609 string dummy; 610 element *elementhash[MAX_ELEMENTS]; 611 char name[MAX_ELEMENTS]; 612 char keyword[MAX_ELEMENTS]; 613 int Z, No[MAX_ELEMENTS]; 614 int verbose = 0; 615 double value[3]; 616 617 /* Namen einlesen */ 618 619 ParseForParameter(verbose,FileBuffer, "mainname", 0, 1, 1, string_type, (config::mainname), 1, critical); 620 ParseForParameter(verbose,FileBuffer, "defaultpath", 0, 1, 1, string_type, (config::defaultpath), 1, critical); 621 ParseForParameter(verbose,FileBuffer, "pseudopotpath", 0, 1, 1, string_type, (config::pseudopotpath), 1, critical); 622 ParseForParameter(verbose,FileBuffer,"ProcPEGamma", 0, 1, 1, int_type, &(config::ProcPEGamma), 1, critical); 623 ParseForParameter(verbose,FileBuffer,"ProcPEPsi", 0, 1, 1, int_type, &(config::ProcPEPsi), 1, critical); 624 625 if (!ParseForParameter(verbose,FileBuffer,"Seed", 0, 1, 1, int_type, &(config::Seed), 1, optional)) 626 config::Seed = 1; 627 628 if(!ParseForParameter(verbose,FileBuffer,"DoOutOrbitals", 0, 1, 1, int_type, &(config::DoOutOrbitals), 1, optional)) { 629 config::DoOutOrbitals = 0; 630 } else { 631 if (config::DoOutOrbitals < 0) config::DoOutOrbitals = 0; 632 if (config::DoOutOrbitals > 1) config::DoOutOrbitals = 1; 633 } 634 ParseForParameter(verbose,FileBuffer,"DoOutVis", 0, 1, 1, int_type, &(config::DoOutVis), 1, critical); 635 if (config::DoOutVis < 0) config::DoOutVis = 0; 636 if (config::DoOutVis > 1) config::DoOutVis = 1; 637 if (!ParseForParameter(verbose,FileBuffer,"VectorPlane", 0, 1, 1, int_type, &(config::VectorPlane), 1, optional)) 638 config::VectorPlane = -1; 639 if (!ParseForParameter(verbose,FileBuffer,"VectorCut", 0, 1, 1, double_type, &(config::VectorCut), 1, optional)) 640 config::VectorCut = 0.; 641 ParseForParameter(verbose,FileBuffer,"DoOutMes", 0, 1, 1, int_type, &(config::DoOutMes), 1, critical); 642 if (config::DoOutMes < 0) config::DoOutMes = 0; 643 if (config::DoOutMes > 1) config::DoOutMes = 1; 644 if (!ParseForParameter(verbose,FileBuffer,"DoOutCurr", 0, 1, 1, int_type, &(config::DoOutCurrent), 1, optional)) 645 config::DoOutCurrent = 0; 646 if (config::DoOutCurrent < 0) config::DoOutCurrent = 0; 647 if (config::DoOutCurrent > 1) config::DoOutCurrent = 1; 648 ParseForParameter(verbose,FileBuffer,"AddGramSch", 0, 1, 1, int_type, &(config::UseAddGramSch), 1, critical); 649 if (config::UseAddGramSch < 0) config::UseAddGramSch = 0; 650 if (config::UseAddGramSch > 2) config::UseAddGramSch = 2; 651 if(!ParseForParameter(verbose,FileBuffer,"DoWannier", 0, 1, 1, int_type, &(config::DoWannier), 1, optional)) { 652 config::DoWannier = 0; 653 } else { 654 if (config::DoWannier < 0) config::DoWannier = 0; 655 if (config::DoWannier > 1) config::DoWannier = 1; 656 } 657 if(!ParseForParameter(verbose,FileBuffer,"CommonWannier", 0, 1, 1, int_type, &(config::CommonWannier), 1, optional)) { 658 config::CommonWannier = 0; 659 } else { 660 if (config::CommonWannier < 0) config::CommonWannier = 0; 661 if (config::CommonWannier > 4) config::CommonWannier = 4; 662 } 663 if(!ParseForParameter(verbose,FileBuffer,"SawtoothStart", 0, 1, 1, double_type, &(config::SawtoothStart), 1, optional)) { 664 config::SawtoothStart = 0.01; 665 } else { 666 if (config::SawtoothStart < 0.) config::SawtoothStart = 0.; 667 if (config::SawtoothStart > 1.) config::SawtoothStart = 1.; 668 } 669 670 ParseForParameter(verbose,FileBuffer,"MaxOuterStep", 0, 1, 1, int_type, &(config::MaxOuterStep), 1, critical); 671 if (!ParseForParameter(verbose,FileBuffer,"Deltat", 0, 1, 1, double_type, &(config::Deltat), 1, optional)) 672 config::Deltat = 1; 673 ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 674 ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 675 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional); 676 //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 677 if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional)) 678 config::EpsWannier = 1e-8; 679 680 // stop conditions 681 //if (config::MaxOuterStep <= 0) config::MaxOuterStep = 1; 682 ParseForParameter(verbose,FileBuffer,"MaxPsiStep", 0, 1, 1, int_type, &(config::MaxPsiStep), 1, critical); 683 if (config::MaxPsiStep <= 0) config::MaxPsiStep = 3; 684 685 ParseForParameter(verbose,FileBuffer,"MaxMinStep", 0, 1, 1, int_type, &(config::MaxMinStep), 1, critical); 686 ParseForParameter(verbose,FileBuffer,"RelEpsTotalE", 0, 1, 1, double_type, &(config::RelEpsTotalEnergy), 1, critical); 687 ParseForParameter(verbose,FileBuffer,"RelEpsKineticE", 0, 1, 1, double_type, &(config::RelEpsKineticEnergy), 1, critical); 688 ParseForParameter(verbose,FileBuffer,"MaxMinStopStep", 0, 1, 1, int_type, &(config::MaxMinStopStep), 1, critical); 689 ParseForParameter(verbose,FileBuffer,"MaxMinGapStopStep", 0, 1, 1, int_type, &(config::MaxMinGapStopStep), 1, critical); 690 if (config::MaxMinStep <= 0) config::MaxMinStep = config::MaxPsiStep; 691 if (config::MaxMinStopStep < 1) config::MaxMinStopStep = 1; 692 if (config::MaxMinGapStopStep < 1) config::MaxMinGapStopStep = 1; 693 694 ParseForParameter(verbose,FileBuffer,"MaxInitMinStep", 0, 1, 1, int_type, &(config::MaxInitMinStep), 1, critical); 695 ParseForParameter(verbose,FileBuffer,"InitRelEpsTotalE", 0, 1, 1, double_type, &(config::InitRelEpsTotalEnergy), 1, critical); 696 ParseForParameter(verbose,FileBuffer,"InitRelEpsKineticE", 0, 1, 1, double_type, &(config::InitRelEpsKineticEnergy), 1, critical); 697 ParseForParameter(verbose,FileBuffer,"InitMaxMinStopStep", 0, 1, 1, int_type, &(config::InitMaxMinStopStep), 1, critical); 698 ParseForParameter(verbose,FileBuffer,"InitMaxMinGapStopStep", 0, 1, 1, int_type, &(config::InitMaxMinGapStopStep), 1, critical); 699 if (config::MaxInitMinStep <= 0) config::MaxInitMinStep = config::MaxPsiStep; 700 if (config::InitMaxMinStopStep < 1) config::InitMaxMinStopStep = 1; 701 if (config::InitMaxMinGapStopStep < 1) config::InitMaxMinGapStopStep = 1; 702 703 // Unit cell and magnetic field 704 ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 705 mol->cell_size[0] = BoxLength[0]; 706 mol->cell_size[1] = BoxLength[3]; 707 mol->cell_size[2] = BoxLength[4]; 708 mol->cell_size[3] = BoxLength[6]; 709 mol->cell_size[4] = BoxLength[7]; 710 mol->cell_size[5] = BoxLength[8]; 711 //if (1) fprintf(stderr,"\n"); 712 713 ParseForParameter(verbose,FileBuffer,"DoPerturbation", 0, 1, 1, int_type, &(config::DoPerturbation), 1, optional); 714 ParseForParameter(verbose,FileBuffer,"DoOutNICS", 0, 1, 1, int_type, &(config::DoOutNICS), 1, optional); 715 if (!ParseForParameter(verbose,FileBuffer,"DoFullCurrent", 0, 1, 1, int_type, &(config::DoFullCurrent), 1, optional)) 716 config::DoFullCurrent = 0; 717 if (config::DoFullCurrent < 0) config::DoFullCurrent = 0; 718 if (config::DoFullCurrent > 2) config::DoFullCurrent = 2; 719 if (config::DoOutNICS < 0) config::DoOutNICS = 0; 720 if (config::DoOutNICS > 2) config::DoOutNICS = 2; 721 if (config::DoPerturbation == 0) { 722 config::DoFullCurrent = 0; 723 config::DoOutNICS = 0; 724 } 725 726 ParseForParameter(verbose,FileBuffer,"ECut", 0, 1, 1, double_type, &(config::ECut), 1, critical); 727 ParseForParameter(verbose,FileBuffer,"MaxLevel", 0, 1, 1, int_type, &(config::MaxLevel), 1, critical); 728 ParseForParameter(verbose,FileBuffer,"Level0Factor", 0, 1, 1, int_type, &(config::Lev0Factor), 1, critical); 729 if (config::Lev0Factor < 2) { 730 config::Lev0Factor = 2; 731 } 732 ParseForParameter(verbose,FileBuffer,"RiemannTensor", 0, 1, 1, int_type, &di, 1, critical); 733 if (di >= 0 && di < 2) { 734 config::RiemannTensor = di; 735 } else { 736 fprintf(stderr, "0 <= RiemanTensor < 2: 0 UseNotRT, 1 UseRT"); 737 exit(1); 738 } 739 switch (config::RiemannTensor) { 740 case 0: //UseNoRT 741 if (config::MaxLevel < 2) { 742 config::MaxLevel = 2; 743 } 744 config::LevRFactor = 2; 745 config::RTActualUse = 0; 746 break; 747 case 1: // UseRT 748 if (config::MaxLevel < 3) { 749 config::MaxLevel = 3; 750 } 751 ParseForParameter(verbose,FileBuffer,"RiemannLevel", 0, 1, 1, int_type, &(config::RiemannLevel), 1, critical); 752 if (config::RiemannLevel < 2) { 753 config::RiemannLevel = 2; 754 } 755 if (config::RiemannLevel > config::MaxLevel-1) { 756 config::RiemannLevel = config::MaxLevel-1; 757 } 758 ParseForParameter(verbose,FileBuffer,"LevRFactor", 0, 1, 1, int_type, &(config::LevRFactor), 1, critical); 759 if (config::LevRFactor < 2) { 760 config::LevRFactor = 2; 761 } 762 config::Lev0Factor = 2; 763 config::RTActualUse = 2; 764 break; 765 } 766 ParseForParameter(verbose,FileBuffer,"PsiType", 0, 1, 1, int_type, &di, 1, critical); 767 if (di >= 0 && di < 2) { 768 config::PsiType = di; 769 } else { 770 fprintf(stderr, "0 <= PsiType < 2: 0 UseSpinDouble, 1 UseSpinUpDown"); 771 exit(1); 772 } 773 switch (config::PsiType) { 774 case 0: // SpinDouble 775 ParseForParameter(verbose,FileBuffer,"MaxPsiDouble", 0, 1, 1, int_type, &(config::MaxPsiDouble), 1, critical); 776 ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(config::AddPsis), 1, optional); 777 break; 778 case 1: // SpinUpDown 779 if (config::ProcPEGamma % 2) config::ProcPEGamma*=2; 780 ParseForParameter(verbose,FileBuffer,"PsiMaxNoUp", 0, 1, 1, int_type, &(config::PsiMaxNoUp), 1, critical); 781 ParseForParameter(verbose,FileBuffer,"PsiMaxNoDown", 0, 1, 1, int_type, &(config::PsiMaxNoDown), 1, critical); 782 ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(config::AddPsis), 1, optional); 783 break; 784 } 785 786 // IonsInitRead 787 788 ParseForParameter(verbose,FileBuffer,"RCut", 0, 1, 1, double_type, &(config::RCut), 1, critical); 789 ParseForParameter(verbose,FileBuffer,"IsAngstroem", 0, 1, 1, int_type, &(config::IsAngstroem), 1, critical); 790 ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(config::MaxTypes), 1, critical); 791 if (!ParseForParameter(verbose,FileBuffer,"RelativeCoord", 0, 1, 1, int_type, &(config::RelativeCoord) , 1, optional)) 792 config::RelativeCoord = 0; 793 if (!ParseForParameter(verbose,FileBuffer,"StructOpt", 0, 1, 1, int_type, &(config::StructOpt), 1, optional)) 794 config::StructOpt = 0; 795 if (MaxTypes == 0) { 796 cerr << "There are no atoms according to MaxTypes in this config file." << endl; 797 } else { 798 // prescan number of ions per type 799 cout << Verbose(0) << "Prescanning ions per type: " << endl; 800 int NoAtoms = 0; 801 for (int i=0; i < config::MaxTypes; i++) { 802 sprintf(name,"Ion_Type%i",i+1); 803 ParseForParameter(verbose,FileBuffer, (const char*)name, 0, 1, 1, int_type, &No[i], 1, critical); 804 ParseForParameter(verbose,FileBuffer, name, 0, 2, 1, int_type, &Z, 1, critical); 805 elementhash[i] = periode->FindElement(Z); 806 cout << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl; 807 NoAtoms += No[i]; 808 } 809 int repetition = 0; // which repeated keyword shall be read 810 811 // sort the lines via the LineMapping 812 812 sprintf(name,"Ion_Type%i",config::MaxTypes); 813 814 813 if (!ParseForParameter(verbose,FileBuffer, (const char*)name, 1, 1, 1, int_type, &value[0], 1, critical)) { 814 cerr << "There are no atoms in the config file!" << endl; 815 815 return; 816 816 } 817 818 819 820 821 //cout << FileBuffer->buffer[ FileBuffer->LineMapping[FileBuffer->CurrentLine+i]];822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 817 FileBuffer->CurrentLine++; 818 //cout << FileBuffer->buffer[ FileBuffer->LineMapping[FileBuffer->CurrentLine]]; 819 FileBuffer->MapIonTypesInBuffer(NoAtoms); 820 //for (int i=0; i<(NoAtoms < 100 ? NoAtoms : 100 < 100 ? NoAtoms : 100);++i) { 821 // cout << FileBuffer->buffer[ FileBuffer->LineMapping[FileBuffer->CurrentLine+i]]; 822 //} 823 824 map<int, atom *> AtomList[config::MaxTypes]; 825 map<int, atom *> LinearList; 826 if (!FastParsing) { 827 // parse in trajectories 828 bool status = true; 829 atom *neues = NULL; 830 while (status) { 831 cout << "Currently parsing MD step " << repetition << "." << endl; 832 for (int i=0; i < config::MaxTypes; i++) { 833 sprintf(name,"Ion_Type%i",i+1); 834 for(int j=0;j<No[i];j++) { 835 sprintf(keyword,"%s_%i",name, j+1); 836 if (repetition == 0) { 837 neues = new atom(); 838 AtomList[i][j] = neues; 839 LinearList[FileBuffer->CurrentLine] = neues; 840 neues->type = elementhash[i]; // find element type 841 } else 842 neues = AtomList[i][j]; 843 843 status = (status && 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 //cout << "Parsed position of step " << (repetition) << ": (";883 //for (int d=0;d<NDIM;d++)884 // cout << mol->Trajectories[neues].R.at(repetition).x[d] << " ";// next step885 //cout << ")\t(";886 //for (int d=0;d<NDIM;d++)887 // cout << mol->Trajectories[neues].U.at(repetition).x[d] << " ";// next step888 //cout << ")\t(";889 //for (int d=0;d<NDIM;d++)890 // cout << mol->Trajectories[neues].F.at(repetition).x[d] << " ";// next step891 //cout << ")" << endl;892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 844 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x.x[0], 1, (repetition == 0) ? critical : optional) && 845 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x.x[1], 1, (repetition == 0) ? critical : optional) && 846 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x.x[2], 1, (repetition == 0) ? critical : optional) && 847 ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, 1, (repetition == 0) ? critical : optional)); 848 if (!status) break; 849 850 // check size of vectors 851 if (mol->Trajectories[neues].R.size() <= (unsigned int)(repetition)) { 852 //cout << "Increasing size for trajectory array of " << keyword << " to " << (repetition+10) << "." << endl; 853 mol->Trajectories[neues].R.resize(repetition+10); 854 mol->Trajectories[neues].U.resize(repetition+10); 855 mol->Trajectories[neues].F.resize(repetition+10); 856 } 857 858 // put into trajectories list 859 for (int d=0;d<NDIM;d++) 860 mol->Trajectories[neues].R.at(repetition).x[d] = neues->x.x[d]; 861 862 // parse velocities if present 863 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->v.x[0], 1,optional)) 864 neues->v.x[0] = 0.; 865 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->v.x[1], 1,optional)) 866 neues->v.x[1] = 0.; 867 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->v.x[2], 1,optional)) 868 neues->v.x[2] = 0.; 869 for (int d=0;d<NDIM;d++) 870 mol->Trajectories[neues].U.at(repetition).x[d] = neues->v.x[d]; 871 872 // parse forces if present 873 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 8, 1, double_type, &value[0], 1,optional)) 874 value[0] = 0.; 875 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 9, 1, double_type, &value[1], 1,optional)) 876 value[1] = 0.; 877 if(!ParseForParameter(verbose,FileBuffer, keyword, 1, 10, 1, double_type, &value[2], 1,optional)) 878 value[2] = 0.; 879 for (int d=0;d<NDIM;d++) 880 mol->Trajectories[neues].F.at(repetition).x[d] = value[d]; 881 882 // cout << "Parsed position of step " << (repetition) << ": ("; 883 // for (int d=0;d<NDIM;d++) 884 // cout << mol->Trajectories[neues].R.at(repetition).x[d] << " "; // next step 885 // cout << ")\t("; 886 // for (int d=0;d<NDIM;d++) 887 // cout << mol->Trajectories[neues].U.at(repetition).x[d] << " "; // next step 888 // cout << ")\t("; 889 // for (int d=0;d<NDIM;d++) 890 // cout << mol->Trajectories[neues].F.at(repetition).x[d] << " "; // next step 891 // cout << ")" << endl; 892 } 893 } 894 repetition++; 895 } 896 // put atoms into the molecule in their original order 897 for(map<int, atom*>::iterator runner = LinearList.begin(); runner != LinearList.end(); ++runner) { 898 mol->AddAtom(runner->second); 899 } 900 repetition--; 901 cout << "Found " << repetition << " trajectory steps." << endl; 902 mol->MDSteps = repetition; 903 } else { 904 // find the maximum number of MD steps so that we may parse last one (Ion_Type1_1 must always be present, because is the first atom) 905 repetition = 0; 906 while ( ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 1, 1, double_type, &value[0], repetition, (repetition == 0) ? critical : optional) && 907 ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 2, 1, double_type, &value[1], repetition, (repetition == 0) ? critical : optional) && 908 ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 3, 1, double_type, &value[2], repetition, (repetition == 0) ? critical : optional)) 909 repetition++; 910 cout << "I found " << repetition << " times the keyword Ion_Type1_1." << endl; 911 // parse in molecule coordinates 912 for (int i=0; i < config::MaxTypes; i++) { 913 sprintf(name,"Ion_Type%i",i+1); 914 for(int j=0;j<No[i];j++) { 915 sprintf(keyword,"%s_%i",name, j+1); 916 atom *neues = new atom(); 917 // then parse for each atom the coordinates as often as present 918 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x.x[0], repetition,critical); 919 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x.x[1], repetition,critical); 920 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x.x[2], repetition,critical); 921 ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, repetition,critical); 922 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->v.x[0], repetition,optional)) 923 neues->v.x[0] = 0.; 924 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->v.x[1], repetition,optional)) 925 neues->v.x[1] = 0.; 926 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->v.x[2], repetition,optional)) 927 neues->v.x[2] = 0.; 928 // here we don't care if forces are present (last in trajectories is always equal to current position) 929 neues->type = elementhash[i]; // find element type 930 mol->AddAtom(neues); 931 } 932 } 933 } 934 } 935 delete(FileBuffer); 936 936 }; 937 937 … … 943 943 void config::LoadOld(char *filename, periodentafel *periode, molecule *mol) 944 944 { 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 input >> AtomNo;// number of atoms1112 input >> Z;// atomic number1113 1114 1115 1116 input >> b;// element mass1117 1118 cout << Verbose(1) << "AtomNo: " << AtomNo << "\tZ: " << Z << "\ta:" << a << "\tl:"<< l << "\b:" << b << "\tElement:" << elementhash[No] << "\t:" << endl;1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 945 ifstream *file = new ifstream(filename); 946 if (file == NULL) { 947 cerr << "ERROR: config file " << filename << " missing!" << endl; 948 return; 949 } 950 RetrieveConfigPathAndName(filename); 951 // ParseParameters 952 953 /* Oeffne Hauptparameterdatei */ 954 int l, i, di; 955 double a,b; 956 double BoxLength[9]; 957 string zeile; 958 string dummy; 959 element *elementhash[128]; 960 int Z, No, AtomNo, found; 961 int verbose = 0; 962 963 /* Namen einlesen */ 964 965 ParseForParameter(verbose,file, "mainname", 0, 1, 1, string_type, (config::mainname), 1, critical); 966 ParseForParameter(verbose,file, "defaultpath", 0, 1, 1, string_type, (config::defaultpath), 1, critical); 967 ParseForParameter(verbose,file, "pseudopotpath", 0, 1, 1, string_type, (config::pseudopotpath), 1, critical); 968 ParseForParameter(verbose,file, "ProcsGammaPsi", 0, 1, 1, int_type, &(config::ProcPEGamma), 1, critical); 969 ParseForParameter(verbose,file, "ProcsGammaPsi", 0, 2, 1, int_type, &(config::ProcPEPsi), 1, critical); 970 config::Seed = 1; 971 config::DoOutOrbitals = 0; 972 ParseForParameter(verbose,file,"DoOutVis", 0, 1, 1, int_type, &(config::DoOutVis), 1, critical); 973 if (config::DoOutVis < 0) config::DoOutVis = 0; 974 if (config::DoOutVis > 1) config::DoOutVis = 1; 975 config::VectorPlane = -1; 976 config::VectorCut = 0.; 977 ParseForParameter(verbose,file,"DoOutMes", 0, 1, 1, int_type, &(config::DoOutMes), 1, critical); 978 if (config::DoOutMes < 0) config::DoOutMes = 0; 979 if (config::DoOutMes > 1) config::DoOutMes = 1; 980 config::DoOutCurrent = 0; 981 ParseForParameter(verbose,file,"AddGramSch", 0, 1, 1, int_type, &(config::UseAddGramSch), 1, critical); 982 if (config::UseAddGramSch < 0) config::UseAddGramSch = 0; 983 if (config::UseAddGramSch > 2) config::UseAddGramSch = 2; 984 config::CommonWannier = 0; 985 config::SawtoothStart = 0.01; 986 987 ParseForParameter(verbose,file,"MaxOuterStep", 0, 1, 1, double_type, &(config::MaxOuterStep), 1, critical); 988 ParseForParameter(verbose,file,"Deltat", 0, 1, 1, double_type, &(config::Deltat), 1, optional); 989 ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 990 ParseForParameter(verbose,file,"VisSrcOuterStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 991 ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional); 992 ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 993 config::EpsWannier = 1e-8; 994 995 // stop conditions 996 //if (config::MaxOuterStep <= 0) config::MaxOuterStep = 1; 997 ParseForParameter(verbose,file,"MaxPsiStep", 0, 1, 1, int_type, &(config::MaxPsiStep), 1, critical); 998 if (config::MaxPsiStep <= 0) config::MaxPsiStep = 3; 999 1000 ParseForParameter(verbose,file,"MaxMinStep", 0, 1, 1, int_type, &(config::MaxMinStep), 1, critical); 1001 ParseForParameter(verbose,file,"MaxMinStep", 0, 2, 1, double_type, &(config::RelEpsTotalEnergy), 1, critical); 1002 ParseForParameter(verbose,file,"MaxMinStep", 0, 3, 1, double_type, &(config::RelEpsKineticEnergy), 1, critical); 1003 ParseForParameter(verbose,file,"MaxMinStep", 0, 4, 1, int_type, &(config::MaxMinStopStep), 1, critical); 1004 if (config::MaxMinStep <= 0) config::MaxMinStep = config::MaxPsiStep; 1005 if (config::MaxMinStopStep < 1) config::MaxMinStopStep = 1; 1006 config::MaxMinGapStopStep = 1; 1007 1008 ParseForParameter(verbose,file,"MaxInitMinStep", 0, 1, 1, int_type, &(config::MaxInitMinStep), 1, critical); 1009 ParseForParameter(verbose,file,"MaxInitMinStep", 0, 2, 1, double_type, &(config::InitRelEpsTotalEnergy), 1, critical); 1010 ParseForParameter(verbose,file,"MaxInitMinStep", 0, 3, 1, double_type, &(config::InitRelEpsKineticEnergy), 1, critical); 1011 ParseForParameter(verbose,file,"MaxInitMinStep", 0, 4, 1, int_type, &(config::InitMaxMinStopStep), 1, critical); 1012 if (config::MaxInitMinStep <= 0) config::MaxInitMinStep = config::MaxPsiStep; 1013 if (config::InitMaxMinStopStep < 1) config::InitMaxMinStopStep = 1; 1014 config::InitMaxMinGapStopStep = 1; 1015 1016 ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 1017 mol->cell_size[0] = BoxLength[0]; 1018 mol->cell_size[1] = BoxLength[3]; 1019 mol->cell_size[2] = BoxLength[4]; 1020 mol->cell_size[3] = BoxLength[6]; 1021 mol->cell_size[4] = BoxLength[7]; 1022 mol->cell_size[5] = BoxLength[8]; 1023 if (1) fprintf(stderr,"\n"); 1024 config::DoPerturbation = 0; 1025 config::DoFullCurrent = 0; 1026 1027 ParseForParameter(verbose,file,"ECut", 0, 1, 1, double_type, &(config::ECut), 1, critical); 1028 ParseForParameter(verbose,file,"MaxLevel", 0, 1, 1, int_type, &(config::MaxLevel), 1, critical); 1029 ParseForParameter(verbose,file,"Level0Factor", 0, 1, 1, int_type, &(config::Lev0Factor), 1, critical); 1030 if (config::Lev0Factor < 2) { 1031 config::Lev0Factor = 2; 1032 } 1033 ParseForParameter(verbose,file,"RiemannTensor", 0, 1, 1, int_type, &di, 1, critical); 1034 if (di >= 0 && di < 2) { 1035 config::RiemannTensor = di; 1036 } else { 1037 fprintf(stderr, "0 <= RiemanTensor < 2: 0 UseNotRT, 1 UseRT"); 1038 exit(1); 1039 } 1040 switch (config::RiemannTensor) { 1041 case 0: //UseNoRT 1042 if (config::MaxLevel < 2) { 1043 config::MaxLevel = 2; 1044 } 1045 config::LevRFactor = 2; 1046 config::RTActualUse = 0; 1047 break; 1048 case 1: // UseRT 1049 if (config::MaxLevel < 3) { 1050 config::MaxLevel = 3; 1051 } 1052 ParseForParameter(verbose,file,"RiemannLevel", 0, 1, 1, int_type, &(config::RiemannLevel), 1, critical); 1053 if (config::RiemannLevel < 2) { 1054 config::RiemannLevel = 2; 1055 } 1056 if (config::RiemannLevel > config::MaxLevel-1) { 1057 config::RiemannLevel = config::MaxLevel-1; 1058 } 1059 ParseForParameter(verbose,file,"LevRFactor", 0, 1, 1, int_type, &(config::LevRFactor), 1, critical); 1060 if (config::LevRFactor < 2) { 1061 config::LevRFactor = 2; 1062 } 1063 config::Lev0Factor = 2; 1064 config::RTActualUse = 2; 1065 break; 1066 } 1067 ParseForParameter(verbose,file,"PsiType", 0, 1, 1, int_type, &di, 1, critical); 1068 if (di >= 0 && di < 2) { 1069 config::PsiType = di; 1070 } else { 1071 fprintf(stderr, "0 <= PsiType < 2: 0 UseSpinDouble, 1 UseSpinUpDown"); 1072 exit(1); 1073 } 1074 switch (config::PsiType) { 1075 case 0: // SpinDouble 1076 ParseForParameter(verbose,file,"MaxPsiDouble", 0, 1, 1, int_type, &(config::MaxPsiDouble), 1, critical); 1077 config::AddPsis = 0; 1078 break; 1079 case 1: // SpinUpDown 1080 if (config::ProcPEGamma % 2) config::ProcPEGamma*=2; 1081 ParseForParameter(verbose,file,"MaxPsiUp", 0, 1, 1, int_type, &(config::PsiMaxNoUp), 1, critical); 1082 ParseForParameter(verbose,file,"MaxPsiDown", 0, 1, 1, int_type, &(config::PsiMaxNoDown), 1, critical); 1083 config::AddPsis = 0; 1084 break; 1085 } 1086 1087 // IonsInitRead 1088 1089 ParseForParameter(verbose,file,"RCut", 0, 1, 1, double_type, &(config::RCut), 1, critical); 1090 ParseForParameter(verbose,file,"IsAngstroem", 0, 1, 1, int_type, &(config::IsAngstroem), 1, critical); 1091 config::RelativeCoord = 0; 1092 config::StructOpt = 0; 1093 1094 // Routine from builder.cpp 1095 1096 1097 for (i=MAX_ELEMENTS;i--;) 1098 elementhash[i] = NULL; 1099 cout << Verbose(0) << "Parsing Ions ..." << endl; 1100 No=0; 1101 found = 0; 1102 while (getline(*file,zeile,'\n')) { 1103 if (zeile.find("Ions_Data") == 0) { 1104 cout << Verbose(1) << "found Ions_Data...begin parsing" << endl; 1105 found ++; 1106 } 1107 if (found > 0) { 1108 if (zeile.find("Ions_Data") == 0) 1109 getline(*file,zeile,'\n'); // read next line and parse this one 1110 istringstream input(zeile); 1111 input >> AtomNo; // number of atoms 1112 input >> Z; // atomic number 1113 input >> a; 1114 input >> l; 1115 input >> l; 1116 input >> b; // element mass 1117 elementhash[No] = periode->FindElement(Z); 1118 cout << Verbose(1) << "AtomNo: " << AtomNo << "\tZ: " << Z << "\ta:" << a << "\tl:" << l << "\b:" << b << "\tElement:" << elementhash[No] << "\t:" << endl; 1119 for(i=0;i<AtomNo;i++) { 1120 if (!getline(*file,zeile,'\n')) {// parse on and on 1121 cout << Verbose(2) << "Error: Too few items in ionic list of element" << elementhash[No] << "." << endl << "Exiting." << endl; 1122 // return 1; 1123 } else { 1124 //cout << Verbose(2) << "Reading line: " << zeile << endl; 1125 } 1126 istringstream input2(zeile); 1127 atom *neues = new atom(); 1128 input2 >> neues->x.x[0]; // x 1129 input2 >> neues->x.x[1]; // y 1130 input2 >> neues->x.x[2]; // z 1131 input2 >> l; 1132 neues->type = elementhash[No]; // find element type 1133 mol->AddAtom(neues); 1134 } 1135 No++; 1136 } 1137 } 1138 file->close(); 1139 delete(file); 1140 1140 }; 1141 1141 … … 1147 1147 bool config::Save(const char *filename, periodentafel *periode, molecule *mol) const 1148 1148 { 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 //switch (PsiType) {1220 //case 0:1221 1222 //break;1223 //case 1:1224 1225 1226 //break;1227 //}1228 1229 1230 1231 1232 1233 1234 *output << "MaxTypes\t" << mol->ElementCount <<"\t# maximum number of different ion types" << endl;1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1149 bool result = true; 1150 // bring MaxTypes up to date 1151 mol->CountElements(); 1152 ofstream *output = NULL; 1153 output = new ofstream(filename, ios::out); 1154 if (output != NULL) { 1155 *output << "# ParallelCarParinello - main configuration file - created with molecuilder" << endl; 1156 *output << endl; 1157 *output << "mainname\t" << config::mainname << "\t# programm name (for runtime files)" << endl; 1158 *output << "defaultpath\t" << config::defaultpath << "\t# where to put files during runtime" << endl; 1159 *output << "pseudopotpath\t" << config::pseudopotpath << "\t# where to find pseudopotentials" << endl; 1160 *output << endl; 1161 *output << "ProcPEGamma\t" << config::ProcPEGamma << "\t# for parallel computing: share constants" << endl; 1162 *output << "ProcPEPsi\t" << config::ProcPEPsi << "\t# for parallel computing: share wave functions" << endl; 1163 *output << "DoOutVis\t" << config::DoOutVis << "\t# Output data for OpenDX" << endl; 1164 *output << "DoOutMes\t" << config::DoOutMes << "\t# Output data for measurements" << endl; 1165 *output << "DoOutOrbitals\t" << config::DoOutOrbitals << "\t# Output all Orbitals" << endl; 1166 *output << "DoOutCurr\t" << config::DoOutCurrent << "\t# Ouput current density for OpenDx" << endl; 1167 *output << "DoOutNICS\t" << config::DoOutNICS << "\t# Output Nucleus independent current shieldings" << endl; 1168 *output << "DoPerturbation\t" << config::DoPerturbation << "\t# Do perturbation calculate and determine susceptibility and shielding" << endl; 1169 *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl; 1170 *output << "CommonWannier\t" << config::CommonWannier << "\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center" << endl; 1171 *output << "SawtoothStart\t" << config::SawtoothStart << "\t# Absolute value for smooth transition at cell border " << endl; 1172 *output << "VectorPlane\t" << config::VectorPlane << "\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot" << endl; 1173 *output << "VectorCut\t" << config::VectorCut << "\t# Cut plane axis value" << endl; 1174 *output << "AddGramSch\t" << config::UseAddGramSch << "\t# Additional GramSchmidtOrtogonalization to be safe" << endl; 1175 *output << "Seed\t\t" << config::Seed << "\t# initial value for random seed for Psi coefficients" << endl; 1176 *output << endl; 1177 *output << "MaxOuterStep\t" << config::MaxOuterStep << "\t# number of MolecularDynamics/Structure optimization steps" << endl; 1178 *output << "Deltat\t" << config::Deltat << "\t# time per MD step" << endl; 1179 *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl; 1180 *output << "OutSrcStep\t" << config::OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl; 1181 *output << "TargetTemp\t" << config::TargetTemp << "\t# Target temperature" << endl; 1182 *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl; 1183 *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl; 1184 *output << endl; 1185 *output << "# Values specifying when to stop" << endl; 1186 *output << "MaxMinStep\t" << config::MaxMinStep << "\t# Maximum number of steps" << endl; 1187 *output << "RelEpsTotalE\t" << config::RelEpsTotalEnergy << "\t# relative change in total energy" << endl; 1188 *output << "RelEpsKineticE\t" << config::RelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl; 1189 *output << "MaxMinStopStep\t" << config::MaxMinStopStep << "\t# check every ..th steps" << endl; 1190 *output << "MaxMinGapStopStep\t" << config::MaxMinGapStopStep << "\t# check every ..th steps" << endl; 1191 *output << endl; 1192 *output << "# Values specifying when to stop for INIT, otherwise same as above" << endl; 1193 *output << "MaxInitMinStep\t" << config::MaxInitMinStep << "\t# Maximum number of steps" << endl; 1194 *output << "InitRelEpsTotalE\t" << config::InitRelEpsTotalEnergy << "\t# relative change in total energy" << endl; 1195 *output << "InitRelEpsKineticE\t" << config::InitRelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl; 1196 *output << "InitMaxMinStopStep\t" << config::InitMaxMinStopStep << "\t# check every ..th steps" << endl; 1197 *output << "InitMaxMinGapStopStep\t" << config::InitMaxMinGapStopStep << "\t# check every ..th steps" << endl; 1198 *output << endl; 1199 *output << "BoxLength\t\t\t# (Length of a unit cell)" << endl; 1200 *output << mol->cell_size[0] << "\t" << endl; 1201 *output << mol->cell_size[1] << "\t" << mol->cell_size[2] << "\t" << endl; 1202 *output << mol->cell_size[3] << "\t" << mol->cell_size[4] << "\t" << mol->cell_size[5] << "\t" << endl; 1203 // FIXME 1204 *output << endl; 1205 *output << "ECut\t\t" << config::ECut << "\t# energy cutoff for discretization in Hartrees" << endl; 1206 *output << "MaxLevel\t" << config::MaxLevel << "\t# number of different levels in the code, >=2" << endl; 1207 *output << "Level0Factor\t" << config::Lev0Factor << "\t# factor by which node number increases from S to 0 level" << endl; 1208 *output << "RiemannTensor\t" << config::RiemannTensor << "\t# (Use metric)" << endl; 1209 switch (config::RiemannTensor) { 1210 case 0: //UseNoRT 1211 break; 1212 case 1: // UseRT 1213 *output << "RiemannLevel\t" << config::RiemannLevel << "\t# Number of Riemann Levels" << endl; 1214 *output << "LevRFactor\t" << config::LevRFactor << "\t# factor by which node number increases from 0 to R level from" << endl; 1215 break; 1216 } 1217 *output << "PsiType\t\t" << config::PsiType << "\t# 0 - doubly occupied, 1 - SpinUp,SpinDown" << endl; 1218 // write out both types for easier changing afterwards 1219 // switch (PsiType) { 1220 // case 0: 1221 *output << "MaxPsiDouble\t" << config::MaxPsiDouble << "\t# here: specifying both maximum number of SpinUp- and -Down-states" << endl; 1222 // break; 1223 // case 1: 1224 *output << "PsiMaxNoUp\t" << config::PsiMaxNoUp << "\t# here: specifying maximum number of SpinUp-states" << endl; 1225 *output << "PsiMaxNoDown\t" << config::PsiMaxNoDown << "\t# here: specifying maximum number of SpinDown-states" << endl; 1226 // break; 1227 // } 1228 *output << "AddPsis\t\t" << config::AddPsis << "\t# Additional unoccupied Psis for bandgap determination" << endl; 1229 *output << endl; 1230 *output << "RCut\t\t" << config::RCut << "\t# R-cut for the ewald summation" << endl; 1231 *output << "StructOpt\t" << config::StructOpt << "\t# Do structure optimization beforehand" << endl; 1232 *output << "IsAngstroem\t" << config::IsAngstroem << "\t# 0 - Bohr, 1 - Angstroem" << endl; 1233 *output << "RelativeCoord\t" << config::RelativeCoord << "\t# whether ion coordinates are relative (1) or absolute (0)" << endl; 1234 *output << "MaxTypes\t" << mol->ElementCount << "\t# maximum number of different ion types" << endl; 1235 *output << endl; 1236 result = result && mol->Checkout(output); 1237 if (mol->MDSteps <=1 ) 1238 result = result && mol->Output(output); 1239 else 1240 result = result && mol->OutputTrajectories(output); 1241 output->close(); 1242 output->clear(); 1243 delete(output); 1244 return result; 1245 } else 1246 return false; 1247 1247 }; 1248 1248 … … 1254 1254 bool config::SaveMPQC(const char *filename, molecule *mol) const 1255 1255 { 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1256 int ElementNo = 0; 1257 int AtomNo; 1258 atom *Walker = NULL; 1259 element *runner = NULL; 1260 Vector *center = NULL; 1261 ofstream *output = NULL; 1262 stringstream *fname = NULL; 1263 1264 // first without hessian 1265 fname = new stringstream; 1266 *fname << filename << ".in"; 1267 output = new ofstream(fname->str().c_str(), ios::out); 1268 *output << "% Created by MoleCuilder" << endl; 1269 *output << "mpqc: (" << endl; 1270 *output << "\tsavestate = no" << endl; 1271 *output << "\tdo_gradient = yes" << endl; 1272 *output << "\tmole<MBPT2>: (" << endl; 1273 *output << "\t\tmaxiter = 200" << endl; 1274 *output << "\t\tbasis = $:basis" << endl; 1275 *output << "\t\tmolecule = $:molecule" << endl; 1276 *output << "\t\treference<CLHF>: (" << endl; 1277 *output << "\t\t\tbasis = $:basis" << endl; 1278 *output << "\t\t\tmolecule = $:molecule" << endl; 1279 *output << "\t\t)" << endl; 1280 *output << "\t)" << endl; 1281 *output << ")" << endl; 1282 *output << "molecule<Molecule>: (" << endl; 1283 *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl; 1284 *output << "\t{ atoms geometry } = {" << endl; 1285 center = mol->DetermineCenterOfAll(output); 1286 // output of atoms 1287 runner = mol->elemente->start; 1288 while (runner->next != mol->elemente->end) { // go through every element 1289 runner = runner->next; 1290 if (mol->ElementsInMolecule[runner->Z]) { // if this element got atoms 1291 ElementNo++; 1292 AtomNo = 0; 1293 Walker = mol->start; 1294 while (Walker->next != mol->end) { // go through every atom of this element 1295 Walker = Walker->next; 1296 if (Walker->type == runner) { // if this atom fits to element 1297 AtomNo++; 1298 *output << "\t\t" << Walker->type->symbol << " [ " << Walker->x.x[0]-center->x[0] << "\t" << Walker->x.x[1]-center->x[1] << "\t" << Walker->x.x[2]-center->x[2] << " ]" << endl; 1299 } 1300 } 1301 } 1302 } 1303 delete(center); 1304 *output << "\t}" << endl; 1305 *output << ")" << endl; 1306 *output << "basis<GaussianBasisSet>: (" << endl; 1307 *output << "\tname = \""<< basis << "\"" << endl; 1308 *output << "\tmolecule = $:molecule" << endl; 1309 *output << ")" << endl; 1310 output->close(); 1311 delete(output); 1312 delete(fname); 1313 1314 // second with hessian 1315 fname = new stringstream; 1316 *fname << filename << ".hess.in"; 1317 output = new ofstream(fname->str().c_str(), ios::out); 1318 *output << "% Created by MoleCuilder" << endl; 1319 *output << "mpqc: (" << endl; 1320 *output << "\tsavestate = no" << endl; 1321 *output << "\tdo_gradient = yes" << endl; 1322 *output << "\tmole<CLHF>: (" << endl; 1323 *output << "\t\tmaxiter = 200" << endl; 1324 *output << "\t\tbasis = $:basis" << endl; 1325 *output << "\t\tmolecule = $:molecule" << endl; 1326 *output << "\t)" << endl; 1327 *output << "\tfreq<MolecularFrequencies>: (" << endl; 1328 *output << "\t\tmolecule=$:molecule" << endl; 1329 *output << "\t)" << endl; 1330 *output << ")" << endl; 1331 *output << "molecule<Molecule>: (" << endl; 1332 *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl; 1333 *output << "\t{ atoms geometry } = {" << endl; 1334 center = mol->DetermineCenterOfAll(output); 1335 // output of atoms 1336 runner = mol->elemente->start; 1337 while (runner->next != mol->elemente->end) { // go through every element 1338 runner = runner->next; 1339 if (mol->ElementsInMolecule[runner->Z]) { // if this element got atoms 1340 ElementNo++; 1341 AtomNo = 0; 1342 Walker = mol->start; 1343 while (Walker->next != mol->end) { // go through every atom of this element 1344 Walker = Walker->next; 1345 if (Walker->type == runner) { // if this atom fits to element 1346 AtomNo++; 1347 *output << "\t\t" << Walker->type->symbol << " [ " << Walker->x.x[0]-center->x[0] << "\t" << Walker->x.x[1]-center->x[1] << "\t" << Walker->x.x[2]-center->x[2] << " ]" << endl; 1348 } 1349 } 1350 } 1351 } 1352 delete(center); 1353 *output << "\t}" << endl; 1354 *output << ")" << endl; 1355 *output << "basis<GaussianBasisSet>: (" << endl; 1356 *output << "\tname = \"3-21G\"" << endl; 1357 *output << "\tmolecule = $:molecule" << endl; 1358 *output << ")" << endl; 1359 output->close(); 1360 delete(output); 1361 delete(fname); 1362 1363 return true; 1364 1364 }; 1365 1365 … … 1373 1373 * \param name Name of value in file (at least 3 chars!) 1374 1374 * \param sequential 1 - do not reset file pointer to begin of file, 0 - set to beginning 1375 * 1376 * 1377 * 1375 * (if file is sequentially parsed this can be way faster! However, beware of multiple values per line, as whole line is read - 1376 * best approach: 0 0 0 1 (not resetted only on last value of line) - and of yth, which is now 1377 * counted from this unresetted position!) 1378 1378 * \param xth Which among a number of parameters it is (in grid case it's row number as grid is read as a whole!) 1379 1379 * \param yth In grid case specifying column number, otherwise the yth \a name matching line … … 1386 1386 */ 1387 1387 int config::ParseForParameter(int verbose, ifstream *file, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical) { 1388 int i,j;// loop variables1389 1390 1391 char *dummy1, *dummy, *free_dummy;// pointers in the line that is read in per step1392 1393 1394 1395 1396 1397 1398 1399 1400 int found = (type >= grid) ? 0 : (-yth + 1);// marks if yth parameter name was found1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 file->seekg(file_position, ios::beg);// rewind to start position1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 dummy = strchr(dummy1,'\t');// set dummy on first tab or space which ever's nearer1438 1439 dummy = strchr(dummy1, ' ');// if not found seek for space1440 while ((dummy != NULL) && ((*dummy == '\t') || (*dummy == ' ')))// skip some more tabs and spaces if necessary1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 file->seekg(file_position, ios::beg);// rewind to start position1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 while ((*dummy == '\t') || (*dummy == ' '))// skip interjacent tabs and spaces1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 dummy = strchr(dummy1, ' ');// if not found seek for space1511 1512 dummy = strchr(dummy1, '\n');// ... at line end then1513 if ((j < yth-1) && (type < 4)) {// check if xth value or not yet1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 file->seekg(file_position, ios::beg);// rewind to start position1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 file->seekg(file_position, ios::beg);// rewind to start position1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 strncpy((char *)value, dummy1, length);// copy as much1576 ((char *)value)[length] = '\0';// and set end marker1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 file->seekg(file_position, ios::beg);// rewind to start position1596 1597 1598 1599 1388 int i,j; // loop variables 1389 int length = 0, maxlength = -1; 1390 long file_position = file->tellg(); // mark current position 1391 char *dummy1, *dummy, *free_dummy; // pointers in the line that is read in per step 1392 dummy1 = free_dummy = (char *) Malloc(256 * sizeof(char), "config::ParseForParameter: *free_dummy"); 1393 1394 //fprintf(stderr,"Parsing for %s\n",name); 1395 if (repetition == 0) 1396 //Error(SomeError, "ParseForParameter(): argument repetition must not be 0!"); 1397 return 0; 1398 1399 int line = 0; // marks line where parameter was found 1400 int found = (type >= grid) ? 0 : (-yth + 1); // marks if yth parameter name was found 1401 while((found != repetition)) { 1402 dummy1 = dummy = free_dummy; 1403 do { 1404 file->getline(dummy1, 256); // Read the whole line 1405 if (file->eof()) { 1406 if ((critical) && (found == 0)) { 1407 Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); 1408 //Error(InitReading, name); 1409 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); 1410 exit(255); 1411 } else { 1412 //if (!sequential) 1413 file->clear(); 1414 file->seekg(file_position, ios::beg); // rewind to start position 1415 Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); 1416 return 0; 1417 } 1418 } 1419 line++; 1420 } while (dummy != NULL && dummy1 != NULL && ((dummy1[0] == '#') || (dummy1[0] == '\0'))); // skip commentary and empty lines 1421 1422 // C++ getline removes newline at end, thus re-add 1423 if ((dummy1 != NULL) && (strchr(dummy1,'\n') == NULL)) { 1424 i = strlen(dummy1); 1425 dummy1[i] = '\n'; 1426 dummy1[i+1] = '\0'; 1427 } 1428 //fprintf(stderr,"line %i ends at %i, newline at %i\n", line, strlen(dummy1), strchr(dummy1,'\n')-free_dummy); 1429 1430 if (dummy1 == NULL) { 1431 if (verbose) fprintf(stderr,"Error reading line %i\n",line); 1432 } else { 1433 //fprintf(stderr,"Now parsing the line %i: %s\n", line, dummy1); 1434 } 1435 // Seek for possible end of keyword on line if given ... 1436 if (name != NULL) { 1437 dummy = strchr(dummy1,'\t'); // set dummy on first tab or space which ever's nearer 1438 if (dummy == NULL) { 1439 dummy = strchr(dummy1, ' '); // if not found seek for space 1440 while ((dummy != NULL) && ((*dummy == '\t') || (*dummy == ' '))) // skip some more tabs and spaces if necessary 1441 dummy++; 1442 } 1443 if (dummy == NULL) { 1444 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword) 1445 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); 1446 //Free((void **)&free_dummy); 1447 //Error(FileOpenParams, NULL); 1448 } else { 1449 //fprintf(stderr,"found tab at %i\n",(char *)dummy-(char *)dummy1); 1450 } 1451 } else dummy = dummy1; 1452 // ... and check if it is the keyword! 1453 //fprintf(stderr,"name %p, dummy %i/%c, dummy1 %i/%c, strlen(name) %i\n", &name, dummy, *dummy, dummy1, *dummy1, strlen(name)); 1454 if ((name == NULL) || (((dummy-dummy1 >= 3) && (strncmp(dummy1, name, strlen(name)) == 0)) && ((unsigned int)(dummy-dummy1) == strlen(name)))) { 1455 found++; // found the parameter! 1456 //fprintf(stderr,"found %s at line %i between %i and %i\n", name, line, dummy1, dummy); 1457 1458 if (found == repetition) { 1459 for (i=0;i<xth;i++) { // i = rows 1460 if (type >= grid) { 1461 // grid structure means that grid starts on the next line, not right after keyword 1462 dummy1 = dummy = free_dummy; 1463 do { 1464 file->getline(dummy1, 256); // Read the whole line, skip commentary and empty ones 1465 if (file->eof()) { 1466 if ((critical) && (found == 0)) { 1467 Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); 1468 //Error(InitReading, name); 1469 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); 1470 exit(255); 1471 } else { 1472 //if (!sequential) 1473 file->clear(); 1474 file->seekg(file_position, ios::beg); // rewind to start position 1475 Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); 1476 return 0; 1477 } 1478 } 1479 line++; 1480 } while ((dummy1[0] == '#') || (dummy1[0] == '\n')); 1481 if (dummy1 == NULL){ 1482 if (verbose) fprintf(stderr,"Error reading line %i\n", line); 1483 } else { 1484 //fprintf(stderr,"Reading next line %i: %s\n", line, dummy1); 1485 } 1486 } else { // simple int, strings or doubles start in the same line 1487 while ((*dummy == '\t') || (*dummy == ' ')) // skip interjacent tabs and spaces 1488 dummy++; 1489 } 1490 // C++ getline removes newline at end, thus re-add 1491 if ((dummy1 != NULL) && (strchr(dummy1,'\n') == NULL)) { 1492 j = strlen(dummy1); 1493 dummy1[j] = '\n'; 1494 dummy1[j+1] = '\0'; 1495 } 1496 1497 int start = (type >= grid) ? 0 : yth-1 ; 1498 for (j=start;j<yth;j++) { // j = columns 1499 // check for lower triangular area and upper triangular area 1500 if ( ((i > j) && (type == upper_trigrid)) || ((j > i) && (type == lower_trigrid))) { 1501 *((double *)value) = 0.0; 1502 fprintf(stderr,"%f\t",*((double *)value)); 1503 value = (void *)((long)value + sizeof(double)); 1504 //value += sizeof(double); 1505 } else { 1506 // otherwise we must skip all interjacent tabs and spaces and find next value 1507 dummy1 = dummy; 1508 dummy = strchr(dummy1, '\t'); // seek for tab or space 1509 if (dummy == NULL) 1510 dummy = strchr(dummy1, ' '); // if not found seek for space 1511 if (dummy == NULL) { // if still zero returned ... 1512 dummy = strchr(dummy1, '\n'); // ... at line end then 1513 if ((j < yth-1) && (type < 4)) { // check if xth value or not yet 1514 if (critical) { 1515 if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name); 1516 Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); 1517 //return 0; 1518 exit(255); 1519 //Error(FileOpenParams, NULL); 1520 } else { 1521 //if (!sequential) 1522 file->clear(); 1523 file->seekg(file_position, ios::beg); // rewind to start position 1524 Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); 1525 return 0; 1526 } 1527 } 1528 } else { 1529 //fprintf(stderr,"found tab at %i\n",(char *)dummy-(char *)free_dummy); 1530 } 1531 if (*dummy1 == '#') { 1532 // found comment, skipping rest of line 1533 //if (verbose) fprintf(stderr,"Error: '#' at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name); 1534 if (!sequential) { // here we need it! 1535 file->seekg(file_position, ios::beg); // rewind to start position 1536 } 1537 Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); 1538 return 0; 1539 } 1540 //fprintf(stderr,"value from %i to %i\n",(char *)dummy1-(char *)free_dummy,(char *)dummy-(char *)free_dummy); 1541 switch(type) { 1542 case (row_int): 1543 *((int *)value) = atoi(dummy1); 1544 if ((verbose) && (i==0) && (j==0)) fprintf(stderr,"%s = ", name); 1545 if (verbose) fprintf(stderr,"%i\t",*((int *)value)); 1546 value = (void *)((long)value + sizeof(int)); 1547 //value += sizeof(int); 1548 break; 1549 case(row_double): 1550 case(grid): 1551 case(lower_trigrid): 1552 case(upper_trigrid): 1553 *((double *)value) = atof(dummy1); 1554 if ((verbose) && (i==0) && (j==0)) fprintf(stderr,"%s = ", name); 1555 if (verbose) fprintf(stderr,"%lg\t",*((double *)value)); 1556 value = (void *)((long)value + sizeof(double)); 1557 //value += sizeof(double); 1558 break; 1559 case(double_type): 1560 *((double *)value) = atof(dummy1); 1561 if ((verbose) && (i == xth-1)) fprintf(stderr,"%s = %lg\n", name, *((double *) value)); 1562 //value += sizeof(double); 1563 break; 1564 case(int_type): 1565 *((int *)value) = atoi(dummy1); 1566 if ((verbose) && (i == xth-1)) fprintf(stderr,"%s = %i\n", name, *((int *) value)); 1567 //value += sizeof(int); 1568 break; 1569 default: 1570 case(string_type): 1571 if (value != NULL) { 1572 //if (maxlength == -1) maxlength = strlen((char *)value); // get maximum size of string array 1573 maxlength = MAXSTRINGSIZE; 1574 length = maxlength > (dummy-dummy1) ? (dummy-dummy1) : maxlength; // cap at maximum 1575 strncpy((char *)value, dummy1, length); // copy as much 1576 ((char *)value)[length] = '\0'; // and set end marker 1577 if ((verbose) && (i == xth-1)) fprintf(stderr,"%s is '%s' (%i chars)\n",name,((char *) value), length); 1578 //value += sizeof(char); 1579 } else { 1580 } 1581 break; 1582 } 1583 } 1584 while (*dummy == '\t') 1585 dummy++; 1586 } 1587 } 1588 } 1589 } 1590 } 1591 if ((type >= row_int) && (verbose)) fprintf(stderr,"\n"); 1592 Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); 1593 if (!sequential) { 1594 file->clear(); 1595 file->seekg(file_position, ios::beg); // rewind to start position 1596 } 1597 //fprintf(stderr, "End of Parsing\n\n"); 1598 1599 return (found); // true if found, false if not 1600 1600 } 1601 1601
Note:
See TracChangeset
for help on using the changeset viewer.