PSCF v1.4.0
Pscf::Rpg::Block< D > Class Template Reference

Block within a branched polymer. More...

#include <Block.h>

Inheritance diagram for Pscf::Rpg::Block< D >:
Pscf::BlockTmpl< Propagator< D >, RField< D > > Pscf::Edge

Public Types

using BlockTmplT = BlockTmpl< Propagator<D>, RField<D> >
 Direct (parent) base class.
using FFTT = FFT<D>
 Fast Fourier Transform (FFT) type.
using WaveListT = WaveList<D>
 Wavelist type.
Public Types inherited from Pscf::BlockTmpl< Propagator< D >, RField< D > >
using PropagatorT
 Modified diffusion equation solver (propagator) type.
using FieldT
 Field type.

Public Member Functions

 Block ()
 Constructor.
 ~Block ()
 Destructor.
Propagator< D > & propagator (int directionId)
 Get a Propagator for a specified direction.
Propagator< D > const & propagator (int directionId) const
 Get a const Propagator for a specified direction.
RField< D > & cField ()
 Get the associated monomer concentration field.
RField< D > const & cField () const
 Get the associated const monomer concentration field.
Setup (mutators)
void associate (Mesh< D > const &mesh, FFT< D > const &fft, UnitCell< D > const &cell, WaveList< D > &waveList)
 Create permanent associations with related objects.
void allocate (double ds, bool useBatchedFFT=true)
 Allocate memory and set contour step size for thread model.
void clearUnitCellData ()
 Clear all internal data that depends on lattice parameters.
void setLength (double newLength)
 Set or reset block length (only used in thread model).
void setKuhn (double kuhn)
 Set or reset monomer statistical segment length.
void setupSolver (RField< D > const &w)
 Set solver for this block.
MDE Step Functions
void stepThread (RField< D > const &qin, RField< D > &qout) const
 Compute step of integration loop, from i to i+1.
void stepBead (RField< D > const &qin, RField< D > &qout) const
 Compute one step of solution of MDE for the bead model.
void stepFieldBead (RField< D > &q) const
 Apply the exponential field operator for the bead model.
void stepBondBead (RField< D > const &qin, RField< D > &qout) const
 Compute a bond operator for the bead model.
void stepHalfBondBead (RField< D > const &qin, RField< D > &qout) const
 Compute a half-bond operator for the bead model.
Monomer Concentration Computation
void computeConcentrationThread (double prefactor)
 Compute unnormalized concentration for block by integration.
void computeConcentrationBead (double prefactor)
 Compute the concentration for this block, using the bead model.
Stress Computation
void computeStressThread (double prefactor)
 Compute stress contribution for this block, using thread model.
void computeStressBead (double prefactor)
 Compute stress contribution for this block, using bead model.
double stress (int n) const
 Get derivative of free energy w/ respect to a unit cell parameter.
Accessors
double ds () const
 Contour length step size.
int ns () const
 Number of contour length steps.
Public Member Functions inherited from Pscf::BlockTmpl< Propagator< D >, RField< D > >
Propagator< D > & propagator (int directionId)
 Get a Propagator for a specified direction.
Propagator< D > const & propagator (int directionId) const
 Get a const Propagator for a specified direction.
RField< D > & cField ()
 Get the associated monomer concentration field.
RField< D > const & cField () const
 Get the associated const monomer concentration field.
double kuhn () const
 Get monomer statistical segment length.
Public Member Functions inherited from Pscf::Edge
 Edge ()
 Constructor.
virtual ~Edge ()=default
 Destructor.
template<class Archive>
void serialize (Archive &ar, unsigned int versionId)
 Serialize to/from archive.
void setId (int id)
 Set the id for this block.
void setMonomerId (int monomerId)
 Set the monomer type id.
void setVertexIds (int vertexId0, int vertexId1)
 Set indices of associated vertices.
virtual void setNBead (int nBead)
 Set the number of beads in this block (only valid for bead model).
void setPolymerType (PolymerType::Enum type)
 Set the type of the parent polymer (branched or linear).
int id () const
 Get the id of this block (unique within the polymer).
int monomerId () const
 Get the monomer type id for this block.
const Pair< int > & vertexIds () const
 Get the pair of associated vertex ids.
int vertexId (int i) const
 Get the id of one associated vertex.
double length () const
 Get the length of this block, in the thread model.
int nBead () const
 Get the number of beads in this block, in the bead model.
PolymerType::Enum polymerType () const
 Get the type of the parent polymer (branched or linear).

Additional Inherited Members

Protected Member Functions inherited from Pscf::BlockTmpl< Propagator< D >, RField< D > >
 BlockTmpl ()
 Constructor.
 ~BlockTmpl ()=default
 Destructor.

