PSCF v1.2
rpg/solvers/Polymer.tpp
1#ifndef RPG_POLYMER_TPP
2#define RPG_POLYMER_TPP
3
4/*
5* PSCF - Polymer Self-Consistent Field Theory
6*
7* Copyright 2016 - 2022, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include "Polymer.h"
12
13namespace Pscf {
14namespace Rpg {
15
16 template <int D>
18 : nParams_(0)
19 { setClassName("Polymer"); }
20
21 template <int D>
24
25 template <int D>
26 void Polymer<D>::setPhi(double phi)
27 {
28 UTIL_CHECK(ensemble() == Species::Closed);
29 UTIL_CHECK(phi >= 0.0);
30 UTIL_CHECK(phi <= 1.0);
31 phi_ = phi;
32 }
33
34 template <int D>
35 void Polymer<D>::setMu(double mu)
36 {
37 UTIL_CHECK(ensemble() == Species::Open);
38 mu_ = mu;
39 }
40
41 /*
42 * Store the number of lattice parameters in the unit cell.
43 */
44 template <int D>
45 void Polymer<D>::setNParams(int nParams)
46 {
47 nParams_ = nParams;
48 }
49
50 /*
51 * Compute solution to MDE and concentrations.
52 */
53 template <int D>
54 void Polymer<D>::compute(DArray< RField<D> > const & wFields,
55 double phiTot)
56 {
57 // Setup solvers for all blocks
58 int monomerId;
59 for (int j = 0; j < nBlock(); ++j) {
60 monomerId = block(j).monomerId();
61 block(j).setupSolver(wFields[monomerId]);
62 }
63
64 // Call base class PolymerTmpl solve() function
65 solve(phiTot);
66 }
67
68 /*
69 * Compute stress from a polymer chain.
70 */
71
72 template <int D>
74 {
75 UTIL_CHECK(nParams_ > 0);
76
77 double prefactor;
78
79 // Initialize stress_ to 0
80 for (int i = 0; i < nParams_; ++i) {
81 stress_ [i] = 0.0;
82 }
83
84 for (int i = 0; i < nBlock(); ++i) {
85 prefactor = exp(mu_)/length();
86 block(i).computeStress(prefactor);
87
88 for (int j=0; j < nParams_; ++j){
89 stress_ [j] += block(i).stress(j);
90 //std::cout<<"stress_[j] "<<stress_[j]<<std::endl;
91 }
92 }
93 }
94
95}
96}
97#endif
Field of real double precision values on an FFT mesh.
void computeStress()
Compute stress from a polymer chain, needs a pointer to basis.
void setClassName(const char *className)
Set class name string.
void setMu(double mu)
Set the mu (chemical potential) for this species.
void compute(DArray< RField< D > > const &wFields, double phiTot=1.0)
Compute solution to MDE and block concentrations.
void setPhi(double phi)
Set the phi (volume fraction) for this species.
void setNParams(int nParams)
Store the number of lattice parameters in the unit cell.
Dynamically allocatable contiguous array template.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
PSCF package top-level namespace.
Definition param_pc.dox:1