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
RevLine 
[e2e0a5a]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
[807c0e]8/*
9 * CreateMicelleAction.cpp
[e2e0a5a]10 *
[807c0e]11 * Created on: Sept 29, 2010
12 * Author: dueck
[e2e0a5a]13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19#include "CodePatterns/MemDebug.hpp"
20
[807c0e]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"
[faca99]30#include "CodePatterns/Assert.hpp"
31#include "CodePatterns/Log.hpp"
32#include "CodePatterns/Verbose.hpp"
33#include "LinearAlgebra/Line.hpp"
[807c0e]34#include "molecule.hpp"
35#include "World.hpp"
36
37#include <iostream>
38#include <string>
39
[faca99]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
[807c0e]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
[e2e0a5a]60#include <iostream>
61#include <fstream>
62#include <config.h>
63#include "atom.hpp"
64#include "molecule.hpp"
65#include "LinearAlgebra/Vector.hpp"
[faca99]66#include "LinearAlgebra/Line.hpp"
[e2e0a5a]67#include "World.hpp"
68#include <gsl/gsl_poly.h>
69#include <gsl/gsl_eigen.h>
[faca99]70//#define PATH "/home/dueck/workspace/tenside/tmp/"
[e2e0a5a]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
[807c0e]78/** =========== define the function ====================== */
[faca99]79Action::state_ptr MoleculeCreateMicelleAction::performCall()
80{
81 getParametersfromValueStorage();
[807c0e]82
[faca99]83 AtomVector ever = World::getInstance().getAllAtoms();
[e2e0a5a]84
[faca99]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());
[e2e0a5a]90
[faca99]91 //3.Molekuel zentrieren
[e2e0a5a]92
[faca99]93 stick->CenterOrigin();
[e2e0a5a]94
[faca99]95 //4.Haupttraegheitsachse bestimmen
96 Vector den(0.0,0.0,1.0);
[e2e0a5a]97
[faca99]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
[e2e0a5a]115
[faca99]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
[e2e0a5a]117
[faca99]118 for (molecule::iterator it=stick->begin(); it !=stick->end(); ++it)
119 (*it)->setPosition(RotationAxis.rotateVector((*it)->getPosition(),M_PI));
[e2e0a5a]120
121
[faca99]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 }*/
[e2e0a5a]130
[faca99]131 //6.Molekuel mehrfach strukturiert mit der Haupttraegheitsachse senkrecht zu einer parametrisierten Oberflaeche anordnen
[e2e0a5a]132
[faca99]133 //6.1. Punkte auf der Oberflaeche bestimmen
134 //Algorithmus entnommen aus "http://www.cgafaq.info/wiki/Evenly_distributed_points_on_sphere"
[e2e0a5a]135
[faca99]136 int ka =0;
137 //double radius= 1.5*sqrt(pow(1.55, 2)*params.N);
[e2e0a5a]138
[faca99]139 Shape s = resize(Sphere(), params.radius);
140 std::vector<Vector> pt = s.getHomogeneousPointsOnSurface(params.N);
[e2e0a5a]141
[faca99]142 //6.2.a. "stick" 180 Grad an x-y-Ebene spiegeln
[e2e0a5a]143
[faca99]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 }
[e2e0a5a]150
151
[faca99]152 //6.2.b. "stick" um Radius und Molekuelausdehnung in z-Richtung verschieben.
[e2e0a5a]153
[faca99]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 }
[e2e0a5a]160
161
162
163
[faca99]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 }*/
[e2e0a5a]172
[faca99]173//6.3.Erzeugen einer Molekuelliste, die das Molekuel "stick" "N" mal kopiert und um eine Sphaere herum verteilt
[e2e0a5a]174
[faca99]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 ...";
[807c0e]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
[e2e0a5a]207
[807c0e]208 for (molecule::iterator it2=Tensid->begin();it2 !=Tensid->end();++it2)
[faca99]209 {
[807c0e]210 (*it2)->setPosition(RotationAxis.rotateVector((*it2)->getPosition(),alpha));
[faca99]211 *(*it2)+=params.center;
212 }
[807c0e]213 cout << "done." << endl;
[e2e0a5a]214
[807c0e]215 Tensid=NULL;
[e2e0a5a]216
[807c0e]217 GraphSubgraphDissection();
218 return Action::success;
[e2e0a5a]219}
220
[faca99]221Action::state_ptr MoleculeCreateMicelleAction::performUndo(Action::state_ptr _state)
222{
223 // MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.());
[e2e0a5a]224
[faca99]225 // string newName = state->mol->Name();
226 // state->mol->setName(state->lastName);
[807c0e]227
228 return Action::failure;
[e2e0a5a]229}
[807c0e]230
[faca99]231Action::state_ptr MoleculeCreateMicelleAction::performRedo(Action::state_ptr _state)
232{
[807c0e]233 // Undo and redo have to do the same for this action
234 return performUndo(_state);
[e2e0a5a]235}
236
[807c0e]237
[faca99]238bool MoleculeCreateMicelleAction::canUndo()
239{
[807c0e]240 return false;
[e2e0a5a]241}
242
[faca99]243bool MoleculeCreateMicelleAction::shouldUndo()
244{
[807c0e]245 return false;
[e2e0a5a]246}
247
[807c0e]248/** =========== end of function ====================== */
Note: See TracBrowser for help on using the repository browser.