Detailed Description

template<int D>
class Pscf::Rpg::Block< D >

Block within a branched polymer.

A Block has two Propagator<D> members and a RField<D> concentraiton field.

Specializations of Rpg::Block with D=1, 2, and 3 are directly derived from corresponding specializations of Pscf::BlockTmpl, and indirectly derived from Pscf::Edge.

Definition at line 56 of file rpg/solvers/Block.h.

Member Typedef Documentation

◆ BlockTmplT

template<int D>
using Pscf::Rpg::Block< D >::BlockTmplT = BlockTmpl< Propagator<D>, RField<D> >

Direct (parent) base class.

Definition at line 64 of file rpg/solvers/Block.h.

◆ FFTT

template<int D>
using Pscf::Rpg::Block< D >::FFTT = FFT<D>

Fast Fourier Transform (FFT) type.

Definition at line 73 of file rpg/solvers/Block.h.

◆ WaveListT

template<int D>
using Pscf::Rpg::Block< D >::WaveListT = WaveList<D>

Wavelist type.

Definition at line 76 of file rpg/solvers/Block.h.

Constructor & Destructor Documentation

◆ Block()

template<int D>
Pscf::Rpg::Block< D >::Block ( )

Constructor.

Definition at line 219 of file rpg/solvers/Block.tpp.

References propagator().

◆ ~Block()

template<int D>
Pscf::Rpg::Block< D >::~Block ( )

Destructor.

Definition at line 242 of file rpg/solvers/Block.tpp.

Member Function Documentation

◆ associate()

template<int D>
void Pscf::Rpg::Block< D >::associate ( Mesh< D > const & mesh,
FFT< D > const & fft,
UnitCell< D > const & cell,
WaveList< D > & waveList )

Create permanent associations with related objects.

This function creates associations of this block with the Mesh, FFT, UnitCell, and WaveList objects by storing their addresses. It must be called before allocate().

Parameters
meshMesh<D> object - spatial discretization mesh
fftFFT<D> object - Fourier transforms
cellUnitCell<D> object - crystallographic unit cell
waveListWaveList<D> object - properties of wavevectors

Definition at line 246 of file rpg/solvers/Block.tpp.

References Pscf::Prdc::UnitCellBase< D >::nParameter(), and UTIL_CHECK.

◆ allocate()

template<int D>
void Pscf::Rpg::Block< D >::allocate ( double ds,
bool useBatchedFFT = true )

Allocate memory and set contour step size for thread model.

This function choses a value for the number ns of contour variable grid points for this block, sets the step size, and allocates memory for several private arrays. Spatial grid dimensions are obtained from a pointers to the associated mesh.

For the thread model, if PolymerModel::isThread() is true, the value for the number ns of contour variable grid points for this block is chosen to yield a value for the the actual step size length/(ns-1) as close as possible to the input parameter ds (the target step size), consistent with the requirements that ns be an odd integer and ns > 1. These requirements allow use of Simpson's rule for integration with respect to the contour variable s to compute monomer concentration fields and stress contributions.

For the bead model, if PolymerModel::isThread() is true, the value of ns is given by nBead + 2.

Precondition: associate() must be called before this function

Parameters
dstarget (optimal) value for contour length step size
useBatchedFFTFlag indicating whether to use batched FFTs

Definition at line 269 of file rpg/solvers/Block.tpp.

References cField(), Pscf::Prdc::Cuda::FFT< D >::computeKMesh(), ds(), Pscf::PolymerModel::isBead(), Pscf::PolymerModel::isThread(), Pscf::Edge::length(), Pscf::Edge::nBead(), propagator(), and UTIL_CHECK.

◆ clearUnitCellData()

template<int D>
void Pscf::Rpg::Block< D >::clearUnitCellData ( )

Clear all internal data that depends on lattice parameters.

This method changes the internal hasExpKsq_ flag to false, so that the expKsq arrays will need to be recalculated before a step function can be called.

Definition at line 401 of file rpg/solvers/Block.tpp.

References UTIL_CHECK.

◆ setLength()

template<int D>
void Pscf::Rpg::Block< D >::setLength ( double newLength)
virtual

Set or reset block length (only used in thread model).

Precondition: PolymerModel::isThread()

Parameters
newLengthnew block length

Reimplemented from Pscf::Edge.

Definition at line 346 of file rpg/solvers/Block.tpp.

References Pscf::PolymerModel::isThread(), Pscf::Edge::length(), propagator(), Pscf::Edge::setLength(), and UTIL_CHECK.

◆ setKuhn()

