8#include "FilmFieldGenMask_c.h"
10#include <rp/solvers/Mixture.h>
11#include <rp/scft/iterator/Iterator.h>
12#include <rp/scft/ScftThermo.h>
13#include <rp/field/Domain.h>
14#include <rp/field/FieldIo.h>
15#include <rp/field/WFields.h>
16#include <rp/field/CFields.h>
17#include <rp/field/Mask.h>
19#include <pscf/field/cpp/RField.h>
20#include <pscf/crystal/UnitCell.h>
21#include <pscf/crystal/Basis.h>
22#include <pscf/crystal/paramIdConversions.h>
24#include <pscf/interaction/Interaction.h>
25#include <pscf/math/IntVec.h>
77 if (normalVecParamId != paramId)
return 0.0;
83 double phiTot =
system().mask().phiTot();
88 for (
int ind = 0; ind < 3; ind++) {
106 for (x = 0; x < dim[0]; x++) {
108 for (y = 0; y < dim[1]; y++) {
110 for (z = 0; z < dim[2]; z++) {
112 maskVal = maskRGrid[counter];
119 deriv[counter] = maskVal * (maskVal - 1) * 8.0
120 * (std::abs(d - 0.5) - 0.5)
128 int nMonomer =
system().mixture().nMonomer();
129 int nx = mesh.
size();
134 for (
int i = 0; i < nx; i++) {
135 xi[i] =
system().w().rgrid(0)[i];
138 for (
int in = 0; in < nMonomer; in++) {
139 chi =
system().interaction().chi(0,in);
140 if (fabs(chi) > 1e-6) {
142 for (
int i = 0; i < nx; i++) {
144 xi[i] -= cfield[i] * chi;
149 if (
system().h().hasData()) {
151 for (
int i = 0; i < nx; i++) {
158 double intTerm = 0.0;
159 for (
int i = 0; i < nx; i++) {
160 intTerm += xi[i] * deriv[i];
162 intTerm /= (phiTot * nx);
165 if (!
system().scft().hasData()) {
166 sysPtr_->scft().compute();
168 double pSys =
system().scft().pressure();
172 double dPhiTot = 0.0;
173 for (
int i = 0; i < nx; i++) {
176 dPhiTot /= double(nx);
177 double pTerm = pSys * dPhiTot / phiTot;
179 return pTerm - intTerm;
192 system().domain().lattice());
193 if (nvParamId == paramId) {
197 UTIL_THROW(
"fBulk must be set before calculating this stress.");
201 if (!
system().scft().hasData()) {
202 sysPtr_->scft().compute();
204 double fSys =
system().scft().fHelmholtz();
207 double L =
system().domain().unitCell().parameter(paramId);
212 return modifiedStress;
232 system().domain().lattice());
233 double L =
system().domain().unitCell().parameter(paramId);
238 for (
int ind = 0; ind < 3; ind++) {
240 dim[ind] =
system().domain().mesh().dimensions()[ind];
248 rGrid.allocate(
system().domain().mesh().dimensions());
254 for (x = 0; x < dim[0]; x++) {
256 for (y = 0; y < dim[1]; y++) {
258 for (z = 0; z < dim[2]; z++) {
268 rGrid[counter++] = 1-rhoW;
274 bool isSymmetric =
system().domain().hasGroup();
280 system().mask().setRGrid(rGrid, isSymmetric);
294 if (
system().hasIterator() &&
system().iterator().isFlexible()) {
297 system().domain().unitCell());
298 sysPtr_->iterator().setFlexibleParams(updated);
308 template class FilmFieldGenMask<1,CPT>;
309 template class FilmFieldGenMask<2,CPT>;
310 template class FilmFieldGenMask<3,CPT>;
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.
Spatial domain for a periodic structure with real fields.
Mesh< D > & mesh()
Get the Mesh by non-const reference.
UnitCell< D >::LatticeSystem lattice() const
Get the lattice type (enumeration value).
double excludedThickness() const
Get value of excludedThickness.
double fBulk_
Reference free energy used to calculate stress normal to the film.
int normalVecId() const
Get value of normalVecId.
FilmFieldGenMaskBase()
Constructor.
double interfaceThickness() const
Get value of interfaceThickness.
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.
RealVec< D > normalVecCurrent_
The lattice vector normal to the film used to generate these fields.
RealVec< D > systemLatticeVector(int id) const
Get one of the lattice vectors for this system.
Rp::System< D, CPT > & system()
Get the parent System by non-const reference.
double stress(int paramId) const
Get contribution to the stress from this mask.
FilmFieldGenMask()
Default constructor.
Base class template for classes that represent a complete system.
A fixed capacity (static) contiguous array with a variable logical size.
void setClassName(const char *className)
Set class name string.
#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.
Code for programs that simulate real-valued periodic fields.
PSCF package top-level namespace.