Changes in src/molecule_dynamics.cpp [1513a74:920c70]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_dynamics.cpp
r1513a74 r920c70 10 10 #include "config.hpp" 11 11 #include "element.hpp" 12 #include "info.hpp" 12 13 #include "log.hpp" 13 14 #include "memoryallocator.hpp" … … 189 190 { 190 191 stringstream zeile1, zeile2; 191 int *DoubleList = Calloc<int>(AtomCount, "PrintPermutationMap: *DoubleList"); 192 int *DoubleList = new int[AtomCount]; 193 for(int i=0;i<AtomCount;i++) 194 DoubleList[i] = 0; 192 195 int doubles = 0; 193 196 zeile1 << "PermutationMap: "; … … 203 206 if (doubles >0) 204 207 DoLog(2) && (Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl); 205 Free(&DoubleList);208 delete[](DoubleList); 206 209 // Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl; 207 210 }; … … 338 341 double Potential, OldPotential, OlderPotential; 339 342 struct EvaluatePotential Params; 340 Params.PermutationMap = Calloc<atom*>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.**PermutationMap");341 Params.DistanceList = Malloc<DistanceMap*>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.**DistanceList");342 Params.DistanceIterators = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DistanceIterators");343 Params.DoubleList = Calloc<int>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DoubleList");344 Params.StepList = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*StepList");343 Params.PermutationMap = new atom *[AtomCount]; 344 Params.DistanceList = new DistanceMap *[AtomCount]; 345 Params.DistanceIterators = new DistanceMap::iterator[AtomCount]; 346 Params.DoubleList = new int[AtomCount]; 347 Params.StepList = new DistanceMap::iterator[AtomCount]; 345 348 int round; 346 349 atom *Walker = NULL, *Runner = NULL, *Sprinter = NULL; 347 350 DistanceMap::iterator Rider, Strider; 351 352 // set to zero 353 for (int i=0;i<AtomCount;i++) { 354 Params.PermutationMap[i] = NULL; 355 Params.DoubleList[i] = 0; 356 } 348 357 349 358 /// Minimise the potential … … 362 371 DoLog(1) && (Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl); 363 372 MakeInjectivePermutation(this, Params); 364 Free(&Params.DoubleList);373 delete[](Params.DoubleList); 365 374 366 375 // argument minimise the constrained potential in this injective PermutationMap … … 444 453 for (int i=AtomCount; i--;) 445 454 Params.DistanceList[i]->clear(); 446 Free(&Params.DistanceList);447 Free(&Params.DistanceIterators);455 delete[](Params.DistanceList); 456 delete[](Params.DistanceIterators); 448 457 return ConstrainedPotential(Params); 449 458 }; … … 487 496 MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem()); 488 497 else { 489 PermutationMap = Malloc<atom *>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap");498 PermutationMap = new atom *[AtomCount]; 490 499 SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr ); 491 500 } … … 522 531 523 532 // store the list to single step files 524 int *SortIndex = Malloc<int>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: *SortIndex");533 int *SortIndex = new int[AtomCount]; 525 534 for (int i=AtomCount; i--; ) 526 535 SortIndex[i] = i; 527 536 status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex); 537 delete[](SortIndex); 528 538 529 539 // free and return 530 Free(&PermutationMap);540 delete[](PermutationMap); 531 541 delete(MoleculePerStep); 532 542 return status; … … 548 558 bool molecule::VerletForceIntegration(char *file, config &configuration) 549 559 { 560 Info FunctionInfo(__func__); 550 561 ifstream input(file); 551 562 string token; … … 588 599 ConstrainedPotentialEnergy = MinimiseConstrainedPotential(PermutationMap,configuration.DoConstrainedMD, 0, configuration.GetIsAngstroem()); 589 600 EvaluateConstrainedForces(configuration.DoConstrainedMD, 0, PermutationMap, &Force); 590 Free(&PermutationMap);601 delete[](PermutationMap); 591 602 } 592 603 593 604 // and perform Verlet integration for each atom with position, velocity and force vector 594 605 // check size of vectors 595 ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 );596 597 ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps , &configuration, &Force);606 //ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 ); 607 608 ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force); 598 609 } 599 610 // correct velocities (rather momenta) so that center of mass remains motionless 600 611 Velocity.Zero(); 601 612 IonMass = 0.; 602 ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps , &IonMass, &Velocity );613 ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps+1, &IonMass, &Velocity ); 603 614 604 615 // correct velocities (rather momenta) so that center of mass remains motionless 605 616 Velocity.Scale(1./IonMass); 606 617 ActualTemp = 0.; 607 ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps , &Velocity );618 ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps+1, &Velocity ); 608 619 Thermostats(configuration, ActualTemp, Berendsen); 609 620 MDSteps++;
Note:
See TracChangeset
for help on using the changeset viewer.