PSCF v1.4.0
ConcentrationDerivative.tpp
1#ifndef RP_CONCENTRATION_DERIVATIVE_TPP
2#define RP_CONCENTRATION_DERIVATIVE_TPP
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2025, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include "ConcentrationDerivative.h"
12
13namespace Pscf {
14namespace Rp {
15
16 using namespace Util;
17
18 /*
19 * Constructor.
20 */
21 template <int D, class T>
23 typename T::Simulator& simulator,
24 typename T::System& system)
25 : AverageAnalyzerT(simulator, system)
26 { ParamComposite::setClassName("ConcentrationDerivative"); }
27
28 /*
29 * Compute and return the derivative of interest.
30 */
31 template <int D, class T>
33 {
34 UTIL_CHECK(system().w().hasData());
35
36 // For AB diblock
37 const int nMonomer = system().mixture().nMonomer();
38 UTIL_CHECK(nMonomer == 2);
39
40 double vMonomer = system().mixture().vMonomer();
41 const int meshSize = system().domain().mesh().size();
43 // Compute and retrieve Hamiltonian
44 if (!system().c().hasData()) {
45 system().compute();
46 }
47 if (!simulator().hasWc()){
48 simulator().computeWc();
49 }
50 if (!simulator().hasHamiltonian()) {
51 simulator().computeHamiltonian();
52 }
53 double h = simulator().hamiltonian();
54
55 // Calculate derivative with respect to concentration
56 double dfdc = h * vMonomer;
57
58 // With N term
59 double Hh = double(meshSize)/2.0 * vMonomer;
60 dfdc -= Hh;
61
62 return dfdc;
63 }
64
65}
66}
67#endif
ConcentrationDerivative(typename T::Simulator &simulator, typename T::System &system)
Constructor.
double compute() override
Compute and return the derivative of H w/ respect to concentration.
void setClassName(const char *className)
Set class name string.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Class templates for real-valued periodic fields.
PSCF package top-level namespace.