Changeset 0a4f7f for src/molecule.cpp


Ignore:
Timestamp:
Apr 7, 2010, 3:45:38 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:
72e7fa
Parents:
f9352d
Message:

Made data internal data-structure of vector class private

  • Replaced occurences of access to internals with operator
  • moved Vector-class into LinAlg-Module
  • Reworked Vector to allow clean modularization
  • Added Plane class to describe arbitrary planes in 3d space
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule.cpp

    rf9352d r0a4f7f  
    2525#include "tesselation.hpp"
    2626#include "vector.hpp"
     27#include "Plane.hpp"
     28#include "Exceptions/LinearDependenceException.hpp"
    2729
    2830/************************************* Functions for class molecule *********************************/
     
    231233    Orthovector1.Zero();
    232234    for (int i=NDIM;i--;) {
    233       l = TopReplacement->x.x[i] - TopOrigin->x.x[i];
     235      l = TopReplacement->x[i] - TopOrigin->x[i];
    234236      if (fabs(l) > BondDistance) { // is component greater than bond distance
    235         Orthovector1.x[i] = (l < 0) ? -1. : +1.;
     237        Orthovector1[i] = (l < 0) ? -1. : +1.;
    236238      } // (signs are correct, was tested!)
    237239    }
     
    305307
    306308        // determine the plane of these two with the *origin
    307         AllWentWell = AllWentWell && Orthovector1.MakeNormalVector(&TopOrigin->x, &FirstOtherAtom->x, &SecondOtherAtom->x);
     309        try {
     310          Orthovector1 =Plane(TopOrigin->x, FirstOtherAtom->x, SecondOtherAtom->x).getNormal();
     311        }
     312        catch(LinearDependenceException &excp){
     313          Log() << Verbose(0) << excp;
     314          // TODO: figure out what to do with the Orthovector in this case
     315          AllWentWell = false;
     316        }
    308317      } else {
    309318        Orthovector1.GetOneNormalVector(&InBondvector);
     
    313322      //Log() << Verbose(0) << endl;
    314323      // orthogonal vector and bond vector between origin and replacement form the new plane
    315       Orthovector1.MakeNormalVector(&InBondvector);
     324      Orthovector1.MakeNormalTo(InBondvector);
    316325      Orthovector1.Normalize();
    317326      //Log() << Verbose(3) << "ReScaleCheck: " << Orthovector1.Norm() << " and " << InBondvector.Norm() << "." << endl;
     
    345354      SecondOtherAtom->x.Zero();
    346355      for(int i=NDIM;i--;) { // rotate by half the bond angle in both directions (InBondvector is bondangle = 0 direction)
    347         FirstOtherAtom->x.x[i] = InBondvector.x[i] * cos(bondangle) + Orthovector1.x[i] * (sin(bondangle));
    348         SecondOtherAtom->x.x[i] = InBondvector.x[i] * cos(bondangle) + Orthovector1.x[i] * (-sin(bondangle));
     356        FirstOtherAtom->x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle));
     357        SecondOtherAtom->x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle));
    349358      }
    350359      FirstOtherAtom->x.Scale(&BondRescale);  // rescale by correct BondDistance
     
    352361      //Log() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl;
    353362      for(int i=NDIM;i--;) { // and make relative to origin atom
    354         FirstOtherAtom->x.x[i] += TopOrigin->x.x[i];
    355         SecondOtherAtom->x.x[i] += TopOrigin->x.x[i];
     363        FirstOtherAtom->x[i] += TopOrigin->x[i];
     364        SecondOtherAtom->x[i] += TopOrigin->x[i];
    356365      }
    357366      // ... and add to molecule
     
    394403//      Orthovector1.Output(out);
    395404//      Log() << Verbose(0) << endl;
    396       AllWentWell = AllWentWell && Orthovector2.MakeNormalVector(&InBondvector, &Orthovector1);
     405      try{
     406        Orthovector2 = Plane(InBondvector, Orthovector1,0).getNormal();
     407      }
     408      catch(LinearDependenceException &excp) {
     409        Log() << Verbose(0) << excp;
     410        AllWentWell = false;
     411      }
    397412//      Log() << Verbose(3) << "Orthovector2: ";
    398413//      Orthovector2.Output(out);
     
    514529    }
    515530    for(j=NDIM;j--;) {
    516       Walker->x.x[j] = x[j];
    517       Walker->Trajectory.R.at(MDSteps-1).x[j] = x[j];
    518       Walker->Trajectory.U.at(MDSteps-1).x[j] = 0;
    519       Walker->Trajectory.F.at(MDSteps-1).x[j] = 0;
     531      Walker->x[j] = x[j];
     532      Walker->Trajectory.R.at(MDSteps-1)[j] = x[j];
     533      Walker->Trajectory.U.at(MDSteps-1)[j] = 0;
     534      Walker->Trajectory.F.at(MDSteps-1)[j] = 0;
    520535    }
    521536    AddAtom(Walker);  // add to molecule
     
    661676void molecule::SetBoxDimension(Vector *dim)
    662677{
    663   cell_size[0] = dim->x[0];
     678  cell_size[0] = dim->at(0);
    664679  cell_size[1] = 0.;
    665   cell_size[2] = dim->x[1];
     680  cell_size[2] = dim->at(1);
    666681  cell_size[3] = 0.;
    667682  cell_size[4] = 0.;
    668   cell_size[5] = dim->x[2];
     683  cell_size[5] = dim->at(2);
    669684};
    670685
     
    755770  for (int i=0;i<NDIM;i++) {
    756771    j += i+1;
    757     result = result && ((x->x[i] >= 0) && (x->x[i] < cell_size[j]));
     772    result = result && ((x->at(i) >= 0) && (x->at(i) < cell_size[j]));
    758773  }
    759774  //return result;
     
    10051020    DeterminePeriodicCenter(CenterOfGravity);
    10061021    OtherMolecule->DeterminePeriodicCenter(OtherCenterOfGravity);
    1007     Log() << Verbose(5) << "Center of Gravity: ";
    1008     CenterOfGravity.Output();
    1009     Log() << Verbose(0) << endl << Verbose(5) << "Other Center of Gravity: ";
    1010     OtherCenterOfGravity.Output();
    1011     Log() << Verbose(0) << endl;
     1022    Log() << Verbose(5) << "Center of Gravity: " << CenterOfGravity << endl;
     1023    Log() << Verbose(5) << "Other Center of Gravity: " << OtherCenterOfGravity << endl;
    10121024    if (CenterOfGravity.DistanceSquared(&OtherCenterOfGravity) > threshold*threshold) {
    10131025      Log() << Verbose(4) << "Centers of gravity don't match." << endl;
Note: See TracChangeset for help on using the changeset viewer.