PSCF v1.4.0
Pscf::Cpc::Propagator< D > Class Template Reference

MDE solver for one direction of one block. More...

#include <Propagator.h>

Inheritance diagram for Pscf::Cpc::Propagator< D >:
Pscf::PropagatorTmpl< Propagator< D > >

Public Types

using Base = PropagatorTmpl< Propagator<D> >
 Base class (partial template specialization).
using FieldT = CField<D>
 Field type (function of position, defined on a r-space grid).

Public Member Functions

 Propagator ()
 Constructor.
 ~Propagator ()
 Destructor.
void setBlock (Block< D > &block)
 Associate this propagator with a block.
void allocate (int ns, const Mesh< D > &mesh)
 Allocate memory used by this propagator.
void reallocate (int ns)
 Reallocate memory used by this propagator.
void solve ()
 Solve the modified diffusion equation (MDE) for this block.
void solve (FieldT const &head)
 Solve the MDE for a specified initial condition.
void computeQ (std::complex< double > &Q) const
 Compute and return partition function for the polymer.
const FieldTq (int i) const
 Return slice of q-field at a specified step.
const FieldThead () const
 Return q-field at beginning of the block (initial condition).
const FieldTtail () const
 Return q-field at the end of the block.
Block< D > const & block () const
 Get the associated Block<D> object by const reference.
int ns () const
 Get the number of values of s (or slices), including head and tail.
bool isAllocated () const
 Has memory been allocated for this propagator?
int nSource () const
 Number of source / prerequisite propagators.
const Propagator< D > & source (int id) const
 Get a source propagator.
const Propagator< D > & partner () const
 Get partner propagator.
void setIsSolved (bool isSolved)
 Set the isSolved flag to true or false.
bool isSolved () const
 Has the modified diffusion equation been solved?
bool hasPartner () const
 Does this have a partner propagator?
bool isHeadEnd () const
 Is the head vertex a chain end?
bool isTailEnd () const
 Is the tail vertex a chain end?
Public Member Functions inherited from Pscf::PropagatorTmpl< Propagator< D > >
void setDirectionId (int directionId)
 Associate this propagator with a direction index.
void setPartner (const Propagator< D > &partner)
 Set the partner of this propagator.
void addSource (const Propagator< D > &source)
 Add a propagator to the list of sources for this one.
void setIsSolved (bool isSolved)
 Set the isSolved flag to true or false.
void setEndFlags (bool isHeadEnd, bool isTailEnd)
 Set flags indicating whether vertices are chain ends.
const Propagator< D > & source (int id) const
 Get a source propagator.
const Propagator< D > & partner () const
 Get partner propagator.
int directionId () const
 Get direction index for this propagator.
int nSource () const
 Number of source / prerequisite propagators.
bool hasPartner () const
 Does this have a partner propagator?
bool isHeadEnd () const
 Is the head vertex a chain end?
bool isTailEnd () const
 Is the tail vertex a chain end?
bool isSolved () const
 Has the modified diffusion equation been solved?
bool isReady () const
 Are all source propagators solved?

Additional Inherited Members

Protected Member Functions inherited from Pscf::PropagatorTmpl< Propagator< D > >
 PropagatorTmpl ()
 Constructor.

Detailed Description

template<int D>
class Pscf::Cpc::Propagator< D >

MDE solver for one direction of one block.

A fully initialized Propagator<D> has associations with a parent Block<D> and with a partner Propagator<D> that solves the MDE within the same block in the opposite direction. It also has an association with a Mesh<D> that describes a spatial grid, and associations with zero or more source Propagator<D> objects that are used to compute an initial condition for this propagator at the head vertex.

The associated Block<D> stores information required to numerically solve the modified diffusion equation (MDE), including quantities that depend upon the w-field associated with this block, the unit cell parameters and (in the thread model) the contour step size. These quantities are set and stored by the block because their values are the same for the two propagators owned by each block, but may be different for different blocks. The algorithm used by a Propagator to solve the MDE repeatedly calls functions provided by the parent Block that advance the solution by one bead or step.

Definition at line 53 of file cpc/solvers/Propagator.h.

Member Typedef Documentation

◆ Base

template<int D>
using Pscf::Cpc::Propagator< D >::Base = PropagatorTmpl< Propagator<D> >

