文档反馈

问题文档片段

问题文档片段包含公式时,显示为空格。

提交类型
issue

有点复杂...

找人问问吧。

PR

小问题,全程线上修改...

一键搞定!

请选择提交类型

问题类型
规范和低错类

- 规范和低错类:

- 错别字或拼写错误,标点符号使用错误、公式错误或显示异常。

- 链接错误、空单元格、格式错误。

- 英文中包含中文字符。

- 界面和描述不一致,但不影响操作。

- 表述不通顺,但不影响理解。

- 版本号不匹配:如软件包名称、界面版本号。

易用性

- 易用性:

- 关键步骤错误或缺失,无法指导用户完成任务。

- 缺少主要功能描述、关键词解释、必要前提条件、注意事项等。

- 描述内容存在歧义指代不明、上下文矛盾。

- 逻辑不清晰,该分类、分项、分步骤的没有给出。

正确性

- 正确性:

- 技术原理、功能、支持平台、参数类型、异常报错等描述和软件实现不一致。

- 原理图、架构图等存在错误。

- 命令、命令参数等错误。

- 代码片段错误。

- 命令无法完成对应功能。

- 界面错误,无法指导操作。

- 代码样例运行报错、运行结果不符。

风险提示

- 风险提示:

- 对重要数据或系统存在风险的操作,缺少安全提示。

内容合规

- 内容合规:

- 违反法律法规,涉及政治、领土主权等敏感词。

- 内容侵权。

请选择问题类型

问题描述

点击输入详细问题描述,以帮助我们快速定位问题。

一维Lax激波管

下载Notebook下载样例代码查看源文件

本案例要求MindSpore版本 >= 2.0.0调用如下接口: mindspore.jit,mindspore.jit_class

激波管问题是检验计算流体代码准确性的常见问题。这个案例为一个一维黎曼问题,即理想气体在左右端不同条件下的发展问题。

问题描述

Lax激波管问题的定义为:

t(ρρuE)+x(ρuρu2+pu(E+p))=0
E=ργ1+12ρu2

其中,对理想气体, γ=1.4 ,初始条件为:

(ρup)x<0.5=(0.4450.6983.528),(ρup)x>0.5=(0.50.00.571)

在激波管两端,施加第二类边界条件。

本案例中src包可以在src下载。

[1]:
import mindspore as ms
from mindflow import load_yaml_config, vis_1d
from mindflow import cfd
from mindflow.cfd.runtime import RunTime
from mindflow.cfd.simulator import Simulator

from src.ic import lax_ic_1d

ms.set_context(device_target="GPU", device_id=3)

定义Simulator和RunTime

网格、材料、仿真时间、边界条件和数值方法的设置在文件numeric.yaml中。

[2]:
config = load_yaml_config('numeric.yaml')
simulator = Simulator(config)
runtime = RunTime(config['runtime'], simulator.mesh_info, simulator.material)

初始条件

根据网格坐标确定初始条件。

[3]:
mesh_x, _, _ = simulator.mesh_info.mesh_xyz()
pri_var = lax_ic_1d(mesh_x)
con_var = cfd.cal_con_var(pri_var, simulator.material)

执行仿真

随时间推进执行仿真。

[4]:
while runtime.time_loop(pri_var):
    pri_var = cfd.cal_pri_var(con_var, simulator.material)
    runtime.compute_timestep(pri_var)
    con_var = simulator.integration_step(con_var, runtime.timestep)
    runtime.advance()
current time = 0.000000, time step = 0.001117
current time = 0.001117, time step = 0.001107
current time = 0.002224, time step = 0.001072
current time = 0.003296, time step = 0.001035
current time = 0.004332, time step = 0.001016
current time = 0.005348, time step = 0.001008
current time = 0.006356, time step = 0.000991
current time = 0.007347, time step = 0.000976
current time = 0.008324, time step = 0.000966
current time = 0.009290, time step = 0.000960
current time = 0.010250, time step = 0.000957
current time = 0.011207, time step = 0.000954
current time = 0.012161, time step = 0.000953
current time = 0.013113, time step = 0.000952
current time = 0.014066, time step = 0.000952
current time = 0.015017, time step = 0.000951
current time = 0.015969, time step = 0.000951
current time = 0.016920, time step = 0.000952
current time = 0.017872, time step = 0.000951
current time = 0.018823, time step = 0.000951
current time = 0.019775, time step = 0.000952
current time = 0.020726, time step = 0.000953
current time = 0.021679, time step = 0.000952
current time = 0.022631, time step = 0.000952
current time = 0.023583, time step = 0.000952
current time = 0.024535, time step = 0.000952
current time = 0.025488, time step = 0.000952
current time = 0.026440, time step = 0.000952
current time = 0.027392, time step = 0.000953
current time = 0.028345, time step = 0.000952
...
current time = 0.136983, time step = 0.000953
current time = 0.137936, time step = 0.000953
current time = 0.138889, time step = 0.000953
current time = 0.139843, time step = 0.000953

Post Processing

您可以对密度、压力、速度进行可视化。

[5]:
pri_var = cfd.cal_pri_var(con_var, simulator.material)
vis_1d(pri_var, 'lax.jpg')
../_images/cfd_solver_lax_tube_10_0.png