Changeset 2440ce
- Timestamp:
- Jan 14, 2015, 9:03:24 PM (10 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:
- cad383
- Parents:
- 601ef8
- git-author:
- Frederik Heber <heber@…> (01/14/15 20:31:24)
- git-committer:
- Frederik Heber <heber@…> (01/14/15 21:03:24)
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FillAction/SuspendInMoleculeAction.cpp
r601ef8 r2440ce 129 129 filler->CenterEdge(); 130 130 131 std::vector<molecule *> molecules = World::getInstance().getAllMolecules(); 132 if (molecules.size() < 2) { 133 STATUS("There must be at least two molecules: filler and to be suspended."); 134 return Action::failure; 135 } 136 131 137 /// first we need to calculate some volumes and masses 132 std::vector<molecule *> molecules = World::getInstance().getAllMolecules();133 138 double totalmass = 0.; 134 139 const bool IsAngstroem = true; … … 139 144 iter != molecules.end(); ++iter) 140 145 { 146 // skip the filler 147 if (*iter == filler) 148 continue; 141 149 molecule & mol = **iter; 142 150 const double mass = calculateMass(mol); … … 152 160 LOG(1, "INFO: The average density is " << setprecision(10) 153 161 << totalmass / clustervolume << " atomicmassunit/" 154 << (IsAngstroem ? "angstrom" : "atomiclength") << "^3."); 162 << (IsAngstroem ? " angstrom" : " atomiclength") << "^3."); 163 if ( ((totalmass / clustervolume < 1.) && (params.density.get() > 1.)) 164 || ((totalmass / clustervolume > 1.) && (params.density.get() < 1.))) { 165 STATUS("Desired and present molecular densities must both be either in [0,1) or in (1, inf)."); 166 return Action::failure; 167 } 155 168 156 169 // calculate maximum solvent density 157 170 std::vector<double> fillerdiameters(NDIM, 0.); 158 const double solventdensity = 159 calculateMass(*filler) / calculateEnvelopeVolume(*filler, fillerdiameters); 160 161 std::vector<unsigned int> counts(3, 0); 162 Vector offset(.5,.5,.5); 171 const double fillervolume = calculateEnvelopeVolume(*filler, fillerdiameters); 172 const double fillermass = calculateMass(*filler); 173 LOG(1, "INFO: The filler's mass is " << setprecision(10) 174 << fillermass << " atomicmassunit, and it's volume is " 175 << fillervolume << (IsAngstroem ? " angstrom" : " atomiclength") << "^3."); 176 const double solventdensity = fillermass / fillervolume; 163 177 164 178 /// solve cubic polynomial 165 179 double cellvolume = 0.; 166 180 LOG(1, "Solving equidistant suspension in water problem ..."); 167 cellvolume = (totalmass / solventdensity 168 - (totalmass / clustervolume)) / (params.density.get() - 1.); 181 // s = solvent, f = filler, 0 = initial molecules/cluster 182 // v_s = v_0 + v_f, m_s = m_0 + rho_f * v_f --> rho_s = m_s/v_s ==> v_f = (m_0 - rho_s * v_o) / (rho_s - rho_f) 183 cellvolume = (totalmass - params.density.get() * clustervolume) / (params.density.get() - 1.) + clustervolume; 169 184 LOG(1, "Cellvolume needed for a density of " << params.density.get() 170 185 << " g/cm^3 is " << cellvolume << " angstroem^3."); … … 173 188 (GreatestDiameter[0] * GreatestDiameter[1] * GreatestDiameter[2]); 174 189 LOG(1, "Minimum volume of the convex envelope contained in a rectangular box is " 175 << minimumvolume << " angstrom^3.");190 << minimumvolume << " angstrom^3."); 176 191 177 192 if (minimumvolume > cellvolume) { … … 187 202 + GreatestDiameter[1] * GreatestDiameter[2]; 188 203 BoxLengths[2] = minimumvolume - cellvolume; 189 double x0 = 0.; 190 double x1 = 0.; 191 double x2 = 0.; 204 std::vector<double> x(3, 0.); 192 205 // for cubic polynomial there are either 1 or 3 unique solutions 193 if (gsl_poly_solve_cubic(BoxLengths[0], BoxLengths[1], BoxLengths[2], &x0, &x1, &x2) == 1) 194 LOG(0, "RESULT: The resulting spacing is: " << x0 << " ."); 195 else { 196 LOG(0, "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ."); 197 std::swap(x0, x2); // sorted in ascending order 198 } 206 if (gsl_poly_solve_cubic(BoxLengths[0], BoxLengths[1], BoxLengths[2], &x[0], &x[1], &x[2]) == 1) { 207 x[1] = x[0]; 208 x[2] = x[0]; 209 } else { 210 std::swap(x[0], x[2]); // sorted in ascending order 211 } 212 LOG(0, "RESULT: The resulting spacing is: " << x << " ."); 199 213 200 214 cellvolume = 1.; 201 215 for (size_t i = 0; i < NDIM; ++i) { 202 BoxLengths[i] = x 0+ GreatestDiameter[i];216 BoxLengths[i] = x[i] + GreatestDiameter[i]; 203 217 cellvolume *= BoxLengths[i]; 204 218 } 205 206 // set new box dimensions 207 LOG(0, "Translating to box with these boundaries."); 208 { 209 RealSpaceMatrix domain; 210 for(size_t i =0; i<NDIM;++i) 211 domain.at(i,i) = BoxLengths[i]; 212 World::getInstance().setDomain(domain); 213 } 214 // mol->CenterInBox(); 219 } 220 221 // TODO: Determine counts from resulting mass correctly (hard problem due to integers) 222 std::vector<unsigned int> counts(3, 0); 223 const unsigned int totalcounts = round(params.density.get() * cellvolume - totalmass) / fillermass; 224 if (totalcounts > 0) { 225 counts[0] = ceil(BoxLengths[0]/3.1); 226 counts[1] = ceil(BoxLengths[1]/3.1); 227 counts[2] = ceil(BoxLengths[2]/3.1); 215 228 } 216 229 … … 231 244 params.RandMoleculeDisplacement.get(), 232 245 params.DoRotate.get()); 246 Vector offset(.5,.5,.5); 233 247 filler_preparator.addCubeMesh( 234 248 counts, -
src/Actions/FillAction/SuspendInMoleculeAction.def
r601ef8 r2440ce 17 17 #include "Parameters/Validators/RangeValidator.hpp" 18 18 #include "Parameters/Validators/STLVectorValidator.hpp" 19 #include "Parameters/Validators/Ops_Validator.hpp" 19 20 #include "Parameters/Validators/Specific/BoxLengthValidator.hpp" 20 21 #include "Parameters/Validators/Specific/VectorZeroOneComponentsValidator.hpp" … … 25 26 #define paramtypes (double)(double)(double)(double)(bool) 26 27 #define paramtokens ("density")("min-distance")("random-atom-displacement")("random-molecule-displacement")("DoRotate") 27 #define paramdescriptions ("desired density for the total domain ")("minimum distance of water molecules to present atoms")("magnitude of random atom displacement")("magnitude of random molecule displacement")("whether to rotate or not")28 #define paramdescriptions ("desired density for the total domain, unequal 1.")("minimum distance of water molecules to present atoms")("magnitude of random atom displacement")("magnitude of random molecule displacement")("whether to rotate or not") 28 29 #define paramdefaults (PARAM_DEFAULT(1.))(PARAM_DEFAULT(1.))(PARAM_DEFAULT(0.))(PARAM_DEFAULT(0.))(PARAM_DEFAULT(false)) 29 30 #define paramreferences (density)(mindistance)(RandAtomDisplacement)(RandMoleculeDisplacement)(DoRotate) 30 31 #define paramvalids \ 31 (RangeValidator< double >(0., std::numeric_limits<double>::max())) \32 (RangeValidator< double >(0., 1. - std::numeric_limits<double>::epsilon()) || RangeValidator< double >(1. + std::numeric_limits<double>::epsilon(), std::numeric_limits<double>::max())) \ 32 33 (BoxLengthValidator()) \ 33 34 (BoxLengthValidator()) \ -
tests/regression/Filling/SuspendInWater/pre/test.conf
r601ef8 r2440ce 28 28 OutSrcStep 5 # Output "restart" data every ..th step 29 29 TargetTemp 0.000950045 # Target temperature 30 MaxPsiStep 0# number of Minimisation steps per state (0 - default)30 MaxPsiStep 3 # number of Minimisation steps per state (0 - default) 31 31 EpsWannier 1e-07 # tolerance value for spread minimisation of orbitals 32 32 … … 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0# check every ..th steps38 MaxMinGapStopStep 0# check every ..th steps37 MaxMinStopStep 12 # check every ..th steps 38 MaxMinGapStopStep 1 # check every ..th steps 39 39 40 40 # Values specifying when to stop for INIT, otherwise same as above … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0# check every ..th steps45 InitMaxMinGapStopStep 0# check every ..th steps44 InitMaxMinStopStep 12 # check every ..th steps 45 InitMaxMinGapStopStep 1 # check every ..th steps 46 46 47 47 BoxLength # (Length of a unit cell) … … 55 55 RiemannTensor 0 # (Use metric) 56 56 PsiType 0 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 MaxPsiDouble 0# here: specifying both maximum number of SpinUp- and -Down-states58 PsiMaxNoUp 0# here: specifying maximum number of SpinUp-states59 PsiMaxNoDown 0# here: specifying maximum number of SpinDown-states57 MaxPsiDouble 12 # here: specifying both maximum number of SpinUp- and -Down-states 58 PsiMaxNoUp 12 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 12 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 … … 64 64 IsAngstroem 1 # 0 - Bohr, 1 - Angstroem 65 65 RelativeCoord 0 # whether ion coordinates are relative (1) or absolute (0) 66 MaxTypes 2# maximum number of different ion types66 MaxTypes 3 # maximum number of different ion types 67 67 68 68 # Ion type data (PP = PseudoPotential, Z = atomic number) 69 69 #Ion_TypeNr. Amount Z RGauss L_Max(PP)L_Loc(PP)IonMass # chemical name, symbol 70 Ion_Type1 81 1.0 3 3 1.00800000000 Hydrogen H70 Ion_Type1 10 1 1.0 3 3 1.00800000000 Hydrogen H 71 71 Ion_Type2 3 6 1.0 3 3 12.01100000000 Carbon C 72 Ion_Type3 1 8 1.0 3 3 15.99900000000 Oxygen O 72 73 #Ion_TypeNr._Nr.R[0] R[1] R[2] MoveType (0 MoveIon, 1 FixedIon) 73 Ion_Type2_1 9.782085945 3.275186040 3.535886037 0 # molecule nr 0 74 Ion_Type2_2 8.532785963 4.158586027 3.535886037 0 # molecule nr 1 75 Ion_Type2_3 7.283585982 3.275186040 3.535886037 0 # molecule nr 2 76 Ion_Type1_1 9.782085945 2.645886050 2.645886050 0 # molecule nr 3 77 Ion_Type1_2 9.782085945 2.645886050 4.425886024 0 # molecule nr 4 78 Ion_Type1_3 10.672039608 3.904536878 3.535886037 0 # molecule nr 5 79 Ion_Type1_4 8.532785963 4.787886018 2.645886050 0 # molecule nr 6 80 Ion_Type1_5 8.532785963 4.787886018 4.425886024 0 # molecule nr 7 81 Ion_Type1_6 6.393632318 3.904536877 3.535886037 0 # molecule nr 8 82 Ion_Type1_7 7.283585982 2.645886050 2.645886050 0 # molecule nr 9 83 Ion_Type1_8 7.283585982 2.645886050 4.425886024 0 # molecule nr 10 74 Ion_Type1_1 9.782085945 2.645886050 2.645886050 0 # molecule nr 0 75 Ion_Type1_2 9.782085945 2.645886050 4.425886024 0 # molecule nr 1 76 Ion_Type1_3 10.672039608 3.904536878 3.535886037 0 # molecule nr 2 77 Ion_Type1_4 8.532785963 4.787886018 2.645886050 0 # molecule nr 3 78 Ion_Type1_5 8.532785963 4.787886018 4.425886024 0 # molecule nr 4 79 Ion_Type1_6 6.393632318 3.904536877 3.535886037 0 # molecule nr 5 80 Ion_Type1_7 7.283585982 2.645886050 2.645886050 0 # molecule nr 6 81 Ion_Type1_8 7.283585982 2.645886050 4.425886024 0 # molecule nr 7 82 Ion_Type2_1 9.782085945 3.275186040 3.535886037 0 # molecule nr 8 83 Ion_Type2_2 8.532785963 4.158586027 3.535886037 0 # molecule nr 9 84 Ion_Type2_3 7.283585982 3.275186040 3.535886037 0 # molecule nr 10 85 Ion_Type3_1 2.000000000 2.000000000 2.000000000 0 # molecule nr 11 86 Ion_Type1_9 2.758602000 2.000000000 2.504284000 0 # molecule nr 12 87 Ion_Type1_10 2.758602000 2.000000000 1.495716000 0 # molecule nr 13 -
tests/regression/Filling/SuspendInWater/testsuite-suspend-in-water.at
r601ef8 r2440ce 18 18 ### suspend in water with certain density 19 19 20 AT_SETUP([Filling - suspend in water fails with rho=1]) 21 AT_KEYWORDS([filling suspend-in-water]) 22 23 file=test.conf 24 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/pre/test.conf $file], 0) 25 AT_CHECK([chmod u+w $file], 0) 26 AT_CHECK([../../molecuilder -i $file -I -v 3 --select-molecule-by-id 0 -u --density 1.], 5, [stdout], [stderr]) 27 28 AT_CLEANUP 29 30 AT_SETUP([Filling - suspend in water fails with just one molecule]) 31 AT_KEYWORDS([filling suspend-in-water]) 32 33 file=single_molecule.conf 34 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/pre/$file $file], 0) 35 AT_CHECK([chmod u+w $file], 0) 36 AT_CHECK([../../molecuilder -i $file -I -v 3 --select-molecule-by-id 0 -u --density 1.], 5, [stdout], [stderr]) 37 AT_CHECK([grep "at least two molecules" stdout], 0, [ignore], [ignore]) 38 39 AT_CLEANUP 40 41 # rho must be on same side of 1 as the present density 42 AT_SETUP([Filling - suspend in water fails with wrong rho]) 43 AT_KEYWORDS([filling suspend-in-water]) 44 45 file=test.conf 46 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/pre/$file $file], 0) 47 AT_CHECK([chmod u+w $file], 0) 48 AT_CHECK([../../molecuilder -i $file -I -v 3 --select-molecule-by-id 0 -u --density .5], 5, [stdout], [stderr]) 49 AT_CHECK([grep "Desired and present molecular densities must both be either" stdout], 0, [ignore], [ignore]) 50 51 AT_CLEANUP 52 20 53 AT_SETUP([Filling - suspend in water]) 21 54 AT_XFAIL_IF([/bin/true]) … … 23 56 24 57 file=test.conf 25 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/pre/ test.conf$file], 0)58 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/pre/$file $file], 0) 26 59 AT_CHECK([chmod u+w $file], 0) 27 AT_CHECK([../../molecuilder -i $file -v 3 --select-molecule-by-id 0 -u 1.3], 0, [stdout], [stderr])60 AT_CHECK([../../molecuilder -i $file -I -v 3 --select-molecule-by-id 0 -u --density 2.], 5, [stdout], [stderr]) 28 61 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/post/test.conf], 0, [ignore], [ignore]) 29 62 30 63 AT_CLEANUP 31 32 64 33 65 AT_SETUP([Filling - suspend in water with Undo]) … … 38 70 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/pre/test.conf $file], 0) 39 71 AT_CHECK([chmod u+w $file], 0) 40 AT_CHECK([../../molecuilder -i $file -v 3 --select-molecule-by-id 0 -u 1.3--undo], 0, [stdout], [stderr])72 AT_CHECK([../../molecuilder -i $file -I -v 3 --select-molecule-by-id 0 -u --density 2. --undo], 0, [stdout], [stderr]) 41 73 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/post/test.conf], 0, [ignore], [ignore]) 42 74 … … 51 83 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/pre/test.conf $file], 0) 52 84 AT_CHECK([chmod u+w $file], 0) 53 AT_CHECK([../../molecuilder -i $file -v 3 --select-molecule-by-id 0 -u 1.3--undo --redo], 0, [stdout], [stderr])85 AT_CHECK([../../molecuilder -i $file -I -v 3 --select-molecule-by-id 0 -u --density 2. --undo --redo], 0, [stdout], [stderr]) 54 86 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/post/test.conf], 0, [ignore], [ignore]) 55 87
Note:
See TracChangeset
for help on using the changeset viewer.