Commit 70c786ae authored by mischa's avatar mischa
Browse files

Comments for visualisation

parent 837c2ee9
......@@ -2,9 +2,11 @@
Python module that allows you to calculate the weights and velocities of
a stencil for a given order of isotropy, dimension and a list of velocities
you want to include.
Code is based on the work and partially copied from
Code is based on the work and partially taken from
https://github.com/BDuenweg/Lattice-Boltzmann-weights
Usage with Python3.6 recommended.
## Installation
$ git clone this repository
......@@ -12,14 +14,21 @@ https://github.com/BDuenweg/Lattice-Boltzmann-weights
$ source env/bin/activate
$ pip install ./lbmweights
Assignmentlist not yet implemented !
## Optional Requirements for Code generation
AssignmentCollection for the implementation of the Lattice-Boltzmann method:
$ pip install pystencils
MRT Moments (Repository not public yet)
pip install pystencils
## Usage:
Get lattices by their established name:
``` Python
from lbmweights import Lattice
Lattice().from_name("D2V37").weights
Lattice.from_name("D2V37").weights
```
Or by their dimension, order and shell list:
......
......@@ -10,6 +10,9 @@ import numpy as np
from numpy.linalg import svd
x, y, z = MOMENT_SYMBOLS
"""Simple script that shows how the weights can be retrieved from the Maxwell-Moltzmann distribution
See function get_moments for the derivation."""
def get_duplicate_moment(selected_moments, velocities):
duplicate = []
......@@ -49,7 +52,7 @@ def get_weights(selected_moments, c_s_sq, velocities, order):
def get_moments(lattice):
lattice = Lattice.from_name("D2V17")
"""Retrieve weights from velocity moments"""
if lattice.q == 17:
d2v17 = lattice.velocities
......@@ -123,11 +126,15 @@ def get_moments(lattice):
return selected_moments
lattice = Lattice.from_name("D2V17")
lattice = Lattice.from_name("D2V37")
moments = get_moments(lattice)
pprint(moments)
M = sp.Matrix(get_moments_of_continuous_maxwellian_equilibrium(moments=moments, dim=2, order=4, c_s_sq=lattice.c_s_sq))
"""
M = sp.Matrix(get_moments_of_continuous_maxwellian_equilibrium(moments=moments, dim=2, order=3, c_s_sq=lattice.c_s_sq))
m = make_matrix(moments, lattice.velocities)
pprint(m.inv() * M)
......@@ -135,17 +142,12 @@ tau = 0.55
lb_method = create_with_continuous_maxwellian_eq_moments(stencil=lattice.velocities,
moment_to_relaxation_rate_dict={m: 1/tau for m in moments},
compressible=True,
equilibrium_order=None,
equilibrium_order=3,
c_s_sq=lattice.c_s_sq,
)
def l2norm(approximation, solution):
"""
Calculating the l2norm of two matrices.
The matrices have to have the same shape
:return Value that indicates how close mat2 i
"""
assert (
approximation.shape == solution.shape
), "The shape of the matrices have to be the same"
......@@ -185,6 +187,7 @@ def taylor_green(data_shape, t, tau, c_s_sq, test=False):
rho = (p_0 - roh_avg * u_0 ** 2 / 4 * (np.cos(2 * kx * X) + np.cos(2 * ky * Y)) * np.exp(-2*t/t_d))/c_s_sq
return rho, u_x, u_y
def get_error(sc):
rho_analytical, ux_analytical, uy_analytical = taylor_green(sc.domain_size, sc.time_steps_run, tau, 1/3)
uy_analytical = - uy_analytical
......@@ -216,4 +219,4 @@ for x in range(1000):
plt.plot(time, errors)
plt.show()
"""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment