1#ifndef RPG_FOURTH_ORDER_PARAMETER_TPP
2#define RPG_FOURTH_ORDER_PARAMETER_TPP
4#include "FourthOrderParameter.h"
6#include <rpg/fts/simulator/Simulator.h>
7#include <rpg/system/System.h>
9#include <prdc/cuda/FFT.h>
10#include <prdc/cuda/RField.h>
11#include <prdc/cuda/resources.h>
12#include <prdc/crystal/shiftToMinimum.h>
14#include <pscf/inter/Interaction.h>
15#include <pscf/mesh/MeshIterator.h>
16#include <pscf/math/IntVec.h>
18#include <util/misc/ioUtil.h>
19#include <util/format/Int.h>
20#include <util/format/Dbl.h>
54 const int nMonomer =
system().mixture().nMonomer();
67 wc0_.allocate(dimensions);
68 wK_.allocate(dimensions);
69 prefactor_.allocate(kMeshDimensions_);
73 isInitialized_ =
true;
92 system().domain().fft().forwardTransform(wc0_, wK_);
103 FourthOrderParameter_ = 0.0;
105 for (
int i = 1; i < kSize_; ++i){
106 FourthOrderParameter_ += psiHost[i];
109 FourthOrderParameter_ = std::pow(FourthOrderParameter_, 0.25);
111 return FourthOrderParameter_;
118 double chi =
system().interaction().chi(0,1);
121 outputFile_ <<
Int(step);
122 outputFile_ <<
Dbl(chi);
123 outputFile_ <<
Dbl(value);
136 for (
int i = 0; i < kSize_; ++i){
150 Gmin = shiftToMinimum(G, meshDimensions, unitCell);
151 GminList[itr.
rank()] = Gmin;
156 bool inverseFound =
false;
159 if (prefactor_h[itr.
rank()] == 0){
160 Gmin = GminList[itr.
rank()];
167 for (; !searchItr.
atEnd(); ++searchItr){
168 if (nGmin == GminList[searchItr.
rank()]){
169 prefactor_h[itr.
rank()] = 1.0/2.0;
170 prefactor_h[searchItr.
rank()] = 1.0/2.0;
175 if (inverseFound ==
false){
176 prefactor_h[itr.
rank()] = 1.0;
184 prefactor_ = prefactor_h;
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)?
IntVec< D > position() const
Get current position in the grid, as integer vector.
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.
void allocate(IntVec< D > const &meshDimensions)
Allocate the underlying C array for an FFT grid.
Base template for UnitCell<D> classes, D=1, 2 or 3.
AverageAnalyzer(Simulator< D > &simulator, System< D > &system)
Constructor.
virtual void setup()
Setup before loop.
virtual void outputValue(int step, double value)
Output a sampled or block average value.
int nSamplePerOutput() const
Get value of nSamplePerOutput.
Simulator< D > & simulator()
Return reference to parent simulator.
System< D > & system()
Return reference to parent system.
virtual ~FourthOrderParameter()
Destructor.
virtual double compute()
Compute and return the fourth order parameter.
void setClassName(const char *className)
Set class name string.
FourthOrderParameter(Simulator< D > &simulator, System< D > &system)
Constructor.
virtual void outputValue(int step, double value)
Output a sampled or block average value.
virtual void setup()
Setup before simulation loop.
void computePrefactor()
Compute prefactor for each Fourier wavevector.
Field theoretic simulator (base class).
Main class, representing one complete system.
Vec< D, T > & negate(const Vec< D, T > &v)
Return negative of vector v.
Dynamically allocatable contiguous array template.
void allocate(int capacity)
Allocate the underlying C array.
Wrapper for a double precision number, for formatted ostream output.
Wrapper for an int, for formatted ostream output.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
void eqV(DeviceArray< cudaReal > &a, DeviceArray< cudaReal > const &b, const int beginIdA, const int beginIdB, const int n)
Vector assignment, a[i] = b[i], kernel wrapper (cudaReal).
void eqS(DeviceArray< cudaReal > &a, const cudaReal b, const int beginIdA, const int n)
Vector assignment, a[i] = b, kernel wrapper (cudaReal).
void sqSqNormV(DeviceArray< cudaReal > &a, DeviceArray< cudaComplex > const &b)
Norm of complex number to the 4th power, a[i] = norm(b[i])^4, kernel wrapper.
void mulEqV(DeviceArray< cudaReal > &a, DeviceArray< cudaReal > const &b, const int beginIdA, const int beginIdB, const int n)
Vector multiplication in-place, a[i] *= b[i], kernel wrapper (cudaReal).
Periodic fields and crystallography.
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.