mindflow.cfd
- class mindflow.cfd.RunTime(config, mesh_info, material)[源代码]
仿真运行时控制器。
- 参数:
config (dict) - 参数字典。
mesh_info (MeshInfo) - 计算网格的信息。
material (Material) - 流体材料模型。
- 支持平台:
GPU
样例:
>>> from mindflow import cfd >>> config = {'mesh': {'dim': 1, 'nx': 100, 'gamma': 1.4, 'x_range': [0, 1], 'pad_size': 3}, ... 'material': {'type': 'IdealGas', 'heat_ratio': 1.4, 'specific_heat_ratio': 1.4, ... 'specific_gas_constant': 1.0}, 'runtime': {'CFL': 0.9, 'current_time': 0.0, 'end_time': 0.2}, ... 'integrator': {'type': 'RungeKutta3'}, 'space_solver': {'is_convective_flux': True, ... 'convective_flux': {'reconstructor': 'WENO5', 'riemann_computer': 'Rusanov'}, ... 'is_viscous_flux': False}, 'boundary_conditions': {'x_min': {'type': 'Neumann'}, ... 'x_max': {'type': 'Neumann'}}} >>> s = cfd.Simulator(config) >>> r = cfd.RunTime(c, s.mesh_info, s.material)
- class mindflow.cfd.Simulator(config, net_dict=None)[源代码]
CFD仿真器。MindFlow CFD中最上层的类。
- 参数:
config (dict) - 参数字典。
net_dict (dict) - 网络字典, 默认为None。
- 支持平台:
GPU
样例:
>>> from mindflow import cfd >>> config = {'mesh': {'dim': 1, 'nx': 100, 'gamma': 1.4, 'x_range': [0, 1], 'pad_size': 3}, ... 'material': {'type': 'IdealGas', 'heat_ratio': 1.4, 'specific_heat_ratio': 1.4, ... 'specific_gas_constant': 1.0}, 'runtime': {'CFL': 0.9, 'current_time': 0.0, 'end_time': 0.2}, ... 'integrator': {'type': 'RungeKutta3'}, 'space_solver': {'is_convective_flux': True, ... 'convective_flux': {'reconstructor': 'WENO5', 'riemann_computer': 'Rusanov'}, ... 'is_viscous_flux': False}, 'boundary_conditions': {'x_min': {'type': 'Neumann'}, ... 'x_max': {'type': 'Neumann'}}} >>> s = cfd.Simulator(config)
- mindflow.cfd.cal_pri_var(con_var, material)[源代码]
从守恒量中计算原始量。
- 参数:
con_var (Tensor) - 守恒量。
material (Material) - 流体材料。
- 返回:
Tensor,shape和 con_var 一致。
- 支持平台:
GPU
样例:
>>> import numpy as np >>> from mindspore import Tensor >>> from mindflow.utils import cal_pri_var >>> from mindflow import material >>> config = {'type': 'IdealGas', 'heat_ratio': 1.4, 'specific_heat_ratio': 1.4, 'specific_gas_constant': 1.0} >>> m = material.select_material(config) >>> x1 = Tensor(np.random.randn(5, 32, 32, 1)) >>> x2 = cal_pri_var(x, m) >>> x2.shape (5, 32, 32, 1)
- mindflow.cfd.cal_con_var(pri_var, material)[源代码]
从原始量中计算守恒量。
- 参数:
pri_var (Tensor) - 原始量。
material (Material) - 流体材料。
- 返回:
Tensor,shape和 pri_var 一致。
- 支持平台:
GPU
样例:
>>> import numpy as np >>> from mindspore import Tensor >>> from mindflow.utils import cal_con_var >>> from mindflow import material >>> config = {'type': 'IdealGas', 'heat_ratio': 1.4, 'specific_heat_ratio': 1.4, 'specific_gas_constant': 1.0} >>> m = material.select_material(config) >>> x1 = Tensor(np.random.randn(5, 32, 32, 1)) >>> x2 = cal_con_var(x, m) >>> x2.shape (5, 32, 32, 1)