1#ifndef RPC_MASK_GEN_FILM_TPP
2#define RPC_MASK_GEN_FILM_TPP
11#include "FilmFieldGenMask.h"
12#include <rpc/solvers/Mixture.h>
13#include <rpc/scft/iterator/Iterator.h>
14#include <rpc/scft/ScftThermo.h>
15#include <rpc/field/Domain.h>
16#include <rpc/field/FieldIo.h>
17#include <rpc/field/WFields.h>
18#include <rpc/field/CFields.h>
19#include <rpc/field/Mask.h>
21#include <prdc/cpu/RField.h>
22#include <prdc/crystal/UnitCell.h>
23#include <prdc/crystal/Basis.h>
24#include <prdc/crystal/paramIdConversions.h>
25#include <pscf/interaction/Interaction.h>
26#include <pscf/math/IntVec.h>
76 if (normalVecParamId != paramId)
return 0.0;
82 double nvLength = domain.
unitCell().parameter(paramId);
85 double phiTot =
system().mask().phiTot();
90 for (
int ind = 0; ind < 3; ind++) {
108 for (x = 0; x < dim[0]; x++) {
110 for (y = 0; y < dim[1]; y++) {
112 for (z = 0; z < dim[2]; z++) {
114 maskVal = maskRGrid[counter];
121 deriv[counter] = maskVal * (maskVal - 1) * 8.0
122 * (std::abs(d - 0.5) - 0.5)
130 int nMonomer =
system().mixture().nMonomer();
131 int nx = mesh.
size();
136 for (
int i = 0; i < nx; i++) {
137 xi[i] =
system().w().rgrid(0)[i];
140 for (
int in = 0; in < nMonomer; in++) {
141 chi =
system().interaction().chi(0,in);
142 if (fabs(chi) > 1e-6) {
144 for (
int i = 0; i < nx; i++) {
146 xi[i] -= cfield[i] * chi;
151 if (
system().h().hasData()) {
153 for (
int i = 0; i < nx; i++) {
160 double intTerm = 0.0;
161 for (
int i = 0; i < nx; i++) {
162 intTerm += xi[i] * deriv[i];
164 intTerm /= (phiTot * nx);
167 if (!
system().scft().hasData()) {
168 sysPtr_->scft().compute();
170 double pSys =
system().scft().pressure();
172 (phiTot * nvLength * nvLength);
174 return pTerm - intTerm;
183 system().domain().lattice());
184 if (nvParamId == paramId) {
188 UTIL_THROW(
"fBulk must be set before calculating this stress.");
192 if (!
system().scft().hasData()) {
193 sysPtr_->scft().compute();
195 double fSys =
system().scft().fHelmholtz();
198 double L =
system().domain().unitCell().parameter(paramId);
203 return modifiedStress;
219 if (
system().iterator().isSymmetric()) {
225 system().domain().lattice());
226 double L =
system().domain().unitCell().parameter(paramId);
231 for (
int ind = 0; ind < 3; ind++) {
233 dim[ind] =
system().domain().mesh().dimensions()[ind];
247 for (x = 0; x < dim[0]; x++) {
249 for (y = 0; y < dim[1]; y++) {
251 for (z = 0; z < dim[2]; z++) {
261 rGrid[counter++] = 1-rhoW;
267 system().mask().setRGrid(rGrid,
system().iterator().isSymmetric());
281 if (
system().iterator().isFlexible()) {
284 system().domain().unitCell());
285 sysPtr_->iterator().setFlexibleParams(updated);
An IntVec<D, T> is a D-component vector of elements of integer type T.
Description of a regular grid of points in a periodic domain.
IntVec< D > dimensions() const
Get an IntVec<D> of the grid dimensions.
int size() const
Get total number of grid points.
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.
RealVec< D > normalVecCurrent_
The lattice vector normal to the film used to generate these fields.
int normalVecId() const
Get value of normalVecId.
double fBulk_
Reference free energy used to calculate stress normal to the film.
bool hasFBulk() const
Check whether a value of fBulk was provided.
FSArray< bool, 6 > modifyFlexibleParams(FSArray< bool, 6 > current, UnitCell< D > const &cell) const
Modifies a flexibleParams array to be compatible with this mask.
double interfaceThickness() const
Get value of interfaceThickness.
double excludedThickness() const
Get value of excludedThickness.
FilmFieldGenMaskBase()
Constructor.
UnitCell< D > & unitCell()
Get the UnitCell by non-const reference.
UnitCell< D >::LatticeSystem lattice() const
Get the lattice type (enumeration value).
Mesh< D > & mesh()
Get the Mesh by non-const reference.
Spatial domain for a periodic structure with real fields, on a CPU.
void setFlexibleParams() const
Modifies iterator().flexibleParams_ to be compatible with the mask.
void setClassName(const char *className)
Set class name string.
double modifyStress(int paramId, double stress) const
Modify stress value in direction normal to the film.
RealVec< D > systemLatticeVector(int id) const
Get one of the lattice vectors for this system.
System< D > & system()
Get the parent System by non-const reference.
~FilmFieldGenMask()
Destructor.
FilmFieldGenMask()
Default constructor.
double stress(int paramId) const
Get contribution to the stress from this mask.
void compute()
Compute the field and store where the System can access.
A complete physical system.
A fixed capacity (static) contiguous array with a variable logical size.
#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.
int convertFullParamIdToReduced(const int fullId, const typename UnitCell< D >::LatticeSystem lattice)
Convert full lattice parameter index to a reduced index.
Fields and FFTs for periodic boundary conditions (CPU)
Periodic fields and crystallography.
Real periodic fields, SCFT and PS-FTS (CPU).
PSCF package top-level namespace.