Simpatico  v1.10
MdAnalyzerFactory.cpp
1 /*
2 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
3 *
4 * Copyright 2010 - 2017, The Regents of the University of Minnesota
5 * Distributed under the terms of the GNU General Public License.
6 */
7 
8 #include "MdAnalyzerFactory.h" // Class header
9 
10 // Analyzers for MdSystem only
11 #include "MdEnergyAnalyzer.h"
12 #include "MdEnergyOutput.h"
13 #include "MdPotentialEnergyAverage.h"
14 #include "MdKineticEnergyAverage.h"
15 #include "MdPressureAverage.h"
16 #include "MdStressAutoCorr.h"
17 #include "MdPairEnergyCoefficients.h"
18 #ifdef SIMP_BOND
19 #include "MdIntraBondStressAutoCorr.h"
20 #include "MdIntraBondTensorAutoCorr.h"
21 #endif
22 
23 #include <mcMd/mdSimulation/MdSimulation.h>
24 
25 namespace McMd
26 {
27 
28  using namespace Util;
29 
30  /*
31  * Constructor.
32  */
34  MdSystem& system)
35  : systemFactory_(simulation, system),
36  simulationPtr_(&simulation),
37  systemPtr_(&system)
38  {}
39 
40  /*
41  * Return a pointer to an instance of Analyzer subclass className.
42  */
43  Analyzer* MdAnalyzerFactory::factory(const std::string &className) const
44  {
45  Analyzer* ptr = 0;
46 
47  // Try subfactories first (if any)
48  ptr = trySubfactories(className);
49  if (ptr) return ptr;
50 
51  // MdSystem Analyzers
52  if (className == "MdEnergyAnalyzer") {
53  ptr = new MdEnergyAnalyzer(system());
54  } else
55  if (className == "MdEnergyOutput") {
56  ptr = new MdEnergyOutput(system());
57  } else
58  if (className == "MdPotentialEnergyAverage") {
59  ptr = new MdPotentialEnergyAverage(system());
60  } else
61  if (className == "MdKineticEnergyAverage") {
62  ptr = new MdKineticEnergyAverage(system());
63  } else
64  if (className == "MdPressureAverage") {
65  ptr = new MdPressureAverage(system());
66  } else
67  if (className == "MdStressAutoCorr") {
68  ptr = new MdStressAutoCorr(system());
69  }
70 
71  #ifndef SIMP_NOPAIR
72  else
73  if (className == "MdPairEnergyCoefficients") {
74  ptr = new MdPairEnergyCoefficients(system());
75  }
76  #endif
77 
78  #ifdef SIMP_BOND
79  else
80  if (className == "MdIntraBondStressAutoCorr") {
81  ptr = new MdIntraBondStressAutoCorr(system());
82  } else
83  if (className == "MdIntraBondTensorAutoCorr") {
84  ptr = new MdIntraBondTensorAutoCorr(system());
85  }
86  #endif
87 
88  // If none of the above, try the SystemAnalyzerFactory
89  if (!ptr) {
90  ptr = systemFactory_.factory(className);
91  }
92 
93  return ptr;
94  }
95 
96 }
MdPotentialEnergyAverage averages of total potential energy.
Autocorrelation for bond stress of a molecule.
Analyzer to output the total pair energy and the sum of squares of the monomeric and molecular pair e...
virtual Analyzer * factory(const std::string &className) const
Return pointer to a new Analyzer object.
MdSystem & system() const
Return reference to parent MdSystem.
Calculate average scalar pressure for an MdSystem.
MdKineticEnergyAverage averages of total kinetic energy.
Abstract base for periodic output and/or analysis actions.
Analyzer * trySubfactories(const std::string &className) const
Search through subfactories for match.
Utility classes for scientific computation.
Definition: accumulators.mod:1
virtual Analyzer * factory(const std::string &className) const
Return pointer to a new Analyzer object.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
A System for Molecular Dynamics simulation.
Definition: MdSystem.h:68
Compute averages and output block averages of energy components.
Analyzer to output total potential and kinetic energies.
A molecular dynamics simulation of a single MdSystem.
Definition: MdSimulation.h:26
Autocorrelation for bond orientation of of a molecule.
MdAnalyzerFactory(MdSimulation &simulation, MdSystem &system)
Constructor.
Analyzer to calculate average isotropic pressure.