1#ifndef PSCF_CORRELATION_POLYMER_TPP
2#define PSCF_CORRELATION_POLYMER_TPP
13#include <pscf/chem/PolymerSpecies.h>
14#include <pscf/chem/Edge.h>
15#include <pscf/chem/EdgeIterator.h>
16#include <pscf/chem/PolymerModel.h>
17#include <pscf/correlation/Debye.h>
30 template <
typename WT>
32 : speciesPtr_(nullptr),
41 template <
typename WT>
43 : speciesPtr_(&polymer),
52 template <
typename WT>
59 template <
typename WT>
61 { speciesPtr_ = &polymer; }
66 template <
typename WT>
72 nBlock_ = species().nBlock();
75 kuhn_.allocate(nBlock_);
76 length_.allocate(nBlock_);
77 rSq_.allocate(nBlock_, nBlock_);
78 blockIds_.allocate(nMonomer_);
82 for (
int i = 0; i < nBlock_; ++i) {
83 monomerId = species().edge(i).monomerId();
86 blockIds_[monomerId].append(i);
93 template <
typename WT>
110 for (
int i = 0; i < nBlock_; ++i) {
111 Edge const & edge = species().edge(i);
113 length_[i] = edge.
length();
115 length_[i] = (double) edge.
nBead();
117 totalLength_ += length_[i];
123 kuhn_[i] = kuhn[monomerId];
128 phi_ = species().phi();
131 for (
int ia = 0; ia < nBlock_; ++ia) {
139 double kuhnA, kuhnB, kuhnC, lengthC, rsq;
143 for (ia = 1; ia < nBlock_; ++ia) {
147 for (ib = 0; ib < ia; ++ib) {
154 rsq = 0.5*(kuhnA*kuhnA + kuhnB*kuhnB);
158 edgeItr.begin(ia, ib);
159 while (edgeItr.notEnd()) {
160 ic = edgeItr.currentEdgeId();
161 if (ic != ia && ic != ib) {
162 lengthC = length_[ic];
164 rsq += lengthC * kuhnC * kuhnC;
183 template <
typename WT>
194 double lengthA = length_[ia];
195 double kuhnA = kuhn_[ia];
203 double lengthB = length_[ib];
204 double kuhnB = kuhn_[ib];
205 double x = std::exp( -rSq_(ia, ib) * kSq / 6.0);
214 correlation = prefactor * x * eA * eB;
226 template <
typename WT>
240 const double lengthA = length_[ia];
241 const double kuhnA = kuhn_[ia];
246 for (
int j = 0; j < nk; ++j) {
248 correlation[j] += prefactor * d;
251 for (
int j = 0; j < nk; ++j) {
253 correlation[j] += prefactor * d;
257 const double lengthB = length_[ib];
258 const double kuhnB = kuhn_[ib];
259 const double alpha = -1.0*rSq_(ia, ib)/6.0;
260 double ks, x, eA, eB;
262 for (
int j = 0; j < nk; ++j) {
264 x = std::exp(alpha*ks);
267 correlation[j] += prefactor * x * eA * eB;
270 for (
int j = 0; j < nk; ++j) {
272 x = std::exp(alpha*ks);
275 correlation[j] += prefactor * x * eA * eB;
284 template <
typename WT>
298 double lengthA, kuhnA, d;
299 for (
int ia = 0; ia < nBlock_; ++ia) {
300 lengthA = length_[ia];
303 for (
int j = 0; j < nk; ++j) {
305 correlation[j] += prefactor * d;
308 for (
int j = 0; j < nk; ++j) {
310 correlation[j] += prefactor * d;
317 double lengthB, kuhnB, alpha, c, ks, x, eA, eB;
319 for (ia = 1; ia < nBlock_; ++ia) {
320 lengthA = length_[ia];
322 for (ib = 0; ib < ia; ++ib) {
323 lengthB = length_[ib];
325 alpha = -1.0*rSq_(ia, ib)/6.0;
328 for (
int j = 0; j < nk; ++j) {
330 x = std::exp(alpha*ks);
333 correlation[j] += c * x * eA * eB;
336 for (
int j = 0; j < nk; ++j) {
338 x = std::exp(alpha*ks);
341 correlation[j] += c * x * eA * eB;
double computeOmega(int ia, int ib, double prefactor, double kSq) const
Compute intramolecular correlation function for a pair of blocks.
void associate(PolymerSpecies< WT > const &polymer)
Create association with a PolymerSpecies.
Polymer()
Default constructor.
void allocate(int nMonomer)
Allocate memory and initialize immutable data.
void setup(Array< double > const &kuhn)
Set private mutable data.
void computeOmegaTotal(double prefactor, Array< double > const &kSq, Array< double > &correlations) const
Compute total intramolecular correlation function.
Edge iterator for graph associated with a polymer.
Descriptor for a block within a block polymer.
int nBead() const
Get the number of beads in this block, in the bead model.
int monomerId() const
Get the monomer type id for this block.
double length() const
Get the length of this block, in the thread model.
Descriptor for a linear or acyclic branched block polymer.
Array container class template.
int capacity() const
Return allocated size.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
double dt(double ksq, double length, double kuhn)
Compute and return intrablock correlation function (thread model)
double et(double ksq, double length, double kuhn)
Compute and return one-sided factor for one block (thread model).
double eb(double ksq, double nBead, double kuhn)
Compute and return one-sided factor for one block (bead model).
double db(double ksq, double nBead, double kuhn)
Compute and return an intrablock correlation function (bead model)
Intramolecular correlations in homogeneous systems.
bool isThread()
Is the thread model in use ?
PSCF package top-level namespace.