Simpatico  v1.10
McAnalyzerFactory.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 "McAnalyzerFactory.h" // Class header
9 
10 #include "McEnergyOutput.h"
11 #include "McEnergyAnalyzer.h"
12 #include "McEnergyAverage.h"
13 #include "McPressureAverage.h"
14 #include "McVirialStressTensorAverage.h"
15 
16 #ifndef SIMP_NOPAIR
17 #include "McPairEnergyAverage.h"
18 #include "McMuExchange.h"
19 #endif
20 
21 #ifdef SIMP_BOND
22 #include "McIntraBondStressAutoCorr.h"
23 #include "McBondEnergyAverage.h"
24 #include "McIntraBondTensorAutoCorr.h"
25 #ifndef SIMP_NOPAIR
26 #include "McNVTChemicalPotential.h"
27 #endif
28 #endif
29 
30 #ifdef SIMP_EXTERNAL
31 #include "McExternalEnergyAverage.h"
32 #endif
33 
34 #include <mcMd/analyzers/mutable/TypeDistribution.h>
35 #include <mcMd/analyzers/mutable/SemiGrandDistribution.h>
36 
37 #include <mcMd/mcSimulation/McSimulation.h>
38 #include <mcMd/mcSimulation/McSystem.h>
39 
40 namespace McMd
41 {
42 
43  using namespace Util;
44 
45  /*
46  * Constructor.
47  */
49  McSystem& system)
50  : systemFactory_(simulation, system),
51  simulationPtr_(&simulation),
52  systemPtr_(&system)
53  {}
54 
55  /*
56  * Return a pointer to a instance of Analyzer subclass className.
57  */
58  Analyzer* McAnalyzerFactory::factory(const std::string &className) const
59  {
60  Analyzer* ptr = 0;
61 
62  // Try subfactories first (if any)
63  ptr = trySubfactories(className);
64  if (ptr) return ptr;
65 
66  if (className == "McEnergyOutput") {
67  ptr = new McEnergyOutput(system());
68  } else
69  if (className == "McEnergyAnalyzer") {
70  ptr = new McEnergyAnalyzer(system());
71  } else
72  if (className == "McEnergyAverage") {
73  ptr = new McEnergyAverage(system());
74  } else
75  if (className == "McPressureAverage") {
76  ptr = new McPressureAverage(system());
77  } else
78  if (className == "McVirialStressTensorAverage") {
80  }
81 
82  #ifndef SIMP_NOPAIR
83  else
84  if (className == "McPairEnergyAverage") {
85  ptr = new McPairEnergyAverage(system());
86  } else
87  if (className == "McMuExchange") {
88  ptr = new McMuExchange(system());
89  }
90  #endif
91 
92  #ifdef SIMP_BOND
93  else
94  if (className == "McBondEnergyAverage") {
95  ptr = new McBondEnergyAverage(system());
96  } else
97  if (className == "McIntraBondStressAutoCorr") {
98  ptr = new McIntraBondStressAutoCorr(system());
99  } else
100  if (className == "McIntraBondTensorAutoCorr") {
101  ptr = new McIntraBondTensorAutoCorr(system());
102  }
103  #ifndef SIMP_NOPAIR
104  else
105  if (className == "McNVTChemicalPotential") {
106  ptr = new McNVTChemicalPotential(system());
107  }
108  #endif
109  #endif
110 
111  #ifdef SIMP_EXTERNAL
112  else
113  if (className == "McExternalEnergyAverage") {
114  ptr = new McExternalEnergyAverage(system());
115  }
116  #endif
117 
118  // Semi-grand ensemble
119  else
120  if (className == "TypeDistribution") {
121  ptr = new TypeDistribution(system());
122  } else
123  if (className == "SemiGrandDistribution") {
124  ptr = new SemiGrandDistribution(system());
125  }
126 
127  // If none of the above are matched, try SystemAnalyzerFactory
128  if (!ptr) {
129  ptr = systemFactory_.factory(className);
130  }
131 
132  return ptr;
133  }
134 
135 }
A System for use in a Markov chain Monte Carlo simulation.
Definition: McSystem.h:52
Exchange chemical potential for semigrand ensemble.
Definition: McMuExchange.h:41
virtual Analyzer * factory(const std::string &className) const
Return pointer to a new Analyzer object.
Analyzer to output total potential energy.
McNVTChemicalPotential uses configuration bias algorithm to calculate the chemical potential of a lin...
Analyzer to calculate average isotropic pressure.
A Monte-Carlo simulation of one McSystem.
Definition: McSimulation.h:32
Autocorrelation for bond stress of a molecule.
McBondEnergyAverage averages of bond potential energy.
Abstract base for periodic output and/or analysis actions.
McAnalyzerFactory(McSimulation &simulation, McSystem &system)
Constructor.
Calculate distribution of type indices for mutable species.
Analyzer * trySubfactories(const std::string &className) const
Search through subfactories for match.
McSystem & system() const
Return reference to parent McSystem.
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).
Autocorrelation for bond stress of a molecule.
McEnergyAverage averages of total potential energy.
McExternalEnergyAverage averages of total external energy.
Periodically write (tensor) StressTensor to file.
Calculate distribution of type indices for mutable species.
McPairEnergyAverage averages of total potential energy.
Compute averages and output block averages of energy components.