template<int D>
void Pscf::Rpg::Block< D >::setKuhn ( double kuhn)
virtual

Set or reset monomer statistical segment length.

Parameters
kuhnnew monomer statistical segment length.

Reimplemented from Pscf::BlockTmpl< Propagator< D >, RField< D > >.

Definition at line 391 of file rpg/solvers/Block.tpp.

References Pscf::BlockTmpl< Propagator< D >, RField< D > >::kuhn(), and Pscf::BlockTmpl< Propagator< D >, RField< D > >::setKuhn().

◆ setupSolver()

template<int D>
void Pscf::Rpg::Block< D >::setupSolver ( RField< D > const & w)

Set solver for this block.

This should be called once after every change in w fields, the unit cell parameters, the block length or kuhn length, before entering the loop used to solve the MDE for either propagator. This function is called by Polymer<D>::compute.

Parameters
wchemical potential field for this monomer type

Definition at line 442 of file rpg/solvers/Block.tpp.

References Pscf::VecOp::divSV(), Pscf::VecOp::expVc(), Pscf::PolymerModel::isThread(), and UTIL_CHECK.

◆ stepThread()

template<int D>
void Pscf::Rpg::Block< D >::stepThread ( RField< D > const & qin,
RField< D > & qout ) const

Compute step of integration loop, from i to i+1.

This function is called internally by the Propagator::solve function within a loop over steps. It is implemented in the Block class because the same private data structures are needed for the two propagators associated with a Block.

Parameters
qinslice i of propagator q (input)
qoutslice i+1 of propagator q (output)

Definition at line 469 of file rpg/solvers/Block.tpp.

References Pscf::Prdc::Cuda::RField< D >::associate(), Pscf::Prdc::Cuda::RFieldDft< D >::associate(), Pscf::DeviceArray< Data >::dissociate(), Pscf::VecOp::mulEqV(), Pscf::VecOp::mulEqVPair(), Pscf::VecOp::mulVVPair(), and UTIL_CHECK.

◆ stepBead()

template<int D>
void Pscf::Rpg::Block< D >::stepBead ( RField< D > const & qin,
RField< D > & qout ) const

Compute one step of solution of MDE for the bead model.

This function is called internally by the Propagator::solve function within a loop over steps. It is implemented in the Block class because the same private data structures are needed for the two propagators associated with a Block.

Parameters
qinslice i of propagator q (input)
qoutslice i+1 of propagator q (output)

Definition at line 517 of file rpg/solvers/Block.tpp.

References stepBondBead(), and stepFieldBead().

◆ stepFieldBead()

template<int D>
void Pscf::Rpg::Block< D >::stepFieldBead ( RField< D > & q) const

Apply the exponential field operator for the bead model.

This function applies exp( -w(r)) in-place, where w(r) is the w-field for the monomer type of this block.

Parameters
qslice of propagator q, modified in placde

Definition at line 527 of file rpg/solvers/Block.tpp.

References Pscf::DeviceArray< Data >::capacity(), Pscf::VecOp::mulEqV(), and UTIL_CHECK.

Referenced by stepBead().

◆ stepBondBead()

template<int D>
void Pscf::Rpg::Block< D >::stepBondBead ( RField< D > const & qin,
RField< D > & qout ) const

Compute a bond operator for the bead model.

This function applies exp( -|G|^2 b^2 / 6) in Fourier space. To do so, it peforms a forward FFT, multplication in k-space, and an inverse FFT.

Parameters
qinslice i of propagator q (input)
qoutslice i+1 of propagator q (output)

Definition at line 541 of file rpg/solvers/Block.tpp.

References Pscf::DeviceArray< Data >::capacity(), Pscf::VecOp::mulEqV(), and UTIL_CHECK.

Referenced by stepBead().

◆ stepHalfBondBead()

template<int D>
void Pscf::Rpg::Block< D >::stepHalfBondBead ( RField< D > const & qin,
RField< D > & qout ) const

Compute a half-bond operator for the bead model.

This function applies exp( -|G|^2 b^2 / 12) in Fourier space. To do so, it peforms a forward FFT, multplication in k-space, and an inverse FFT.

Parameters
qinslice i of propagator q (input)
qoutslice i+1 of propagator q (output)

Definition at line 567 of file rpg/solvers/Block.tpp.

References Pscf::DeviceArray< Data >::capacity(), Pscf::VecOp::mulEqV(), and UTIL_CHECK.

◆ computeConcentrationThread()

template<int D>
void Pscf::Rpg::Block< D >::computeConcentrationThread ( double prefactor)

Compute unnormalized concentration for block by integration.