Base class (partial template specialization).

Definition at line 63 of file cpc/solvers/Propagator.h.

◆ FieldT

template<int D>
using Pscf::Cpc::Propagator< D >::FieldT = CField<D>

Field type (function of position, defined on a r-space grid).

Definition at line 68 of file cpc/solvers/Propagator.h.

Constructor & Destructor Documentation

◆ Propagator()

template<int D>
Pscf::Cpc::Propagator< D >::Propagator ( )

Constructor.

Definition at line 27 of file cpc/solvers/Propagator.tpp.

◆ ~Propagator()

template<int D>
Pscf::Cpc::Propagator< D >::~Propagator ( )

Destructor.

Definition at line 38 of file cpc/solvers/Propagator.tpp.

Member Function Documentation

◆ setBlock()

template<int D>
void Pscf::Cpc::Propagator< D >::setBlock ( Block< D > & block)
inline

Associate this propagator with a block.

Parameters
blockassociated Block object.

Definition at line 45 of file cpc/solvers/Propagator.tpp.

References block(), and UTIL_CHECK.

◆ allocate()

template<int D>
void Pscf::Cpc::Propagator< D >::allocate ( int ns,
const Mesh< D > & mesh )

Allocate memory used by this propagator.

The parameter ns is the number of values of s at which q(r,s) is calculated, including the end values at the terminating vertices. See docs for the function ns(), which returns this value.

The address of the associated Mesh<D> object is retained.

An Exception is thrown if the propagator is already allocated.

Parameters
nsnumber of slices (including end points at vertices)
meshspatial discretization mesh

Definition at line 55 of file cpc/solvers/Propagator.tpp.

References Pscf::Mesh< D >::dimensions(), ns(), and UTIL_CHECK.

◆ reallocate()

template<int D>
void Pscf::Cpc::Propagator< D >::reallocate ( int ns)

Reallocate memory used by this propagator.

This function is used when the value of ns is changed, which can occur during some parameter sweeps. See docs for allocate and ns.

An Exception is thrown if the propagator has not been previously allocated, or if the parameter ns is equal to the current value.

Parameters
nsnumber of slices (including end points)

Definition at line 72 of file cpc/solvers/Propagator.tpp.

References ns(), setIsSolved(), and UTIL_CHECK.

◆ solve() [1/2]

template<int D>
void Pscf::Cpc::Propagator< D >::solve ( )

Solve the modified diffusion equation (MDE) for this block.

This function computes an initial q-field at the head of this block, and then solves the modified diffusion equation (MDE) to propagate the solution from the head to the tail. Algorithms for the thread or bead model may be used, depending on the value of PolymerModel::model().

Definition at line 153 of file cpc/solvers/Propagator.tpp.

References block(), isAllocated(), Pscf::PolymerModel::isBead(), isHeadEnd(), isTailEnd(), Pscf::PolymerModel::isThread(), setIsSolved(), UTIL_CHECK, and UTIL_THROW.

◆ solve() [2/2]

template<int D>
void Pscf::Cpc::Propagator< D >::solve ( FieldT const & head)

Solve the MDE for a specified initial condition.

This function solves the modified diffusion equation (MDE) for this block with a specified initial condition, which is given by the function parameter "head".

Parameters
headinitial condition of q-field at head of block

Definition at line 204 of file cpc/solvers/Propagator.tpp.

References Pscf::assign(), block(), head(), Pscf::PolymerModel::isBead(), isHeadEnd(), isTailEnd(), Pscf::PolymerModel::isThread(), setIsSolved(), UTIL_CHECK, and UTIL_THROW.

◆ computeQ()

template<int D>
void Pscf::Cpc::Propagator< D >::computeQ ( std::complex< double > & Q) const

Compute and return partition function for the polymer.

This function computes the partition function Q for the molecule as a spatial average of the pointwise product of the initial/head slice for this propagator and the final/tail slice of its partner.

Parameters
Qoutput value, spatial average of q*q^{+} at head

Definition at line 262 of file cpc/solvers/Propagator.tpp.

References Pscf::addEq(), Pscf::assign(), Pscf::divEq(), hasPartner(), head(), Pscf::PolymerModel::isBead(), isHeadEnd(), isSolved(), isTailEnd(), Pscf::mul(), partner(), Util::product(), UTIL_CHECK, and UTIL_THROW.

