bte.grad.distribution#

Module Contents#

Classes#

distributionBase

The base class for gas distribution.

HermitedistributionBase

HermiteDis

HermiteDis: Gas distribution in Hermite form.

DVDisMeta

Base class for all neural network modules.

DVDisMeta_Grid

Base class for all neural network modules.

DVDis

The gas distribution for discrete velocity method.

DVDis_Chu

The base class for gas distribution.

HermiteDisND

HermiteDis: Gas distribution in Hermite form.

Functions#

d3roll(tensor, idx)

Project_RK4_helper(dis, u0, theta0, u, theta)

Project_RK4_step(dis, u0, theta0, u, theta, h)

Project_RK4(dis, u, theta[, STEP])

Project_RK4 使用R-K4格式对分布函数进行投影

Project_RK4_helperT(dis, u0, theta0, u, theta)

Project_RK4_stepT(dis, u0, theta0, u, theta[, h])

Project_RK4T(dis, u0, theta0, u, theta[, STEP])

eval_hermitenorm(n, x)

eval_hermitenorm_seq(n, x)

uniform_velocity(nv, vmin, vmax)

return a discrete of velocity with uniform partition.

legendre_velocity(nv, vmin, vmax)

return a discrete of velocity with points on legendre-gauss points.

uniform_velocity_2d(nv, vmin, vmax)

legendre_velocity_2d(nv, vmin, vmax)

ND_velocity(func)

velocity_list(func, nvT, vminT, vmaxT)

product_meshgrid(vL, wL)

Attributes#

class bte.grad.distribution.distributionBase[source]#

The base class for gas distribution.

abstract density()[source]#
abstract velocity()[source]#
abstract temperature()[source]#
abstract __add__(anotherDis)[source]#
abstract __radd__(anotherDis)[source]#
abstract __sub__(anotherDis)[source]#
abstract __mul__(multiplier)[source]#
abstract __rmul__(multiplier)[source]#
abstract __truediv__(divider)[source]#
class bte.grad.distribution.HermitedistributionBase[source]#
abstract down()[source]#
abstract new(*args, **kw)[source]#
class bte.grad.distribution.HermiteDis(u, theta, coef)[source]#

Bases: HermitedistributionBase

HermiteDis: Gas distribution in Hermite form.

Parameters:
  • u (bte.utils.indexs.torch.Tensor) –

  • theta (bte.utils.indexs.torch.Tensor) –

  • coef (bte.utils.indexs.torch.Tensor) –

property ORDER[source]#
property rho[source]#
property moments[source]#
property rho_u_theta[source]#
new(u, theta, coef, *args, **kw)[source]#
__str__()[source]#

Return str(self).

Return type:

str

static empty(order, device='cpu')[source]#
Parameters:

order (int) –

Return type:

HermiteDis

from_DVDis(dis, u=None, theta=None)[source]#
Parameters:

dis (DVDis) –

Return type:

HermiteDis

cpu()[source]#
cuda()[source]#
to(args)[source]#
to_tensor()[source]#
density()[source]#
velocity()[source]#
temperature()[source]#
as_tuple()[source]#
__add__(anotherDis)[source]#
__radd__(anotherDis)[source]#
__sub__(anotherDis)[source]#
__mul__(multiplier)[source]#
__rmul__(multiplier)[source]#
__truediv__(divider)[source]#
roll(idx)[source]#
clone()[source]#
mulvec()[source]#
down()[source]#
Project_to_STD(STEP=1)[source]#

Project_to_STD 将分布参数重设,重新投影到最佳参数上

Parameters:

STEP (int) –

Project_2B(dest, STEP=1)[source]#

Project_A2B 将分布投影到dest对应的参数上

Parameters:
Return type:

HermiteDis

bte.grad.distribution.d3roll(tensor, idx)[source]#
bte.grad.distribution.Project_RK4_helper(dis, u0, theta0, u, theta)[source]#
bte.grad.distribution.Project_RK4_step(dis, u0, theta0, u, theta, h)[source]#
Parameters:

h (float) –

bte.grad.distribution.Project_RK4(dis, u, theta, STEP=1)[source]#

Project_RK4 使用R-K4格式对分布函数进行投影

