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/field/Domain.h>
17#include <prdc/cpu/FFT.h>
18#include <prdc/cpu/RField.h>
19#include <prdc/crystal/shiftToMinimum.h>
20#include <prdc/crystal/UnitCell.h>
22#include <pscf/mesh/MeshIterator.h>
23#include <pscf/chem/PolymerSpecies.h>
24#include <pscf/chem/Edge.h>
25#include <pscf/chem/Debye.h>
26#include <pscf/chem/EdgeIterator.h>
62 const int nPolymer = mixture.
nPolymer();
63 const int nSolvent = mixture.
nSolvent();
64 const double vMonomer = mixture.
vMonomer();
80 Gmin = shiftToMinimum(G, dimensions, unitCell);
81 Gsq[iter.
rank()] = unitCell.
ksq(Gmin);
85 for (
int i = 0; i < correlations.
capacity(); ++i){
86 correlations[i] = 0.0;
89 double phi, cPolymer, polymerLength, rsqAB;
90 double length, lengthA, lengthB, lengthC, ksq;
91 double kuhn, kuhnA, kuhnB, kuhnC, eA, eB;
92 int monomerId, monomerIdA, monomerIdB, monomerIdC;
96 for (
int i = 0; i < nPolymer; i++){
100 const int nBlock = polymer.
nBlock();
105 for (
int j = 0; j < nBlock; j++) {
109 length = (double) polymer.
edge(j).
nBead();
111 polymerLength += length;
115 cPolymer = phi/(polymerLength*vMonomer);
118 for (
int j = 0; j < nBlock; j++) {
129 correlations[rank] +=
133 length = (double) polymer.
edge(j).
nBead();
137 correlations[rank] +=
149 for (
int ia = 1; ia < nBlock; ++ia) {
152 Edge const & edgeA = polymer.
edge(ia);
156 lengthA = (double) edgeA.
nBead();
162 for (
int ib = 0; ib < ia; ++ib) {
165 Edge const & edgeB = polymer.
edge(ib);
169 lengthB = (double) edgeB.
nBead();
178 rsqAB = 0.5*(kuhnA*kuhnA + kuhnB*kuhnB);
183 edgeItr.
begin(ia, ib);
184 while (edgeItr.
notEnd()) {
186 Edge const & edgeC = polymer.
edge(edgeId);
189 if (edgeId != ia && edgeId != ib) {
193 lengthC = double(edgeC.
nBead());
195 rsqAB += lengthC * kuhnC * kuhnC;
202 double prefactor = 2.0*cPolymer;
207 x = std::exp( -rsqAB * ksq / 6.0);
210 correlations[rank] += prefactor * x * eA * eB;
216 x = std::exp( -rsqAB * ksq / 6.0);
219 correlations[rank] += prefactor * x * eA * eB;
232 for (
int i = 0; i < nSolvent; i++){
235 size = solvent.
size();
236 dcorr = phi*size/vMonomer;
238 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.
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.
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).
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.
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.