Ignore:
Timestamp:
Jun 2, 2010, 4:17:17 PM (15 years ago)
Author:
Frederik Heber <heber@…>
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:
3610bb
Parents:
584a2a
git-author:
Frederik Heber <heber@…> (06/02/10 15:41:52)
git-committer:
Frederik Heber <heber@…> (06/02/10 16:17:17)
Message:

Case 'd' is now handled by CommandLineUI (RepeatBoxAction).

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/WorldAction/RepeatBoxAction.cpp

    r584a2a re30ce8  
    2323#include "UIElements/Dialog.hpp"
    2424#include "Actions/MapOfActions.hpp"
     25#include "Descriptors/MoleculeDescriptor.hpp"
     26#include "Descriptors/MoleculePtrDescriptor.hpp"
    2527
    2628const char WorldRepeatBoxAction::NAME[] = "repeat-box";
     
    4143  int j = 0;
    4244  atom *Walker = NULL;
     45  MoleculeListClass *molecules = World::getInstance().getMolecules();
    4346
    4447  dialog->queryVector(NAME, &Repeater, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));
    45   dialog->queryMolecule("molecule-by-id", &mol,MapOfActions::getInstance().getDescription("molecule-by-id"));
     48  //dialog->queryMolecule("molecule-by-id", &mol,MapOfActions::getInstance().getDescription("molecule-by-id"));
     49  vector<molecule *> AllMolecules;
     50  if (mol != NULL) {
     51    DoLog(0) && (Log() << Verbose(0) << "Using molecule " << mol->name << "." << endl);
     52    AllMolecules = World::getInstance().getAllMolecules(MoleculeByPtr(mol));
     53  } else {
     54    DoLog(0) && (Log() << Verbose(0) << "Using all molecules." << endl);
     55    AllMolecules = World::getInstance().getAllMolecules();
     56  }
    4657
    4758  if(dialog->display()) {
     59    (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl);
    4860    double * const cell_size = World::getInstance().getDomain();
     61    double *M = ReturnFullMatrixforSymmetric(cell_size);
    4962    Vector x,y;
    50     for (int axis = 1; axis <= NDIM; axis++) {
    51       Vector ** vectors;
     63    int n[NDIM];
     64    for (int axis = 0; axis < NDIM; axis++) {
    5265      Repeater[axis] = floor(Repeater[axis]);
    5366      if (Repeater[axis] < 1) {
     
    5568        Repeater[axis] = 1;
    5669      }
    57       if (mol->getAtomCount() != 0) {  // if there is more than none
    58         count = mol->getAtomCount();   // is changed becausing of adding, thus has to be stored away beforehand
    59         Elements = new const element *[count];
    60         vectors = new Vector *[count];
    61         j = 0;
    62         for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) {
    63           Elements[j] = (*AtomRunner)->type;
    64           vectors[j] = &(*AtomRunner)->x;
    65           j++;
    66         }
    67         if (count != j)
    68           DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
    69         x.Zero();
    70         y.Zero();
    71         y[abs(axis)-1] = cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    72         for (int i=1;i<Repeater[axis];i++) {  // then add this list with respective translation factor times
    73           x += y; // per factor one cell width further
    74           for (int k=count;k--;) { // go through every atom of the original cell
    75             Walker = World::getInstance().createAtom(); // create a new body
    76             Walker->x = (*vectors[k]) + x;
    77             Walker->type = Elements[k];  // insert original element
    78             mol->AddAtom(Walker);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
     70      cell_size[(abs(axis+1) == 2) ? 2 : ((abs(axis+2) == 3) ? 5 : 0)] *= Repeater[axis];
     71    }
     72
     73    molecule *newmol = NULL;
     74    Vector ** vectors = NULL;
     75    for (n[0] = 0; n[0] < Repeater[0]; n[0]++) {
     76      y[0] = n[0];
     77      for (n[1] = 0; n[1] < Repeater[1]; n[1]++) {
     78        y[1] = n[1];
     79        for (n[2] = 0; n[2] < Repeater[2]; n[2]++) {
     80          y[2] = n[2];
     81          if (n[0] == n[1] == n[2] == 0)
     82            continue;
     83          for (vector<molecule *>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
     84            mol = *MolRunner;
     85            DoLog(1) && (Log() << Verbose(1) << "Current mol is " << mol->name << "." << endl);
     86            count = mol->getAtomCount();   // is changed becausing of adding, thus has to be stored away beforehand
     87            if (count != 0) {  // if there is more than none
     88              Elements = new const element *[count];
     89              vectors = new Vector *[count];
     90              j = 0;
     91              for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) {
     92                Elements[j] = (*AtomRunner)->type;
     93                vectors[j] = &(*AtomRunner)->x;
     94                j++;
     95              }
     96              if (count != j)
     97                DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
     98              x = y;
     99              x.MatrixMultiplication(M);
     100              newmol = World::getInstance().createMolecule();
     101              molecules->insert(newmol);
     102              for (int k=count;k--;) { // go through every atom of the original cell
     103                Walker = World::getInstance().createAtom(); // create a new body
     104                Walker->x = (*vectors[k]) + x;
     105                Walker->type = Elements[k];  // insert original element
     106                cout << "new atom is " << *Walker << endl;
     107                newmol->AddAtom(Walker);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
     108              }
     109              // free memory
     110              delete[](Elements);
     111              delete[](vectors);
     112            } else {
     113              DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl);
     114            }
    79115          }
    80116        }
    81         // free memory
    82         delete[](Elements);
    83         delete[](vectors);
    84         // correct cell size
    85         if (axis < 0) { // if sign was negative, we have to translate everything
    86           x =(-(Repeater[axis]-1)) * y;
    87           mol->Translate(&x);
    88         }
    89         cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= Repeater[axis];
    90117      }
    91118    }
     119    delete(M);
    92120    delete dialog;
    93121    return Action::success;
Note: See TracChangeset for help on using the changeset viewer.