Changeset 807c0e for src


Ignore:
Timestamp:
Oct 5, 2011, 9:18:20 AM (13 years ago)
Author:
Frederik Heber <heber@…>
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:
faca99
Parents:
e2e0a5a
git-author:
Daniel Dueck <dueck@…> (10/13/10 08:26:41)
git-committer:
Frederik Heber <heber@…> (10/05/11 09:18:20)
Message:

Daniel has recently changed his mizelledata to work as an action "create-micelle" within molecuilder.

  • BUGFIX: performCall() did not return an Action::success.

Changes due to rebase to v1.1.3:

Location:
src
Files:
2 added
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/Actions/Makefile.am

    re2e0a5a r807c0e  
    179179  Actions/MoleculeAction/ChangeNameAction.cpp \
    180180  Actions/MoleculeAction/CopyAction.cpp \
     181  Actions/MoleculeAction/CreateMicelleAction.cpp \
    181182  Actions/MoleculeAction/FillWithMoleculeAction.cpp \
    182183  Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp \
     
    195196  Actions/MoleculeAction/ChangeNameAction.hpp \
    196197  Actions/MoleculeAction/CopyAction.hpp \
     198  Actions/MoleculeAction/CreateMicelleAction.hpp \
    197199  Actions/MoleculeAction/FillWithMoleculeAction.hpp \
    198200  Actions/MoleculeAction/FillVoidWithMoleculeAction.hpp \
     
    211213  Actions/MoleculeAction/ChangeNameAction.def \
    212214  Actions/MoleculeAction/CopyAction.def \
     215  Actions/MoleculeAction/CreateMicelleAction.def \
    213216  Actions/MoleculeAction/FillWithMoleculeAction.def \
    214217  Actions/MoleculeAction/FillVoidWithMoleculeAction.def \
  • src/Actions/MoleculeAction/CreateMicelleAction.cpp

    • Property mode changed from 100755 to 100644
    re2e0a5a r807c0e  
    66 */
    77
    8 /** \file mizelledata.cpp
     8/*
     9 * CreateMicelleAction.cpp
    910 *
    10  * Implementation of a micelle creator by Daniel Dueck.
     11 *  Created on: Sept 29, 2010
     12 *      Author: dueck
    1113 */
    1214
     
    1719
    1820#include "CodePatterns/MemDebug.hpp"
     21
     22#include "CodePatterns/Log.hpp"
     23#include "CodePatterns/Verbose.hpp"
     24
     25#include "Actions/ActionHistory.hpp"
     26#include "Actions/ActionRegistry.hpp"
     27#include "Actions/GraphAction/SubgraphDissectionAction.hpp"
     28#include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
     29#include "Descriptors/AtomIdDescriptor.hpp"
     30#include "Descriptors/MoleculeDescriptor.hpp"
     31#include "LinearAlgebra/Line.hpp"
     32#include "Parser/PdbParser.hpp"
     33#include "Parser/TremoloParser.hpp"
     34#include "Parser/XyzParser.hpp"
     35#include "Parser/FormatParserStorage.hpp"
     36#include "Shapes/BaseShapes.hpp"
     37#include "Shapes/ShapeOps.hpp"
     38
     39
     40#include "atom.hpp"
     41#include "Bond/bond.hpp"
     42#include "boundary.hpp"
     43#include "molecule.hpp"
     44#include "World.hpp"
     45
     46#include <iostream>
     47#include <string>
     48
     49#include "Actions/MoleculeAction/CreateMicelleAction.hpp"
     50
     51#include "CreateMicelleAction.def"
     52#include "Action_impl_pre.hpp"
     53
     54using namespace std;
     55
     56#include "UIElements/UIFactory.hpp"
     57#include "UIElements/Dialog.hpp"
     58#include "Actions/ValueStorage.hpp"
     59
     60// memento to remember the state when undoing
    1961
    2062#include <iostream>
     
    2466#include "molecule.hpp"
    2567#include "LinearAlgebra/Vector.hpp"
    26 #include "LinearAlgebra/Line.hpp"
    2768#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"
    3369#include <gsl/gsl_poly.h>
    3470#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 
    4171#define PATH "/home/heber/tmp/"
    42 
    4372#define AtomVector std::vector <atom *>
    4473#define MoleculeVector std::vector <molecule *>
     
    4776int Delta2(int x1, int x2);
    4877double Sqlength (Vector x);
    49 int 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 
    57 string 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 }
     78
     79/** =========== define the function ====================== */
     80Action::state_ptr MoleculeCreateMicelleAction::performCall() {
     81       
     82getParametersfromValueStorage();
     83       
    6684AtomVector ever = World::getInstance().getAllAtoms();
    6785
    6886// as all parsed atoms go into same molecule
    6987// we don't need to create one and add them all to it
    70 molecule *stick = ever[0]->getMolecule();
     88MoleculeVector all = World::getInstance().getSelectedMolecules();
     89molecule *stick = *(all.begin());
    7190
    7291//3.Molekuel zentrieren
     
    7796Vector den(0.0,0.0,1.0);
    7897
    79 World::getInstance().clearMoleculeSelection();  // unselect all
    80 World::getInstance().selectMolecule(stick);     // select the desired molecule for the following action
    8198MoleculeRotateToPrincipalAxisSystem(den);
    8299/* determine
     
    84101(0,0,1)
    85102*/
    86 
     103string path;
    87104/**/
    88105{
     
    103120
    104121
    105 
    106122{
    107123  std::ofstream file;
     
    115131//6.Molekuel mehrfach strukturiert mit der Haupttraegheitsachse senkrecht zu einer parametrisierten Oberflaeche anordnen
    116132
    117 int N=200;
    118133//6.1. Punkte auf der Oberflaeche bestimmen
    119134//Algorithmus entnommen aus "http://www.cgafaq.info/wiki/Evenly_distributed_points_on_sphere"
    120135
    121136int ka =0;
    122 double radius= 1.5*sqrt(pow(1.55, 2)*N);
     137double radius= 1.5*sqrt(pow(1.55, 2)*params.N);
    123138
    124139Shape s = resize(Sphere(), radius);
    125 std::vector<Vector> pt = s.getHomogeneousPointsOnSurface(N);
     140std::vector<Vector> pt = s.getHomogeneousPointsOnSurface(params.N);
    126141
    127142//6.2."stick" um Radius und Molekuelausdehnung in z-Richtung verschieben.
     
    146161//double MYEPSILON=1e-10;
    147162
    148 for (ka = 0; ka<N; ka++){
    149   cout << "Creating " << ka+1 << " copy of tenside molecule, ";
     163for (ka = 0; ka<params.N-1; ka++){
     164  cout << "Creating " << ka+1 << " copy of tenside molecule 'stick' with " << stick->getAtomCount() << " atoms, ";
    150165        molecule *Tensid=stick->CopyMolecule();
    151166
     
    163178  Tensid=NULL;
    164179}
    165 
    166 GraphSubgraphDissection();
    167 
    168 molecule::iterator it2= stick->begin();
    169 while(it2!=stick->end()) {
    170                 atom *part=*it2;
    171                 ++it2;
    172                 stick->RemoveAtom(part);
    173                 World::getInstance().destroyAtom (part);
    174   };
    175 World::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 
    206 MoleculeVector never= World::getInstance().getAllMolecules();
    207 MoleculeVector::iterator it3 = never.begin();
    208 while(it3!=never.end()) {
    209                 molecule *Tensid=*it3;
    210                 ++it3;
    211                 World::getInstance().destroyMolecule(Tensid);
    212   };
    213 ever=World::getInstance().getAllAtoms();
    214 AtomVector::iterator it=ever.begin();
    215 while(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         }
    226 delete[] Tensor;
    227 for(int Zaehler=0; Zaehler<3;Zaehler++){
    228         delete[] rotationmatrix[Zaehler];
    229 }
    230 delete[] rotationmatrix;
    231 */
    232 /*for (ka = 0; ka<N; ka++){
    233     delete pt[ka];
    234 }
    235 delete[] pt;
    236 */
    237 
    238 return 0;
    239 }
    240 
    241 int Delta2 (int x1, int x2) {
    242         if (x1==x2) return 1;
    243         else return 0; 
    244 }
    245 
    246 double 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 }*/
     180cout << "shifting " << ka+1 << " copy of tenside molecule, ";
     181        molecule *Tensid=stick;
     182
     183        cout << "rotating ...";
     184  Vector ZAxis(Vector(0.0,0.0,1.0));
     185  Vector Axis(pt[params.N-1]);
     186  const double alpha = ZAxis.Angle(Axis);
     187  Axis.VectorProduct(ZAxis);
     188  Line RotationAxis2(Vector(0.0,0.0,1.0), Axis);        // pt is the current Vector of point on surface
     189
     190  for (molecule::iterator it2=Tensid->begin();it2 !=Tensid->end();++it2)
     191    (*it2)->setPosition(RotationAxis.rotateVector((*it2)->getPosition(),alpha));
     192  cout << "done." << endl;
     193
     194  Tensid=NULL;
     195
     196  GraphSubgraphDissection();
     197
     198  return Action::success;
     199}
     200
     201Action::state_ptr MoleculeCreateMicelleAction::performUndo(Action::state_ptr _state) {
     202//  MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.get());
     203
     204//  string newName = state->mol->getName();
     205//  state->mol->setName(state->lastName);
     206
     207  return Action::failure;
     208}
     209
     210Action::state_ptr MoleculeCreateMicelleAction::performRedo(Action::state_ptr _state){
     211  // Undo and redo have to do the same for this action
     212  return performUndo(_state);
     213}
     214
     215
     216bool MoleculeCreateMicelleAction::canUndo() {
     217  return false;
     218}
     219
     220
     221bool MoleculeCreateMicelleAction::shouldUndo() {
     222  return false;
     223}
     224
     225/** =========== end of function ====================== */
  • src/Makefile.am

    re2e0a5a r807c0e  
    271271
    272272noinst_LIBRARIES = libmenu.a
    273 bin_PROGRAMS = mizelledata molecuilder molecuildergui joiner analyzer
     273bin_PROGRAMS = molecuilder molecuildergui joiner analyzer
    274274EXTRA_PROGRAMS = unity
    275275
     
    277277
    278278libmenu_a_SOURCES = ${UISOURCE} ${UIHEADER}
    279 
    280 # mizelledata stuff
    281 mizelledata_SOURCES = mizelledata.cpp
    282 mizelledata_CXXFLAGS = $(BOOST_CPPFLAGS)
    283 mizelledata_LDFLAGS = $(BOOST_LIB)
    284 mizelledata_LDADD = \
    285         libMolecuilderUI.la \
    286         $(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la \
    287         ${CodePatterns_LIBS} \
    288         $(BOOST_LIB)
    289279
    290280molecuilder_DATA = elements.db valence.db orbitals.db Hbonddistance.db Hbondangle.db
Note: See TracChangeset for help on using the changeset viewer.