Parameters:
  • dis (torch.Tensor) – 分布函数

  • u (torch.Tensor) – 分布中心

  • theta (torch.Tensor) – 分布宽度

  • STEP (int, optional) – RK方法的步数, by default 1

Returns:

投影后的分布函数

Return type:

torch.Tensor

bte.grad.distribution.Project_RK4_helperT(dis, u0, theta0, u, theta)[source]#
bte.grad.distribution.Project_RK4_stepT(dis, u0, theta0, u, theta, h=1)[source]#
Parameters:

h (float) –

bte.grad.distribution.Project_RK4T(dis, u0, theta0, u, theta, STEP=1)[source]#
Parameters:

STEP (int) –

bte.grad.distribution.eval_hermitenorm(n, x)[source]#
Parameters:
  • n (int) –

  • x (bte.utils.indexs.torch.Tensor) –

bte.grad.distribution.eval_hermitenorm_seq(n, x)[source]#
Parameters:
  • n (int) –

  • x (bte.utils.indexs.torch.Tensor) –

class bte.grad.distribution.DVDisMeta(v, v_w, *args)[source]#

Bases: torch.nn.Module

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables:

training (bool) – Boolean represents whether this module is in training or evaluation mode.

class bte.grad.distribution.DVDisMeta_Grid(vL, v_wL, *args)[source]#

Bases: DVDisMeta

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables:

training (bool) – Boolean represents whether this module is in training or evaluation mode.

Parameters:
  • vL (bte.utils.indexs.List) –

  • v_wL (bte.utils.indexs.List) –

class bte.grad.distribution.DVDis(v_meta, data)[source]#

Bases: distributionBase

The gas distribution for discrete velocity method.

Parameters:

v_meta (DVDisMeta) –

property v[source]#
property v2[source]#
property v3[source]#
property w[source]#
cpu()[source]#
cuda()[source]#
to(args)[source]#
__add__(anotherDis)[source]#
Parameters:

anotherDis (DVDis) –

__radd__(anotherDis)[source]#
Parameters:

anotherDis (DVDis) –

__sub__(anotherDis)[source]#
__mul__(multiplier)[source]#
__rmul__(multiplier)[source]#
__truediv__(divider)[source]#
static empty(nv, vmin, vmax, method='uni', device='cpu')[source]#

An empty new distribution. with velocity grid created by method ‘uni’ or ‘leg’.

Parameters:
  • nv (int) – Numbers of grid

  • vmin (float) – vmin

  • vmax (float) – vmax

  • method (str, optional) – ‘uni’ for uniform_velocity, ‘leg’ for legendre_velocity. Defaults to ‘uni’.

Raises:

ValueError – [description]

Returns:

[description]

Return type:

DVDis

sum(f)[source]#
Parameters:

f (bte.utils.indexs.torch.Tensor) –

density(f=None)[source]#

Compute the macro quantity: density

velocity(f=None)[source]#

Compute the macro quantity: velocity

temperature(f=None)[source]#

Compute the macro quantity: temperature

_m0(f=None)[source]#

0-th order momentum of f

_m1(f=None)[source]#

1st order momentum of f

_m2(f=None)[source]#

2nd order momentum of f

_m3(f=None)[source]#

3nd order momentum of f

heatflux(f=None)[source]#
rho_u_theta(f=None)[source]#
maxwellian(rho_u_theta=None)[source]#
maxwellian_half(rho_u_theta=None, sign=0)[source]#
one_side(f=None, sign=0)[source]#
reverse(f=None)[source]#
from_HermiteDis(dis)[source]#
Parameters:

dis (HermiteDis) –

Return type:

DVDis

bte.grad.distribution.uniform_velocity(nv, vmin, vmax)[source]#

return a discrete of velocity with uniform partition.

v_0=vmin+0.5*(vmax-vmin)/nv v_{nv-1}=vmax-0.5*(vmax-vmin)/nv

Parameters:
  • nv (int) – Numbers of grid

  • vmin (float) – vmin

  • vmax (float) – vmax

Returns:

v, weight of v

Return type:

Tuple[torch.Tensor,torch.Tensor]

bte.grad.distribution.legendre_velocity(nv, vmin, vmax)[source]#

return a discrete of velocity with points on legendre-gauss points.

