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.

2D Riemann

DownloadNotebookDownloadCodeViewSource

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

A Riemann problem, named after Bernhard Riemann, is a specific initial value problem composed of a conservation equation together with piecewise constant initial data which has a single discontinuity in the domain of interest. The Riemann problem is very useful for the understanding of equations like Euler conservation equations because all properties, such as shocks and rarefaction waves, appear as characteristics in the solution. It also gives an exact solution to some complex nonlinear equations, such as the Euler equations.

In numerical analysis, Riemann problems appear in a natural way in finite volume methods for the solution of conservation law equations due to the discreteness of the grid. For that it is widely used in computational fluid dynamics and in computational magnetohydrodynamics simulations.

Problem Description

The definition of the 2 dimensional Riemann problem is:

t(ρρuρvE)+x(ρuρu2+pρuvu(E+p))+y(ρvρuvρv2+pv(E+p))=0
E=ργ1+12ρu2

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

(ρuvp)x<0.5,y>0.5=(0.53231.2060.00.3),(ρuvp)x>0.5,y>0.5=(1.50.00.01.5)
(ρuvp)x<0.5,y<0.5=(0.1381.2061.2060.029),(ρuvp)x>0.5,y<0.5=(0.53230.01.2060.3)

The following src pacakage can be downloaded in src.

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

from src.ic import riemann2d_ic

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, mesh_y, _ = simulator.mesh_info.mesh_xyz()
pri_var = riemann2d_ic(mesh_x, mesh_y)
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.001005
current time = 0.001005, time step = 0.001005
current time = 0.002010, time step = 0.001005
current time = 0.003016, time step = 0.001005
current time = 0.004021, time step = 0.001005
current time = 0.005026, time step = 0.001005
current time = 0.006031, time step = 0.001005
current time = 0.007036, time step = 0.001005
current time = 0.008041, time step = 0.001005
current time = 0.009046, time step = 0.001005
current time = 0.010051, time step = 0.001005
current time = 0.011057, time step = 0.001005
current time = 0.012062, time step = 0.001005
current time = 0.013067, time step = 0.001005
current time = 0.014072, time step = 0.001005
current time = 0.015076, time step = 0.001005
current time = 0.016081, time step = 0.001005
current time = 0.017086, time step = 0.001005
current time = 0.018091, time step = 0.001005
current time = 0.019097, time step = 0.001005
current time = 0.020102, time step = 0.001005
current time = 0.021107, time step = 0.001005
current time = 0.022112, time step = 0.001005
current time = 0.023117, time step = 0.001005
current time = 0.024121, time step = 0.001005
current time = 0.025126, time step = 0.001005
current time = 0.026131, time step = 0.001005
current time = 0.027137, time step = 0.001005
current time = 0.028142, time step = 0.001005
...
current time = 0.297090, time step = 0.000760
current time = 0.297849, time step = 0.000759
current time = 0.298609, time step = 0.000759
current time = 0.299368, time step = 0.000759

Post Processing

You can view the density, pressure and velocity.

[5]:
pri_var = cfd.cal_pri_var(con_var, simulator.material)
vis_2d(pri_var, 'riemann2d.jpg')
../_images/cfd_solver_riemann2d_10_0.png