- Timestamp:
- Oct 5, 2011, 4:23:19 PM (13 years ago)
- 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:
- 8990879
- Parents:
- c521e1
- git-author:
- Frederik Heber <heber@…> (09/27/11 09:07:46)
- git-committer:
- Frederik Heber <heber@…> (10/05/11 16:23:19)
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/CreateMicelleAction.cpp
rc521e1 rf6ba43 51 51 #include "Action_impl_pre.hpp" 52 52 53 using namespace std;54 55 53 #include "UIElements/UIFactory.hpp" 56 54 #include "UIElements/Dialog.hpp" … … 71 69 // we don't need to create one and add them all to it 72 70 MoleculeVector all = World::getInstance().getSelectedMolecules(); 73 ASSERT(!all.empty(), "MoleculeCreateMicelleAction::performCall() - no molecules selected."); 71 72 // return success when none are selected 73 if (all.empty()) 74 return Action::success; 75 76 // check that there is precisely one molecule 77 ASSERT(all.size() == 1, 78 "MoleculeCreateMicelleAction::performCall() - more than one molecule selected, this is not supported."); 79 74 80 molecule *stick = *(all.begin()); 75 81 82 83 // create undo state for original molecule 84 std::vector<Vector> stickPositions; 85 for (molecule::const_iterator iter = stick->begin(); iter != stick->end(); ++iter) 86 stickPositions.push_back((*iter)->getPosition()); 87 88 // determine principal axis system and rotate such that greatest extension is along z axis 89 if(stick->size() > 1) { // only rotate if more than one molecule present 90 Vector den(0.0,0.0,1.0); 91 92 MoleculeRotateToPrincipalAxisSystem(den); 93 } 94 76 95 // center molecule 77 78 96 stick->CenterOrigin(); 79 97 80 // determine principal axis system and rotate such that greatest extension is along z axis81 Vector den(0.0,0.0,1.0);82 83 MoleculeRotateToPrincipalAxisSystem(den);84 /* determine85 principal axis system and make greatest eigenvector be aligned along86 (0,0,1)87 */88 string path;89 90 Line RotationAxis(Vector(0.0,0.0,0.0), Vector(1.0,0.0,0.0)); // pt is the current Vector of point on surface91 92 //for (molecule::iterator it=stick->begin(); it !=stick->end(); ++it)93 //(*it)->setPosition(RotationAxis.rotateVector((*it)->getPosition(),M_PI));94 95 98 /// Align molecule with its PAS multiple times with the some surface 96 99 97 100 // get points on surface 98 101 99 int ka =0;100 102 //double radius= 1.5*sqrt(pow(1.55, 2)*params.N); 101 103 … … 104 106 105 107 // mirror along x-y plane 108 109 // additionally invert molecule if desired 110 if (params.DoRotate) { 111 for (molecule::iterator it2=stick->begin();it2 !=stick->end();++it2) 112 { 113 Vector pos= (**it2).getPosition(); 114 pos[2]= - pos[2];// -Min[2] 115 (**it2).setPosition(pos); 116 } 117 } 118 119 // shift molecule by its extension along z axis 106 120 107 121 for (molecule::iterator it2=stick->begin();it2 !=stick->end();++it2) 108 122 { 109 123 Vector pos= (**it2).getPosition(); 110 pos[2]= - pos[2];// -Min[2]124 pos[2]=pos[2]+params.radius; 111 125 (**it2).setPosition(pos); 112 126 } 113 127 114 // shift molecule by its extension along z axis115 116 for (molecule::iterator it2=stick->begin();it2 !=stick->end();++it2)117 {118 Vector pos= (**it2).getPosition();119 pos[2]=pos[2]+params.radius; // -Min[2]120 (**it2).setPosition(pos);121 }122 123 128 // copy molecule N times and rotate it to point radially away from surface 124 129 125 130 //double MYEPSILON=1e-10; 126 131 127 for (ka = 0; ka<pt.size()-1; ka++) 132 // gather created molecules for undo state 133 std::vector<molecule *> CreatedMolecules; 134 135 // TODO: remove this when we do not need MoleculeListClass anymore 136 MoleculeListClass *&molecules = World::getInstance().getMolecules(); 137 138 size_t ka = 0; 139 for (; ka<pt.size()-1; ka++) 128 140 { 129 141 LOG(1, "STATUS: Creating " << ka+1 << " copy of tenside molecule 'stick' with " << stick->getAtomCount() << " atoms, "); 130 molecule *Tensid=stick->CopyMolecule(); 131 132 LOG(2, "INFO: Rotating ... "); 142 molecule *Tensid=stick->CopyMolecule(); 143 molecules->insert(Tensid); 144 CreatedMolecules.push_back(Tensid); 145 133 146 Vector ZAxis(Vector(0.0,0.0,1.0)); 134 147 Vector Axis(pt[ka]); … … 136 149 Axis.VectorProduct(ZAxis); 137 150 Line RotationAxis(Vector(0.0,0.0,1.0), Axis); // pt is the current Vector of point on surface 151 LOG(2, "INFO: Rotating along axis " << RotationAxis << " by angle " << alpha << "."); 138 152 139 153 for (molecule::iterator it2=Tensid->begin();it2 !=Tensid->end();++it2) … … 142 156 *(*it2)+=params.center; 143 157 } 144 LOG(2, "INFO: \tdone.");145 158 146 159 Tensid=NULL; … … 148 161 149 162 // shift molecule at given position on surface 150 151 LOG(1, "STATUS: Shifting " << ka+1 << " copy of tenside molecule, ");152 molecule *Tensid=stick;153 LOG(2, "INFO: Rotating ...");154 Vector ZAxis(Vector(0.0,0.0,1.0));155 Vector Axis(pt[pt.size()-1]);156 const double alpha = ZAxis.Angle(Axis);157 Axis.VectorProduct(ZAxis);158 Line RotationAxis2(Vector(0.0,0.0,1.0), Axis); // pt is the current Vector of point on surface159 160 for (molecule::iterator it2=Tensid->begin();it2 !=Tensid->end();++it2)161 163 { 162 (*it2)->setPosition(RotationAxis.rotateVector((*it2)->getPosition(),alpha)); 163 *(*it2)+=params.center; 164 } 165 LOG(2, "INFO: \tdone."); 166 167 Tensid=NULL; 168 169 return Action::success; 164 LOG(1, "STATUS: Shifting " << ka+1 << " copy of tenside molecule 'stick' with " << stick->getAtomCount() << " atoms, "); 165 molecule *Tensid=stick; 166 // this molecule was present before, hence do not remove it! 167 //CreatedMolecules.push_back(Tensid); 168 169 Vector ZAxis(Vector(0.0,0.0,1.0)); 170 Vector Axis(pt[pt.size()-1]); 171 const double alpha = ZAxis.Angle(Axis); 172 Axis.VectorProduct(ZAxis); 173 Line RotationAxis(Vector(0.0,0.0,1.0), Axis); // pt is the current Vector of point on surface 174 LOG(2, "INFO: Rotating along axis " << RotationAxis << " by angle " << alpha << "."); 175 176 for (molecule::iterator it2=Tensid->begin();it2 !=Tensid->end();++it2) 177 { 178 (*it2)->setPosition(RotationAxis.rotateVector((*it2)->getPosition(),alpha)); 179 *(*it2)+=params.center; 180 } 181 } 182 183 184 return Action::state_ptr(new MoleculeCreateMicelleState(CreatedMolecules, stick, stickPositions, params)); 170 185 } 171 186 172 187 Action::state_ptr MoleculeCreateMicelleAction::performUndo(Action::state_ptr _state) 173 188 { 174 // MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.()); 175 176 // string newName = state->mol->Name(); 177 // state->mol->setName(state->lastName); 178 189 MoleculeCreateMicelleState *state = assert_cast<MoleculeCreateMicelleState*>(_state.get()); 190 191 // removing all created molecules 192 MoleculeListClass *&molecules = World::getInstance().getMolecules(); 193 LOG(0, "STATUS: Removing " << state->CreatedMolecules.size() << " molecules again."); 194 for(std::vector<molecule *>::const_iterator iter = state->CreatedMolecules.begin(); 195 iter != state->CreatedMolecules.end(); 196 ++iter) { 197 LOG(2, "INFO: Removing " << (*iter)->getName()); 198 for(molecule::iterator AtomRunner = (*iter)->begin(); 199 !(*iter)->empty(); 200 AtomRunner = (*iter)->begin()) { 201 World::getInstance().destroyAtom(*AtomRunner); 202 } 203 //LOG(3, "INFO: molecules contains still " << molecules->ListOfMolecules.size() << " molecules."); 204 molecules->erase(*iter); 205 World::getInstance().destroyMolecule(*iter); 206 } 207 208 // undo changes to original molecule 209 ASSERT(state->stickPositions.size() == state->stick->size(), 210 "MoleculeCreateMicelleAction::performUndo() - number of stored positions (" 211 +toString(state->stickPositions.size())+") and number of atoms (" 212 +toString(state->stick->size())+") do not match."); 213 std::vector<Vector>::const_iterator PosIter = state->stickPositions.begin(); 214 molecule::iterator iter = state->stick->begin(); 215 for (; iter != state->stick->end(); ++iter, ++PosIter) 216 (*iter)->setPosition(*PosIter); 217 218 return Action::state_ptr(_state); 219 } 220 221 Action::state_ptr MoleculeCreateMicelleAction::performRedo(Action::state_ptr _state) 222 { 223 LOG(0, "STATUS: CreateMicelleAction::performRedo() is nit implemented yet."); 179 224 return Action::failure; 180 225 } 181 226 182 Action::state_ptr MoleculeCreateMicelleAction::performRedo(Action::state_ptr _state)183 {184 // Undo and redo have to do the same for this action185 return performUndo(_state);186 }187 188 227 189 228 bool MoleculeCreateMicelleAction::canUndo() 190 229 { 191 return false;230 return true; 192 231 } 193 232 194 233 bool MoleculeCreateMicelleAction::shouldUndo() 195 234 { 196 return false;235 return true; 197 236 } 198 237 -
src/Actions/MoleculeAction/CreateMicelleAction.def
rc521e1 rf6ba43 9 9 #include <vector> 10 10 #include "LinearAlgebra/Vector.hpp" 11 class CreateMicelle;12 11 12 class molecule; 13 13 14 14 // "undefine" if no parameters are required 15 #define paramtypes (int) (Vector) (double)16 #define paramtokens ("create-micelle") ("position") ("radius")17 #define paramdescriptions ("number of molecules")("center of micelle in R^3 space")("radius of mcielle") 18 # undef paramdefaults19 #define paramreferences (N) (center) (radius)15 #define paramtypes (int)(Vector)(double)(bool) 16 #define paramtokens ("create-micelle")("position")("radius")("DoRotate") 17 #define paramdescriptions ("number of molecules")("center of micelle in R^3 space")("radius of mcielle")("whether to mirror molecule perpendicular to z axis") 18 #define paramdefaults (NODEFAULT)(NODEFAULT)(NODEFAULT)("0") 19 #define paramreferences (N)(center)(radius)(DoRotate) 20 20 21 # undef statetypes22 # undef statereferences21 #define statetypes (std::vector<molecule *>)(molecule *)(std::vector<Vector>) 22 #define statereferences (CreatedMolecules)(stick)(stickPositions) 23 23 24 24 // some defines for all the names, you may use ACTION, STATE and PARAMS … … 30 30 31 31 // finally the information stored in the ActionTrait specialization 32 #define DESCRIPTION "creates a micelle of molecules "32 #define DESCRIPTION "creates a micelle of molecules by aligning molecule along z axis and placing perpendicular to sphere\'s surface. Note that alignment has freedom with respect to z axis, use DoRotate to compensate." 33 33 #undef SHORTFORM -
src/Shapes/BaseShapes.cpp
rc521e1 rf6ba43 69 69 * \param N number of points on surface 70 70 */ 71 std::vector<Vector> Sphere_impl::getHomogeneousPointsOnSurface(const size_t N) const { 71 std::vector<Vector> Sphere_impl::getHomogeneousPointsOnSurface(const size_t N) const 72 { 72 73 std::vector<Vector> PointsOnSurface; 73 74 … … 108 109 length = length + dlength;*/ 109 110 110 //ASSERT(PointsOnSurface.size() == N, "Sphere_impl::getHomogeneousPointsOnSurface() did not create enough points."); 111 // ASSERT(PointsOnSurface.size() == N, 112 // "Sphere_impl::getHomogeneousPointsOnSurface() did not create " 113 // +::toString(N)+" but "+::toString(PointsOnSurface.size())+" points."); 111 114 return PointsOnSurface; 112 115 }
Note:
See TracChangeset
for help on using the changeset viewer.