Thermal-FIST 1.6.1
Package for hadron resonance gas model applications
Loading...
Searching...
No Matches
ExcludedVolumeModelsMulti.h
Go to the documentation of this file.
1/*
2 * Thermal-FIST package
3 *
4 * Copyright (c) 2017-2022 Volodymyr Vovchenko
5 *
6 * GNU General Public License (GPLv3 or later)
7 */
8#ifndef EXCLUDEVOLUMEMODELSMULTI_H
9#define EXCLUDEVOLUMEMODELSMULTI_H
10#include <cmath>
11#include <vector>
12
14#include "HRGBase/Broyden.h"
15
16namespace thermalfist {
17
26 public:
33 m_N(N),
34 m_densities(std::vector<double>(m_N,0.)),
35 m_components(std::vector<int>(m_N, 0))
36 {
38 }
40
47 virtual double f(int i) const { return 1.; }
48
56 virtual double df(int i, int j) const { return 0.; }
57
66 virtual double d2f(int i, int j, int k) const { return 0.; }
67
77 virtual double d3f(int i, int j, int k, int l) const { return 0.; }
78
89 virtual double d4f(int i, int j, int k, int l, int m) const { return 0.; }
90
97 virtual double dfdT(int i) const { return 0.; }
98
105 virtual std::vector<double> nsol(const std::vector<double>& ntil) { return ntil; }
106
113 virtual std::vector<double> nsolBroyden(const std::vector<double>& ntil);
114
121 virtual std::vector<double> nsolBroydenComponents(const std::vector<double>& ntil);
122
128 virtual void SetDensities(const std::vector<double>& n) { m_densities = n; }
129
135 virtual const std::vector<int>& ComponentIndices() const { return m_components; }
136
142 virtual const std::vector<int>& ComponentIndicesFrom() const { return m_componentsFrom; }
143
149 virtual const int ComponentsNumber() const { return m_componentsNumber; }
150 protected:
154 virtual void ComputeComponents();
155 int m_N;
156 std::vector<double> m_densities;
157 std::vector<int> m_components;
158 std::vector<int> m_componentsFrom;
160
162 std::vector<double> m_previousSolComponents;
164
166 {
167 public:
175 BroydenEquationsEVMulti(ExcludedVolumeModelMultiBase* evmodel, const std::vector<double>* ntil, bool componentsMode = false) :
177 m_EVM(evmodel),
178 m_ntil(ntil),
179 m_componentsMode(componentsMode)
180 {
181 m_N = evmodel->m_N;
182 if (m_componentsMode)
183 m_N = evmodel->m_componentsNumber;
184 }
185
192 std::vector<double> Equations(const std::vector<double>& x);
193 private:
195 const std::vector<double>* m_ntil;
196 bool m_componentsMode;
197 };
198
200 {
201 public:
210 const std::vector<double>* ntil,
211 bool componentsMode = false) :
213 m_EVM(evmodel),
214 m_ntil(ntil),
215 m_componentsMode(componentsMode)
216 {
217 }
218
225 std::vector<double> Jacobian(const std::vector<double>& x);
226 private:
228 const std::vector<double>* m_ntil;
229 bool m_componentsMode;
230 };
231
232
233 };
234
241 public:
248 ExcludedVolumeModelDiagonalVDW(const std::vector<double>& b, const std::vector<double>& dbdT = std::vector<double>())
249 : ExcludedVolumeModelMultiBase(b.size()), m_b(b), m_dbdT(dbdT) {
250 if (m_dbdT.size() == 0)
251 m_dbdT = std::vector<double>(m_b.size(), 0.);
253 }
254
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);
313 protected:
317 virtual void ComputeComponents();
318 std::vector<double> m_b;
319 std::vector<double> m_dbdT;
320 };
321
329 public:
338 ExcludedVolumeModelBase *evmodelsingle,
339 const std::vector<double>& b,
340 const std::vector<double>& dbdT = std::vector<double>())
341 : ExcludedVolumeModelMultiBase(b.size()), m_evmodelsingle(evmodelsingle), m_b(b), m_dbdT(dbdT), m_eta(0.) {
342 if (m_dbdT.size() == 0)
343 m_dbdT = std::vector<double>(m_b.size(), 0.);
345 }
346
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);
415 protected:
419 virtual void ComputeComponents();
426 double GetEta(const std::vector<double>& n) const;
428 std::vector<double> m_b;
429 std::vector<double> m_dbdT;
430 double m_eta;
431 };
432
433
442 public:
449 ExcludedVolumeModelCrosstermsVDW(const std::vector< std::vector<double> >& b, const std::vector< std::vector<double> >& dbdT = std::vector< std::vector<double> >())
450 : ExcludedVolumeModelMultiBase(b.size()), m_b(b), m_dbdT(dbdT) {
451 if (m_dbdT.size() == 0)
452 m_dbdT = std::vector< std::vector<double> >(m_b.size(), std::vector<double>(m_b.size(), 0.));
454 }
455
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);
514 protected:
518 virtual void ComputeComponents();
519 std::vector< std::vector<double> > m_b;
520 std::vector< std::vector<double> > m_dbdT;
521 };
522
533 public:
542 ExcludedVolumeModelBase* evmodelsingle,
543 const std::vector< std::vector<double> >& b,
544 const std::vector< std::vector<double> >& dbdT = std::vector< std::vector<double> >()
545 )
546 : ExcludedVolumeModelMultiBase(b.size()), m_evmodelsingle(evmodelsingle), m_b(b), m_dbdT(dbdT), m_componentsDisconnected(false) {
547 if (m_dbdT.size() == 0)
548 m_dbdT = std::vector< std::vector<double> >(m_b.size(), std::vector<double>(m_b.size(), 0.));
550 m_etas = std::vector<double>(m_componentsNumber, 0.);
551 }
552
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);
621 protected:
625 virtual void ComputeComponents();
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;
637 std::vector<double> m_etas;
639 };
640
649 public:
660 int components,
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>()
665 )
666 : ExcludedVolumeModelMultiBase(ind.size()),
667 //m_N_components(components),
668 m_evmodels(evmods),
669 //m_indices(ind),
670 m_b(b),
671 m_dbdT(dbdT),
672 m_densities_components(std::vector<double>(b.size(), 0.))
673 {
674 if (m_dbdT.size() == 0)
675 m_dbdT.resize(m_b.size(), 0.);
676 m_components = ind;
677 m_componentsNumber = components;
679 }
680
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);
749 protected:
753 virtual void ComputeComponents();
754 //int m_N_components;
755 std::vector<ExcludedVolumeModelBase*> m_evmodels;
756 //std::vector<int> m_indices;
757 std::vector<double> m_b;
758 std::vector<double> m_dbdT;
759 std::vector<double> m_densities_components;
760 };
761
762} // namespace thermalfist
763
764#endif // REALGASMODELS_H
Implementation of the generic Broyden's method routines.
int m_N
The number of equations.
Definition Broyden.h:66
BroydenEquations()=default
Default constructor. Does nothing.
BroydenJacobian(BroydenEquations *eqs=NULL)
Construct a new BroydenJacobian object.
Definition Broyden.h:89
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.
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
virtual double df(int i, int j) const
Calculates the first derivative of the suppression factor.
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.
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.
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 ~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.
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.
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.
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.
virtual void ComputeComponents()
Computes the components based on the excluded volume parameters.
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.
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.
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.
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_previousSolComponents
Cached previous Broyden solution (per component) for use as initial guess.
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.
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 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.
Definition CosmicEoS.h:9