source: src/Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp@ b25fa3

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
Last change on this file since b25fa3 was d6f886, checked in by Frederik Heber <heber@…>, 14 years ago

changed stupid --lengths parameter of fill...-with-molecule into three distinct ones.

  • in this Vector length three distinct things had been mixed, with --distance it made sense, with lengths this's been just nonsense.
  • new parameters are --distance-to-molecule --random-atom-displacement and --random-molecule-displacement and all default to zero.
  • moved files into regression/Filling and three files, one for each test case according to new scheme.

TESTFIXES:

  • Filling/1-3: lengths mostly replaced by --distance-to-molecule
  • Property mode set to 100644
File size: 6.5 KB
RevLine 
[eee966]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 * FillVoidWithMoleculeAction.cpp
10 *
11 * Created on: May 10, 2010
12 * Author: heber
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
[ad011c]20#include "CodePatterns/MemDebug.hpp"
[eee966]21
22#include "atom.hpp"
23#include "bondgraph.hpp"
24#include "boundary.hpp"
25#include "config.hpp"
26#include "molecule.hpp"
[ad011c]27#include "CodePatterns/Verbose.hpp"
[eee966]28#include "World.hpp"
29
[66fd49]30#include "Descriptors/MoleculeIdDescriptor.hpp"
[eee966]31#include "Parser/MpqcParser.hpp"
32#include "Parser/PcpParser.hpp"
33#include "Parser/PdbParser.hpp"
34#include "Parser/TremoloParser.hpp"
35#include "Parser/XyzParser.hpp"
36#include "Parser/FormatParserStorage.hpp"
37
[66fd49]38#include <algorithm>
[eee966]39#include <iostream>
40#include <string>
41
42using namespace std;
43
44#include "Actions/MoleculeAction/FillVoidWithMoleculeAction.hpp"
45
46// and construct the stuff
47#include "FillVoidWithMoleculeAction.def"
48#include "Action_impl_pre.hpp"
49/** =========== define the function ====================== */
50Action::state_ptr MoleculeFillVoidWithMoleculeAction::performCall() {
51 // obtain information
52 getParametersfromValueStorage();
53
[66fd49]54 if (!boost::filesystem::exists(params.fillername)) {
55 DoeLog(1) && (eLog() << Verbose(1) << "File with filler molecule " << params.fillername << " does not exist!" << endl);
56 return Action::failure;
57 }
58
[d6f886]59 DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, "
60 << " minimum distance to molecules" << params.boundary
61 << ", random atom displacement " << params.RandAtomDisplacement
62 << ", random molecule displacement " << params.RandMoleculeDisplacement
63 << ", distances between fillers (" << params.distances[0] << "," << params.distances[1] << "," << params.distances[2]
64 << "), MinDistance " << params.MinDistance
65 << ", DoRotate " << params.DoRotate << "." << endl);
[eee966]66 // construct water molecule
[66fd49]67 std::vector<molecule *> presentmolecules = World::getInstance().getAllMolecules();
68// DoLog(0) && (Log() << Verbose(0) << presentmolecules.size() << " molecules initially are present." << std::endl);
[e4afb4]69 std::string FilenameSuffix = params.fillername.string().substr(params.fillername.string().find_last_of('.')+1, params.fillername.string().length());
[eee966]70 ifstream input;
[e4afb4]71 input.open(params.fillername.string().c_str());
[eee966]72 switch (FormatParserStorage::getInstance().getTypeFromSuffix(FilenameSuffix)) {
73 case mpqc:
74 {
75 MpqcParser mpqcparser;
76 mpqcparser.load(&input);
77 break;
78 }
79 case pcp:
80 {
81 PcpParser pcpparser;
82 pcpparser.load(&input);
83 break;
84 }
85 case pdb:
86 {
87 PdbParser pdbparser;
88 pdbparser.load(&input);
89 break;
90 }
91 case tremolo:
92 {
93 TremoloParser tremoloparser;
94 tremoloparser.load(&input);
95 break;
96 }
97 case xyz:
98 {
99 XyzParser xyzparser;
100 xyzparser.load(&input);
101 break;
102 }
103 default:
104 DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << params.fillername << "." << endl);
105 break;
106 }
[66fd49]107
108 // search the filler molecule that has been just parsed
109 molecule *filler = NULL;
110 for (World::MoleculeIterator iter = World::getInstance().getMoleculeIter();
111 iter != World::getInstance().moleculeEnd();
112 ++iter)
[eee966]113 filler = *iter; // get last molecule
[e4afb4]114 filler->SetNameFromFilename(params.fillername.string().c_str());
[eee966]115 World::getInstance().getConfig()->BG->ConstructBondGraph(filler);
116
117 // call routine
118 double distance[NDIM];
119 for (int i=0;i<NDIM;i++)
120 distance[i] = params.distances[i];
[d6f886]121 FillVoidWithMolecule(
122 filler,
123 *(World::getInstance().getConfig()),
124 distance,
125 params.boundary,
126 params.RandAtomDisplacement,
127 params.RandMoleculeDisplacement,
128 params.MinDistance,
129 params.DoRotate);
[66fd49]130
131 // generate list of newly created molecules
132 // (we can in general remove more quickly from a list than a vector)
133 std::vector<molecule *> fillermolecules = World::getInstance().getAllMolecules();
134// DoLog(0) && (Log() << Verbose(0) << fillermolecules.size() << " molecules are present." << std::endl);
135 std::list<molecule *> fillermolecules_list;
136 std::copy( fillermolecules.begin(), fillermolecules.end(), std::back_inserter( fillermolecules_list ));
137// DoLog(0) && (Log() << Verbose(0) << fillermolecules_list.size() << " molecules have been copied." << std::endl);
138 for (std::vector<molecule *>::const_iterator iter = presentmolecules.begin();
139 iter != presentmolecules.end();
140 ++iter) {
141 fillermolecules_list.remove(*iter);
142 }
143// DoLog(0) && (Log() << Verbose(0) << fillermolecules_list.size() << " molecules left after removal." << std::endl);
144 fillermolecules.clear();
145 std::copy(fillermolecules_list.begin(), fillermolecules_list.end(), std::back_inserter( fillermolecules ));
146
147// DoLog(0) && (Log() << Verbose(0) << fillermolecules.size() << " molecules have been inserted." << std::endl);
[eee966]148
[66fd49]149 return Action::state_ptr(new MoleculeFillVoidWithMoleculeState(fillermolecules,params));
[eee966]150}
151
152Action::state_ptr MoleculeFillVoidWithMoleculeAction::performUndo(Action::state_ptr _state) {
[66fd49]153 MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.get());
154
155 MoleculeListClass *MolList = World::getInstance().getMolecules();
156
157 BOOST_FOREACH(molecule *_mol, state->fillermolecules) {
158 MolList->erase(_mol);
159 if ((_mol != NULL) && (!(World::getInstance().getAllMolecules(MoleculeById(_mol->getId()))).empty())) {
160 for(molecule::iterator iter = _mol->begin();
161 !_mol->empty();
162 iter = _mol->begin()) {
163 atom *Walker = *iter;
164 _mol->erase(iter);
165 World::getInstance().destroyAtom(Walker);
166 }
167 World::getInstance().destroyMolecule(_mol);
168 }
169 }
[eee966]170
[66fd49]171 // as molecules and atoms from state are removed, we have to create a new one
172 std::vector<molecule *> fillermolecules;
173 return Action::state_ptr(new MoleculeFillVoidWithMoleculeState(fillermolecules,state->params));
[eee966]174}
175
176Action::state_ptr MoleculeFillVoidWithMoleculeAction::performRedo(Action::state_ptr _state){
[66fd49]177 //MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.get());
178
179 return Action::failure;
180 //return Action::state_ptr(_state);
[eee966]181}
182
183bool MoleculeFillVoidWithMoleculeAction::canUndo() {
[66fd49]184 return true;
[eee966]185}
186
187bool MoleculeFillVoidWithMoleculeAction::shouldUndo() {
[66fd49]188 return true;
[eee966]189}
190/** =========== end of function ====================== */
Note: See TracBrowser for help on using the repository browser.