The "prefactor" parameter must equal phi/(L q), where L is the total length of all blocks in the polymer species and q is the species partition function.

Upon return, grid point r of array cField() contains the integral int ds q(r,s)q^{*}(r,L-s) times the prefactor, where q(r,s) is the solution obtained from propagator(0), and q^{*} is the solution of propagator(1), and s is a contour variable that is integrated over the domain 0 < s < length(), where length() is the block length.

Parameters
prefactorconstant multiplying integral over s

Definition at line 590 of file rpg/solvers/Block.tpp.

References cField(), Pscf::VecOp::eqS(), Pscf::VecOp::mulEqS(), propagator(), Pscf::Rp::Propagator< D, T >::q(), and UTIL_CHECK.

◆ computeConcentrationBead()

template<int D>
void Pscf::Rpg::Block< D >::computeConcentrationBead ( double prefactor)

Compute the concentration for this block, using the bead model.

This function is called by Polymer::compute if a bead model is is used.

The "prefactor" parameter must equal phi/(N q), where N is the total number of beads owned by all blocks of the polymer, and q is the species partition function.

Upon return, grid point r of array cField() contains the sum sum_s ds q(r,s) q^{*}(r,N-s) exp(W(r)*ds) over beads owned by this block times the "prefactor" parameter, where q(r,s) and q^{*}(r,s) are propagators associated with different directions.

Parameters
prefactorconstant multiplying sum over beads

Definition at line 626 of file rpg/solvers/Block.tpp.

References cField(), Pscf::VecOp::eqS(), Pscf::VecOp::mulEqS(), propagator(), Pscf::Rp::Propagator< D, T >::q(), and UTIL_CHECK.

◆ computeStressThread()

template<int D>
void Pscf::Rpg::Block< D >::computeStressThread ( double prefactor)

Compute stress contribution for this block, using thread model.

This function is called by Polymer<D>::computeStress. The prefactor is equal to that used in computeConcentrationThread.

Parameters
prefactorconstant multiplying integral over s

Definition at line 656 of file rpg/solvers/Block.tpp.

References Util::FSArray< Data, Capacity >::append(), Pscf::PropagatorTmpl< QT >::isSolved(), Pscf::PolymerModel::isThread(), Pscf::BlockTmpl< Propagator< D >, RField< D > >::kuhn(), propagator(), Pscf::Rp::Propagator< D, T >::q(), Pscf::Rpg::Propagator< D >::qAll(), Pscf::Reduce::sum(), and UTIL_CHECK.

◆ computeStressBead()

template<int D>
void Pscf::Rpg::Block< D >::computeStressBead ( double prefactor)

◆ stress()

template<int D>
double Pscf::Rpg::Block< D >::stress ( int n) const
inline

Get derivative of free energy w/ respect to a unit cell parameter.

Parameters
nunit cell parameter index

Definition at line 462 of file rpg/solvers/Block.h.

◆ ds()

template<int D>
double Pscf::Rpg::Block< D >::ds ( ) const
inline

Contour length step size.

Definition at line 457 of file rpg/solvers/Block.h.

Referenced by allocate().

◆ ns()

template<int D>
int Pscf::Rpg::Block< D >::ns ( ) const
inline

Number of contour length steps.

Definition at line 452 of file rpg/solvers/Block.h.

◆ propagator() [1/2]

template<int D>
Propagator< D > & Pscf::BlockTmpl< Propagator< D >, RField< D > >::propagator ( int directionId)

Get a Propagator for a specified direction.

For a block with v0 = vertexId(0) and v1 = vertexId(1), propagator(0) propagates from vertex v0 to v1, while propagator(1) propagates from vertex v1 to v0.

Parameters
directionIdinteger index for direction (0 or 1)

Referenced by allocate(), Block(), computeConcentrationBead(), computeConcentrationThread(), computeStressBead(), computeStressThread(), and setLength().

◆ propagator() [2/2]

template<int D>
Propagator< D > const & Pscf::BlockTmpl< Propagator< D >, RField< D > >::propagator ( int directionId) const

Get a const Propagator for a specified direction.

See above for number conventions.

Parameters
directionIdinteger index for direction (0 or 1)

◆ cField() [1/2]

template<int D>
RField< D > & Pscf::BlockTmpl< Propagator< D >, RField< D > >::cField ( )

Get the associated monomer concentration field.

Referenced by allocate(), computeConcentrationBead(), and computeConcentrationThread().

◆ cField() [2/2]

template<int D>
RField< D > const & Pscf::BlockTmpl< Propagator< D >, RField< D > >::cField ( ) const

Get the associated const monomer concentration field.


The documentation for this class was generated from the following files: