PSCF v1.5.0
PerturbationFactory.tpp
1/*
2* PSCF - Polymer Self-Consistent Field
3*
4* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "PerturbationFactory.h"
9
10// Subclasses of Perturbation
11#include <rp/fts/perturbation/EinsteinCrystalPerturbation.h>
12
13namespace Pscf {
14namespace Rp {
15
16 using namespace Util;
17
18 /*
19 * Constructor
20 */
21 template <int D, class T>
23 Simulator<D,T>& simulator)
24 : simulatorPtr_(&simulator)
25 {}
26
27 /*
28 * Return a pointer to a instance of Perturbation subclass className.
29 */
30 template <int D, class T>
32 PerturbationFactory<D,T>::factory(const std::string & className) const
33 {
34 Perturbation<D,T>* ptr = 0;
35
36 // Try subfactories first
37 ptr = trySubfactories(className);
38 if (ptr) return ptr;
40 // Try to match classname. The generic label "Perturbation"
41 // selects the default algorithm, EinsteinCrystalPerturbation.
42 if (className == "EinsteinCrystal" ||
43 className == "EinsteinCrystalPerturbation" ||
44 className == "Perturbation") {
45 ptr = new EinsteinCrystalPerturbation<D,T>(*simulatorPtr_);
46 }
48 return ptr;
49 }
50
51}
52}
EinsteinCrystalPerturbation(Simulator< D, T > &simulator)
Constructor.
PerturbationFactory(Simulator< D, T > &simulator)
Constructor.
Perturbation< D, T > * factory(const std::string &className) const
Method to create any Perturbation supplied with PSCF.
Base class for additive perturbations of standard FTS Hamiltonian.
Base class for field theoretic PS-FTS simulator.
Definition Simulator.h:93
Perturbation< D, T > * trySubfactories(const std::string &className) const
Definition Factory.h:427
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.