Ignore:
Timestamp:
Apr 29, 2010, 1:55:21 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
d79639
Parents:
632bc3 (diff), 753f02 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'VectorRefactoring' into StructureRefactoring

Conflicts:

molecuilder/src/Legacy/oldmenu.cpp
molecuilder/src/Makefile.am
molecuilder/src/analysis_correlation.cpp
molecuilder/src/boundary.cpp
molecuilder/src/builder.cpp
molecuilder/src/config.cpp
molecuilder/src/ellipsoid.cpp
molecuilder/src/linkedcell.cpp
molecuilder/src/molecule.cpp
molecuilder/src/molecule_fragmentation.cpp
molecuilder/src/molecule_geometry.cpp
molecuilder/src/molecule_graph.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/tesselation.cpp
molecuilder/src/tesselationhelpers.cpp
molecuilder/src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
molecuilder/src/unittests/bondgraphunittest.cpp
molecuilder/src/vector.cpp
molecuilder/src/vector.hpp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Legacy/oldmenu.cpp

    r632bc3 r8cbb97  
    2424#include "molecule.hpp"
    2525#include "periodentafel.hpp"
     26#include "vector_ops.hpp"
     27#include "Plane.hpp"
    2628
    2729#include "UIElements/UIFactory.hpp"
     
    5961  char choice;  // menu choice char
    6062  bool valid;
     63  bool aborted;
    6164
    6265  Log() << Verbose(0) << "===========ADD ATOM============================" << endl;
     
    7780      break;
    7881      case 'a': // absolute coordinates of atom
    79         Log() << Verbose(0) << "Enter absolute coordinates." << endl;
     82      {
     83        Dialog *dialog = UIFactory::getInstance().makeDialog();
    8084        first = World::getInstance().createAtom();
    81         first->x.AskPosition(World::getInstance().getDomain(), false);
    82         first->type = periode->AskElement();  // give type
    83         mol->AddAtom(first);  // add to molecule
     85        dialog->queryVector("Please enter coordinates: ",&first->x,World::getInstance().getDomain(), false);
     86        dialog->queryElement("Please choose element: ",&first->type);
     87        if(dialog->display()){
     88          mol->AddAtom(first);  // add to molecule
     89        }
     90        else{
     91          World::getInstance().destroyAtom(first);
     92        }
     93      }
     94      break;
     95
     96      case 'b': // relative coordinates of atom wrt to reference point
     97        first = World::getInstance().createAtom();
     98        valid = true;
     99        aborted = false;
     100        do {
     101          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
     102          auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
     103          dialog->queryVector("Enter reference coordinates.",&x,World::getInstance().getDomain(), true);
     104          dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), false);
     105          if((aborted = !dialog->display())){
     106            continue;
     107          }
     108          first->x += x;
     109        } while (!aborted && !(valid = mol->CheckBounds((const Vector *)&first->x)));
     110        if(!aborted){
     111          first->type = periode->AskElement();  // give type
     112          mol->AddAtom(first);  // add to molecule
     113        }
     114        else{
     115          World::getInstance().destroyAtom(first);
     116        }
    84117        break;
    85118
    86       case 'b': // relative coordinates of atom wrt to reference point
     119      case 'c': // relative coordinates of atom wrt to already placed atom
     120      {
    87121        first = World::getInstance().createAtom();
    88122        valid = true;
    89123        do {
    90124          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
    91           Log() << Verbose(0) << "Enter reference coordinates." << endl;
    92           x.AskPosition(World::getInstance().getDomain(), true);
    93           Log() << Verbose(0) << "Enter relative coordinates." << endl;
    94           first->x.AskPosition(World::getInstance().getDomain(), false);
    95           first->x.AddVector((const Vector *)&x);
    96           Log() << Verbose(0) << "\n";
    97         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    98         first->type = periode->AskElement();  // give type
    99         mol->AddAtom(first);  // add to molecule
    100         break;
    101 
    102       case 'c': // relative coordinates of atom wrt to already placed atom
    103         first = World::getInstance().createAtom();
    104         valid = true;
    105         do {
    106           if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
     125          auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
    107126          second = mol->AskAtom("Enter atom number: ");
    108           Log() << Verbose(0) << "Enter relative coordinates." << endl;
    109           first->x.AskPosition(World::getInstance().getDomain(), false);
     127          dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), false);
     128          dialog->display();
    110129          for (int i=NDIM;i--;) {
    111             first->x.x[i] += second->x.x[i];
     130            first->x[i] += second->x[i];
    112131          }
    113132        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    114133        first->type = periode->AskElement();  // give type
    115134        mol->AddAtom(first);  // add to molecule
    116         break;
     135      }
     136      break;
    117137
    118138    case 'd': // two atoms, two angles and a distance
     
    154174          */
    155175          // calc axis vector
    156           x.CopyVector(&second->x);
    157           x.SubtractVector(&third->x);
     176          x= second->x - third->x;
    158177          x.Normalize();
    159           Log() << Verbose(0) << "x: ",
    160           x.Output();
    161           Log() << Verbose(0) << endl;
    162           z.MakeNormalVector(&second->x,&third->x,&fourth->x);
    163           Log() << Verbose(0) << "z: ",
    164           z.Output();
    165           Log() << Verbose(0) << endl;
    166           y.MakeNormalVector(&x,&z);
    167           Log() << Verbose(0) << "y: ",
    168           y.Output();
    169           Log() << Verbose(0) << endl;
     178          Log() << Verbose(0) << "x: " << x << endl;
     179          z = Plane(second->x,third->x,fourth->x).getNormal();
     180          Log() << Verbose(0) << "z: " << z << endl;
     181          y = Plane(x,z,0).getNormal();
     182          Log() << Verbose(0) << "y: " << y << endl;
    170183
    171184          // rotate vector around first angle
    172           first->x.CopyVector(&x);
    173           first->x.RotateVector(&z,b - M_PI);
    174           Log() << Verbose(0) << "Rotated vector: ",
    175           first->x.Output();
    176           Log() << Verbose(0) << endl;
     185          first->x = x;
     186          first->x = RotateVector(first->x,z,b - M_PI);
     187          Log() << Verbose(0) << "Rotated vector: " << first->x << endl,
    177188          // remove the projection onto the rotation plane of the second angle
    178           n.CopyVector(&y);
    179           n.Scale(first->x.ScalarProduct(&y));
    180           Log() << Verbose(0) << "N1: ",
    181           n.Output();
    182           Log() << Verbose(0) << endl;
    183           first->x.SubtractVector(&n);
    184           Log() << Verbose(0) << "Subtracted vector: ",
    185           first->x.Output();
    186           Log() << Verbose(0) << endl;
    187           n.CopyVector(&z);
    188           n.Scale(first->x.ScalarProduct(&z));
    189           Log() << Verbose(0) << "N2: ",
    190           n.Output();
    191           Log() << Verbose(0) << endl;
    192           first->x.SubtractVector(&n);
    193           Log() << Verbose(0) << "2nd subtracted vector: ",
    194           first->x.Output();
    195           Log() << Verbose(0) << endl;
     189          n = y;
     190          n.Scale(first->x.ScalarProduct(y));
     191          Log() << Verbose(0) << "N1: " << n << endl;
     192          first->x -= n;
     193          Log() << Verbose(0) << "Subtracted vector: " << first->x << endl;
     194          n = z;
     195          n.Scale(first->x.ScalarProduct(z));
     196          Log() << Verbose(0) << "N2: " << n << endl;
     197          first->x -= n;
     198          Log() << Verbose(0) << "2nd subtracted vector: " << first->x << endl;
    196199
    197200          // rotate another vector around second angle
    198           n.CopyVector(&y);
    199           n.RotateVector(&x,c - M_PI);
    200           Log() << Verbose(0) << "2nd Rotated vector: ",
    201           n.Output();
    202           Log() << Verbose(0) << endl;
     201          n = y;
     202          n = RotateVector(n,x,c - M_PI);
     203          Log() << Verbose(0) << "2nd Rotated vector: " << n << endl;
    203204
    204205          // add the two linear independent vectors
    205           first->x.AddVector(&n);
     206          first->x += n;
    206207          first->x.Normalize();
    207208          first->x.Scale(a);
    208           first->x.AddVector(&second->x);
    209 
    210           Log() << Verbose(0) << "resulting coordinates: ";
    211           first->x.Output();
    212           Log() << Verbose(0) << endl;
     209          first->x += second->x;
     210
     211          Log() << Verbose(0) << "resulting coordinates: " << first->x << endl;
    213212        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    214213        first->type = periode->AskElement();  // give type
     
    233232        } while ((j != -1) && (i<128));
    234233        if (i >= 2) {
    235           first->x.LSQdistance((const Vector **)atoms, i);
    236 
    237           first->x.Output();
     234          LSQdistance(first->x,(const Vector **)atoms, i);
     235
     236          Log() << Verbose(0) << first->x;
    238237          first->type = periode->AskElement();  // give type
    239238          mol->AddAtom(first);  // add to molecule
     
    280279      for (int i=0;i<NDIM;i++) {
    281280        Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
    282         cin >> y.x[i];
     281        cin >> y[i];
    283282      }
    284283      mol->CenterEdge(&x);  // make every coordinate positive
    285       mol->Center.AddVector(&y); // translate by boundary
    286       helper.CopyVector(&y);
    287       helper.Scale(2.);
    288       helper.AddVector(&x);
     284      mol->Center += y; // translate by boundary
     285      helper = (2*y)+x;
    289286      mol->SetBoxDimension(&helper);  // update Box of atoms by boundary
    290287      break;
     
    293290      for (int i=0;i<NDIM;i++) {
    294291        Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
    295         cin >> x.x[i];
     292        cin >> x[i];
    296293      }
    297294      // update Box of atoms by boundary
     
    330327      third = mol->AskAtom("Enter third atom: ");
    331328
    332       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
     329      n = Plane(first->x,second->x,third->x).getNormal();
    333330      break;
    334331    case 'b': // normal vector of mirror plane
    335       Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    336       n.AskPosition(World::getInstance().getDomain(),0);
     332    {
     333      Dialog *dialog = UIFactory::getInstance().makeDialog();
     334      dialog->queryVector("Enter normal vector of mirror plane.",&n,World::getInstance().getDomain(),false);
     335      dialog->display();
     336      delete dialog;
    337337      n.Normalize();
    338       break;
     338    }
     339    break;
     340
    339341    case 'c': // three atoms defining mirror plane
    340342      first = mol->AskAtom("Enter first atom: ");
    341343      second = mol->AskAtom("Enter second atom: ");
    342344
    343       n.CopyVector((const Vector *)&first->x);
    344       n.SubtractVector((const Vector *)&second->x);
     345      n = first->x - second->x;
    345346      n.Normalize();
    346347      break;
     
    356357      mol->GetAlignvector(&param);
    357358      for (int i=NDIM;i--;) {
    358         x.x[i] = gsl_vector_get(param.x,i);
    359         n.x[i] = gsl_vector_get(param.x,i+NDIM);
     359        x[i] = gsl_vector_get(param.x,i);
     360        n[i] = gsl_vector_get(param.x,i+NDIM);
    360361      }
    361362      gsl_vector_free(param.x);
    362       Log() << Verbose(0) << "Offset vector: ";
    363       x.Output();
    364       Log() << Verbose(0) << endl;
     363      Log() << Verbose(0) << "Offset vector: " << x << endl;
    365364      n.Normalize();
    366365      break;
    367366  };
    368   Log() << Verbose(0) << "Alignment vector: ";
    369   n.Output();
    370   Log() << Verbose(0) << endl;
     367  Log() << Verbose(0) << "Alignment vector: " << n << endl;
    371368  mol->Align(&n);
    372369};
     
    397394      third = mol->AskAtom("Enter third atom: ");
    398395
    399       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
     396      n = Plane(first->x,second->x,third->x).getNormal();
    400397      break;
    401398    case 'b': // normal vector of mirror plane
    402       Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    403       n.AskPosition(World::getInstance().getDomain(),0);
     399    {
     400      Dialog *dialog = UIFactory::getInstance().makeDialog();
     401      dialog->queryVector("Enter normal vector of mirror plane.",&n,World::getInstance().getDomain(),false);
     402      dialog->display();
     403      delete dialog;
    404404      n.Normalize();
    405       break;
     405    }
     406    break;
     407
    406408    case 'c': // three atoms defining mirror plane
    407409      first = mol->AskAtom("Enter first atom: ");
    408410      second = mol->AskAtom("Enter second atom: ");
    409411
    410       n.CopyVector((const Vector *)&first->x);
    411       n.SubtractVector((const Vector *)&second->x);
     412      n = first->x - second->x;
    412413      n.Normalize();
    413414      break;
    414415  };
    415   Log() << Verbose(0) << "Normal vector: ";
    416   n.Output();
    417   Log() << Verbose(0) << endl;
     416  Log() << Verbose(0) << "Normal vector: " << n << endl;
    418417  mol->Mirror((const Vector *)&n);
    419418};
     
    455454        first = second;
    456455        second = first->next;
    457         if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
     456        if (first->x.DistanceSquared(second->x) > tmp1*tmp1) // distance to first above radius ...
    458457          mol->RemoveAtom(first);
    459458      }
     
    471470        first = second;
    472471        second = first->next;
    473         if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
     472        if ((first->x[axis] < tmp1) || (first->x[axis] > tmp2)) {// out of boundary ...
    474473          //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    475474          mol->RemoveAtom(first);
     
    522521        tmp1 = 0.;
    523522        if (first != second) {
    524           x.CopyVector((const Vector *)&first->x);
    525           x.SubtractVector((const Vector *)&second->x);
     523          x = first->x - second->x;
    526524          tmp1 = x.Norm();
    527525        }
     
    538536      for (int i=NDIM;i--;)
    539537        min[i] = 0.;
    540       x.CopyVector((const Vector *)&first->x);
    541       x.SubtractVector((const Vector *)&second->x);
     538      x = first->x - second->x;
    542539      tmp1 = x.Norm();
    543       Log() << Verbose(1) << "Distance vector is ";
    544       x.Output();
    545       Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl;
     540      Log() << Verbose(1) << "Distance vector is " << x << "." << "/n"
     541            << "Norm of distance is " << tmp1 << "." << endl;
    546542      break;
    547543
     
    552548      third  = mol->AskAtom("Enter last atom: ");
    553549      tmp1 = tmp2 = tmp3 = 0.;
    554       x.CopyVector((const Vector *)&first->x);
    555       x.SubtractVector((const Vector *)&second->x);
    556       y.CopyVector((const Vector *)&third->x);
    557       y.SubtractVector((const Vector *)&second->x);
     550      x = first->x - second->x;
     551      y = third->x - second->x;
    558552      Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
    559       Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
     553      Log() << Verbose(0) << (acos(x.ScalarProduct(y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
    560554      break;
    561555    case 'd':
     
    676670        minBond = 0.;
    677671        for (int i=NDIM;i--;)
    678           minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
     672          minBond += (first->x[i]-second->x[i])*(first->x[i] - second->x[i]);
    679673        minBond = sqrt(minBond);
    680674        Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
     
    682676        cin >> bond;
    683677        for (int i=NDIM;i--;) {
    684           second->x.x[i] -= (second->x.x[i]-first->x.x[i])/minBond*(minBond-bond);
     678          second->x[i] -= (second->x[i]-first->x[i])/minBond*(minBond-bond);
    685679        }
    686680        //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
     
    778772      x.Zero();
    779773      y.Zero();
    780       y.x[abs(axis)-1] = World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
     774      y[abs(axis)-1] = World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    781775      for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    782         x.AddVector(&y); // per factor one cell width further
     776        x += y; // per factor one cell width further
    783777        for (int k=count;k--;) { // go through every atom of the original cell
    784778          first = World::getInstance().createAtom(); // create a new body
    785           first->x.CopyVector(vectors[k]);  // use coordinate of original atom
    786           first->x.AddVector(&x);     // translate the coordinates
     779          first->x = (*vectors[k]) + x;  // use coordinate of original atom
    787780          first->type = Elements[k];  // insert original element
    788781          mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
     
    796789      // correct cell size
    797790      if (axis < 0) { // if sign was negative, we have to translate everything
    798         x.Zero();
    799         x.AddVector(&y);
     791        x = y;
    800792        x.Scale(-(faktor-1));
    801793        mol->Translate(&x);
     
    893885        mol = *ListRunner;
    894886        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    895         Log() << Verbose(0) << "Enter translation vector." << endl;
    896         x.AskPosition(World::getInstance().getDomain(),0);
    897         mol->Center.AddVector((const Vector *)&x);
     887        Dialog *dialog = UIFactory::getInstance().makeDialog();
     888        dialog->queryVector("Enter translation vector.",&x,World::getInstance().getDomain(),false);
     889        if(dialog->display()){
     890          mol->Center += x;
     891        }
     892        delete dialog;
    898893     }
    899894     break;
Note: See TracChangeset for help on using the changeset viewer.