source: src/LinearAlgebra/RealSpaceMatrix.hpp@ 9df680

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
Last change on this file since 9df680 was 66fd49, checked in by Frederik Heber <heber@…>, 14 years ago

Rewrite of FillVoidWithMoleculeAction.

FillVoidWithMoleculeAction:

  • new parameter MinDistance and default value of 0.
  • BUGFIX: filler is already created when parsing file, removed useless creation of it initially (also caused lots of confusion due to an "extra" molecule).
  • Undo implemented, regression test inserted.
  • Redo is somewhat hard to implement, as one would use performCall() if it only it would not retrieve its values from ValueStorage ...

FillVoidWithMolecule():

  • filler is now the zeroth not the last molecule, marked by firstInsertion and firstInserter. Filler is removed if no molecules are filled.
  • outsourced stuff into smaller functions
  • removed FillIt to through every atom despite only CurrentPosition, indepedent of atom position, is checked.

TESTFIXES:

  • Analysis/3: test.xyz changed because boundary is now 1.5 instead of 2.1 as 2.1 is not enough of molecules get filled in (and the filler already is).
  • Analysis/3: tensid.data was actually lacking water at (0,0,0) which is after the rewrite present.
  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * RealSpaceMatrix.hpp
3 *
4 * Created on: Jun 25, 2010
5 * Author: crueger
6 */
7
8#ifndef REALSPACEMATRIX_HPP_
9#define REALSPACEMATRIX_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16
17#include <iosfwd>
18#include "Helpers/defs.hpp"
19
20/**
21 * Simple class to store matrices with a few extra functions
22 */
23
24class Vector;
25class MatrixContent;
26
27/** 3x3 Matrix class.
28 * This class has some specific features for 3D space such as rotations or
29 * hard-coded determinants.
30 */
31class RealSpaceMatrix
32{
33 friend Vector operator*(const RealSpaceMatrix&,const Vector&);
34public:
35 RealSpaceMatrix();
36
37 /**
38 * construct a matrix from a 3x3 double array that contains all Elements.
39 *
40 * The elements are laid out in the following way:
41 * array -> matrix
42 * 0 -> (0,0)
43 * 1 -> (1,0)
44 * 2 -> (2,0)
45 * 3 -> (0,1)
46 * 4 -> (1,1)
47 * 5 -> (2,1)
48 * 6 -> (0,2)
49 * 7 -> (1,2)
50 * 8 -> (2,2)
51 *
52 */
53 RealSpaceMatrix(const double*);
54 RealSpaceMatrix(const RealSpaceMatrix&);
55 RealSpaceMatrix(const MatrixContent&);
56 virtual ~RealSpaceMatrix();
57
58 /**
59 * Set the matrix to a unit matrix.
60 */
61 void setIdentity();
62
63 /**
64 * Set all matrix entries to zero.
65 */
66 void setZero();
67
68 /**
69 * Sets all matrix corresponding to a rotation matrix,
70 * first around the x-, then the y-, finally the z-axis
71 * with given angles.
72 */
73 void setRotation(const double x, const double y, const double z);
74 void setRandomRotation();
75
76 /**
77 * Access the matrix at index (i,j)
78 */
79 double &at(size_t i, size_t j);
80 /**
81 * Access the matrix at index (i,j)
82 */
83 const double at(size_t i, size_t j) const;
84
85 /**
86 * Set the matrix at index (i,j).
87 *
88 * Slightly faster than at(i,j)=x
89 */
90 void set(size_t i, size_t j, const double value);
91
92 /**
93 * get the ith row of the matrix as a vector
94 */
95 Vector &row(size_t);
96 const Vector &row(size_t) const;
97
98 /**
99 * get the ith column of the matrix as a vector
100 */
101 Vector &column(size_t);
102 const Vector &column(size_t) const;
103
104 /**
105 * get the diagonal of the matrix as a vector
106 */
107 Vector &diagonal();
108 const Vector &diagonal() const;
109
110 /**
111 * Calculate the determinant of the matrix
112 */
113 double determinant() const;
114
115 /**
116 * Calculate the inverse of the matrix.
117 *
118 * Rather costly, so use precomputation as often as possible.
119 */
120 RealSpaceMatrix invert() const;
121
122 /**
123 * Diagonalizes a matrix and sets its rows to the resulting eigenvalues.
124 * The eigenvalues are returned as a vector.
125 *
126 * Rather costly, so use precomputation as often as possible.
127 */
128 Vector transformToEigenbasis();
129
130 /**
131 * Calculate the transpose of the matrix.
132 */
133 RealSpaceMatrix transpose() const;
134 RealSpaceMatrix &transpose();
135
136 // operators
137 RealSpaceMatrix &operator=(const RealSpaceMatrix&);
138
139 const RealSpaceMatrix &operator+=(const RealSpaceMatrix&);
140 const RealSpaceMatrix &operator-=(const RealSpaceMatrix&);
141 const RealSpaceMatrix &operator*=(const RealSpaceMatrix&);
142
143 const RealSpaceMatrix &operator*=(const double);
144
145 const RealSpaceMatrix operator+(const RealSpaceMatrix&) const;
146 const RealSpaceMatrix operator-(const RealSpaceMatrix&) const;
147 const RealSpaceMatrix operator*(const RealSpaceMatrix&) const;
148
149 bool operator==(const RealSpaceMatrix&) const;
150
151private:
152 RealSpaceMatrix(MatrixContent*);
153 void createViews();
154 MatrixContent *content;
155 // we keep around some Vector views of the matrix, to return references
156 Vector* rows_ptr[NDIM];
157 Vector* columns_ptr[NDIM];
158 Vector* diagonal_ptr;
159};
160
161const RealSpaceMatrix operator*(const double,const RealSpaceMatrix&);
162const RealSpaceMatrix operator*(const RealSpaceMatrix&,const double);
163
164/**
165 * Takes a symmetric matrix that stores the lower diagonal and produces a
166 * full matrix.
167 *
168 * The array is laid out as follows:
169 *
170 * array -> matrix
171 * 0 -> (0,0)
172 * 1 -> (1,0);(0,1)
173 * 2 -> (1,1)
174 * 3 -> (2,0);(0,2)
175 * 4 -> (2,1);(1,2)
176 * 5 -> (2,2)
177 */
178RealSpaceMatrix ReturnFullMatrixforSymmetric(const double * const cell_size);
179
180std::ostream &operator<<(std::ostream&,const RealSpaceMatrix&);
181Vector operator*(const RealSpaceMatrix&,const Vector&);
182Vector& operator*=(Vector&,const RealSpaceMatrix&);
183
184#endif /* REALSPACEMATRIX_HPP_ */
Note: See TracBrowser for help on using the repository browser.