PSCF v1.3
rpc/solvers/Polymer.tpp
1#ifndef RPC_POLYMER_TPP
2#define RPC_POLYMER_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 "Polymer.h"
12#include <prdc/cpu/RField.h>
13
14namespace Pscf {
15namespace Rpc {
16
17 template <int D>
19 : stress_(),
20 nParam_(0)
21 { ParamComposite::setClassName("Polymer");}
22
23 template <int D>
26
27 /*
28 * Set the number of unit cell parameters.
29 */
30 template <int D>
31 void Polymer<D>::setNParams(int nParam)
32 { nParam_ = nParam; }
33
34 /*
35 * Clear all data that depends on unit cell parameters.
36 */
37 template <int D>
39 {
40 for (int j = 0; j < nBlock(); ++j) {
41 block(j).clearUnitCellData();
42 }
43 stress_.clear();
44 }
45
46 /*
47 * Compute solution to MDE and block concentrations.
48 */
49 template <int D>
50 void Polymer<D>::compute(DArray< RField<D> > const & wFields,
51 double phiTot)
52 {
53 // Setup solvers for all blocks
54 int monomerId;
55 for (int j = 0; j < nBlock(); ++j) {
56 monomerId = block(j).monomerId();
57 block(j).setupSolver(wFields[monomerId]);
58 }
59
60 // Call base class PolymerTmpl solve() function
61 // Solve MDE for all propagators
62 solve(phiTot);
63
64 // Compute block concentration fields
65 double prefactor;
67 prefactor = phi() / ( q() * length() );
68 for (int i = 0; i < nBlock(); ++i) {
69 block(i).computeConcentrationThread(prefactor);
70 }
71 } else
73 prefactor = phi() / ( q() * (double)nBead() );
74 for (int i = 0; i < nBlock(); ++i) {
75 block(i).computeConcentrationBead(prefactor);
76 }
77 }
78
79 }
80
81 /*
82 * Compute stress contribution from a polymer species.
83 */
84 template <int D>
86 {
87
88 // Compute stress contributions for all blocks
89 double prefactor;
91 prefactor = phi() / ( q() * length() );
92 for (int i = 0; i < nBlock(); ++i) {
93 block(i).computeStressThread(prefactor);
94 }
95 } else {
96 prefactor = phi() / ( q() * (double)nBead() );
97 for (int i = 0; i < nBlock(); ++i) {
98 block(i).computeStressBead(prefactor);
99 }
100 }
101
102 // Initialize all stress_ elements zero
103 stress_.clear();
104 for (int i = 0; i < nParam_; ++i) {
105 stress_.append(0.0);
106 }
107
108 // Sum over all block stress contributions
109 for (int i = 0; i < nBlock(); ++i) {
110 for (int j = 0; j < nParam_ ; ++j){
111 stress_[j] += block(i).stress(j);
112 }
113 }
114
115 }
116
117}
118}
119#endif
Field of real double precision values on an FFT mesh.
Definition cpu/RField.h:29
double phi() const
Get the overall volume fraction for this species.
Definition Species.h:149
void compute(DArray< RField< D > > const &wFields, double phiTot=1.0)
Compute solution to MDE and block concentrations.
void computeStress()
Compute SCFT stress contribution from this polymer species.
int nBead() const
Total number of beads in the polymer (bead model).
int nBlock() const
Number of blocks.
void clearUnitCellData()
Clear all data that depends on unit cell parameters.
Block< D > & block(int id)
Get a specified Block (solver and descriptor).
void setNParams(int nParam)
Set the number of unit cell parameters.
double length() const
Sum of the lengths of all blocks in the polymer (thread model).
double q() const
Get the molecular partition function for this species.
Definition Species.h:161
Dynamically allocatable contiguous array template.
Definition DArray.h:32
void setClassName(const char *className)
Set class name string.
bool isThread()
Is the thread model in use ?
bool isBead()
Is the bead model in use ?
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.
Definition param_pc.dox:1