ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/hydrodynamics/Hydro.cpp
Revision: 2596
Committed: Wed Feb 22 20:35:16 2006 UTC (18 years, 6 months ago) by tim
File size: 5832 byte(s)
Log Message:
Adding Hydrodynamics Module

File Contents

# User Rev Content
1 tim 2596 /*
2     * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3     *
4     * The University of Notre Dame grants you ("Licensee") a
5     * non-exclusive, royalty free, license to use, modify and
6     * redistribute this software in source and binary code form, provided
7     * that the following conditions are met:
8     *
9     * 1. Acknowledgement of the program authors must be made in any
10     * publication of scientific results based in part on use of the
11     * program. An acceptable form of acknowledgement is citation of
12     * the article in which the program was described (Matthew
13     * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14     * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15     * Parallel Simulation Engine for Molecular Dynamics,"
16     * J. Comput. Chem. 26, pp. 252-271 (2005))
17     *
18     * 2. Redistributions of source code must retain the above copyright
19     * notice, this list of conditions and the following disclaimer.
20     *
21     * 3. Redistributions in binary form must reproduce the above copyright
22     * notice, this list of conditions and the following disclaimer in the
23     * documentation and/or other materials provided with the
24     * distribution.
25     *
26     * This software is provided "AS IS," without a warranty of any
27     * kind. All express or implied conditions, representations and
28     * warranties, including any implied warranty of merchantability,
29     * fitness for a particular purpose or non-infringement, are hereby
30     * excluded. The University of Notre Dame and its licensors shall not
31     * be liable for any damages suffered by licensee as a result of
32     * using, modifying or distributing the software or its
33     * derivatives. In no event will the University of Notre Dame or its
34     * licensors be liable for any lost revenue, profit or data, or for
35     * direct, indirect, special, consequential, incidental or punitive
36     * damages, however caused and regardless of the theory of liability,
37     * arising out of the use of or inability to use software, even if the
38     * University of Notre Dame has been advised of the possibility of
39     * such damages.
40     */
41    
42     #include <iostream>
43     #include <fstream>
44     #include <string>
45    
46     #include "applications/hydrodynamics/HydroCmd.h"
47     #include "applications/hydrodynamics/HydrodynamicsModel.hpp"
48     #include "applications/hydrodynamics/HydrodynamicsModelCreator.hpp"
49     #include "applications/hydrodynamics/HydrodynamicsModelFactory.hpp"
50     #include "applications/hydrodynamics/BeadModel.hpp"
51     #include "applications/hydrodynamics/RoughShell.hpp"
52     #include "brains/Register.hpp"
53     #include "brains/SimCreator.hpp"
54     #include "brains/SimInfo.hpp"
55    
56     using namespace oopse;
57    
58     /** Register different hydrodynamics models */
59     void registerHydrodynamicsModels();
60    
61     bool calcHydrodynamicsProp(const std::string& modelType, Molecule* mol, const DynamicProperty& param, const std::string& prefix,double viscosity);
62    
63     int main(int argc, char* argv[]){
64     //register force fields
65     registerForceFields();
66     registerHydrodynamicsModels();
67    
68     gengetopt_args_info args_info;
69     std::string dumpFileName;
70     std::string mdFileName;
71     std::string prefix;
72    
73     //parse the command line option
74     if (cmdline_parser (argc, argv, &args_info) != 0) {
75     exit(1) ;
76     }
77    
78     //get the dumpfile name and meta-data file name
79     if (args_info.input_given){
80     dumpFileName = args_info.input_arg;
81     } else {
82     std::cerr << "Does not have input file name" << std::endl;
83     exit(1);
84     }
85    
86     mdFileName = dumpFileName;
87     mdFileName = mdFileName.substr(0, mdFileName.rfind(".")) + ".md";
88    
89     if (args_info.output_given){
90     prefix = args_info.output_arg;
91     } else {
92     prefix = "hydro";
93     }
94    
95     DynamicProperty param;
96     if (args_info.sigma_given) {
97     param.insert(DynamicProperty::value_type("Sigma", args_info.sigma_arg));
98     }
99    
100    
101     //parse md file and set up the system
102     SimCreator creator;
103     SimInfo* info = creator.createSim(mdFileName, true);
104    
105     SimInfo::MoleculeIterator mi;
106     Molecule* mol;
107     Molecule::RigidBodyIterator ri;
108     RigidBody* rb;
109     //update atoms of rigidbody
110     for (mol = info->beginMolecule(mi); mol != NULL; mol = info->nextMolecule(mi)) {
111    
112     //change the positions of atoms which belong to the rigidbodies
113     for (rb = mol->beginRigidBody(ri); rb != NULL; rb = mol->nextRigidBody(ri)) {
114     rb->updateAtoms();
115     }
116     }
117    
118     for (mol = info->beginMolecule(mi); mol != NULL; mol = info->nextMolecule(mi)) {
119     calcHydrodynamicsProp(args_info.model_arg, mol, param, prefix, args_info.viscosity_arg);
120     }
121    
122     delete info;
123    
124     }
125    
126     void registerHydrodynamicsModels() {
127     HydrodynamicsModelFactory::getInstance()->registerHydrodynamicsModel(new HydrodynamicsModelBuilder<RoughShell>("RoughShell"));
128     HydrodynamicsModelFactory::getInstance()->registerHydrodynamicsModel(new HydrodynamicsModelBuilder<BeadModel>("BeadModel"));
129    
130     }
131    
132     bool calcHydrodynamicsProp(const std::string& modelType, Molecule* mol, const DynamicProperty& param, const std::string& prefix,double viscosity) {
133     HydrodynamicsModel* hydroModel = HydrodynamicsModelFactory::getInstance()->createHydrodynamicsModel(modelType, mol, param);
134     bool ret = false;
135     if (hydroModel == NULL) {
136     std::cout << "Integrator Factory can not create " << modelType <<std::endl;
137     }
138    
139     if (hydroModel->calcHydrodyanmicsProps(viscosity)) {
140     ret = true;
141     std::stringstream outputDiffTensor;
142     outputDiffTensor << prefix << "_" << mol->getType() << ".diff";
143     std::ofstream ofs;
144     ofs.open(outputDiffTensor.str().c_str());
145     hydroModel->writeDiffCenterAndDiffTensor(ofs);
146     ofs.close();
147    
148     std::stringstream outputBeads;
149     outputBeads << prefix << "_" << mol->getType() << ".xyz";
150     ofs.open(outputBeads.str().c_str());
151     hydroModel->writeBeads(ofs);
152     ofs.close();
153     }
154    
155     delete hydroModel;
156    
157     return ret;
158     }

Properties

Name Value
svn:executable *