JDFTx  1.7.0
FluidMixture Class Reference

Mixture of fluids that provides the total free energy functional for minimization Constructing Fex and IdealGas objects require a FluidMixture reference, to which they add themselves. The FluidMixture object is ready to use after initialize() is called. More...

#include <FluidMixture.h>

Inheritance diagram for FluidMixture:
Minimizable< ScalarFieldArray >

Classes

struct  Outputs
 Optional outputs for operator() and getFreeEnergy(), retrieve results for all non-null pointers. More...
 

Public Member Functions

 FluidMixture (const GridInfo &gInfo, const double T=298 *Kelvin)
 
void initialize (double P=1.01325 *Bar, double epsBulkOverride=0., double epsInfOverride=0.)
 
double getBoilingPressure (double NliqGuess, double NvapGuess, std::vector< double > *Nvap=0) const
 
unsigned get_nIndep () const
 get the number of scalar fields used as independent variables
 
unsigned get_nDensities () const
 get the total number of site densities
 
const std::vector< const FluidComponent * > & getComponents () const
 access component list
 
void initState (double scale=0.0, double Elo=-DBL_MAX, double Ehi=+DBL_MAX)
 
void loadState (const char *filename)
 Load the state from a single binary file.
 
void saveState (const char *filename) const
 Save the state to a single binary file.
 
double operator() (const ScalarFieldArray &indep, ScalarFieldArray &Phi_indep, Outputs outputs=Outputs()) const
 Free energy and gradient evaluation. More...
 
double getFreeEnergy (Outputs outputs=Outputs()) const
 Get the free energy, densities and moments for the current state. More...
 
void step (const ScalarFieldArray &dir, double alpha)
 Advance step along direction dir by scale alpha (interface for minimize())
 
double compute (ScalarFieldArray *grad, ScalarFieldArray *Kgrad)
 Return energy at current state, and optionally the gradient (interface for minimize())
 
double sync (double x) const
 All processes minimize together; make sure scalars are in sync to round-off error.
 
- Public Member Functions inherited from Minimizable< ScalarFieldArray >
virtual bool report (int iter)
 
virtual void constrain (ScalarFieldArray &)
 Constrain search directions to the space of free directions for minimize.
 
virtual double safeStepSize (const ScalarFieldArray &dir) const
 Override to return maximum safe step size along a given direction. Steps can be arbitrarily large by default.
 
double minimize (const MinimizeParams &params)
 Minimize this objective function with algorithm controlled by params and return the minimized value.
 
void fdTest (const MinimizeParams &params)
 

Public Attributes

const GridInfogInfo
 
const double T
 Temperature.
 
bool verboseLog
 print energy components etc. if enabled (off by default)
 
vector3 Eexternal
 External uniform electric field.
 
ScalarFieldArray state
 
ScalarFieldTilde rhoExternal
 
bool useMFKernel
 
double Qtol
 If true, use the mean field kernel for external coulomb interactions as well. More...
 

Friends

struct FluidComponent
 
class Fmix
 
struct BoilingPressureSolver
 

Detailed Description

Mixture of fluids that provides the total free energy functional for minimization Constructing Fex and IdealGas objects require a FluidMixture reference, to which they add themselves. The FluidMixture object is ready to use after initialize() is called.

Member Function Documentation

◆ getBoilingPressure()

double FluidMixture::getBoilingPressure ( double  NliqGuess,
double  NvapGuess,
std::vector< double > *  Nvap = 0 
) const

Compute the boiling pressure (vapor-liquid equilbirum) at current temperature, given guesses for the total liquid and vapor densities, and optionally retrieve equilibrium vapor densities

◆ getFreeEnergy()

double FluidMixture::getFreeEnergy ( Outputs  outputs = Outputs()) const

Get the free energy, densities and moments for the current state.

Parameters
[out]outputsoptional outputs, see Outputs
Returns
Free energy at current state

◆ initialize()

void FluidMixture::initialize ( double  P = 1.01325 *Bar,
double  epsBulkOverride = 0.,
double  epsInfOverride = 0. 
)

Call after initializing and adding all the components of the fluid mixture This calculates the bulk equilibrium densities for all components and corresponding chemical potentials so as to achieve pressure P with the specified mole fractions. The initial guess for the densities is taken from FluidComponent::Nbulk, and this may be altered to select a particular phase The dielectric constants for mixtures is estimated as a weighted combination of the components, and may be overriden by non-zero overrides

◆ initState()

void FluidMixture::initState ( double  scale = 0.0,
double  Elo = -DBL_MAX,
double  Ehi = +DBL_MAX 
)

Initialize the independent variables

Parameters
scalescale the state that would produce the equilibrium ideal gas densities by this amount to ge tthe guess
EloLower cap on the individiual molecule energy configurations used in the estimate
EhiUpper cap on the individiual molecule energy configurations used in the estimate

◆ operator()()

double FluidMixture::operator() ( const ScalarFieldArray indep,
ScalarFieldArray Phi_indep,
Outputs  outputs = Outputs() 
) const

Free energy and gradient evaluation.

Parameters
[in]indepCurrent value of the independent variables
[out]Phi_indepGradient w.r.t indep at the current value of indep
[out]outputsoptional outputs, see Outputs
Returns
Free energy difference (compared to uniform fluid) at this value of indep Implemented in FluidMixtureCompute.cpp

Member Data Documentation

◆ Qtol

double FluidMixture::Qtol

If true, use the mean field kernel for external coulomb interactions as well.

tolerance for unit cell neutrality (default 1e-12)

◆ rhoExternal

ScalarFieldTilde FluidMixture::rhoExternal

External charge density. The interaction energy between internal charges and rhoExternal is included in getFreeEnergy() etc. When charged components are present, the unit cell will be neutral including this charge.


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