Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

1D Lax Tube

DownloadNotebookDownloadCodeViewSource

This notebook requires MindSpore version >= 2.0.0 to support new APIs including: mindspore.jit, mindspore.jit_class.

The shock tube problem is a common test for the accuracy of computational fluid codes, like Riemann solvers. The test consists of a one-dimensional Riemann problem, i.e., the development of an ideal gas under different conditions at the left and right ends.

Problem Description

The definition of the Lax tube problem is:

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

where γ=1.4 for ideal gas. The initial condition is:

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

The Neumann boundary condition is applied on both side of the tube.

The following src pacakage can be downloaded in 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)

Defining Simulator and RunTime

The mesh, material, runtime, boundary conditions and numerical methods are defined in numeric.yaml.

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

Initial Condition

Initial condition is determined according to mesh coordinates.

[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)

Running Simulation

Run CFD simulation with time marching.

[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

You can view the density, pressure and velocity.

[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