1#ifndef PSCF_POLYMER_TMPL_H
2#define PSCF_POLYMER_TMPL_H
11#include <pscf/chem/PolymerSpecies.h>
12#include <util/param/ParamComposite.h>
14#include <util/containers/Pair.h>
15#include <util/containers/DArray.h>
17#include <pscf/chem/Vertex.h>
18#include <pscf/chem/PolymerType.h>
19#include <pscf/chem/PolymerModel.h>
115 virtual void solve(
double phiTot = 1.0);
238 {
return blocks_[id]; }
246 {
return blocks_[id]; }
254 {
return blocks_[id]; }
262 {
return blocks_[id]; }
269 typename BT::PropagatorT&
271 {
return block(blockId).propagator(directionId); }
278 typename BT::PropagatorT
const &
280 {
return block(blockId).propagator(directionId); }
317 { blocks_.allocate(nBlock()); }
324 { readDArray<BT>(in,
"blocks", blocks_, nBlock()); }
340 PropagatorT * propagatorPtr =
nullptr;
341 PropagatorT
const * sourcePtr =
nullptr;
342 Vertex const * headPtr =
nullptr;
343 Vertex const * tailPtr =
nullptr;
345 int blockId, forwardId, reverseId, headId, tailId, i;
346 bool isHeadEnd, isTailEnd;
349 for (blockId = 0; blockId < nBlock(); ++blockId) {
350 for (forwardId = 0; forwardId < 2; ++forwardId) {
352 propagatorPtr = &block(blockId).propagator(forwardId);
355 if (forwardId == 0) {
360 headId = block(blockId).vertexId(forwardId);
361 tailId = block(blockId).vertexId(reverseId);
362 headPtr = &vertex(headId);
363 tailPtr = &vertex(tailId);
366 for (i = 0; i < headPtr->size(); ++i) {
367 propId = headPtr->inPropagatorId(i);
368 if (propId[0] == blockId) {
372 &block(propId[0]).propagator(propId[1]);
373 propagatorPtr->addSource(*sourcePtr);
378 isHeadEnd = (headPtr->size() == 1) ? true :
false;
379 isTailEnd = (tailPtr->size() == 1) ? true :
false;
380 propagatorPtr->setEndFlags(isHeadEnd, isTailEnd);
399 void PolymerTmpl<BT>::isValid()
401 Vertex const * v0Ptr =
nullptr;
402 Vertex const * v1Ptr =
nullptr;
403 PropagatorT
const * p0Ptr =
nullptr;
404 PropagatorT
const * p1Ptr =
nullptr;
408 for (bId = 0; bId < nBlock(); ++bId) {
409 v0Id = block(bId).vertexId(0);
410 v1Id = block(bId).vertexId(1);
414 v0Ptr = &vertex(v0Id);
415 v1Ptr = &vertex(v1Id);
416 p0Ptr = &(block(bId).propagator(0));
417 p1Ptr = &(block(bId).propagator(1));
418 UTIL_CHECK(p0Ptr->nSource() == (v0Ptr->size() - 1));
419 UTIL_CHECK(p1Ptr->nSource() == (v1Ptr->size() - 1));
420 UTIL_CHECK(p0Ptr->isHeadEnd() == p1Ptr->isTailEnd());
421 UTIL_CHECK(p0Ptr->isHeadEnd() == (v0Ptr->size() == 1));
422 UTIL_CHECK(p1Ptr->isHeadEnd() == (v1Ptr->size() == 1));
435 for (
int j = 0; j < nPropagator(); ++j) {
436 propagator(j).setIsSolved(
false);
441 for (
int j = 0; j < nPropagator(); ++j) {
443 propagator(j).solve();
447 double Q = block(0).propagator(0).computeQ();
460#include "PolymerTmpl.tpp"
Descriptor for a block within a block polymer.
Descriptor for a linear or acyclic branched block polymer.
const Vertex & vertex(int id) const
Get a specified Vertex by const reference.
PolymerSpecies()
Constructor.
Pair< int > const & path(int is, int it) const
Get an id for a propagator from one vertex towards a target.
int nVertex() const
Number of vertices (junctions and chain ends).
virtual void readParameters(std::istream &in)
Read parameters and initialize.
int nPropagator() const
Number of propagators (2*nBlock).
int nBead() const
Total number of beads in the polymer (bead model).
int nBlock() const
Number of blocks.
double length() const
Sum of the lengths of all blocks in the polymer (thread model).
Pair< int > const & propagatorId(int id) const
Get a propagator identifier, indexed by order of computation.
PolymerType::Enum type() const
Get Polymer type (Branched or Linear)
typename BT::PropagatorT PropagatorT
Modified diffusion equation solver for one block, in one direction.
void allocateBlocks() final
Allocate array of Block objects.
BT const & block(int id) const
Get a specified Block (solver and descriptor) by const reference.
void readBlocks(std::istream &in) final
~PolymerTmpl()
Destructor.
PropagatorT const & propagator(int blockId, int directionId) const
Get the propagator for a specific block and direction (const).
PropagatorT & propagator(int id)
Get a propagator indexed in order of computation (non-const).
virtual void readParameters(std::istream &in)
Read and initialize.
PropagatorT & propagator(int blockId, int directionId)
Get the propagator for a specific block and direction (non-const).
Edge const & edge(int id) const final
Get a specified Edge (block descriptor) by const reference.
BT BlockT
Block of a block polymer.
virtual void solve(double phiTot=1.0)
Solve modified diffusion equation for all propagators.
PolymerTmpl()
Constructor.
Pair< int > const & propagatorId(int id) const
Get a propagator identifier, indexed by order of computation.
Edge & edge(int id) final
Get a specified Edge (block descriptor) by non-const reference.
BT & block(int id)
Get a specified Block (solver and descriptor).
double phi() const
Get the overall volume fraction for this species.
void setQ(double q)
Set q and compute phi or mu (depending on the ensemble).
double mu() const
Get the chemical potential for this species (units kT=1).
Ensemble ensemble() const
Get the statistical ensemble for this species (open or closed).
double q() const
Get the molecular partition function for this species.
A junction or chain end in a block polymer.
Dynamically allocatable contiguous array template.
An array of exactly 2 objects.
void setClassName(const char *className)
Set class name string.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
PSCF package top-level namespace.