PSCF v1.4.0
BinaryStructureFactor.cu
1/*
2* PSCF - Polymer Self-Consistent Field
3*
4* Copyright 2015 - 2025, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "BinaryStructureFactor.h"
9
10#include <rpg/fts/simulator/Simulator.h>
11#include <rpg/system/System.h>
12#include <rpg/solvers/Mixture.h>
13#include <rpg/field/Domain.h>
14#include <rpg/field/WFields.h>
15
16#include <prdc/cuda/FFT.h>
17#include <prdc/cuda/WaveList.h>
18
19#include <pscf/cuda/VecOp.h>
20#include <pscf/cuda/complex.h>
21
22#include <rp/fts/analyzer/BinaryStructureFactor.tpp>
23
24namespace Pscf {
25namespace Rpg {
26
27 using namespace Util;
28 using namespace Pscf::Prdc;
29
30 /*
31 * Constructor.
32 */
33 template <int D>
35 Simulator<D>& simulator,
36 System<D>& system)
37 : Rp::BinaryStructureFactor< D, Types<D> >(simulator, system)
38 {}
39
40 /*
41 * Setup before entering main loop.
42 */
43 template <int D>
45 {
46 allocate();
47 UTIL_CHECK(wk_.isAllocated());
48 if (!wkHost_.isAllocated()) {
49 wkHost_.allocate(wk_.capacity());
50 }
51
52 Cuda::WaveList<D> const & waveList = AnalyzerT::system().waveList();
53 HostDArray<double> kSq = waveList.kSq();
54 HostDArray<bool> implicit = waveList.implicitInverse();
55 findWaveBunches(kSq, implicit);
56 }
57
58 /*
59 * Compute structure factors for all wavevectors and bunches.
60 */
61 template <int D>
63 {
64 if (AnalyzerT::isAtInterval(iStep)) {
65 computeW();
66 wkHost_ = wk_; // Copy wk_ from device to host
67 computeS(wkHost_);
68 }
69 }
70
71}
72}
73
74// Explicit instantiation definitions
75namespace Pscf {
76 namespace Rp {
77 template class BinaryStructureFactor<1, Rpg::Types<1> >;
78 template class BinaryStructureFactor<2, Rpg::Types<2> >;
79 template class BinaryStructureFactor<3, Rpg::Types<3> >;
80 }
81 namespace Rpg {
82 template class BinaryStructureFactor<1>;
83 template class BinaryStructureFactor<2>;
84 template class BinaryStructureFactor<3>;
85 }
86}
Template for dynamic array stored in host CPU memory.
Definition HostDArray.h:41
Class to compute and store properties associated with wavevectors.
RField< D > const & kSq() const
Get the kSq array on the device by reference.
DeviceArray< bool > const & implicitInverse() const
Get the implicitInverse array by reference.
void computeS(Array< typename Types< D >::Complex > const &wk)
void findWaveBunches(Array< double > const &kSq, Array< bool > const &implicit)
Spherically averaged structure factor for a two-monomer system.
void setup() override
Setup before the main loop.
void sample(long iStep) override
Compute structure factors and add to accumulators.
BinaryStructureFactor(Simulator< D > &simulator, System< D > &system)
Constructor.
Field theoretic simulator (base class).
Main class, representing a complete physical system.
List of aliases for types used in the Rpg program-level namespace.
#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.
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.