summaryrefslogtreecommitdiff
path: root/src/dynamics/entropicDynamics.h
blob: ba67ea12c8482b2429013c61d4705fb331b14686 (plain)
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
/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2006, 2007, 2017 Orestis Malaspinas, Jonas Latt, Mathias J. Krause
 *  E-mail contact: info@openlb.net
 *  The most recent release of OpenLB can be downloaded at
 *  <http://www.openlb.net/>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public
 *  License along with this program; if not, write to the Free
 *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA  02110-1301, USA.
*/

/** \file
 * A collection of entropic dynamics classes (e.g. EntropicEq,
 * ForcedEntropicEq, Entropic, ForcedEntropic) with which a Cell object
 * can be instantiated -- header file.
 *
 * Entropic Modell:
 * Ansumali, Santosh, Iliya V. Karlin, and Hans Christian Öttinger
 * Minimal entropic kinetic models for hydrodynamics
 * EPL (Europhysics Letters) 63.6 (2003): 798
 */

#ifndef ENTROPIC_LB_DYNAMICS_H
#define ENTROPIC_LB_DYNAMICS_H

#include "dynamics/dynamics.h"

namespace olb {

template<typename T, typename DESCRIPTOR> class Cell;


/// Implementation of the entropic collision step
template<typename T, typename DESCRIPTOR>
class EntropicEqDynamics : public BasicDynamics<T,DESCRIPTOR> {
public:
  /// Constructor
  EntropicEqDynamics(T omega_, Momenta<T,DESCRIPTOR>& momenta_);
  /// Compute equilibrium distribution function
  T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d], T uSqr) const override;
  /// Collision step
  void collide(Cell<T,DESCRIPTOR>& cell,
                       LatticeStatistics<T>& statistics_) override;
  /// Get local relaxation parameter of the dynamics
  T getOmega() const override;
  /// Set local relaxation parameter of the dynamics
  void setOmega(T omega_) override;
private:
  T omega;  ///< relaxation parameter
};

/// Implementation of the forced entropic collision step
template<typename T, typename DESCRIPTOR>
class ForcedEntropicEqDynamics : public BasicDynamics<T,DESCRIPTOR> {
public:
  /// Constructor
  ForcedEntropicEqDynamics(T omega_, Momenta<T,DESCRIPTOR>& momenta_);
  /// Compute equilibrium distribution function
  virtual T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d], T uSqr) const;
  /// Collision step
  virtual void collide(Cell<T,DESCRIPTOR>& cell,
                       LatticeStatistics<T>& statistics_);
  /// Get local relaxation parameter of the dynamics
  virtual T getOmega() const;
  /// Set local relaxation parameter of the dynamics
  virtual void setOmega(T omega_);
private:
  T omega;  ///< relaxation parameter
};

/// Implementation of the entropic collision step

template<typename T, typename DESCRIPTOR>
class EntropicDynamics : public BasicDynamics<T,DESCRIPTOR> {
public:
  /// Constructor
  EntropicDynamics(T omega_, Momenta<T,DESCRIPTOR>& momenta_);
  /// Compute equilibrium distribution function
  T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d], T uSqr) const override;
  /// Collision step
  void collide(Cell<T,DESCRIPTOR>& cell,
                       LatticeStatistics<T>& statistics_) override;
  /// Get local relaxation parameter of the dynamics
  T getOmega() const override;
  /// Set local relaxation parameter of the dynamics
  void setOmega(T omega_) override;
private:
  /// computes the entropy function H(f)=sum_i f_i*ln(f_i/t_i)
  T computeEntropy(const T f[]);
  /// computes the entropy growth H(f)-H(f-alpha*fNeq)
  T computeEntropyGrowth(const T f[], const T fNeq[], const T &alpha);
  /// computes the entropy growth derivative
  /// dH/dalpha=-sum_i fNeq_i*ln((f_i-alpha*fNeq_i)/t_i)
  T computeEntropyGrowthDerivative(const T f[], const T fNeq[], const T &alpha);
  /// Get the alpha parameter
  bool getAlpha(T &alpha, const T f[], const T fNeq[]);

  T omega;  ///< relaxation parameter
};

/// Implementation of the forced entropic collision step
template<typename T, typename DESCRIPTOR>
class ForcedEntropicDynamics : public BasicDynamics<T,DESCRIPTOR> {
public:
  /// Constructor
  ForcedEntropicDynamics(T omega_, Momenta<T,DESCRIPTOR>& momenta_);
  /// Compute equilibrium distribution function
  virtual T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d], T uSqr) const;
  /// Collision step
  virtual void collide(Cell<T,DESCRIPTOR>& cell,
                       LatticeStatistics<T>& statistics_);
  /// Get local relaxation parameter of the dynamics
  virtual T getOmega() const;
  /// Set local relaxation parameter of the dynamics
  virtual void setOmega(T omega_);
private:
  /// computes the entropy function H(f)=sum_i f_i*ln(f_i/t_i)
  T computeEntropy(const T f[]);
  /// computes the entropy growth H(f)-H(f-alpha*fNeq)
  T computeEntropyGrowth(const T f[], const T fNeq[], const T &alpha);
  /// computes the entropy growth derivative
  /// dH/dalpha=-sum_i fNeq_i*ln((f_i-alpha*fNeq_i)/t_i)
  T computeEntropyGrowthDerivative(const T f[], const T fNeq[], const T &alpha);
  /// Get the alpha parameter
  bool getAlpha(T &alpha, const T f[], const T fNeq[]);

  T omega;  ///< relaxation parameter
};
}

#endif