1#ifndef RP_MAX_ORDER_PARAMETER_TPP
2#define RP_MAX_ORDER_PARAMETER_TPP
4#include "MaxOrderParameter.h"
6#include <prdc/crystal/shiftToMinimum.h>
7#include <prdc/crystal/UnitCell.h>
9#include <pscf/mesh/Mesh.h>
10#include <pscf/math/IntVec.h>
12#include <util/param/ParamComposite.h>
13#include <util/misc/FileMaster.h>
14#include <util/misc/ioUtil.h>
15#include <util/format/Int.h>
16#include <util/format/Dbl.h>
28 template <
int D,
class T>
30 typename T::Simulator& simulator,
31 typename T::System& system)
32 : AverageAnalyzerT(simulator, system),
39 template <
int D,
class T>
43 const int nMonomer = system().mixture().nMonomer();
46 AverageAnalyzerT::setup();
49 meshDimensions_ = system().domain().mesh().dimensions();
50 FFTT::computeKMesh(meshDimensions_, kMeshDimensions_,
kSize_);
53 if (!wK_.isAllocated()){
55 wK_.allocate(meshDimensions_);
56 psi_.allocate(kMeshDimensions_);
65 template <
int D,
class T>
69 if (!simulator().hasWc()){
70 simulator().computeWc();
72 system().domain().fft().forwardTransform(simulator().wc(0), wK_);
79 template <
int D,
class T>
86 for (
int i = 2; i <
kSize_; ++i){
94 Mesh<D> kMesh(kMeshDimensions_);
96 UnitCell<D> const & unitCell = system().domain().unitCell();
97 Gmax_ = shiftToMinimum(
Gmax_, meshDimensions_, unitCell);
103 template <
int D,
class T>
106 std::ofstream& file = AverageAnalyzerT::outputFile_;
108 int nSamplePerOutput = AverageAnalyzerT::nSamplePerOutput();
109 if (nSamplePerOutput == 1) {
112 for (
int i = 0; i < D; i++){
Description of a regular grid of points in a periodic domain.
IntVec< D > position(int rank) const
Get the position IntVec<D> of a grid point with a specified rank.
Base template for UnitCell<D> classes, D=1, 2 or 3.
void computePsi()
Compute the psi_ array of squared Fourier coefficients.
void outputValue(int step, double value) override
Output a sampled or block average value.
void findMaximum(Array< typename T::Real > const &psi)
Find the wavevector of maximum Fourier magnitude.
void setup() override
Setup before simulation loop.
IntVec< D > Gmax_
Indices of wavevector with maximum magnitude.
double maxPsi_
Maximum square magnitude (value of maximum element of psi_).
T::RField psi_
Square magnitude |W_|^2 in Fourier space.
MaxOrderParameter(typename T::Simulator &simulator, typename T::System &system)
Constructor.
int kSize_
Number of wavevectors in Fourier space (k-grid) mesh.
Array container class template.
Wrapper for a double precision number, for formatted ostream output.
Wrapper for an int, for formatted ostream output.
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.
void sqAbsV(Array< double > &a, Array< fftw_complex > const &b)
Square of absolute magnitude, a[i] = |b[i]|^2 (complex).
Periodic fields and crystallography.
Class templates for real-valued periodic fields.
PSCF package top-level namespace.