Python for CFD (summary of the first two steps)

Source: Internet
Author: User

In the previous question, if the NX is infinitely larger by itself (or NX = 100), the resulting drawing is divergent.

This is because there is an important requirement in the finite difference, the CFL number, in particular, the dependent domain of the difference equation must contain the dependent domain of the corresponding differential equation, the simplest can be understood as the time to push the solution speed (DX/DT) must be greater than the speed of the physical disturbance Propagation (U), only in order to capture all the physical disturbances.

every time intervalDTThe distance from the "wave" spread isDX, whileDXwith theNXrelated, the equation to keep the numerical solution stable is:

Import numpy as npimport matplotlib.pyplot as pltdef linearconv (NX):     dx = 2./(nx-1)     nt = 20     #nt  is the number of timesteps we want to calculate     c = 1    sigma = .5            dt = sigma*dx      #跟步骤2唯一的变化在这      u = np.ones (NX)      u[.5/dx : 1/dx+1]=2     un = np.ones (NX)     for n in range (NT):   # Iterate through time        un = u.copy ()  ## copy the existing values of u into un         for i In range (1,NX):            u[i] =  un[i]-c*dt/dx* (Un[i]-un[i-1])             plt.plot ( Np.linspace (0,2,NX), u)
Linearconv (121), the graph and step 2 are similar


Python for CFD (summary of the first two steps)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.