1#ifndef RPG_INTRACORRELATION_TPP
2#define RPG_INTRACORRELATION_TPP
11#include "IntraCorrelation.h"
13#include <rpg/system/System.h>
14#include <rpg/field/Domain.h>
15#include <rpg/solvers/Mixture.h>
17#include <prdc/cuda/FFT.h>
18#include <prdc/crystal/UnitCell.h>
19#include <prdc/crystal/shiftToMinimum.h>
21#include <pscf/mesh/MeshIterator.h>
22#include <pscf/chem/Debye.h>
23#include <pscf/chem/EdgeIterator.h>
24#include <pscf/chem/PolymerType.h>
25#include <pscf/cuda/HostDArray.h>
54 const int nPolymer = mixture.
nPolymer();
55 const int nSolvent = mixture.
nSolvent();
56 const double vMonomer = mixture.
vMonomer();
72 Gmin = shiftToMinimum(G, dimensions, unitCell);
73 Gsq[iter.
rank()] = unitCell.
ksq(Gmin);
81 for (
int i = 0; i < correlations_h.
capacity(); ++i){
82 correlations_h[i] = 0.0;
85 double phi, cPolymer, polymerLength, rsqAB;
86 double length, lengthA, lengthB, lengthC, ksq;
87 double kuhn, kuhnA, kuhnB, kuhnC, eA, eB;
88 int monomerId, monomerIdA, monomerIdB, monomerIdC;
92 for (
int i = 0; i < nPolymer; i++){
96 const int nBlock = polymer.
nBlock();
101 for (
int j = 0; j < nBlock; j++) {
105 length = (double) polymer.
edge(j).
nBead();
107 polymerLength += length;
111 cPolymer = phi/(polymerLength*vMonomer);
114 for (
int j = 0; j < nBlock; j++) {
125 correlations_h[rank] +=
129 length = (double) polymer.
edge(j).
nBead();
133 correlations_h[rank] +=
145 for (
int ia = 1; ia < nBlock; ++ia) {
148 Edge const & edgeA = polymer.
edge(ia);
152 lengthA = (double) edgeA.
nBead();
158 for (
int ib = 0; ib < ia; ++ib) {
161 Edge const & edgeB = polymer.
edge(ib);
165 lengthB = (double) edgeB.
nBead();
174 rsqAB = 0.5*(kuhnA*kuhnA + kuhnB*kuhnB);
179 edgeItr.
begin(ia, ib);
180 while (edgeItr.
notEnd()) {
182 Edge const & edgeC = polymer.
edge(edgeId);
185 if (edgeId != ia && edgeId != ib) {
189 lengthC = double(edgeC.
nBead());
191 rsqAB += lengthC * kuhnC * kuhnC;
198 double prefactor = 2.0*cPolymer;
203 x = std::exp( -rsqAB * ksq / 6.0);
206 correlations_h[rank] += prefactor * x * eA * eB;
212 x = std::exp( -rsqAB * ksq / 6.0);
215 correlations_h[rank] += prefactor * x * eA * eB;
228 for (
int i = 0; i < nSolvent; i++){
231 size = solvent.
size();
232 dcorr = phi*size/vMonomer;
234 correlations_h[iter.
rank()] += dcorr;
240 correlations = correlations_h;
Edge iterator for graph associated with a polymer.
int currentEdgeId() const
Get index of the current edge.
bool notEnd() const
Return true iff currentId != targetId.
void begin(int sourceId, int targetId)
Initialize iterator.
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.
Template for dynamic array stored in host CPU memory.
An IntVec<D, T> is a D-component vector of elements of integer type T.
Iterator over points in a Mesh<D>.
int rank() const
Get the rank of current element.
void begin()
Set iterator to the first point in the mesh.
bool atEnd() const
Is this the end (i.e., one past the last point)?
void setDimensions(const IntVec< D > &dimensions)
Set the grid dimensions in all directions.
IntVec< D > position() const
Get current position in the grid, as integer vector.
double kuhn() const
Statistical segment length (random walk step size).
Descriptor for a linear or acyclic branched block polymer.
virtual Edge & edge(int id)=0
Get a specified Edge (block descriptor) by non-const reference.
int nBlock() const
Number of blocks.
static void computeKMesh(IntVec< D > const &rMeshDimensions, IntVec< D > &kMeshDimensions, int &kSize)
Compute dimensions and size of k-space mesh for DFT of real data.
Field of real double precision values on an FFT mesh.
SolventT & solvent(int id)
Get a solvent solver object.
PolymerSpecies const & polymerSpecies(int id) const final
Get a PolymerSpecies descriptor by const reference.
virtual double ksq(IntVec< D > const &k) const
Compute square magnitude of reciprocal lattice vector.
Base template for UnitCell<D> classes, D=1, 2 or 3.
System< D > & system()
Return reference to parent system.
void computeIntraCorrelations(RField< D > &correlations)
Compute and return intramolecular correlations.
IntraCorrelation(System< D > &system)
Constructor.
~IntraCorrelation()
Destructor.
Solver and descriptor for a mixture of polymers and solvents.
int nPolymer() const
Get number of polymer species.
Monomer const & monomer(int id) const
Get a Monomer type descriptor by const reference.
int nSolvent() const
Get number of solvent (point particle) species.
double vMonomer() const
Get monomer reference volume (set to 1.0 by default).
Solver and descriptor for a solvent species.
double phi() const
Get the overall volume fraction for this species.
double size() const
Get the size (number of monomers) in this solvent.
Main class, representing one complete system.
double phi() const
Get the overall volume fraction for this species.
int capacity() const
Return allocated size.
Dynamically allocatable contiguous array template.
void allocate(int capacity)
Allocate the underlying C array.
void setClassName(const char *className)
Set class name string.
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 (thread model).
double db(double ksq, double nBead, double kuhn)
Compute and return an intrablock correlation function (bead model)
bool isThread()
Is the thread model in use ?
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.