8#ifndef EXCLUDEVOLUMEMODELSMULTI_H
9#define EXCLUDEVOLUMEMODELSMULTI_H
47 virtual double f(
int i)
const {
return 1.; }
56 virtual double df(
int i,
int j)
const {
return 0.; }
66 virtual double d2f(
int i,
int j,
int k)
const {
return 0.; }
77 virtual double d3f(
int i,
int j,
int k,
int l)
const {
return 0.; }
89 virtual double d4f(
int i,
int j,
int k,
int l,
int m)
const {
return 0.; }
97 virtual double dfdT(
int i)
const {
return 0.; }
105 virtual std::vector<double>
nsol(
const std::vector<double>& ntil) {
return ntil; }
113 virtual std::vector<double>
nsolBroyden(
const std::vector<double>& ntil);
179 m_componentsMode(componentsMode)
182 if (m_componentsMode)
192 std::vector<double>
Equations(
const std::vector<double>& x);
195 const std::vector<double>* m_ntil;
196 bool m_componentsMode;
210 const std::vector<double>* ntil,
211 bool componentsMode =
false) :
215 m_componentsMode(componentsMode)
225 std::vector<double>
Jacobian(
const std::vector<double>& x);
228 const std::vector<double>* m_ntil;
229 bool m_componentsMode;
251 m_dbdT = std::vector<double>(
m_b.size(), 0.);
260 virtual double f(
int i)
const;
268 virtual double df(
int i,
int j)
const;
277 virtual double d2f(
int i,
int j,
int k)
const {
return 0.; }
287 virtual double d3f(
int i,
int j,
int k,
int l)
const {
return 0.; }
298 virtual double d4f(
int i,
int j,
int k,
int l,
int m)
const {
return 0.; }
305 virtual double dfdT(
int i)
const;
312 virtual std::vector<double>
nsol(
const std::vector<double>& nid);
339 const std::vector<double>& b,
340 const std::vector<double>& dbdT = std::vector<double>())
343 m_dbdT = std::vector<double>(
m_b.size(), 0.);
356 virtual double f(
int i)
const;
364 virtual double df(
int i,
int j)
const;
373 virtual double d2f(
int i,
int j,
int k)
const;
383 virtual double d3f(
int i,
int j,
int k,
int l)
const;
394 virtual double d4f(
int i,
int j,
int k,
int l,
int m)
const;
401 virtual double dfdT(
int i)
const;
408 virtual std::vector<double>
nsol(
const std::vector<double>& nid);
414 virtual void SetDensities(
const std::vector<double>& n);
426 double GetEta(
const std::vector<double>& n)
const;
452 m_dbdT = std::vector< std::vector<double> >(
m_b.size(), std::vector<double>(
m_b.size(), 0.));
461 virtual double f(
int i)
const;
469 virtual double df(
int i,
int j)
const;
478 virtual double d2f(
int i,
int j,
int k)
const {
return 0.; }
488 virtual double d3f(
int i,
int j,
int k,
int l)
const {
return 0.; }
499 virtual double d4f(
int i,
int j,
int k,
int l,
int m)
const {
return 0.; }
506 virtual double dfdT(
int i)
const;
513 virtual std::vector<double>
nsol(
const std::vector<double>& nid);
519 std::vector< std::vector<double> >
m_b;
520 std::vector< std::vector<double> >
m_dbdT;
543 const std::vector< std::vector<double> >& b,
544 const std::vector< std::vector<double> >& dbdT = std::vector< std::vector<double> >()
548 m_dbdT = std::vector< std::vector<double> >(
m_b.size(), std::vector<double>(
m_b.size(), 0.));
562 virtual double f(
int i)
const;
570 virtual double df(
int i,
int j)
const;
579 virtual double d2f(
int i,
int j,
int k)
const;
589 virtual double d3f(
int i,
int j,
int k,
int l)
const;
600 virtual double d4f(
int i,
int j,
int k,
int l,
int m)
const;
607 virtual double dfdT(
int i)
const;
614 virtual std::vector<double>
nsol(
const std::vector<double>& nid);
620 virtual void SetDensities(
const std::vector<double>& n);
633 double GetEta(
int i,
const std::vector<double>& n)
const;
635 std::vector< std::vector<double> >
m_b;
636 std::vector< std::vector<double> >
m_dbdT;
661 const std::vector<ExcludedVolumeModelBase*>& evmods,
662 const std::vector<int>& ind,
663 const std::vector<double>& b,
664 const std::vector<double>& dbdT = std::vector<double>()
690 virtual double f(
int i)
const;
698 virtual double df(
int i,
int j)
const;
707 virtual double d2f(
int i,
int j,
int k)
const;
717 virtual double d3f(
int i,
int j,
int k,
int l)
const;
728 virtual double d4f(
int i,
int j,
int k,
int l,
int m)
const;
735 virtual double dfdT(
int i)
const;
742 virtual std::vector<double>
nsol(
const std::vector<double>& nid);
748 virtual void SetDensities(
const std::vector<double>& n);
Implementation of the generic Broyden's method routines.
int m_N
The number of equations.
BroydenEquations()=default
Default constructor. Does nothing.
BroydenJacobian(BroydenEquations *eqs=NULL)
Construct a new BroydenJacobian object.
Base class implementing the ideal gas.
virtual ~ExcludedVolumeModelComponents()
Destructor for the ExcludedVolumeModelComponents class.
virtual double d2f(int i, int j, int k) const
Calculates the second derivative of the suppression factor.
virtual double d4f(int i, int j, int k, int l, int m) const
Calculates the fourth derivative of the suppression factor.
virtual double d3f(int i, int j, int k, int l) const
Calculates the third derivative of the suppression factor.
virtual void SetDensities(const std::vector< double > &n)
Sets the densities of particle species.
virtual void ComputeComponents()
Computes the components based on the excluded volume parameters.
virtual double dfdT(int i) const
Calculates the temperature derivative of the suppression factor.
ExcludedVolumeModelComponents(int components, const std::vector< ExcludedVolumeModelBase * > &evmods, const std::vector< int > &ind, const std::vector< double > &b, const std::vector< double > &dbdT=std::vector< double >())
Constructor for the ExcludedVolumeModelComponents class.
std::vector< double > m_b
virtual std::vector< double > nsol(const std::vector< double > &nid)
Solves for the actual densities given the ideal gas densities.
virtual double f(int i) const
Calculates the suppression factor for species i.
std::vector< ExcludedVolumeModelBase * > m_evmodels
std::vector< double > m_densities_components
std::vector< double > m_dbdT
virtual double df(int i, int j) const
Calculates the first derivative of the suppression factor.
ExcludedVolumeModelBase * m_evmodelsingle
ExcludedVolumeModelCrosstermsGeneralized(ExcludedVolumeModelBase *evmodelsingle, const std::vector< std::vector< double > > &b, const std::vector< std::vector< double > > &dbdT=std::vector< std::vector< double > >())
Constructor for the ExcludedVolumeModelCrosstermsGeneralized class.
std::vector< std::vector< double > > m_dbdT
bool m_componentsDisconnected
virtual double d3f(int i, int j, int k, int l) const
Calculates the third derivative of the suppression factor.
virtual double d2f(int i, int j, int k) const
Calculates the second derivative of the suppression factor.
virtual void SetDensities(const std::vector< double > &n)
Sets the densities of particle species.
virtual std::vector< double > nsol(const std::vector< double > &nid)
Solves for the actual densities given the ideal gas densities.
virtual double dfdT(int i) const
Calculates the temperature derivative of the suppression factor.
double GetEta(int i, const std::vector< double > &n) const
Calculates the eta parameter for the given densities and species index.
virtual double df(int i, int j) const
Calculates the first derivative of the suppression factor.
virtual double d4f(int i, int j, int k, int l, int m) const
Calculates the fourth derivative of the suppression factor.
std::vector< std::vector< double > > m_b
virtual void ComputeComponents()
Computes the components based on the excluded volume parameters.
std::vector< double > m_etas
virtual double f(int i) const
Calculates the suppression factor for species i.
virtual ~ExcludedVolumeModelCrosstermsGeneralized()
Destructor for the ExcludedVolumeModelCrosstermsGeneralized class.
virtual double d2f(int i, int j, int k) const
Calculates the second derivative of the suppression factor.
virtual double d4f(int i, int j, int k, int l, int m) const
Calculates the fourth derivative of the suppression factor.
std::vector< std::vector< double > > m_b
virtual double df(int i, int j) const
Calculates the first derivative of the suppression factor.
virtual void ComputeComponents()
Computes the components based on the excluded volume parameters.
ExcludedVolumeModelCrosstermsVDW(const std::vector< std::vector< double > > &b, const std::vector< std::vector< double > > &dbdT=std::vector< std::vector< double > >())
Constructor for the ExcludedVolumeModelCrosstermsVDW class.
virtual double d3f(int i, int j, int k, int l) const
Calculates the third derivative of the suppression factor.
virtual std::vector< double > nsol(const std::vector< double > &nid)
Solves for the actual densities given the ideal gas densities.
std::vector< std::vector< double > > m_dbdT
virtual double dfdT(int i) const
Calculates the temperature derivative of the suppression factor.
virtual double f(int i) const
Calculates the suppression factor for species i.
virtual ~ExcludedVolumeModelDiagonalGeneralized()
Destructor for the ExcludedVolumeModelDiagonalGeneralized class.
ExcludedVolumeModelBase * m_evmodelsingle
virtual double f(int i) const
Calculates the suppression factor for species i.
ExcludedVolumeModelDiagonalGeneralized(ExcludedVolumeModelBase *evmodelsingle, const std::vector< double > &b, const std::vector< double > &dbdT=std::vector< double >())
Constructor for the ExcludedVolumeModelDiagonalGeneralized class.
virtual double df(int i, int j) const
Calculates the first derivative of the suppression factor.
virtual double d2f(int i, int j, int k) const
Calculates the second derivative of the suppression factor.
double GetEta(const std::vector< double > &n) const
Calculates the eta parameter for the given densities.
virtual double dfdT(int i) const
Calculates the temperature derivative of the suppression factor.
std::vector< double > m_dbdT
virtual void ComputeComponents()
Computes the components based on the excluded volume parameters.
std::vector< double > m_b
virtual std::vector< double > nsol(const std::vector< double > &nid)
Solves for the actual densities given the ideal gas densities.
virtual double d3f(int i, int j, int k, int l) const
Calculates the third derivative of the suppression factor.
virtual double d4f(int i, int j, int k, int l, int m) const
Calculates the fourth derivative of the suppression factor.
virtual void SetDensities(const std::vector< double > &n)
Sets the densities of particle species.
std::vector< double > m_dbdT
virtual double d4f(int i, int j, int k, int l, int m) const
Calculates the fourth derivative of the suppression factor.
virtual double d3f(int i, int j, int k, int l) const
Calculates the third derivative of the suppression factor.
std::vector< double > m_b
ExcludedVolumeModelDiagonalVDW(const std::vector< double > &b, const std::vector< double > &dbdT=std::vector< double >())
Constructor for the ExcludedVolumeModelDiagonalVDW class.
virtual void ComputeComponents()
Computes the components based on the excluded volume parameters.
virtual double f(int i) const
Calculates the suppression factor for species i.
virtual double d2f(int i, int j, int k) const
Calculates the second derivative of the suppression factor.
virtual double df(int i, int j) const
Calculates the first derivative of the suppression factor.
virtual double dfdT(int i) const
Calculates the temperature derivative of the suppression factor.
virtual std::vector< double > nsol(const std::vector< double > &nid)
Solves for the actual densities given the ideal gas densities.
std::vector< double > Equations(const std::vector< double > &x)
Calculates the equations for Broyden's method.
BroydenEquationsEVMulti(ExcludedVolumeModelMultiBase *evmodel, const std::vector< double > *ntil, bool componentsMode=false)
Constructor for the BroydenEquationsEVMulti class.
BroydenJacobianEVMulti(ExcludedVolumeModelMultiBase *evmodel, const std::vector< double > *ntil, bool componentsMode=false)
Constructor for the BroydenJacobianEVMulti class.
std::vector< double > Jacobian(const std::vector< double > &x)
Calculates the Jacobian matrix for Broyden's method.
virtual double f(int i) const
Calculates the suppression factor for species i.
std::vector< int > m_componentsFrom
virtual std::vector< double > nsolBroydenComponents(const std::vector< double > &ntil)
Solves for the actual densities using Broyden's method, considering components.
std::vector< double > m_densities
std::vector< double > m_previousSolComponents
Cached previous Broyden solution (per component) for use as initial guess.
std::vector< int > m_components
virtual const int ComponentsNumber() const
Gets the number of components.
virtual const std::vector< int > & ComponentIndices() const
Gets the component indices.
virtual void ComputeComponents()
Computes the components based on the excluded volume parameters.
virtual double dfdT(int i) const
Calculates the temperature derivative of the suppression factor.
virtual double d4f(int i, int j, int k, int l, int m) const
Calculates the fourth derivative of the suppression factor.
bool m_hasPreviousSolComponents
virtual double d3f(int i, int j, int k, int l) const
Calculates the third derivative of the suppression factor.
virtual double df(int i, int j) const
Calculates the first derivative of the suppression factor.
virtual const std::vector< int > & ComponentIndicesFrom() const
Gets the component indices from.
ExcludedVolumeModelMultiBase(int N)
Constructor for the ExcludedVolumeModelMultiBase class.
virtual ~ExcludedVolumeModelMultiBase()
virtual void SetDensities(const std::vector< double > &n)
Sets the densities of particle species.
virtual std::vector< double > nsolBroyden(const std::vector< double > &ntil)
Solves for the actual densities using Broyden's method.
virtual double d2f(int i, int j, int k) const
Calculates the second derivative of the suppression factor.
virtual std::vector< double > nsol(const std::vector< double > &ntil)
Solves for the actual densities given the ideal gas densities.
The main namespace where all classes and functions of the Thermal-FIST library reside.