1#ifndef RPC_MAX_ORDER_PARAMETER_TPP
2#define RPC_MAX_ORDER_PARAMETER_TPP
4#include "MaxOrderParameter.h"
6#include <rpc/system/System.h>
7#include <rpc/fts/simulator/Simulator.h>
8#include <rpc/solvers/Mixture.h>
9#include <rpc/field/Domain.h>
11#include <prdc/cpu/FFT.h>
12#include <prdc/cpu/RField.h>
13#include <prdc/crystal/shiftToMinimum.h>
15#include <pscf/inter/Interaction.h>
16#include <pscf/mesh/MeshIterator.h>
17#include <pscf/math/IntVec.h>
19#include <util/param/ParamComposite.h>
20#include <util/misc/FileMaster.h>
21#include <util/misc/ioUtil.h>
22#include <util/format/Int.h>
23#include <util/format/Dbl.h>
63 const int nMonomer =
system().mixture().nMonomer();
74 wK_.allocate(dimensions);
77 isInitialized_ =
true;
79 if (!isInitialized_) {
80 UTIL_THROW(
"Error: object is not initialized");
98 std::vector<double> psi(kSize_);
111 Gmin = shiftToMinimum(G, dimensions, unitCell);
112 GminList[itr.
rank()] = Gmin;
114 std::complex<double> wK(wK_[itr.
rank()][0], wK_[itr.
rank()][1]);
115 psi[itr.
rank()] = std::norm(wK);
118 maxOrderParameter_ = psi[1];
120 for (
int i = 2; i < kSize_; ++i){
121 if (psi[i] > maxOrderParameter_){
122 maxOrderParameter_ = psi[i];
127 GminStar_ = GminList[maxIndex];
129 return maxOrderParameter_;
139 double chi=
system().interaction().chi(0,1);
142 outputFile_ <<
Int(step);
143 outputFile_ <<
Dbl(chi);
144 outputFile_ <<
" ( ";
145 for (
int i = 0; i < D; i++){
146 outputFile_ <<
Int(GminStar_[i],3) <<
" ";
148 outputFile_ <<
" ) ";
149 outputFile_ <<
Dbl(value);
153 outputFile_ <<
Int(step);
154 outputFile_ <<
" ( ";
155 for (
int i = 0; i < D; i++){
156 outputFile_ <<
Int(GminStar_[i],3) <<
" ";
158 outputFile_ <<
" ) ";
159 outputFile_ <<
Dbl(value);
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.
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.
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.
int nSamplePerOutput() const
Get value of nSamplePerOutput.
Simulator< D > & simulator()
Return reference to parent simulator.
System< D > & system()
Return reference to parent system.
virtual ~MaxOrderParameter()
Destructor.
virtual double compute()
Compute and return the max order parameter.
MaxOrderParameter(Simulator< D > &simulator, System< D > &system)
Constructor.
void setClassName(const char *className)
Set class name string.
virtual void setup()
Setup before simulation loop.
virtual void outputValue(int step, double value)
Output a sampled or block average value.
Field theoretic simulator (base class).
Main class, representing one complete system.
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.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Periodic fields and crystallography.
Real periodic fields, SCFT and PS-FTS (CPU).
PSCF package top-level namespace.