Parameters:
  • nv (int) – Numbers of grid

  • vmin (float) – vmin

  • vmax (float) – vmax

Returns:

v, weight of v

Return type:

Tuple[torch.Tensor,torch.Tensor]

bte.grad.distribution.uniform_velocity_2d(nv, vmin, vmax)[source]#
bte.grad.distribution.legendre_velocity_2d(nv, vmin, vmax)[source]#
bte.grad.distribution.ND_velocity(func)[source]#
Parameters:

func (Callable[[int, int, int], bte.utils.indexs.Tuple]) –

bte.grad.distribution.uniform_velocity_nd[source]#
bte.grad.distribution.legendre_velocity_nd[source]#
bte.grad.distribution.velocity_list(func, nvT, vminT, vmaxT)[source]#
Parameters:
  • nvT (bte.utils.indexs.Tuple) –

  • vminT (bte.utils.indexs.Tuple) –

  • vmaxT (bte.utils.indexs.Tuple) –

bte.grad.distribution.product_meshgrid(vL, wL)[source]#
Parameters:
  • vL (bte.utils.indexs.List) –

  • wL (bte.utils.indexs.List) –

class bte.grad.distribution.DVDis_Chu(v_meta, data_g, data_h, ndim=3)[source]#

Bases: distributionBase

The base class for gas distribution.

property v[source]#
property v2[source]#
property v3[source]#
property w[source]#
__add__(another)[source]#
__radd__(another)[source]#
__sub__(another)[source]#
__mul__(multiplier)[source]#
__rmul__(multiplier)[source]#
__truediv__(divider)[source]#
density(g=None, h=None)[source]#
velocity(g=None, h=None)[source]#
temperature(g=None, h=None)[source]#
rho_u_theta(g=None, h=None)[source]#
maxwellian(g=None, h=None, rho_u_theta=None)[source]#
class bte.grad.distribution.HermiteDisND(u, theta, coef, indt)[source]#

Bases: HermitedistributionBase

HermiteDis: Gas distribution in Hermite form.

Parameters:
  • u (bte.utils.indexs.torch.Tensor) –

  • theta (bte.utils.indexs.torch.Tensor) –

  • coef (bte.utils.indexs.torch.Tensor) –

  • indt (bte.utils.indexs.index_table) –

property ORDER[source]#
property rho[source]#
property moments[source]#
property rho_u_theta[source]#
new(u, theta, coef, indt=None)[source]#
M()[source]#
__str__()[source]#

Return str(self).

Return type:

str

static empty(order, dim=3, device='cpu')[source]#
Parameters:

order (int) –

Return type:

HermiteDisND

from_DVDis(dis, u=None, theta=None)[source]#
Parameters:

dis (DVDis) –

Return type:

HermiteDis

cpu()[source]#
cuda()[source]#
to(args)[source]#
to_tensor()[source]#
density()[source]#
velocity()[source]#
temperature()[source]#
as_tuple()[source]#
__add__(anotherDis)[source]#
__radd__(anotherDis)[source]#
__sub__(anotherDis)[source]#
__mul__(multiplier)[source]#
__rmul__(multiplier)[source]#
__truediv__(divider)[source]#
roll(idx)[source]#
clone()[source]#
down()[source]#
Project_to_STD(STEP=1)[source]#

Project_to_STD 将分布参数重设,重新投影到最佳参数上

Parameters:

STEP (int) –

Project_2B(dest, STEP=1)[source]#

Project_A2B 将分布投影到dest对应的参数上

Parameters:
Return type:

HermiteDis

mulvec(axis=0)[source]#

axis=0 for x, 1 for y, 2 for z.

Project_RK4_helper(dis, u0, theta0, u, theta)[source]#
Project_RK4_step(dis, u0, theta0, u, theta, h)[source]#
Parameters:

h (float) –

Project_RK4(u, theta, STEP=1)[source]#

Project_RK4 使用R-K 4格式对分布函数进行投影

Parameters:
  • dis (torch.Tensor) – 分布函数

  • u (torch.Tensor) – 分布中心

  • theta (torch.Tensor) – 分布宽度

  • STEP (int, optional) – RK方法的步数, by default 1

Returns:

投影后的分布函数

Return type:

torch.Tensor