1#ifndef RP_FOURTH_ORDER_PARAMETER_TPP
2#define RP_FOURTH_ORDER_PARAMETER_TPP
4#include "FourthOrderParameter.h"
6#include <prdc/crystal/shiftToMinimum.h>
8#include <pscf/interaction/Interaction.h>
9#include <pscf/mesh/MeshIterator.h>
11#include <util/containers/Array.h>
12#include <util/containers/DArray.h>
13#include <util/misc/ioUtil.h>
14#include <util/format/Int.h>
15#include <util/format/Dbl.h>
29 template <
int D,
class T>
31 typename T::Simulator& simulator,
32 typename T::System& system)
33 : AverageAnalyzerT(simulator, system),
41 template <
int D,
class T>
45 UTIL_CHECK(system().mixture().nMonomer() == 2);
47 AverageAnalyzerT::setup();
50 IntVec<D> const & dimensions = system().domain().mesh().dimensions();
51 FFTT::computeKMesh(dimensions, kMeshDimensions_,
kSize_);
55 wK_.allocate(dimensions);
57 psi_.allocate(kMeshDimensions_);
62 isInitialized_ =
true;
68 template <
int D,
class T>
77 if (!simulator().hasWc()){
78 simulator().computeWc();
82 system().domain().fft().forwardTransform(simulator().wc(0), wK_);
90 orderParameter = std::pow(orderParameter, 0.25);
92 return orderParameter;
98 template <
int D,
class T>
111 IntVec<D> meshDimensions = system().domain().mesh().dimensions();
112 UnitCell<D> const & unitCell = system().domain().unitCell();
115 Gmin = shiftToMinimum(G, meshDimensions, unitCell);
116 GminList[itr.
rank()] = Gmin;
121 bool inverseFound =
false;
124 if (prefactor[itr.
rank()] == 0){
125 Gmin = GminList[itr.
rank()];
132 for (; !searchItr.
atEnd(); ++searchItr){
133 if (nGmin == GminList[searchItr.
rank()]){
134 prefactor[itr.
rank()] = 1.0/2.0;
135 prefactor[searchItr.
rank()] = 1.0/2.0;
140 if (inverseFound ==
false){
141 prefactor[itr.
rank()] = 1.0;
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)?
IntVec< D > position() const
Get current position in the grid, as integer vector.
Base template for UnitCell<D> classes, D=1, 2 or 3.
double compute() override
Compute and return the order parameter.
void setup() override
Setup before the main loop.
FourthOrderParameter(typename T::Simulator &simulator, typename T::System &system)
Constructor.
T::RField prefactor_
Prefactor for each Fourier component.
int kSize_
Number of wavevectors in Fourier space (k-grid) mesh.
void computePrefactor(Array< double > &prefactor)
Compute prefactor for each Fourier wavevector.
Vec< D, T > & negate(const Vec< D, T > &v)
Return negative of vector v.
Array container class template.
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 sum(Array< double > const &in)
Compute sum of array elements (real).
void mulEqV(Array< double > &a, Array< double > const &b)
Vector-vector in-place multiplication, a[i] *= b[i] (real).
void sqSqAbsV(Array< double > &a, Array< fftw_complex > const &b)
Fourth power of absolute magnitude, a[i] = |b[i]|^4 (complex).
void eqS(Array< double > &a, double b)
Vector assignment, a[i] = b (real).
Periodic fields and crystallography.
Class templates for real-valued periodic fields.
PSCF package top-level namespace.