PSCF v1.4.0
IntraCorrelation.tpp
1#ifndef RP_INTRACORRELATION_TPP
2#define RP_INTRACORRELATION_TPP
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#include "IntraCorrelation.h"
12
13#include <prdc/crystal/shiftToMinimum.h>
14#include <prdc/crystal/UnitCell.h>
15
16#include <pscf/mesh/Mesh.h>
17#include <pscf/mesh/MeshIterator.h>
18#include <pscf/correlation/Mixture.h>
19
20#include <util/global.h>
21
22namespace Pscf {
23namespace Rp {
24
25 using namespace Util;
26 using namespace Prdc;
27
28 /*
29 * Constructor.
30 */
31 template <int D, class T>
33 typename T::System const & system)
34 : systemPtr_(&system),
35 correlationMixturePtr_(nullptr),
36 kSize_(-1)
37 {
38 correlationMixturePtr_
40 }
41
42 /*
43 * Destructor.
44 */
45 template <int D, class T>
47 { delete correlationMixturePtr_; }
48
49 /*
50 * Compute k-space array of intramolecular correlation functions.
51 */
52 template <int D, class T>
53 void
55 {
57 UTIL_CHECK(correlations.capacity() == kSize_);
58 computeGsq();
59 if (!correlationMixturePtr_->isAllocated()) {
60 correlationMixturePtr_->allocate();
61 }
62 correlationMixturePtr_->setup();
63 correlationMixturePtr_->computeOmegaTotal(Gsq_, correlations);
64 }
65
66 /*
67 * Compute k-grid mesh dimensions and Gsq.
68 */
69 template <int D, class T>
71 {
72 meshDimensions_ = system().domain().mesh().dimensions();
73
74 // Compute k-space mesh dimensions kMeshDimensions_ and size Size_
75 FFTT::computeKMesh(meshDimensions_, kMeshDimensions_, kSize_);
76 }
77
78 /*
79 * Construct array of squared wavevector values.
80 */
81 template <int D, class T>
83 {
84 // Get mesh dimensions if not done previously
85 if (kSize_ <= 0) {
87 }
88
89 // Check allocation of Gsq_ (k-space array of square wavenumbers)
90 if (!Gsq_.isAllocated()) {
91 Gsq_.allocate(kSize_);
92 }
93 UTIL_CHECK(Gsq_.capacity() == kSize_);
94
95 // Compute Gsq_
96 UnitCell<D> const & unitCell = system().domain().unitCell();
97 IntVec<D> G, Gmin;
98 MeshIterator<D> iter;
99 iter.setDimensions(kMeshDimensions_);
100 for (iter.begin(); !iter.atEnd(); ++iter) {
101 G = iter.position();
102 Gmin = shiftToMinimum(G, meshDimensions_, unitCell);
103 Gsq_[iter.rank()] = unitCell.ksq(Gmin);
104 }
105 }
106
107}
108}
109#endif
Correlations in a homogeneous ideal gas mixture.
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
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.
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.
Definition UnitCell.h:56
IntraCorrelation(typename T::System const &system)
Constructor.
T::System const & system() const
Get the parent system by const ref.
void computeGsq()
Compute array of squared wavevectors.
void computeOmegaTotal(Array< typename T::Real > &correlations)
Compute total intramolecular correlation function (all blocks).
void getMeshDimensions()
Get and store r-grid and kgrid-mesh dimensions.
Array container class template.
Definition Array.h:40
int capacity() const
Return allocated size.
Definition Array.h:144
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Periodic fields and crystallography.
Definition complex.cpp:11
Class templates for real-valued periodic fields.
PSCF package top-level namespace.