◆ q()

template<int D>
Propagator< D >::FieldT const & Pscf::Cpc::Propagator< D >::q ( int i) const
inline

Return slice of q-field at a specified step.

Parameters
istep index, 0 <= i < ns

Definition at line 272 of file cpc/solvers/Propagator.h.

References isSolved(), and UTIL_CHECK.

Referenced by Pscf::Cpc::Block< D >::computeConcentrationBead(), and Pscf::Cpc::Block< D >::computeConcentrationThread().

◆ head()

template<int D>
Propagator< D >::FieldT const & Pscf::Cpc::Propagator< D >::head ( ) const
inline

Return q-field at beginning of the block (initial condition).

Definition at line 252 of file cpc/solvers/Propagator.h.

References isSolved(), and UTIL_CHECK.

Referenced by computeQ(), and solve().

◆ tail()

template<int D>
Propagator< D >::FieldT const & Pscf::Cpc::Propagator< D >::tail ( ) const
inline

Return q-field at the end of the block.

This function throws an Exception if invoked while the bead model is in use (i.e., if PolymerModel::isThread() == false) and the tail for this propagator is a chain end (i.e., if isTailEnd() == true). In this case, the tail slice is not needed, and so is not computed.

Definition at line 261 of file cpc/solvers/Propagator.h.

References isSolved(), isTailEnd(), Pscf::PolymerModel::isThread(), and UTIL_CHECK.

◆ block()

template<int D>
Block< D > const & Pscf::Cpc::Propagator< D >::block ( ) const
inline

Get the associated Block<D> object by const reference.

Definition at line 282 of file cpc/solvers/Propagator.h.

References UTIL_ASSERT.

Referenced by setBlock(), solve(), and solve().

◆ ns()

template<int D>
int Pscf::Cpc::Propagator< D >::ns ( ) const
inline

Get the number of values of s (or slices), including head and tail.

The value of ns is the number of values of s at which q(r,s) is calculated, including the end values at the terminating vertices (the head and tail). In the bead model, this is two more than the number of beads in the block. In the thread model, this is one more than the number length/ds of contour length steps.

Definition at line 292 of file cpc/solvers/Propagator.h.

Referenced by allocate(), and reallocate().

◆ isAllocated()

template<int D>
bool Pscf::Cpc::Propagator< D >::isAllocated ( ) const
inline

Has memory been allocated for this propagator?

Definition at line 296 of file cpc/solvers/Propagator.h.

Referenced by solve().

◆ nSource()

template<int D>
int Pscf::PropagatorTmpl< Propagator< D > >::nSource ( ) const

Number of source / prerequisite propagators.

◆ source()

template<int D>
const Propagator< D > & Pscf::PropagatorTmpl< Propagator< D > >::source ( int id) const

Get a source propagator.

Parameters
idindex of source propagator, < nSource

◆ partner()

template<int D>
const Propagator< D > & Pscf::PropagatorTmpl< Propagator< D > >::partner ( ) const

Get partner propagator.

Referenced by computeQ().

◆ setIsSolved()

template<int D>
void Pscf::PropagatorTmpl< Propagator< D > >::setIsSolved ( bool isSolved)

Set the isSolved flag to true or false.

Referenced by reallocate(), solve(), and solve().

◆ isSolved()

template<int D>
bool Pscf::PropagatorTmpl< Propagator< D > >::isSolved ( ) const

Has the modified diffusion equation been solved?

Referenced by computeQ(), head(), q(), and tail().

◆ hasPartner()

template<int D>
bool Pscf::PropagatorTmpl< Propagator< D > >::hasPartner ( ) const

Does this have a partner propagator?

Referenced by computeQ().

◆ isHeadEnd()

template<int D>
bool Pscf::PropagatorTmpl< Propagator< D > >::isHeadEnd ( ) const

Is the head vertex a chain end?

Precondition: PolymerModel::isBead()

Referenced by computeQ(), solve(), and solve().

◆ isTailEnd()

template<int D>
bool Pscf::PropagatorTmpl< Propagator< D > >::isTailEnd ( ) const

Is the tail vertex a chain end?

Precondition: PolymerModel::isBead()

Referenced by computeQ(), solve(), solve(), and tail().


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