-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathMeanFieldModelsMulti.h
More file actions
438 lines (395 loc) · 12 KB
/
MeanFieldModelsMulti.h
File metadata and controls
438 lines (395 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
/*
* Thermal-FIST package
*
* Copyright (c) 2017-2022 Volodymyr Vovchenko
*
* GNU General Public License (GPLv3 or later)
*/
#ifndef MEANFIELDMODELSMULTI_H
#define MEANFIELDMODELSMULTI_H
#include <cmath>
#include <vector>
#include "MeanFieldModels.h"
namespace thermalfist {
/**
* \brief Base class for multi-component mean field models.
*
* This class serves as the base for all multi-component mean field models,
* providing the interface for calculating the mean field effects in a system
* with multiple particle species. By default, it implements the ideal gas case
* with no mean field.
*/
class MeanFieldModelMultiBase {
public:
/**
* \brief Constructor for the MeanFieldModelMultiBase class.
*
* \param N Number of particle species in the system.
*/
MeanFieldModelMultiBase(int N) : m_N(N) { MeanFieldModelMultiBase::ComputeComponents(); }
/**
* \brief Destructor for the MeanFieldModelMultiBase class.
*/
virtual ~MeanFieldModelMultiBase() { }
/**
* \brief Calculates the mean field value.
*
* \return Mean field value in units of GeV/fm^3.
*/
virtual double v() const { return 0.; }
/**
* \brief Calculates the first derivative of the mean field.
*
* \param i Species index.
* \return First derivative of the mean field.
*/
virtual double dv(int i) const { return 0.; }
/**
* \brief Calculates the second derivative of the mean field.
*
* \param i First species index.
* \param j Second species index.
* \return Second derivative of the mean field.
*/
virtual double d2v(int i, int j) const { return 0.; }
/**
* \brief Calculates the third derivative of the mean field.
*
* \param i First species index.
* \param j Second species index.
* \param k Third species index.
* \return Third derivative of the mean field.
*/
virtual double d3v(int i, int j, int k) const { return 0.; }
/**
* \brief Calculates the fourth derivative of the mean field.
*
* \param i First species index.
* \param j Second species index.
* \param k Third species index.
* \param l Fourth species index.
* \return Fourth derivative of the mean field.
*/
virtual double d4v(int i, int j, int k, int l) const { return 0.; }
/**
* \brief Calculates the temperature derivative of the mean field.
*
* \return Temperature derivative of the mean field.
*/
virtual double dvdT() const { return 0.; }
/**
* \brief Sets the densities of particle species.
*
* \param n Vector of densities.
*/
virtual void SetDensities(const std::vector<double>& n);
/**
* \brief Gets the component indices.
*
* \return Vector of component indices.
*/
virtual const std::vector<int>& ComponentIndices() const { return m_components; }
/**
* \brief Gets the component indices from.
*
* \return Vector of component indices from.
*/
virtual const std::vector<int>& ComponentIndicesFrom() const { return m_componentsFrom; }
/**
* \brief Gets the number of components.
*
* \return Number of components.
*/
virtual const int ComponentsNumber() const { return m_componentsNumber; }
protected:
/**
* \brief Computes the components based on the mean field parameters.
*/
virtual void ComputeComponents();
int m_N;
std::vector<double> m_densities;
std::vector<int> m_components;
std::vector<int> m_componentsFrom;
int m_componentsNumber;
std::vector<double> m_densities_components;
};
/**
* \brief Implementation of the van der Waals mean field model for multiple components.
*
* This class implements the van der Waals mean field model for a system
* with multiple particle species, where interactions between different
* particle species are considered.
*/
class MeanFieldModelMultiVDW :
public MeanFieldModelMultiBase {
public:
/**
* \brief Constructor for the MeanFieldModelMultiVDW class.
*
* \param a Matrix of attraction parameters between species.
* \param dadT Matrix of temperature derivatives of attraction parameters (optional).
*/
MeanFieldModelMultiVDW(
const std::vector< std::vector<double> >& a,
const std::vector< std::vector<double> >& dadT = std::vector< std::vector<double> >()
)
: MeanFieldModelMultiBase(a.size()),
m_a(a),
m_dadT(dadT)
{
if (m_dadT.size() == 0)
m_dadT = std::vector< std::vector<double> >(m_a.size(), std::vector<double>(m_a.size(), 0.));
ComputeComponents();
}
/**
* \brief Destructor for the MeanFieldModelMultiVDW class.
*/
virtual ~MeanFieldModelMultiVDW() { }
/**
* \brief Sets the attraction parameters between species.
*
* \param a Matrix of attraction parameters between species.
*/
void setAij(const std::vector< std::vector<double> >& a) { m_a = a; }
/**
* \brief Sets the temperature derivatives of the attraction parameters.
*
* \param dadT Matrix of temperature derivatives of attraction parameters (optional).
*/
void setdAijdT(const std::vector< std::vector<double> >& dadT) { m_dadT = dadT; }
/**
* \brief Calculates the mean field value.
*
* \return Mean field value in units of GeV/fm^3.
*/
virtual double v() const;
/**
* \brief Calculates the first derivative of the mean field.
*
* \param i Species index.
* \return First derivative of the mean field.
*/
virtual double dv(int i) const;
/**
* \brief Calculates the second derivative of the mean field.
*
* \param i First species index.
* \param j Second species index.
* \return Second derivative of the mean field.
*/
virtual double d2v(int i, int j) const;
/**
* \brief Calculates the third derivative of the mean field.
*
* \param i First species index.
* \param j Second species index.
* \param k Third species index.
* \return Third derivative of the mean field.
*/
virtual double d3v(int i, int j, int k) const { return 0.; }
/**
* \brief Calculates the fourth derivative of the mean field.
*
* \param i First species index.
* \param j Second species index.
* \param k Third species index.
* \param l Fourth species index.
* \return Fourth derivative of the mean field.
*/
virtual double d4v(int i, int j, int k, int l) const { return 0.; }
/**
* \brief Calculates the temperature derivative of the mean field.
*
* \return Temperature derivative of the mean field.
*/
virtual double dvdT() const;
protected:
/**
* \brief Computes the components based on the mean field parameters.
*/
virtual void ComputeComponents();
std::vector< std::vector<double> > m_a;
std::vector< std::vector<double> > m_dadT;
};
/**
* \brief Implementation of a mean field model with components.
*
* This class implements a mean field model where particles are
* grouped into components with similar mean field properties.
*/
class MeanFieldModelComponents :
public MeanFieldModelMultiBase {
public:
/**
* \brief Constructor for the MeanFieldModelComponents class.
*
* \param components Number of components.
* \param mfmods Vector of mean field models for each component.
* \param ind Vector of component indices for each particle species.
*/
MeanFieldModelComponents(
int components,
const std::vector<MeanFieldModelBase*>& mfmods,
const std::vector<int>& ind
)
: MeanFieldModelMultiBase(ind.size()),
m_mfmodels(mfmods)
{
m_components = ind;
m_componentsNumber = components;
ComputeComponents();
}
/**
* \brief Destructor for the MeanFieldModelComponents class.
*/
virtual ~MeanFieldModelComponents();
/**
* \brief Calculates the mean field value.
*
* \return Mean field value in units of GeV/fm^3.
*/
virtual double v() const;
/**
* \brief Calculates the first derivative of the mean field.
*
* \param i Species index.
* \return First derivative of the mean field.
*/
virtual double dv(int i) const;
/**
* \brief Calculates the second derivative of the mean field.
*
* \param i First species index.
* \param j Second species index.
* \return Second derivative of the mean field.
*/
virtual double d2v(int i, int j) const;
/**
* \brief Calculates the third derivative of the mean field.
*
* \param i First species index.
* \param j Second species index.
* \param k Third species index.
* \return Third derivative of the mean field.
*/
virtual double d3v(int i, int j, int k) const;
/**
* \brief Calculates the fourth derivative of the mean field.
*
* \param i First species index.
* \param j Second species index.
* \param k Third species index.
* \param l Fourth species index.
* \return Fourth derivative of the mean field.
*/
virtual double d4v(int i, int j, int k, int l) const;
/**
* \brief Calculates the temperature derivative of the mean field.
*
* \return Temperature derivative of the mean field.
*/
virtual double dvdT() const;
//virtual void SetDensities(const std::vector<double>& n);
protected:
/**
* \brief Computes the components based on the mean field parameters.
*/
virtual void ComputeComponents();
//int m_N_components;
std::vector<MeanFieldModelBase*> m_mfmodels;
//std::vector<int> m_indices;
};
/**
* \brief Implementation of a charge density dependent mean field model.
*
* This class implements a mean field model where the mean field
* depends on the charge density of the system rather than the
* individual particle densities.
*/
class MeanFieldModelChargeDensityDependent :
public MeanFieldModelMultiBase {
public:
/**
* \brief Constructor for the MeanFieldModelChargeDensityDependent class.
*
* \param mfmod Pointer to the mean field model for a single component.
* \param chgs Vector of charge indices for each particle species.
*/
MeanFieldModelChargeDensityDependent(
MeanFieldModelBase* mfmod,
const std::vector<double>& chgs
)
: MeanFieldModelMultiBase(chgs.size()),
m_mfmodel(mfmod),
m_charges(chgs),
m_nB(0.)
{
ComputeComponents();
}
/**
* \brief Destructor for the MeanFieldModelChargeDensityDependent class.
*/
virtual ~MeanFieldModelChargeDensityDependent();
/**
* \brief Calculates the mean field value.
*
* \return Mean field value in units of GeV/fm^3.
*/
virtual double v() const;
/**
* \brief Calculates the first derivative of the mean field.
*
* \param i Species index.
* \return First derivative of the mean field.
*/
virtual double dv(int i) const;
/**
* \brief Calculates the second derivative of the mean field.
*
* \param i First species index.
* \param j Second species index.
* \return Second derivative of the mean field.
*/
virtual double d2v(int i, int j) const;
/**
* \brief Calculates the third derivative of the mean field.
*
* \param i First species index.
* \param j Second species index.
* \param k Third species index.
* \return Third derivative of the mean field.
*/
virtual double d3v(int i, int j, int k) const;
/**
* \brief Calculates the fourth derivative of the mean field.
*
* \param i First species index.
* \param j Second species index.
* \param k Third species index.
* \param l Fourth species index.
* \return Fourth derivative of the mean field.
*/
virtual double d4v(int i, int j, int k, int l) const;
/**
* \brief Calculates the temperature derivative of the mean field.
*
* \return Temperature derivative of the mean field.
*/
virtual double dvdT() const;
/**
* \brief Sets the densities of particle species.
*
* \param n Vector of densities.
*/
virtual void SetDensities(const std::vector<double>& n);
protected:
/**
* \brief Computes the components based on the mean field parameters.
*/
virtual void ComputeComponents();
MeanFieldModelBase* m_mfmodel;
std::vector<double> m_charges;
double m_nB;
};
} // namespace thermalfist
#endif // REALGASMODELS_H