有重复的排列组合问题:
从n个元素中选出m个可重复的元素,一共有多少组合?
思路:建立一个映射,使m个可重复的元素变成m个不可重复的元素,再使用公式。
具体来说,原始的m个元素的编号取值区间为1<x<n. 通过映射:
: , , , …,
: +0, +1, +2, …, +m-1
使得新的m个元素的编号取值区间为1<x<(n+m-1),一一对应并且元素不再重复,所以组合数为.
从n个元素中选出m个可重复的元素,并排序,一共有多少序列?
是,还是,思考一下。
思路:建立一个映射,使m个可重复的元素变成m个不可重复的元素,再使用公式。
具体来说,原始的m个元素的编号取值区间为1<x<n. 通过映射:
x: x1, x2, x3, …, xm
f(x): x1+0, x2+1, x3+2, …, xm+m-1
使得新的m个元素的编号取值区间为1<x<(n+m-1),一一对应并且元素不再重复,所以组合数为Cn+m−1m.
是nm,还是An+m−1m,思考一下。
Within a fluid flowing horizontally, the highest speed occurs where the pressure is lowest, and the lowest speed occurs where the pressure is highest. Why?
In fluid mechanics, Bernoulli’s principle states that, in a steady flow, the sum of all forms of energy in a fluid () along a streamline remains constant. The forms of energy involves the kinetic energy, the potential energy and the internal energy. Bernoulli’s principle can also be derived directly from Newton’s Second Law of Motion.
PDE can be classified as elliptic, parabolic or hyperbolic. In fluids dynamics, the governing equations contain first and second derivatives in the spatial coordinates and first derivatives only in time. The spatial derivatives often appear nonlinearly while the time derivatives appear linearly. For linear PDE of second-order in two independent variables x and y,
A∂x2∂2u+B∂x∂y∂2u+C∂y2∂2u+D∂x∂u+E∂y∂u+Fu+G=0
A simple classification is as follows.
The transition from laminar flow to turbulent flow was first examined in pipe flow by O. Reynolds (1883). Prandtl’s comprehensive contribution appeared in Aerodynamic Theory, edited by W.F. Durand, L. Prandtl (1935). A separation of the boundary layer from the body and the formation of large or small eddies at the back of the body can then occur. This kind of separation could be detrimental.
The Reynolds-averaged Navier–Stokes equations (RANS equations) for the three-dimensional incompressible viscous flow consists of the continuity equation and the momentum equations as follows:
∂xi∂ui=0
ρ∂t∂ui+ρuj∂xj∂ui=−∂xi∂p+∂xj∂[μ(∂xj∂ui+∂xi∂uj)]+∂xj∂(−ρui′uj′)
where ui, i=1,2 in two-dimensional flow, denotes the velocity components along x-,y-axis, respectively. p is the pressure. rho is the water density. μ is the dynamic viscosity of water. −ρui′uj′ are the Reynolds stresses or the apparent turbulent shear stress.
The Reynolds stresses can be solved based on the Boussinesq hypothesis using the eddy viscosity turbulence models, or be solved from the transport equation based on Reynolds stress models. In the present studies, one-equation and two-equation eddy viscosity models as well as Reynolds stress models were employed to solve the RANS equations.
In the eddy viscosity models, it is assumed that the Reynolds stresses are related to the mean velocity gradients, the turbulence kinetic energy and eddy viscosity, i.e.,
−ρui′uj′=μt(∂xj∂ui+∂xi∂uj)−32(ρk+μt∂xi∂ui)δij
where μt represents the eddy viscosity, δij is the Kronecker delta, k=21ui′uj′ is the turbulent kinetic energy that can be solved from the transport equations. The Reynolds stress tensor is linearly proportional to the mean strain rate. Note that the term ∂xi∂ui equals to zero for incompressible flows.
The simple one-equation model, Spalart-Allmaras (SA) model is implemented. The SA turbulence model solves a transport equation for the modified diffusivity ν~ to determine the turbulence eddy viscosity, μt, i.e.,
μt=ρfν1ν~
where fν1 is a damping function. The transport equation for the modified diffusivity is:
∂t∂(ρν~)+∇⋅(ρν~v¯)=σν~1∇⋅[(μ+ρν~)∇ν~]+Pν~+Sν~
where v¯ is the mean velocity, σν~ is a model coefficient, μ is the dynamic viscosity, Pν~ is the production term and Sν~ is the source term. SA model has good convergence and robustness for specialized flows. However, the turbulence length and time scales are not well defined as they are in other two-equation models.
Two-equation models are widely used solve the RANS equations, in which both the velocity and length scale are solved using separate transport equations. The turbulence length scale is estimated from the kinetic energy and its dissipation rate. The standard k−ϵ, standard k−ω and the Shear Stress Transport (SST) k−ω models are investigated.
In the k−ϵ model, the turbulent eddy viscosity is calculated as:
μt=ρCμfμkT
where Cμ is a model coefficient, fμ is a damping function and T is the turbulent time scale, which is calculated as:
T=max(Te,Ct√ϵν)
where Te=ϵk is the large-eddy time scale, Ct is a model coefficient, ν is the kinematic viscosity. The transport equations for the turbulent kinetic energy k and the turbulence dissipation rate ϵ are written as:
∂t∂(ρk)+∇⋅(ρkv¯)=∇⋅[(μ+σkμt)∇k]+Pk−ρ(ϵ−ϵ0)+Sk
∂t∂(ρϵ)+∇⋅(ρϵv¯)=∇⋅[(μ+σϵμt)∇ϵ]+Te1Cϵ1Pϵ−Cϵ2f2ρ(Teϵ−T0ϵ0)+Sϵ
where σk, σϵ, Cϵ1 and Cϵ2 are model coefficients, Pk and Pϵ are production terms, f2 is a damping function, Sk and Sϵ are source terms. In the realizable k−ϵ model, the equation for turbulence dissipation rate is modified and the coefficient Cμ is expressed as a function of mean flow and turbulence properties instead of constant in the standard model. The effect of the mean flow distortion on turbulent dissipation is introduced to improve the performance for rotation and streamline curvature. It also improves the boundary layer under strong adverse pressure gradients or separation. The renormalization group (RNG) k−ϵ model is based on renormalization group analysis of the Navier-Stokes equations. Different constants are used in the transportation equations for the turbulence kinetic energy and dissipation. The RNG k−ϵ model leads to lower turbulence levels and generated less viscous flows.
In the k−ω model, the turbulent eddy viscosity is related to the turbulence kinetic energy, k, and the specific turbulence dissipation rate, ω, which is also referred to the mean frequency of the turbulence. The turbulent eddy viscosity is calculated as:
μt=ρkT
where T=ωα∗ is the turbulence time scale in the standard k−ω model. α∗ is a model coefficient. The transport equations for the turbulent kinetic energy k and the specific dissipation rate ω are written as:
∂t∂(ρk)+∇⋅(ρkv¯)=∇⋅[(μ+σkμt)∇k]+Pk−ρβ∗fβ∗(ωk−ω0k0)+Sk
∂t∂(ρω)+∇⋅(ρωv¯)=∇⋅[(μ+σωμt)∇ω]+Pω−ρβfβ(ω2−ω02)+Sk
where σk, σω are model coefficients, Pk and Pω are production terms, fβ∗ is the free-shear modification factor.is the vortex-stretching modification factor, k0 and ω0 are the ambient turbulence values that counteract turbulence decay, Sk and Sω are source terms. The k−ω model predicts strong vortices and the near-wall interactions more accurately than the k−ϵ models. The limitations of the original k−ω model include the over-prediction of shear stresses of adverse pressure gradient boundary layers, and the sensitivity to initial conditions and inlet boundary conditions.
For the SST k−ω model, the transport equations are the same as those of the standard k−ω model by setting the damped cross-diffusion derivative term as zero in the near region. In the far field, the transport equations are the same as those of the standard k−ϵ model, which can avoid the problem that the model is too sensitive to the inlet turbulence properties. Detailed formulations can be found in the work by Menter (1993). The SST k−ω model introduces the transport of the turbulence shear stress and improves the prediction of the onset and the flow separation under adverse pressure gradients.
In the Reynolds stress models (RSM), the transport equations are solved for all the components of the Reynolds stress tensor and the turbulence dissipation rate, i.e.,
∂t∂(ρui′uj′)+∂xk∂(ρukui′uj′)=Pij+Fij+DijT+ϕij−ϵij
where Pij is the stress production, Fij is the rotation production, DijT is the turbulent diffusion, ϕij is the pressure strain tensor and ϵij is the dissipation rate tensor. The isotropic turbulent dissipation rate is solved from a transport equation analogous to the k−ϵ model with various model coefficients.
In order to resolve the viscous sublayer, two RSM models can be implemented, including the elliptic blending model (EB-RSM) and the linear pressure-strain two-layer model (LPS-RSM). EB-RSM model applies only one scalar elliptic equation instead of the original six transport equations for all stress components, which is based on the relaxation formulations of the pressure-strain tensor using a blending function. In the LPS-RSM model, the pressure-strain term ϕij comprises a slow term (also known as the return-to-isotropy term), a rapid term, and wall-reflection terms. The Reynolds stress models can predict complex flows with swirl rotation and high strain rates more accurately than eddy viscosity models.
The incompressible flow can be solved by the segregated solver for pressure-velocity coupling. The pressure-correction equation can be constructed from the continuity equation and the momentum equations. The SIMPLE (Semi-Implicit Method for Pressure Linked Equations) algorithm is used to solve the pressure and velocity for steady and unsteady problems. The PISO (Pressure-Implicit with Splitting of Operators) algorithm is applied for unsteady problems. The SIMPLE algorithm is summarized as follows.
英国是个老牌海军强国,曾拥有世界最强的海军舰队,先后击败西班牙、荷兰和法国,成为新的“日不落帝国”。日不落帝国,即The empire on which the sun never sets,指的是全天任何时候都有领土或海外殖民地处于白昼,出自西班牙国王卡洛斯一世:在我的领土上,太阳永不落下。
1660年5月,查理二世继位,英国恢复君主制,并在同年成立了英国皇家海军和英国皇家学会。在大名鼎鼎的英国皇家海军里面,随便挑几个,无畏号、胡德号、厌战号、胜利号、光辉号等等,都是闪闪发光的名字。本文要讲的故事的主角不算最有名的那一档,但也实打实是一艘名舰。如果你去过伦敦,看过白金汉宫和泰晤士河上的伦敦塔桥(Tower Bridge),那一定记得,有个略微破坏浪漫气息的军舰静静地停靠在市政厅旁边,她就是贝尔法斯特号轻巡洋舰,现已是帝国战争博物馆(Imperial War Museum)。大英帝国什么奇珍异宝没见过,为什么要把一艘退役军舰摆到伦敦最显眼的位置呢?她够格吗?
Shell scripting makes life more comfortable. The command sequences of Linux can be combined in one shell script and be executed automatically without wasting any time. For example, if you would like to rename 9,999,999 files and put them into different directories during one week, clicking the mouse will be devastating. By shell scripting, all you need is to run one command in a loop. After that, you can have a vacation and enjoy coffee in the next seven days.
Suppose we have known at least a little bit about Linux. What is a Linux shell? Shell is an command language interpreter that executes commands. The most commonly used shells are SH (Bourne SHell) and Bash (Bourne again shell), released in 1989. Bash is not a perfect scripting language, but it is very useful. Life is short, get rid of the mouse.