8#include "Interaction.h"
9#include <pscf/math/LuSolver.h>
52 void Interaction::updateMembers()
58 double det = chi_(0,0)*chi_(1, 1) - chi_(0,1)*chi_(1,0);
59 double norm = chi_(0,0)*chi_(0, 0) + chi_(1,1)*chi_(1,1)
60 + 2.0*chi_(0,1)*chi_(1,0);
61 if (fabs(det/norm) < 1.0E-8) {
64 chiInverse_(0,1) = -chi_(0,1)/det;
65 chiInverse_(1,0) = -chi_(1,0)/det;
66 chiInverse_(1,1) = chi_(0,0)/det;
67 chiInverse_(0,0) = chi_(1,1)/det;
72 solver.computeLU(chi_);
73 solver.inverse(chiInverse_);
98 sum += chi_(i, j)* c[i]*c[j];
115 w[i] += chi_(i, j)* c[j];
133 sum1 += chiInverse_(i, j)*w[j];
134 sum2 += chiInverse_(i, j);
137 xi = (sum1 - 1.0)/sum2;
141 c[i] += chiInverse_(i, j)*( w[j] - xi );
158 sum1 += chiInverse_(i, j)*w[j];
159 sum2 += chiInverse_(i, j);
162 xi = (sum1 - 1.0)/sum2;
175 dWdC(i, j) = chi_(i, j);
virtual double fHelmholtz(Array< double > const &c) const
Compute excess Helmholtz free energy per monomer.
virtual void computeDwDc(Array< double > const &c, Matrix< double > &dWdC) const
Compute second derivatives of free energy.
double chi(int i, int j) const
Return one element of the chi matrix.
virtual void readParameters(std::istream &in)
Read chi parameters.
virtual void computeW(Array< double > const &c, Array< double > &w) const
Compute chemical potential from concentration.
virtual void computeC(Array< double > const &w, Array< double > &c, double &xi) const
Compute concentration from chemical potential fields.
void setChi(int i, int j, double chi)
Change one element of the chi matrix.
void setNMonomer(int nMonomer)
Set the number of monomer types.
Interaction()
Constructor.
virtual ~Interaction()
Destructor.
int nMonomer() const
Get number of monomer types.
virtual void computeXi(Array< double > const &w, double &xi) const
Compute Langrange multiplier xi from chemical potential fields.
Array container class template.
void allocate(int capacity1, int capacity2)
Allocate memory for a matrix.
bool isAllocated() const
Return true if the DMatrix has been allocated, false otherwise.
Two-dimensional array container template (abstract).
DSymmMatrixParam< Type > & readDSymmMatrix(std::istream &in, const char *label, DMatrix< Type > &matrix, int n)
Add and read a required symmetrix DMatrix.
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.
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.