source: src/mizelledata.cpp@ e2e0a5a

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

Added Daniels version from 2010/09/15 and Makefile stuff to this branch.

  • Changed Daniels version a bit such that it compiles:

Changes from rebase to v1.1.3:

  • Property mode set to 100755
File size: 7.0 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/** \file mizelledata.cpp
9 *
10 * Implementation of a micelle creator by Daniel Dueck.
11 */
12
13// include config.h
14#ifdef HAVE_CONFIG_H
15#include <config.h>
16#endif
17
18#include "CodePatterns/MemDebug.hpp"
19
20#include <iostream>
21#include <fstream>
22#include <config.h>
23#include "atom.hpp"
24#include "molecule.hpp"
25#include "LinearAlgebra/Vector.hpp"
26#include "LinearAlgebra/Line.hpp"
27#include "World.hpp"
28#include "Parser/FormatParserStorage.hpp"
29#include "Parser/TremoloParser.hpp"
30#include "Parser/XyzParser.hpp"
31#include "Parser/PdbParser.hpp"
32#include "Parser/FormatParserStorage.hpp"
33#include <gsl/gsl_poly.h>
34#include <gsl/gsl_eigen.h>
35#include "Actions/ActionHistory.hpp"
36#include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
37#include "Actions/GraphAction/SubgraphDissectionAction.hpp"
38#include "Shapes/BaseShapes.hpp"
39#include "Shapes/ShapeOps.hpp"
40
41#define PATH "/home/heber/tmp/"
42
43#define AtomVector std::vector <atom *>
44#define MoleculeVector std::vector <molecule *>
45#define AtomList list <atom *>
46
47int Delta2(int x1, int x2);
48double Sqlength (Vector x);
49int main ()
50{
51 setVerbosity(4);
52 // need to init the history before any action is created
53 ActionHistory::init();
54
55//1.Molekuel aus pdbfile einlesen und in Variablen speichern
56
57string path;
58{
59 std::ifstream file;
60 path = PATH;
61 path += "/tensid.data";
62 file.open(path.c_str());
63 FormatParserStorage::getInstance().getTremolo().load(&file);
64 file.close();
65}
66AtomVector ever = World::getInstance().getAllAtoms();
67
68// as all parsed atoms go into same molecule
69// we don't need to create one and add them all to it
70molecule *stick = ever[0]->getMolecule();
71
72//3.Molekuel zentrieren
73
74stick->CenterOrigin();
75
76//4.Haupttraegheitsachse bestimmen
77Vector den(0.0,0.0,1.0);
78
79World::getInstance().clearMoleculeSelection(); // unselect all
80World::getInstance().selectMolecule(stick); // select the desired molecule for the following action
81MoleculeRotateToPrincipalAxisSystem(den);
82/* determine
83principal axis system and make greatest eigenvector be aligned along
84(0,0,1)
85*/
86
87/**/
88{
89 std::ofstream file;
90 path = PATH;
91 path += "/tensidrot.xyz";
92 file.open(path.c_str());
93 FormatParserStorage::getInstance().getXyz().save(&file, World::getInstance().getAllAtoms());
94 file.close();
95}
96
97//5.b: Molekuel um 180 Grad drehen
98
99Line RotationAxis(Vector(0.0,0.0,0.0), Vector(1.0,0.0,0.0)); // pt is the current Vector of point on surface
100
101for (molecule::iterator it=stick->begin(); it !=stick->end(); ++it)
102 (*it)->setPosition(RotationAxis.rotateVector((*it)->getPosition(),M_PI));
103
104
105
106{
107 std::ofstream file;
108 path = PATH;
109 path += "/tensid2rot.xyz";
110 file.open(path.c_str());
111 FormatParserStorage::getInstance().getXyz().save(&file, World::getInstance().getAllAtoms());
112 file.close();
113}
114
115//6.Molekuel mehrfach strukturiert mit der Haupttraegheitsachse senkrecht zu einer parametrisierten Oberflaeche anordnen
116
117int N=200;
118//6.1. Punkte auf der Oberflaeche bestimmen
119//Algorithmus entnommen aus "http://www.cgafaq.info/wiki/Evenly_distributed_points_on_sphere"
120
121int ka =0;
122double radius= 1.5*sqrt(pow(1.55, 2)*N);
123
124Shape s = resize(Sphere(), radius);
125std::vector<Vector> pt = s.getHomogeneousPointsOnSurface(N);
126
127//6.2."stick" um Radius und Molekuelausdehnung in z-Richtung verschieben.
128
129for (molecule::iterator it2=stick->begin();it2 !=stick->end();++it2) {
130 Vector pos= (**it2).getPosition();
131 pos[2]=pos[2]+radius; // -Min[2]
132 (**it2).setPosition(pos);
133}
134
135{
136 std::ofstream file;
137 path = PATH;
138 path += "/tensid3rot.xyz";
139 file.open(path.c_str());
140 FormatParserStorage::getInstance().getXyz().save(&file, World::getInstance().getAllAtoms());
141 file.close();
142}
143
144//6.3.Erzeugen einer Molekuelliste, die das Molekuel "stick" "N" mal kopiert und um eine Sphaere herum verteilt
145
146//double MYEPSILON=1e-10;
147
148for (ka = 0; ka<N; ka++){
149 cout << "Creating " << ka+1 << " copy of tenside molecule, ";
150 molecule *Tensid=stick->CopyMolecule();
151
152 cout << "rotating ...";
153 Vector ZAxis(Vector(0.0,0.0,1.0));
154 Vector Axis(pt[ka]);
155 const double alpha = ZAxis.Angle(Axis);
156 Axis.VectorProduct(ZAxis);
157 Line RotationAxis(Vector(0.0,0.0,1.0), Axis); // pt is the current Vector of point on surface
158
159 for (molecule::iterator it2=Tensid->begin();it2 !=Tensid->end();++it2)
160 (*it2)->setPosition(RotationAxis.rotateVector((*it2)->getPosition(),alpha));
161 cout << "done." << endl;
162
163 Tensid=NULL;
164}
165
166GraphSubgraphDissection();
167
168molecule::iterator it2= stick->begin();
169while(it2!=stick->end()) {
170 atom *part=*it2;
171 ++it2;
172 stick->RemoveAtom(part);
173 World::getInstance().destroyAtom (part);
174 };
175World::getInstance().destroyMolecule(stick);
176
177//7. Speichern der Molekuelliste in einem data-file
178
179{
180 std::ofstream file;
181 path = PATH;
182 path += "/tensidoutput2.pdb";
183 file.open(path.c_str());
184 FormatParserStorage::getInstance().getPdb().save(&file, World::getInstance().getAllAtoms());
185 file.close();
186}
187
188{
189 std::ofstream file;
190 path = PATH;
191 path += "/tensidoutput2.data";
192 file.open(path.c_str());
193 FormatParserStorage::getInstance().getTremolo().save(&file, World::getInstance().getAllAtoms());
194 file.close();
195}
196
197//Anhang
198
199
200//gsl_matrix_free (Tensor1);
201 //gsl_vector_complex_free (eval);
202//gsl_matrix_complex_free (evec);
203//gsl_eigen_nonsymmv_free (w);
204
205
206MoleculeVector never= World::getInstance().getAllMolecules();
207MoleculeVector::iterator it3 = never.begin();
208while(it3!=never.end()) {
209 molecule *Tensid=*it3;
210 ++it3;
211 World::getInstance().destroyMolecule(Tensid);
212 };
213ever=World::getInstance().getAllAtoms();
214AtomVector::iterator it=ever.begin();
215while(it!=ever.end()) {
216 atom *member=*it;
217 ++it;
218 World::getInstance().destroyAtom(member);
219 member=NULL;
220}
221
222//delete parserx;
223/*for(int Zaehler=0; Zaehler<3;Zaehler++){
224 delete[] Tensor[Zaehler];
225 }
226delete[] Tensor;
227for(int Zaehler=0; Zaehler<3;Zaehler++){
228 delete[] rotationmatrix[Zaehler];
229}
230delete[] rotationmatrix;
231*/
232/*for (ka = 0; ka<N; ka++){
233 delete pt[ka];
234}
235delete[] pt;
236*/
237
238return 0;
239}
240
241int Delta2 (int x1, int x2) {
242 if (x1==x2) return 1;
243 else return 0;
244}
245
246double Sqlength (Vector x){
247 double ergebnis= x[0]*x[0]+x[1]*x[1]+x[2]*x[2];
248 return ergebnis;
249 }
250
251/*double[3] rotate (double[3] in[3], double theta, double phi) {
252 double **rotationmatrix;
253 rotationmatrix=new double *[3];
254 for(int Zaehler=0; Zaehler<3;Zaehler++){
255 rotationmatrix[Zaehler]=new double[3];
256 }
257 rotationmatrix[0][0]=cos(theta)*cos(phi);
258 rotationmatrix[0][1]=-sin(phi);
259 rotationmatrix[0][2]=sin(theta)*cos(phi);
260 rotationmatrix[1][0]=cos(theta)*sin(phi);
261 rotationmatrix[1][1]=cos(phi);
262 rotationmatrix[1][2]=sin(theta)*sin(phi);
263 rotationmatrix[2][0]=-sin(theta);
264 rotationmatrix[2][1]=0;
265 rotationmatrix[2][2]=cos(theta);
266 double zahl[3];
267 for(int Zaehler=0; Zaehler<3;Zaehler++){
268 Zahl[Zaehler]=rotationmatrix[Zaehler][0]*in[0]+rotationmatrix[Zaehler][1]*in[1]+rotationmatrix[Zaehler][2]*in[2];
269 }
270 for(int Zaehler=0; Zaehler<3;Zaehler++){
271 delete[] rotationmatrix[Zaehler];
272 }
273 delete[] rotationmatrix;
274}*/
Note: See TracBrowser for help on using the repository browser.