1#ifndef RPC_INTRACORRELATION_TPP
2#define RPC_INTRACORRELATION_TPP
11#include "IntraCorrelation.h"
13#include <rpc/system/System.h>
14#include <rpc/solvers/Mixture.h>
15#include <rpc/solvers/Polymer.h>
16#include <rpc/solvers/Solvent.h>
17#include <rpc/field/Domain.h>
19#include <prdc/cpu/FFT.h>
20#include <prdc/cpu/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>
66 const int nPolymer = mixture.
nPolymer();
67 const int nSolvent = mixture.
nSolvent();
68 const double vMonomer = mixture.
vMonomer();
84 Gmin = shiftToMinimum(G, dimensions, unitCell);
85 Gsq[iter.
rank()] = unitCell.
ksq(Gmin);
89 for (
int i = 0; i < correlations.
capacity(); ++i){
90 correlations[i] = 0.0;
93 double phi, cPolymer, polymerLength, rsqAB;
94 double length, lengthA, lengthB, lengthC, ksq;
95 double kuhn, kuhnA, kuhnB, kuhnC, eA, eB;
96 int monomerId, monomerIdA, monomerIdB, monomerIdC;
100 for (
int i = 0; i < nPolymer; i++){
104 const int nBlock = polymer.
nBlock();
109 for (
int j = 0; j < nBlock; j++) {
113 length = (double) polymer.
edge(j).
nBead();
115 polymerLength += length;
119 cPolymer = phi/(polymerLength*vMonomer);
122 for (
int j = 0; j < nBlock; j++) {
133 correlations[rank] +=
137 length = (double) polymer.
edge(j).
nBead();
141 correlations[rank] +=
153 for (
int ia = 1; ia < nBlock; ++ia) {
156 Edge const & edgeA = polymer.
edge(ia);
160 lengthA = (double) edgeA.
nBead();
166 for (
int ib = 0; ib < ia; ++ib) {
169 Edge const & edgeB = polymer.
edge(ib);
173 lengthB = (double) edgeB.
nBead();
182 rsqAB = 0.5*(kuhnA*kuhnA + kuhnB*kuhnB);
187 edgeItr.
begin(ia, ib);
188 while (edgeItr.
notEnd()) {
190 Edge const & edgeC = polymer.
edge(edgeId);
193 if (edgeId != ia && edgeId != ib) {
197 lengthC = double(edgeC.
nBead());
199 rsqAB += lengthC * kuhnC * kuhnC;
206 double prefactor = 2.0*cPolymer;
211 x = std::exp( -rsqAB * ksq / 6.0);
214 correlations[rank] += prefactor * x * eA * eB;
220 x = std::exp( -rsqAB * ksq / 6.0);
223 correlations[rank] += prefactor * x * eA * eB;
236 for (
int i = 0; i < nSolvent; i++){
239 size = solvent.
size();
240 dcorr = phi*size/vMonomer;
242 correlations[iter.
rank()] += dcorr;
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.
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.
void computeIntraCorrelations(RField< D > &correlations)
Compute and modify intramolecular correlations.
System< D > & system()
Return reference to parent system.
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.
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 ?
Real periodic fields, SCFT and PS-FTS (CPU).
PSCF package top-level namespace.