PSCF v1.4.0
pscf/correlation/Polymer.h
1#ifndef PSCF_CORRELATION_POLYMER_H
2#define PSCF_CORRELATION_POLYMER_H
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// Header includes
12#include <util/containers/DArray.h>
13#include <util/containers/DMatrix.h>
14#include <util/containers/GArray.h>
15
16// Forward declarations
17namespace Pscf {
18 template <typename WT> class PolymerSpecies;
19}
20
21namespace Pscf {
22namespace Correlation {
23
24 using namespace Util;
25
31 template <typename WT>
32 class Polymer
33 {
34
35 public:
36
40 Polymer();
41
47 Polymer(PolymerSpecies<WT> const & polymer);
48
52 ~Polymer();
53
59 void associate(PolymerSpecies<WT> const & polymer);
60
75 void allocate(int nMonomer);
76
92 void setup(Array<double> const & kuhn);
93
120 double computeOmega(int ia, int ib, double prefactor, double kSq)
121 const;
122
155 void computeOmega(int ia, int ib, double prefactor,
156 Array<double> const & kSq,
157 Array<double> & correlation) const;
158
189 void computeOmegaTotal(double prefactor,
190 Array<double> const & kSq,
191 Array<double> & correlations) const;
192
196 double phi() const;
197
201 double totalLength() const;
202
206 int nBlock() const;
207
220 GArray<int> const & blockIds(int i) const;
221
231 double length(int i) const;
232
246 double rSq(int i, int j) const;
247
248 private:
249
250 /*
251 * Block lengths, indexed by block index.
252 *
253 * For the thread model, each element contains the length parameter
254 * for associated block. For the bead model, each element contains
255 * a double precision representation of nBead, the number of beads.
256 */
257 DArray<double> length_;
258
259 /*
260 * Monomer statistical segment lengths, indexed by block index.
261 */
262 DArray<double> kuhn_;
263
264 /*
265 * Symmetric matrix of values of rSq for paths between blocks.
266 *
267 * Diagonal elements are zero.
268 */
269 DMatrix<double> rSq_;
270
271 /*
272 * Identifiers for blocks of specified monomer type.
273 *
274 * Elements of the outer DArray are indexed by monomer type id.
275 * Each element is a GArray<int> container containing a list of
276 * blocks ids for all blocks of the relevant monomer type, if any.
277 */
278 DArray< GArray<int> > blockIds_;
279
280 /*
281 * Pointer to the associated PolymerSpecies object.
282 */
283 PolymerSpecies<WT> const * speciesPtr_;
284
285 /*
286 * Volume fraction of this polymer.
287 */
288 double phi_;
289
290 /*
291 * Sum of lengths of all blocks in the polymer.
292 */
293 double totalLength_;
294
295 /*
296 * Number of blocks in this polymer.
297 */
298 int nBlock_;
299
300 /*
301 * Number of monomer types in the mixture.
302 */
303 int nMonomer_;
304
308 PolymerSpecies<WT> const & species() const;
309
310 };
311
312 // Public inline member functions
313
314 // Get the volume fraction of this polymer species.
315 template <typename WT> inline
316 double Polymer<WT>::phi() const
317 { return phi_; }
318
319 // Get the sum of the lengths of all blocks in this polymer species.
320 template <typename WT> inline
322 { return totalLength_; }
323
324 // Get the number of blocks in this polymer species.
325 template <typename WT> inline
327 { return nBlock_; }
328
329 // Get the list of blocks ids for a specified monomer type.
330 template <typename WT> inline
332 { return blockIds_[i]; }
333
334 // Get the length of a specified block.
335 template <typename WT> inline
336 double Polymer<WT>::length(int i) const
337 { return length_[i]; }
338
339 // Get the mean-squared length of the path connecting two blocks.
340 template <typename WT> inline
341 double Polymer<WT>::rSq(int i, int j) const
342 { return rSq_(i, j); }
343
344 // Private inline member function
345
346 // Get the associated PolymerSpecies molecule descriptor object.
347 template <typename WT> inline
348 PolymerSpecies<WT> const & Polymer<WT>::species() const
349 { return *speciesPtr_; }
350
351 // Explicit specialization declaration
352 extern template class Polymer<double>;
353
354} // namespace Correlation
355} // namespace Pscf
356#endif
double length(int i) const
Get the length of each block.
double computeOmega(int ia, int ib, double prefactor, double kSq) const
Compute intramolecular correlation function for a pair of blocks.
int nBlock() const
Get the number of blocks in the associated polymer species.
double rSq(int i, int j) const
Get the mean-squared length of path between blocks i and j.
void associate(PolymerSpecies< WT > const &polymer)
Create association with a PolymerSpecies.
double phi() const
Return the volume fraction of this polymer species.
void allocate(int nMonomer)
Allocate memory and initialize immutable data.
void setup(Array< double > const &kuhn)
Set private mutable data.
double totalLength() const
Return the sum of lengths of all blocks in this polymer species.
void computeOmegaTotal(double prefactor, Array< double > const &kSq, Array< double > &correlations) const
Compute total intramolecular correlation function.
GArray< int > const & blockIds(int i) const
Get a GArray of block ids for all blocks of one monomer type.
Descriptor for a linear or acyclic branched block polymer.
Array container class template.
Definition Array.h:40
Dynamically allocatable contiguous array template.
Definition DArray.h:32
Dynamically allocated Matrix.
Definition DMatrix.h:25
An automatically growable array, analogous to a std::vector.
Definition GArray.h:34
Intramolecular correlations in homogeneous systems.
PSCF package top-level namespace.