source: src/Actions/MoleculeAction/CreateMicelleAction.cpp@ faca99

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 Candidate_v1.7.0 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 faca99 was faca99, checked in by Frederik Heber <heber@…>, 14 years ago

MoleculeAction create-micelle: code updated; Baseshapes: procedure getHomogeneousPointsonSurface updated

Changed in rebase onto v1.1.3:

  • replaced parser instantiations by getter to FormatParserStorage and World.
  • removed doubly present loop over count (creates 1942 points).
  • We create now less than desired points, Unit tests checks for 194 instead of originally 200 points.
  • Property mode set to 100644
File size: 6.8 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * CreateMicelleAction.cpp
10 *
11 * Created on: Sept 29, 2010
12 * Author: dueck
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19#include "CodePatterns/MemDebug.hpp"
20
21#include "Actions/ActionHistory.hpp"
22#include "Actions/ActionRegistry.hpp"
23#include "Actions/GraphAction/SubgraphDissectionAction.hpp"
24#include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
25#include "Descriptors/AtomIdDescriptor.hpp"
26#include "Descriptors/MoleculeDescriptor.hpp"
27
28#include "atom.hpp"
29#include "Bond/bond.hpp"
30#include "CodePatterns/Assert.hpp"
31#include "CodePatterns/Log.hpp"
32#include "CodePatterns/Verbose.hpp"
33#include "LinearAlgebra/Line.hpp"
34#include "molecule.hpp"
35#include "World.hpp"
36
37#include <iostream>
38#include <string>
39
40#include "Parser/PdbParser.hpp"
41#include "Parser/TremoloParser.hpp"
42#include "Parser/XyzParser.hpp"
43#include "Parser/FormatParserStorage.hpp"
44#include "Shapes/BaseShapes.hpp"
45#include "Shapes/ShapeOps.hpp"
46
47#include "Actions/MoleculeAction/CreateMicelleAction.hpp"
48
49#include "CreateMicelleAction.def"
50#include "Action_impl_pre.hpp"
51
52using namespace std;
53
54#include "UIElements/UIFactory.hpp"
55#include "UIElements/Dialog.hpp"
56#include "Actions/ValueStorage.hpp"
57
58// memento to remember the state when undoing
59
60#include <iostream>
61#include <fstream>
62#include <config.h>
63#include "atom.hpp"
64#include "molecule.hpp"
65#include "LinearAlgebra/Vector.hpp"
66#include "LinearAlgebra/Line.hpp"
67#include "World.hpp"
68#include <gsl/gsl_poly.h>
69#include <gsl/gsl_eigen.h>
70//#define PATH "/home/dueck/workspace/tenside/tmp/"
71#define AtomVector std::vector <atom *>
72#define MoleculeVector std::vector <molecule *>
73#define AtomList list <atom *>
74
75int Delta2(int x1, int x2);
76double Sqlength (Vector x);
77
78/** =========== define the function ====================== */
79Action::state_ptr MoleculeCreateMicelleAction::performCall()
80{
81 getParametersfromValueStorage();
82
83 AtomVector ever = World::getInstance().getAllAtoms();
84
85 // as all parsed atoms go into same molecule
86 // we don't need to create one and add them all to it
87 MoleculeVector all = World::getInstance().getSelectedMolecules();
88 ASSERT(!all.empty(), "MoleculeCreateMicelleAction::performCall() - no molecules selected.");
89 molecule *stick = *(all.begin());
90
91 //3.Molekuel zentrieren
92
93 stick->CenterOrigin();
94
95 //4.Haupttraegheitsachse bestimmen
96 Vector den(0.0,0.0,1.0);
97
98 MoleculeRotateToPrincipalAxisSystem(den);
99 /* determine
100 principal axis system and make greatest eigenvector be aligned along
101 (0,0,1)
102 */
103 string path;
104 /**/
105 /*XyzParser *parserx = new XyzParser;
106 {
107 std::ofstream file;
108 path = PATH;
109 path += "/tensidrot.xyz";
110 file.open(path.c_str());
111 FormatParserStorage::getInstance().getXyz().save(&file, World::getInstance().getAllAtoms());
112 file.close();
113 }*/
114 //5.b: Molekuel um 180 Grad drehen
115
116 Line RotationAxis(Vector(0.0,0.0,0.0), Vector(1.0,0.0,0.0)); // pt is the current Vector of point on surface
117
118 for (molecule::iterator it=stick->begin(); it !=stick->end(); ++it)
119 (*it)->setPosition(RotationAxis.rotateVector((*it)->getPosition(),M_PI));
120
121
122 /*{
123 std::ofstream file;
124 path = PATH;
125 path += "/tensid2rot.xyz";
126 file.open(path.c_str());
127 FormatParserStorage::getInstance().getXyz().save(&file, World::getInstance().getAllAtoms());
128 file.close();
129 }*/
130
131 //6.Molekuel mehrfach strukturiert mit der Haupttraegheitsachse senkrecht zu einer parametrisierten Oberflaeche anordnen
132
133 //6.1. Punkte auf der Oberflaeche bestimmen
134 //Algorithmus entnommen aus "http://www.cgafaq.info/wiki/Evenly_distributed_points_on_sphere"
135
136 int ka =0;
137 //double radius= 1.5*sqrt(pow(1.55, 2)*params.N);
138
139 Shape s = resize(Sphere(), params.radius);
140 std::vector<Vector> pt = s.getHomogeneousPointsOnSurface(params.N);
141
142 //6.2.a. "stick" 180 Grad an x-y-Ebene spiegeln
143
144 for (molecule::iterator it2=stick->begin();it2 !=stick->end();++it2)
145 {
146 Vector pos= (**it2).getPosition();
147 pos[2]= - pos[2];// -Min[2]
148 (**it2).setPosition(pos);
149 }
150
151
152 //6.2.b. "stick" um Radius und Molekuelausdehnung in z-Richtung verschieben.
153
154 for (molecule::iterator it2=stick->begin();it2 !=stick->end();++it2)
155 {
156 Vector pos= (**it2).getPosition();
157 pos[2]=pos[2]+params.radius; // -Min[2]
158 (**it2).setPosition(pos);
159 }
160
161
162
163
164 /*{
165 std::ofstream file;
166 path = PATH;
167 path += "/tensid3rot.xyz";
168 file.open(path.c_str());
169 FormatParserStorage::getInstance().getXyz().save(&file, World::getInstance().getAllAtoms());
170 file.close();
171 }*/
172
173//6.3.Erzeugen einer Molekuelliste, die das Molekuel "stick" "N" mal kopiert und um eine Sphaere herum verteilt
174
175 //double MYEPSILON=1e-10;
176
177 for (ka = 0; ka<params.N-1; ka++)
178 {
179 cout << "Creating " << ka+1 << " copy of tenside molecule 'stick' with " << stick->getAtomCount() << " atoms, ";
180 molecule *Tensid=stick->CopyMolecule();
181
182 cout << "rotating ...";
183 Vector ZAxis(Vector(0.0,0.0,1.0));
184 Vector Axis(pt[ka]);
185 const double alpha = ZAxis.Angle(Axis);
186 Axis.VectorProduct(ZAxis);
187 Line RotationAxis(Vector(0.0,0.0,1.0), Axis); // pt is the current Vector of point on surface
188
189 for (molecule::iterator it2=Tensid->begin();it2 !=Tensid->end();++it2)
190 {
191 (*it2)->setPosition(RotationAxis.rotateVector((*it2)->getPosition(),alpha));
192 *(*it2)+=params.center;
193 }
194 cout << "done." << endl;
195
196 Tensid=NULL;
197 }
198
199 cout << "shifting " << ka+1 << " copy of tenside molecule, ";
200 molecule *Tensid=stick;
201 cout << "rotating ...";
202 Vector ZAxis(Vector(0.0,0.0,1.0));
203 Vector Axis(pt[params.N-1]);
204 const double alpha = ZAxis.Angle(Axis);
205 Axis.VectorProduct(ZAxis);
206 Line RotationAxis2(Vector(0.0,0.0,1.0), Axis); // pt is the current Vector of point on surface
207
208 for (molecule::iterator it2=Tensid->begin();it2 !=Tensid->end();++it2)
209 {
210 (*it2)->setPosition(RotationAxis.rotateVector((*it2)->getPosition(),alpha));
211 *(*it2)+=params.center;
212 }
213 cout << "done." << endl;
214
215 Tensid=NULL;
216
217 GraphSubgraphDissection();
218 return Action::success;
219}
220
221Action::state_ptr MoleculeCreateMicelleAction::performUndo(Action::state_ptr _state)
222{
223 // MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.());
224
225 // string newName = state->mol->Name();
226 // state->mol->setName(state->lastName);
227
228 return Action::failure;
229}
230
231Action::state_ptr MoleculeCreateMicelleAction::performRedo(Action::state_ptr _state)
232{
233 // Undo and redo have to do the same for this action
234 return performUndo(_state);
235}
236
237
238bool MoleculeCreateMicelleAction::canUndo()
239{
240 return false;
241}
242
243bool MoleculeCreateMicelleAction::shouldUndo()
244{
245 return false;
246}
247
248/** =========== end of function ====================== */
Note: See TracBrowser for help on using the repository browser.