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>
16#include <rpg/solvers/Solvent.h>
17#include <rpg/field/Domain.h>
19#include <prdc/cuda/FFT.h>
20#include <prdc/cuda/RField.h>
21#include <prdc/crystal/shiftToMinimum.h>
22#include <prdc/crystal/UnitCell.h>
24#include <pscf/mesh/Mesh.h>
25#include <pscf/mesh/MeshIterator.h>
26#include <pscf/chem/PolymerSpecies.h>
27#include <pscf/chem/SolventSpecies.h>
28#include <pscf/chem/Edge.h>
29#include <pscf/chem/Debye.h>
30#include <pscf/chem/EdgeIterator.h>
32#include <pscf/cuda/HostDArray.h>
61 const int nPolymer = mixture.
nPolymer();
62 const int nSolvent = mixture.
nSolvent();
63 const double vMonomer = mixture.
vMonomer();
79 Gmin = shiftToMinimum(G, dimensions, unitCell);
80 Gsq[iter.
rank()] = unitCell.
ksq(Gmin);
88 for (
int i = 0; i < correlations_h.
capacity(); ++i){
89 correlations_h[i] = 0.0;
92 double phi, cPolymer, polymerLength, rsqAB;
93 double length, lengthA, lengthB, lengthC, ksq;
94 double kuhn, kuhnA, kuhnB, kuhnC, eA, eB;
95 int monomerId, monomerIdA, monomerIdB, monomerIdC;
99 for (
int i = 0; i < nPolymer; i++){
103 const int nBlock = polymer.
nBlock();
108 for (
int j = 0; j < nBlock; j++) {
112 length = (double) polymer.
edge(j).
nBead();
114 polymerLength += length;
118 cPolymer = phi/(polymerLength*vMonomer);
121 for (
int j = 0; j < nBlock; j++) {
132 correlations_h[rank] +=
136 length = (double) polymer.
edge(j).
nBead();
140 correlations_h[rank] +=
152 for (
int ia = 1; ia < nBlock; ++ia) {
155 Edge const & edgeA = polymer.
edge(ia);
159 lengthA = (double) edgeA.
nBead();
165 for (
int ib = 0; ib < ia; ++ib) {
168 Edge const & edgeB = polymer.
edge(ib);
172 lengthB = (double) edgeB.
nBead();
181 rsqAB = 0.5*(kuhnA*kuhnA + kuhnB*kuhnB);
186 edgeItr.
begin(ia, ib);
187 while (edgeItr.
notEnd()) {
189 Edge const & edgeC = polymer.
edge(edgeId);
192 if (edgeId != ia && edgeId != ib) {
196 lengthC = double(edgeC.
nBead());
198 rsqAB += lengthC * kuhnC * kuhnC;
205 double prefactor = 2.0*cPolymer;
210 x = std::exp( -rsqAB * ksq / 6.0);
213 correlations_h[rank] += prefactor * x * eA * eB;
219 x = std::exp( -rsqAB * ksq / 6.0);
222 correlations_h[rank] += prefactor * x * eA * eB;
235 for (
int i = 0; i < nSolvent; i++){
238 size = solvent.
size();
239 dcorr = phi*size/vMonomer;
241 correlations_h[iter.
rank()] += dcorr;
247 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.
PolymerSpecies const & polymerSpecies(int id) const final
Get a PolymerSpecies descriptor by const reference.
SolventSpecies const & solventSpecies(int id) const final
Set a SolventSpecies descriptor object 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).
Main class, representing a complete physical system.
Descriptor for a solvent species.
double size() const
Get the size (number of monomers) in this solvent.
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.