Fluid2d是通用的Python-Fortran CFD代码包,它包含了大量的二维流体方程。该软件对于学生学习流体力学或地球物理流体动力学很有帮助,也可以是授课老师的教学实践工具。其思想是在计算流时可视化动态流,且参数变化的影响可以立即看到。二维流体的关键量是涡度,如果你的涡度动力学很弱,这个代码是为你准备的。你应该迅速成为专家一样的专家。由于动画的强大功能,用户可以了解基本流体性质,进一步超越教科书而触及学术研究的问题是很容易的。 有几个功能特别好: •代码可处理许多不同的方程组:transport, Euler, quasi-geostrophic, Boussinesq, thermal wind equations。 •代码处理一个允许具有复杂几何形状的掩模系统(具有任意形状的封闭域) •代码往往具有非常低的dissipation水平 •允许研究边界层问题的no-slip条件 •代码是并行的,如果需要高分辨率,可以在集群上运行。 下载和安装软件主页: 最新版下载地址: 安装步骤: 作者提供了一个快速编译和安装脚本install.sh:
4 n+ ^- L: [$ S t3 o. Q( C/ C# f
[Shell] 纯文本查看 复制代码
#!/bin/bash
pydir=$HOME/.fluid2d
default=core/defaults.json
srcdir=`pwd`
myexpdir=$srcdir/myexp
echo "--------------------------------------------------------------------------------"
echo ""
echo " Installing Fluid2d"
echo ""
echo "It is recommended to create a virtual environnement. "
echo "If you are using anaconda then you may create the 'pyrsw' environment with"
echo ""
echo "> conda env create -f environment.yml"
echo ""
echo "then whenever you want to use Fluid2d, switch to this environement with"
echo ""
echo "> conda activate fluid2d"
echo ""
echo "Are you ok with you environment? (y/n)"
if [ $ok = "n" ]; then
exit 42
fi
if [ ! -d "$pydir" ]; then
echo " Create $pydir"
mkdir $pydir
fi
if [ ! -f "$pydir/$default" ]; then
echo " Copy $default in $pydir"
cp $default $pydir/
fi
if [ ! -d "$myexpdir" ]; then
echo " Create $myexpdir"
mkdir $myexpdir
fi
echo " Copy reference experiments in $myexpdir"
cp -pR $srcdir/experiments/* $myexpdir
# for bash users
cat > $pydir/activate.sh << EOF
export PYTHONPATH=`pwd`/core
echo Python now knows that Fluid2d is in `pwd`
EOF
# for csh, tcsh users
cat > $pydir/activate.csh << EOF
setenv PYTHONPATH `pwd`/core
echo Python now knows that Fluid2d is in `pwd`
EOF
# for fish users
cat > $pydir/activate.fish << EOF
set -gx PYTHONPATH `(pwd)`/core
echo Python now knows that Fluid2d is in `(pwd)`
EOF
# compile the modules with module
echo "--------------------------------------------------------------------------------"
echo ""
echo " Compile modules with f2py"
echo ""
{
# try
make
} || {
#catch
echo "Unable to compile"
echo "Are you sure f2py is installed?"
exit
}
# copy the experiment into
echo ""
echo " Before starting, please read this note carefully"
echo ""
echo " As it configured, Fluid2d will store the results in"
echo ""
echo " *** $HOME/data/fluid2d ***"
echo ""
echo " If you don't run the code from your laptop then it is likely that"
echo " you are not allowed to store large binary files on $HOME/data"
echo " because this is your home."
echo ""
echo " In this case, edit $HOME/.fluid2d/defaults.json"
echo " and set 'datadir' default value (in the output section) to a"
echo " place where you are authorized to store large binary files."
echo " In the jargon, this place is usually a 'work' directory."
echo ""
echo " If you are unsure where to store your results check that"
echo " with your system administrator."
echo ""
echo " Once you know where to store the results, then you're good to go"
echo ""
echo " Each time you open a new terminal you need to"
echo " source ~/.fluid2d/activate.sh if you're under bash"
echo " source ~/.fluid2d/activate.csh if you're under csh/tcsh"
echo " source ~/.fluid2d/activate.fish if you're under fish"
echo ""
echo " To run your first experiment"
echo " cd $myexpdir/Vortex"
echo " python3 vortex.py"
echo ""
echo " Write your new experiments in $myexpdir"
echo " or wherever you want, but not in $srcdir/experiments !"
echo ""
4 D$ n' H" I: [: O) Y; M2 m5 l. n
0 N' d' |: \* \7 E; |- m$ k3 u测试运行之前需要在主目录下新建文件夹: 3 n. G3 J2 V1 V
[Shell] 纯文本查看 复制代码 mkdir data
cd data
mkdir fluid2d ' u t' @8 q( m1 E7 D( E; K& G; U
执行例子:
9 n' t: u+ |( a& l, E V
* B/ {. D' B) w
[Shell] 纯文本查看 复制代码 cd myexp/ShearInstab
python3 shear_instability.py
' q- m% }6 g9 F. K; E { 3 A$ d* _2 v4 z$ R; a
结果输出:
8 b* u' l5 r$ A$ f
|