XLB lattice
Bases: object
This class represents a lattice in the Lattice Boltzmann Method.
It stores the properties of the lattice, including the dimensions, the number of velocities, the velocity vectors, the weights, the moments, and the indices of the opposite, main, right, and left velocities.
The class also provides methods to construct these properties based on the name of the lattice.
Parameters
name: str The name of the lattice, which specifies the dimensions and the number of velocities. For example, “D2Q9” represents a 2D lattice with 9 velocities. precision: str, optional The precision of the computations. It can be “f32/f32”, “f32/f16”, “f64/f64”, “f64/f32”, or “f64/f16”. The first part before the slash is the precision of the computations, and the second part after the slash is the precision of the outputs.
Source code in src/lattice.py
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 |
|
construct_lattice_moment
This function constructs the moments of the lattice.
The moments are the products of the velocity vectors, which are used in the computation of the equilibrium distribution functions and the collision operator in the Lattice Boltzmann Method (LBM).
Returns
cc: numpy.ndarray The moments of the lattice.
Source code in src/lattice.py
construct_lattice_velocity
This function constructs the velocity vectors of the lattice.
The velocity vectors are defined based on the name of the lattice. For example, for a D2Q9 lattice, there are 9 velocities: (0,0), (1,0), (-1,0), (0,1), (0,-1), (1,1), (-1,-1), (1,-1), and (-1,1).
Returns
c.T: numpy.ndarray The velocity vectors of the lattice.
Source code in src/lattice.py
construct_lattice_weight
This function constructs the weights of the lattice.
The weights are defined based on the name of the lattice. For example, for a D2Q9 lattice, the weights are 4/9 for the rest velocity, 1/9 for the main velocities, and 1/36 for the diagonal velocities.
Returns
w: numpy.ndarray The weights of the lattice.
Source code in src/lattice.py
construct_left_indices
This function constructs the indices of the velocities that point in the negative x-direction.
Returns
numpy.ndarray The indices of the left velocities.
Source code in src/lattice.py
construct_main_indices
This function constructs the indices of the main velocities.
The main velocities are the velocities that have a magnitude of 1 in lattice units.
Returns
numpy.ndarray The indices of the main velocities.
Source code in src/lattice.py
construct_opposite_indices
This function constructs the indices of the opposite velocities for each velocity.
The opposite velocity of a velocity is the velocity that has the same magnitude but the opposite direction.
Returns
opposite: numpy.ndarray The indices of the opposite velocities.
Source code in src/lattice.py
construct_right_indices
This function constructs the indices of the velocities that point in the positive x-direction.
Returns
numpy.ndarray The indices of the right velocities.
Source code in src/lattice.py
Bases: Lattice
Lattice class for 2D D2Q9 lattice.
D2Q9 stands for two-dimensional nine-velocity model. It is a common model used in the Lat tice Boltzmann Method for simulating fluid flows in two dimensions.
Parameters
precision: str, optional The precision of the lattice. The default is “f32/f32”
Source code in src/lattice.py
Bases: Lattice
Lattice class for 3D D3Q19 lattice.
D3Q19 stands for three-dimensional nineteen-velocity model. It is a common model used in the Lattice Boltzmann Method for simulating fluid flows in three dimensions.
Parameters
precision: str, optional The precision of the lattice. The default is “f32/f32”
Source code in src/lattice.py
Bases: Lattice
Lattice class for 3D D3Q27 lattice.
D3Q27 stands for three-dimensional twenty-seven-velocity model. It is a common model used in the Lattice Boltzmann Method for simulating fluid flows in three dimensions.
Parameters
precision: str, optional The precision of the lattice. The default is “f32/f32”