dimanche 27 juin 2010

ubuntu change workspace

You can switch between workspaces in any of the following ways:
In the Workspace Switcher applet in the bottom panel, click on the workspace where you want to work.
Move the mouse over the Workspace Switcher applet in the bottom panel, and scroll the mouse wheel.
Press Ctrl+Alt+right arrow to switch to the workspace on the right of the current workspace.
Press Ctrl+Alt+left arrow to switch to the workspace on the left of the current workspace. Note: The arrow shortcut keys work according to how your workspaces are set out in the Workspace SwitcherCtrl+Alt+up arrow and Ctrl+Alt+down arrow to switch workspaces. applet. If you change your panel so workspaces are displayed vertically instead of horizontally

gnuplot

set logscale x 10
set format x "10^{%L}"
set title 'Turbulence Boundary Layer'
set xlabel 'y^+'
set ylabel 'U^+'
set xrange [1:1e+04]
set grid

set arrow 1 from 5,1 to 5,18 nohead linetype 1 linewidth 2
set arrow 2 from 50,1 to 50,18 nohead linetype 1 linewidth 2
set arrow 3 from 600,1 to 600,26 nohead linetype 1 linewidth 2
show arrow

set label 1 "Visc." at 1.8,7
set label 2 "Buffer" at 15,7
set label 3 "Log." at 150,7
show label

set key top left
set key box
plot 'boundary_vlaw.dat' title 'Van Driest profile' with line
replot 'boundary_line.dat' title 'Visc.' with line
replot 'boundary_log.dat' title 'Log.' with line

replot 'Uplus-zplus_000.dat' title 'NO.1' with points pointtype 4
replot 'Uplus-zplus_067.dat' title 'NO.2' with points pointtype 5
replot 'Uplus-zplus_134.dat' title 'NO.3' with points pointtype 6
replot 'Uplus-zplus_201.dat' title 'NO.4' with points pointtype 7
replot 'Uplus-zplus_268.dat' title 'NO.5' with points pointtype 8

mercredi 23 juin 2010

gnuplot (zz)

对于在Linux下工作的人,如果你经常要画一些二维图和简单的三维图的话,那么,gnuplot无疑是一个非常好的选择,不仅图形漂亮,而且操作简单。当然如果需要质量更高的三维图,请用其他的一些专业绘图软件。建议大家学会使用gnuplot。这个小软件通常都是Redhat Linux自带的,但自带的版本是3.7的,建议将其升级到4.0,新版本具有很多新功能。最新版本可以到www.gnuplot.info下载。

一 些最基本的操作请大家看说明书。这里总结一下我在使用过程中遇到的一些问题以及解决的办法,目的是让那些以前不会的或不熟练的能快速入门,会画自己想要的 图,因为原来的说明书很长,较难有针对性地很快找到自己想要的信息。这里简单的总结不可能面面俱到,所以大家不要抱怨我写的不全,更全面的了解还是请看说 明书,网上的资料也多的是。其实这也是我们从网上一点一点搜集和摸索出来的。我相信看完后,应该平时最常见的问题基本上都能在这里找到答案。如果大家在使 用过程中摸索到了我没有写到的技巧和体会,或有其它建议,请大家提告诉我,以不断完善这篇总结,谢谢!



一、 基础篇:

在linux命令提示符下运行gnuplot命令启动,输入quit或q或exit退出。



1、plot命令

gnuplot> plot sin(x) with line linetype 3 linewidth 2 或

gnuplot> plot sin(x) w l lt 3 lw 2 %用线画,线的类型(包括颜色与虚线的类型)是3,线的宽度是2,对函数sin(x)作图

gnuplot> plot sin(x) with point pointtype 3 pointsize 2 或

gnuplot> plot sin(x) w p pt 3 ps 2 %用点画,点的类型(包括颜色与点的类型)是3,点的大小是2

gnuplot> plot sin(x) title 'f(x)' w lp lt 3 lw 2 pt 3 ps 2 %同时用点和线画,这里title ‘f(x)’表示图例上标'f(x)',如果不用则用默认选项

gnuplot> plot sin(x) %此时所有选项均用默认值。如果缺某一项则将用默认值

gnuplot> plot ‘a.dat’ u 2:3 w l lt 3 lw 2 %利用数据文件a.dat中的第二和第三列作图



顺便提一下,如这里最前面的两个例子所示,在gnuplot中,如果某两个词,按字母先后顺序,前面某几个字母相同,后面的不同,那么只要写到第一个不同的字母就可以了。如with,由于没有其它以w开头的词,因此可以用 w 代替,line也可以用 l 代替。



2、同时画多条曲线

gnuplot> plot sin(x) title ‘sin(x)’ w l lt 1 lw 2, cos(x) title ‘cos(x)’ w l lt 2 lw 2 %两条曲线是用逗号隔开的。画多条曲线时,各曲线间均用逗号隔开就可以了。



以上例子中是对函数作图,如果对数据文件作图,将函数名称换为数据文件名即可,但要用单引号引起来。



3、关于图例的位置

默认位置在右上方。

gnuplot> set key left %放在左边,有left 和right两个选项

gnuplot> set key bottom %放在下边,只有这一个选项;默认在上边

gnuplot> set key outside %放在外边,但只能在右面的外边

以上三个选项可以进行组合。如:

gnuplot> set key left bottom %表示左下边



还可以直接用坐标精确表示图例的位置,如

gnuplot> set key 0.5,0.6 %将图例放在0.5,0.6的位置处


4、关于坐标轴

gnuplot> set xlabel ‘x’ %x轴标为‘x’

gnuplot> set ylabel ‘y’ %y轴标为’y’

gnuplot> set ylabel ‘DOS’ tc lt 3 %其中的tc lt 3表示’DOS’的颜色用第三种颜色。

gnuplot> set xtics 1.0 %x轴的主刻度的宽度为1.0,同样可以为y轴定义ytics

gnuplot> set mxtics 3 %x轴上每个主刻度中画3个分刻度,同样可以为y轴定义mytics

gnuplot> set border 3 lt 3 lw 2 %设为第三种边界,颜色类型为3,线宽为2

同样可以为上边的x轴(称为x2)和右边y(称为y2)轴进行设置,即x2tics,mx2tics,y2tics,my2tics。

gnuplot> set xtics nomirror

gnuplot> unset x2tics %以上两条命令去掉上边x2轴的刻度



gnuplot> set ytics nomirror

gnuplot> unset y2tics %以上两条命令去掉右边y轴的刻度



5、在图中插入文字

gnuplot> set label ‘sin(x)’ at 0.5,0.5 %在坐标(0.5,0.5)处加入字符串’sin(x)’。

在输出为.ps或.eps文件时,如果在set term 的语句中加入了enhanced选现,则可以插入上下标、希腊字母和特殊符号。上下标的插入和latex中的方法是一样的。



6、在图中添加直线和箭头

gnuplot> set arrow from 0.0,0.0 to 0.6,0.8 %从(0.0,0.0)到(0.6,0.8)画一个箭头

gnuplot> set arrow from 0.0,0.0 to 0.6,0.8 lt 3 lw 2 %这个箭头颜色类型为3,线宽类型为2

gnuplot> set arrow from 0.0,0.0 to 0.6,0.8 nohead lt 3 lw 2 %利用nohead可以去掉箭头的头部,这就是添加直线的方法。



注意,在gnuplot中,对于插入多个的label和arrow等等,系统会默认按先后顺序分别对各个label或arrow进行编号,从1开始。如果以后要去掉某个label或arrow,那么只要用unset命令将相应的去掉即可。如:

gnuplot> unset arrow 2

将去掉第二个箭头。



7、图的大小和位置

gnuplot>set size 0.5,0.5 %长宽均为默认宽度的一半,建议用这个取值,尤其是画成ps或eps图形的时候

gnuplot>set origin 0.0,0.5 %设定图的最左下角的那一点在图形面板中的位置。这里图将出现在左上角。



8、画三维图

gnuplot>splot ‘文件名’ u 2:4:5 %以第二和第四列作为x和y坐标,第五列为z坐标。



9.将图形输出到文件

在gnuplot中,输出文件的格式是由terminal来控制的。默认的情况下,都是输出到屏幕,即终端模式为X11。如果想输出到文件,则必须对terminal进行设置。要了解有那些终端类型,可以输入 set terminal后回车,所有支持的终端模式(或文件格式)都列出来了。就我来说,输出文件的格式用得最多的是ps和eps文件。这在运行画图命令plot或splot前必须先运行如下两条命令:



gnuplot>set term post eps color solid enh

gnuplot>set output ‘a.eps’



其中第一条命令为设置终端模式,post即为postscript模式,这是输出到ps或eps文件必须有的。后面的eps,color,solid以及enh选项均可以有或没有,根据你的需要。eps表示输出为eps文件,没有就输出为ps文件;color表示输出图形为彩色,不用就会保存为黑白的;solid表示输出图中的所有线都用实线,不用则除了第一条线为实线外,其它的均用不同的虚线;使用enh(enhanced)选项可以在图中插入上下标、希腊字母和特殊符号,不用则不能实现这些功能。后面的选项可以根据自己的需要选择一个或几个。



第二条命令对output的设置表示要输出的文件的名字。但是请注意,运行完这条命令后,还仅仅是定义了输出文件的名字,实际上,图还没画到这个文件里去。因此运行这两条命令还只是进行了必须的设置。然后运行如下命令

gnuplot>plot sin(x) w l


gnuplot>replot(假如前面已经运行过plot或replot命令的话)

这时,图形就在上面指定的文件中了。



要输出为其它格式,同样要进行这样的设置,比如要输出为jpg格式,则在运行画图命令前先运行如下命令:

gnuplot>set term jpeg

gnuplot>set output ‘a.jpg’



如果要由其它模式再返回到输出到屏幕,则运行如下命令:

gnuplot>set term X11

二、提高篇:

1、如何在同一张图里同时画多个图

gnuplot>set multiplot %设置为多图模式

gnuplot>set origin 0.0,0.5 %设置第一个图的原点的位置

gnuplot>set size 0.5,0.5 %设置第一个图的大小

gnuplot>plot “a1.dat”

gnuplot>set origin 0.5,0.5 %设置第二个图的原点的位置

gnuplot>set size 0.5,0.5 %设置第二个图的大小

gnuplot>plot “a2.dat”

gnuplot>set origin 0.0,0.0 %设置第三个图的原点的位置

gnuplot>set size 0.5,0.5 %设置第三个图的大小

gnuplot>plot “a3.dat”

gnuplot>set origin 0.5,0.0 %设置第四个图的原点的位置

gnuplot>set size 0.5,0.5 %设置第四个图的大小

gnuplot>plot “a4.dat”

当然,如果后一个图中的某个量的设置和前一个的相同,那么后一个中的这个量的设置可以省略。例如上面对第二、第三和第四个图的大小的设置。前一个图中对某个量的设置也会在后一个图中起作用。如果要取消在后面图中的作用,必须用如下命令,如取消label,用

gnuplot>unset label





2、作二维图时,如何使两边坐标轴的单位长度等长

gnuplot> set size square %使图形是方的
gnuplot> set size 0.5,0.5 %使图形是你要的大小
gnuplot> set xrange[-a:a]
gnuplot> set yrange[-a:a] %两坐标轴刻度范围一样
gnuplot> plot ‘a.dat’



3、如何在同一张图里利用左右两边的y轴分别画图

gnuplot> set xtics nomirror %去掉上面坐标轴x2的刻度
gnuplot> set ytics nomirror %去掉右边坐标轴y2的刻度
gnuplot> set x2tics %让上面坐标轴x2刻度自动产生
gnuplot> set y2tics %让右边坐标轴y2的刻度自动产生
gnuplot> plot sin(x),cos(x) axes x1y2 %cos(x)用x1y2坐标,axes x1y2表示用x1y2坐标轴
gnuplot> plot sin(x),cos(x) axes x2y2 %cos(x)用x2y2坐标,axes x2y2表示用x2y2坐标轴
gnuplot> set x2range[-20:20] %设定x2坐标的范围
gnuplot> replot
gnuplot> set xrange[-5:5] %设定x坐标的范围
gnuplot> replot
gnuplot> set xlabel 'x'
gnuplot> set x2label 't'
gnuplot> set ylabel 'y'
gnuplot> set y2label 's'
gnuplot> replot
gnuplot> set title 'The figure'
gnuplot> replot
gnuplot> set x2label 't' textcolor lt 3 %textcolor lt 3或tc lt 3设置坐标轴名称的颜色



4、如何插入希腊字母和特殊符号

一般只能在ps和eps图中,且必须指定enhanced选项。在X11终端(即显示器)中无法显示。

gnuplot> set terminal postscript enhanced

然后希腊字母就可以通过{/Symbol a}输入。例如

gnuplot> set label ‘{/Symbol a}’

各种希腊字母与特殊符号的输入方法请见安装包中gnuplot-4.0.0/docs/psdoc目录下的ps_guide.ps文件。


另外还可参见:
http://t16web.lanl.gov/Kawano/gnuplot/label-e.html#4.3



5、gnuplot中如何插入Angstrom(埃)这个符号(A上面一个小圆圈)

脚本中在插入前先加入
gnuplot>set encoding iso_8859_1
这个命令,然后就可以通过“{\305}”加入了。如横坐标要标上“k(1/Å)”:
gnuplot>set xlabel 'k(1/{\305})

如果是multiplot模式,则这个命令必须放在
gnuplot>set multiplot
的前面。

如果后面还要插入别的转义字符,那么还要在插入字符后加入如下命令:
set encoding default

安装包中gnuplot-4.0.0/docs/psdoc/ps_guide.ps文件中的表中的‘E’代表那一列的所有符号都用这个方法输入。


6、gnuplot画等高线图

gnuplot>splot ‘文件名.dat’ u 1:2:3 w l %做三维图

gnuplot>set dgrid3d 100,100 %设置三维图表面的网格的数目

gnuplot>replot

gnuplot>set contour %设置画等高线

gnuplot>set cntrparam levels incremental -0.2,0.01,0.2 %设置等高线的疏密和范围,数据从 -0.2到0.2中间每隔0.01画一条线

gnuplot>unset surface 去掉上面的三维图形

最后用鼠标拽动图形,选择合理的角度即可。或者直接设置(0,0)的视角也可以:

gnuplot>set view 0,0

gnuplot>replot



这里注意,画三维图的数据文件必须是分块的,也就是x每变换一个值,y在其变化范围内变化一周,这样作为一块,然后再取一个x值,y再变化一周,作为下一数据块,等等。块与块之间用一空行格开。



7、如何画漂亮的pm3d图

gnuplot> set pm3d %设置pm3d模式

gnuplot> set isosamples 50,50 %设置网格点

gnuplot> splot x**2+y**2 %画三维图

gnuplot> splot x**2+y**2 w pm3d %画成pm3d模式,注意比较变化

gnuplot> set view 0,0 %设置视角,(0,0)将投影到底面上去

gnuplot> splot x**2+y**2 w pm3d %重画,注意看变化

gnuplot> unset ztics %把z轴上的数字给去掉

gnuplot> set isosamples 200,200 %使网格变细

gnuplot> replot %重画,注意看变化,主要是过渡更光滑



8、利用脚本文件避免重复输入

有时候对某个数据文件做好一张图后,下次可能还要利用这个数据文件作图,但某个或某些设置要作些细微变化。这时候,可以把第一次作图时的命令全部写到一个文件里,如a.plt,下次只要将相应的设置做修改后,用下面的命令就会自动运行文件所有的命令而最后得到你要的图:

gnuplot>load ‘a.plt’

作为一个例子,假设文件名为a.plt,里面的内容为:

set pm3d

set view 0,0

unset ztics

set isosamples 200,200

splot x**2+y**2 w pm3d

set term post color

set output ‘a.ps’

replot



那么启动gnuplot后,只要运行如下命令就可以了:

gnuplot>load ‘a.plt’



如果我们要得到的仅仅是.ps或.eps图,那也可以在linux命令提示符下直接运行如下命令:

[zxh@theory zxh]$gnuplot a.plt



9、在gnuplot模式下运行linux命令

在gnuplot提示符下也可以运行linux命令,但必须在相应的命令前面加上 ! 号。例如,假设很多参量都已经设置好了,但需要对某个数据文件a.dat进行修改后再画图,则可以用如下方式

gnuplot>!vi a.dat

通过这种方式,所有的linux命令都可以在gnuplot环境里运行。



另外,也可以在gnuplot的提示符后输入shell,暂时性退出gnuplot,进入linux环境,做完要做的事情后,运行exit命令,又回到gnuplot环境下。

gnuplot>shell

[zxh@theory zxh]$vi a.f

[zxh@theory zxh]$f77 a.f

[zxh@theory zxh]$a.out (假设生成a.dat数据文件)

[zxh@theory zxh]$exit

gnuplot>plot ‘a.dat’ w l

jeudi 17 juin 2010

gnuplot速查






http://gnuplot-tricks.blogspot.com/2009/05/gnuplot-tricks-many-say-that-it-is.html

gnuplot

set logscale x 10
set format x "10^{%L}"
set title 'Turbulence Boundary Layer'
set xlabel 'y+'
set ylabel 'U+'
set xrange [1:1e+04]
set grid

set key top left
set key box
plot 'boundary_vlaw.dat' title 'Van Driest profile' with line
replot 'boundary_line.dat' title 'Visc.' with line
replot 'boundary_log.dat' title 'Log.' with line
replot 'Uplus-zplus.dat' title 'Exp.'

set term png
set output 'bl.png'
replot

mardi 15 juin 2010

latex figure

\usepackage[subfigure]{graphfig}
\usepackage{subfigure}


方法1:基本方法
\begin{figure}[htbp]
\centering
\includegraphics[width=0.7\textwidth]{manip_4}\\
\caption{123}
\label{fig:test-section}
\end{figure}

方法2:
\begin{Figure}[h]{Cascade}[fig:cascade]
\graphfile[40]{manip_1}[]
\graphfile[40]{manip_2}[]\\
\graphfile[40]{manip_3}[]
\graphfile[40]{manip_4}[]
\end{Figure}

方法3:
\begin{figure}[htbp]
\centering
\subfigure[Blade with surface pressure ports - distant view]{
\label{fig:pressure_ports_1} %% label for first subfigure
\includegraphics[width=0.5\textwidth]{position-pressure-ports-1}}\\
\subfigure[Bade with surface pressure ports - close view]{
\label{fig:pressure_ports_2} %% label for first subfigure
\includegraphics[width=0.5\textwidth]{position-pressure-ports-2}}\\
\subfigure[Location of the surface pressure ports on the blade]{
\label{fig:pressure_ports_3} %% label for first subfigure
\includegraphics[width=0.6\textwidth]{position-pressure-ports-3}}
\caption{Pressure ports on the balde}
\label{fig:results}
\end{figure}

latex multicols

\usepackage{multicol}


\begin{multicols}{2}

\end{multicols}

lundi 14 juin 2010

latex模板之一

\documentclass[a4paper,10pt,fleqn]{article}
\linespread{1.15}
\usepackage[hmargin={2.0 cm,2.0 cm},vmargin={2.0cm,2cm}]{geometry}
%\usepackage{subeqn}
%\usepackage{overrightarrow}
\usepackage{amsmath,amssymb}
\usepackage{wasysym}
\usepackage{colortbl}
\usepackage{graphicx,float}
\usepackage{multicol}
\usepackage{multirow,tabularx}
\usepackage{subfigure}
\usepackage{cite}
%\usepackage{units} %\nicefrac{}{}
\usepackage{titling}
\usepackage{indentfirst}
\usepackage{authblk}
\usepackage{mathrsfs} %\mathscr{ABCD..}
\usepackage{CJK}

\begin{document}

\title{\Large{PIV Post-Processing Equations}}
\author{\normalsize{MA Wei}}
\date{\today}
\maketitle
%\begin{abstract}
%\end{abstract}

\section{Velocity}

$u_n; v_n; w_n; \vert{v}\vert_n= \sqrt{u_n^2+v_n^2+w_n^2}$

\section{Ensemble average of velocity}
velocity = mean velocity + fluctuation velocity
\begin{equation}
u_n=U+{u_n}^{'};
v_n=V+{v_n}^{'};
w_n=W+{w_n}^{'};
\vert{v}\vert_n =\vert{V}\vert+\vert{v}\vert_n^{'}
\end{equation}

\begin{equation}
U=\dfrac{1}{N}\displaystyle \sum_{n=1}^N u_n;
V=\dfrac{1}{N}\displaystyle \sum_{n=1}^N v_n;
W=\dfrac{1}{N}\displaystyle \sum_{n=1}^N w_n
\end{equation}

\begin{equation}
\begin{array}{rcl}
\vert{V}\vert & = & \dfrac{1}{N}\displaystyle \sum_{n=1}^N\overrightarrow{v}_n
= \dfrac{1}{N}\displaystyle \sum_{n=1}^N\left( \sqrt{u_n^2+v_n^2+w_n^2}\right)
= \sqrt{ \left({\dfrac{1}{N}\displaystyle \sum_{n=1}^N u_n}\right)^2
+\left({\dfrac{1}{N}\displaystyle \sum_{n=1}^N v_n}\right)^2
+\left({\dfrac{1}{N}\displaystyle \sum_{n=1}^N w_n}\right)^2 }\\
& = & \sqrt{U^2+V^2+W^2}
\end{array}
\end{equation}

\section{RMS (Root-Mean-Square) of fluctuation velocity}
\begin{equation}
\begin{array}{rcl}
u^{'}_{rms}&=&\sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(u_n^{'})^2}=\sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(u_n-U)^2}
= \sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(u_n^2-2u_iU+U^2)}
= \sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(u_n^2-U^2)} \\
v^{'}_{rms}&=&\sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(v_n^{'})^2}=\sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(v_n-V)^2}
= \sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(v_n^2-2v_iV+V^2)}
= \sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(v_n^2-V^2)} \\
w^{'}_{rms}&=&\sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(w_n^{'})^2}=\sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(w_n-W)^2}
= \sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(w_n^2-2w_iW+W^2)}
= \sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(w_n^2-W^2)} \\
\vert{v}\vert^{'}_{rms}&=&\sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(\vert{v}\vert_n^{'})^2}
= \sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(\vert{v}\vert_n-\vert{V}\vert)^2}
= \sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(\vert{v}\vert_n^2-\vert{V}\vert^2)}\\
&=&\sqrt{\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}\biggr((u_n^2-U^2)+(v_n^2-V^2)+(w_n^2-W^2)\biggr)}\\
&=&\sqrt{(u^{'}_{rms})^2+(v^{'}_{rms})^2+(w^{'}_{rms})^2}
\end{array}
\end{equation}

\section{Reynolds stress}
\begin{equation}
\begin{array}{rcl}
\tau_{xy}&=&\dfrac{1}{N}\displaystyle{\sum_{n=1}^N\biggr( (u_n-U)(v_n-V)\biggr) }
=\dfrac{1}{N}\displaystyle{\sum_{n=1}^N\left( u_n^{'}v_n^{'}\right)}\\
\tau_{xz}&=&\dfrac{1}{N}\displaystyle{\sum_{n=1}^N\biggr( (u_n-U)(w_n-W)\biggr) }
=\dfrac{1}{N}\displaystyle{\sum_{n=1}^N\left( u_n^{'}w_n^{'}\right)}\\
\tau_{yz}&=&\dfrac{1}{N}\displaystyle{\sum_{n=1}^N\biggr( (v_n-V)(w_n-W)\biggr) }
=\dfrac{1}{N}\displaystyle{\sum_{n=1}^N\left( v_n^{'}w_n^{'}\right)}\\
\tau_{xx}&=&\dfrac{1}{N}\displaystyle{\sum_{n=1}^N\biggr( (u_n-U)(u_n-U)\biggr) }
=\dfrac{1}{N}\displaystyle{\sum_{n=1}^N ( u_n^{'})^2}
=(u^{'}_{rms})^2 \\
\tau_{yy}&=&\dfrac{1}{N}\displaystyle{\sum_{n=1}^N\biggr( (v_n-V)(v_n-V)\biggr) }
=\dfrac{1}{N}\displaystyle{\sum_{n=1}^N ( v_n^{'})^2}
=(v^{'}_{rms})^2\\
\tau_{zz}&=&\dfrac{1}{N}\displaystyle{\sum_{n=1}^N\biggr( (w_n-W)(w_n-W)\biggr) }
=\dfrac{1}{N}\displaystyle{\sum_{n=1}^N ( w_n^{'})^2}
=(w^{'}_{rms})^2
\end{array}
\end{equation}

\section{Kinetic energy}
Average kinetic energy:
\begin{equation}
E_{ake}=\vert{V}\vert^2=U^2+V^2+W^2
\end{equation}
Turbulent kinetic energy:
\begin{equation}
\begin{array}{rcl}
k&=&\dfrac{1}{2}\biggr( \dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(u_n^{'})^2 +
\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(v_n^{'})^2 +
\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(w_n^{'})^2 \biggr)\\
&=&\dfrac{1}{2}\biggr( \tau_{xx}+\tau_{yy}+\tau_{zz} \biggr) \\
&=&\dfrac{1}{2}\biggr( (u^{'}_{rms})^2+(v^{'}_{rms})^2+(w^{'}_{rms})^2 \biggr) \\
&=&\dfrac{1}{2}(\vert{v}\vert^{'}_{rms} )^2

\end{array}
\end{equation}

\section{Turbulence intensity $Tu$}
\begin{equation}
\begin{array}{rcl}
Tu &=& \dfrac{\sqrt{\dfrac{1}{3} \biggr( \dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(u_n^{'})^2 +
\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(v_n^{'})^2 +
\dfrac{1}{N}\displaystyle{\sum_{n=1}^N}(w_n^{'})^2 \biggr) }}
{\vert{V}\vert_{\infty}}\\
&=& \dfrac{\sqrt{\dfrac{2}{3} k }}{\vert{V}\vert}
= \dfrac{\sqrt{\dfrac{2}{3} k }}{\sqrt{U^2+V^2+W^2}}
\end{array}
\end{equation}

\section{Vorticity } %$\overrightarrow{\omega}$
\begin{equation}
\overrightarrow{\omega}={\overrightarrow{\nabla}}\times{\overrightarrow{v}}=
\left\vert \begin{array}{ccc}
\overrightarrow{i} & \overrightarrow{j} & \overrightarrow{n} \\
\dfrac{\partial}{\partial x} & \dfrac{\partial}{\partial y} & \dfrac{\partial}{\partial z} \\
u & v & w
\end{array} \right\vert
= \overrightarrow{i}(\dfrac{\partial{w}}{\partial{y}}-\dfrac{\partial{v}}{\partial{z}})
+\overrightarrow{j}(\dfrac{\partial{u}}{\partial{z}}-\dfrac{\partial{w}}{\partial{x}})
+\overrightarrow{k}(\dfrac{\partial{v}}{\partial{x}}-\dfrac{\partial{u}}{\partial{y}})
\end{equation}
\begin{equation}
\begin{array}{rcl}
\omega_x=\dfrac{\partial{w}}{\partial{y}}-\dfrac{\partial{v}}{\partial{z}};
\omega_y=\dfrac{\partial{u}}{\partial{z}}-\dfrac{\partial{w}}{\partial{x}};
\omega_z=\dfrac{\partial{v}}{\partial{x}}-\dfrac{\partial{u}}{\partial{y}}
\end{array}
\end{equation}

\section{Q criterion}
\begin{equation}
Q=\dfrac{1}{2}\left(\vert \vert \mathbf{\Omega} \vert \vert ^2 -\vert\vert
\mathbf{S} \vert\vert^2\right)=\dfrac{1}{2}\left( {\Omega_{ij}\Omega_{ij}} -
{S_{ij}S_{ij}} \right) > 0
\end{equation}
Where $\vert \vert \mathbf{\Omega} \vert \vert=tr[\mathbf{\Omega}\mathbf{\Omega}^t]^{1/2}$ and $\vert \vert \mathbf{S} \vert
\vert=tr[\mathbf{S}\mathbf{S}^t]^{1/2}$; $S$ and $\Omega$ are the synnetric and antisymmetric components of $\nabla u$ defined as
$\mathbf{S}=1/2[\nabla u+(\nabla u)^t]$ and $\mathbf{\Omega}= 1/2[\nabla u-(\nabla u)^t]$ respectively. Usually $\mathbf{S}$ is called the
rate-of-strain tensor, while $\mathbf{\Omega}$ is called the vorticity tensor.
\begin{equation}
\mathbf{S}=S_{ij}=\dfrac{1}{2}\left( \dfrac{\partial{u_i}}{\partial{x_j}}+\dfrac{\partial{u_j}}{\partial{x_i}} \right)
= \left[ \begin{array}{ccc}
\dfrac{\partial{u}}{\partial{x}} &
\dfrac{1}{2} \left( \dfrac{\partial{u}}{\partial{y}} +\dfrac{\partial{v}}{\partial{x}} \right) &
\dfrac{1}{2} \left( \dfrac{\partial{u}}{\partial{z}} +\dfrac{\partial{w}}{\partial{x}} \right) \\
\dfrac{1}{2} \left( \dfrac{\partial{u}}{\partial{y}} +\dfrac{\partial{v}}{\partial{x}} \right) &
\dfrac{\partial{v}}{\partial{y}} &
\dfrac{1}{2} \left( \dfrac{\partial{v}}{\partial{z}} +\dfrac{\partial{w}}{\partial{y}} \right) \\
\dfrac{1}{2} \left( \dfrac{\partial{u}}{\partial{z}} +\dfrac{\partial{w}}{\partial{x}} \right) &
\dfrac{1}{2} \left( \dfrac{\partial{v}}{\partial{z}} +\dfrac{\partial{w}}{\partial{y}} \right) &
\dfrac{\partial{w}}{\partial{z}}
\end{array} \right]
\end{equation}

\begin{equation}
\mathbf{\Omega}=\Omega_{ij}=\dfrac{1}{2}\left( \dfrac{\partial{u_i}}{\partial{x_j}}-\dfrac{\partial{u_j}}{\partial{x_i}} \right)
= \left[ \begin{array}{ccc}
0 &
\dfrac{1}{2} \left( \dfrac{\partial{u}}{\partial{y}} -\dfrac{\partial{v}}{\partial{x}} \right) &
\dfrac{1}{2} \left( \dfrac{\partial{u}}{\partial{z}} -\dfrac{\partial{w}}{\partial{x}} \right) \\
\dfrac{1}{2} \left( \dfrac{\partial{u}}{\partial{y}} -\dfrac{\partial{v}}{\partial{x}} \right) &
0 &
\dfrac{1}{2} \left( \dfrac{\partial{v}}{\partial{z}} -\dfrac{\partial{w}}{\partial{y}} \right) \\
\dfrac{1}{2} \left( \dfrac{\partial{u}}{\partial{z}} -\dfrac{\partial{w}}{\partial{x}} \right) &
\dfrac{1}{2} \left( \dfrac{\partial{v}}{\partial{z}} -\dfrac{\partial{w}}{\partial{y}} \right) &
0
\end{array} \right]
\end{equation}
\section{$\Delta$ criterion}
\begin{equation}
\Delta=\left(\dfrac{Q}{3}\right)^3+\left(\dfrac{det(\nabla u)}{2}\right)^2 > 0
\end{equation}

\section{$\lambda$ criterion}
\begin{equation}
\lambda_2 \left( \mathbf{S}^2+\mathbf{\Omega}^2 \right) <>
\end{equation}
where $\lambda_2(\mathbf{A})$ denotes the intermediate eigenvalue of a symmetric tensor $\mathbf{A}$.

\section{Turbulence dissipation rate $\epsilon$}
\begin{equation}
\epsilon=2\nu\overline{s_{ij}^{'}s_{ij}^{'}}
\end{equation}
where $\nu$ is kinematic viscosity.

\begin{equation}
s_{ij}^{'}=\dfrac{1}{2}\left( \dfrac{\partial{u_i^{'}}}{\partial{x_j}}+\dfrac{\partial{u_j^{'}}}{\partial{x_i}} \right)
= \left[ \begin{array}{ccc}
\dfrac{\partial{u^{'}}}{\partial{x}} &
\dfrac{1}{2} \left( \dfrac{\partial{u^{'}}}{\partial{y}} +\dfrac{\partial{v^{'}}}{\partial{x}} \right) &
\dfrac{1}{2} \left( \dfrac{\partial{u^{'}}}{\partial{z}} +\dfrac{\partial{w^{'}}}{\partial{x}} \right) \\
\dfrac{1}{2} \left( \dfrac{\partial{u^{'}}}{\partial{y}} +\dfrac{\partial{v^{'}}}{\partial{x}} \right) &
\dfrac{\partial{v^{'}}}{\partial{y}} &
\dfrac{1}{2} \left( \dfrac{\partial{v^{'}}}{\partial{z}} +\dfrac{\partial{w^{'}}}{\partial{y}} \right) \\
\dfrac{1}{2} \left( \dfrac{\partial{u^{'}}}{\partial{z}} +\dfrac{\partial{w^{'}}}{\partial{x}} \right) &
\dfrac{1}{2} \left( \dfrac{\partial{v^{'}}}{\partial{z}} +\dfrac{\partial{w^{'}}}{\partial{y}} \right) &
\dfrac{\partial{w^{'}}}{\partial{z}}
\end{array} \right]
\end{equation}

\section{Kolmogorov scale (dissipative scale) $\eta$, energy-containing scale $L$ and Taylor scale $\lambda$, $Re_\lambda$, $Re_L$}
\begin{equation}
\eta \sim \left(\dfrac{\nu^3}{\epsilon}\right)^{1/4}
\end{equation}
\begin{equation}
L \sim \dfrac{k^{3/2}}{\epsilon}
\end{equation}
\begin{equation}
\lambda \sim 15^{1/2}L^{1/3}\eta^{2/3}
\end{equation}
\begin{equation}
Re_\lambda=15^{1/2}\left( \dfrac{L}{\eta} ^{2/3}\right)
\end{equation}
\begin{equation}
Re_L=\dfrac{1}{15}Re_\lambda^2
\end{equation}

\section*{Equation}
\begin{equation}
S_{ij}S{ij}=\displaystyle{\sum_{j=1}^3}\displaystyle{\sum_{i=1}^3}S_{ij}S_{ij}=
S_{11}S_{11}+S_{12}S_{12}+S_{13}S_{13}+S_{21}S_{21}+S_{22}S_{22}+S_{23}S_{23}+S_{31}S_{31}+S_{32}S_{32}+S_{33}S_{33}
\end{equation}


%\bibliography{../reference-mawei/cornerstall}
%\bibliographystyle{unsrt}
\end{document}

dimanche 13 juin 2010

rsync 备份数据

rsync -avzPO --delete SRC DEST

----------------------------------------------------------

rsync is a file transfer program capable of efficient remote update
via a fast differencing algorithm.

Usage: rsync [OPTION]... SRC [SRC]... DEST
or rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
or rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
or rsync [OPTION]... [USER@]HOST:SRC [DEST]
or rsync [OPTION]... [USER@]HOST::SRC [DEST]
or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect
to an rsync daemon, and require SRC or DEST to start with a module name.

rsync参数的具体解释如下:

-v, --verbose 详细模式输出
-q, --quiet 精简输出模式
-c, --checksum 打开校验开关,强制对文件传输进行校验
-a, --archive 归档模式,表示以递归方式传输文件,并保持所有文件属性,等于-rlptgoD
-r, --recursive 对子目录以递归模式处理
-R, --relative 使用相对路径信息
-b, --backup 创建备份,也就是对于目的已经存在有同样的文件名时,将老的文件重新命名为~filename。可以使用--suffix选项来指定不同的备份文件前缀。
--backup-dir 将备份文件(如~filename)存放在在目录下。
-suffix=SUFFIX 定义备份文件前缀
-u, --update 仅仅进行更新,也就是跳过所有已经存在于DST,并且文件时间晚于要备份的文件。(不覆盖更新的文件)
-l, --links 保留软链结
-L, --copy-links 想对待常规文件一样处理软链结
--copy-unsafe-links 仅仅拷贝指向SRC路径目录树以外的链结
--safe-links 忽略指向SRC路径目录树以外的链结
-H, --hard-links 保留硬链结
-p, --perms 保持文件权限
-o, --owner 保持文件属主信息
-g, --group 保持文件属组信息
-D, --devices 保持设备文件信息
-t, --times 保持文件时间信息
-S, --sparse 对稀疏文件进行特殊处理以节省DST的空间
-n, --dry-run现实哪些文件将被传输
-W, --whole-file 拷贝文件,不进行增量检测
-x, --one-file-system 不要跨越文件系统边界
-B, --block-size=SIZE 检验算法使用的块尺寸,默认是700字节
-e, --rsh=COMMAND 指定使用rsh、ssh方式进行数据同步
--rsync-path=PATH 指定远程服务器上的rsync命令所在路径信息
-C, --cvs-exclude 使用和CVS一样的方法自动忽略文件,用来排除那些不希望传输的文件
--existing 仅仅更新那些已经存在于DST的文件,而不备份那些新创建的文件
--delete 删除那些DST中SRC没有的文件
--delete-excluded 同样删除接收端那些被该选项指定排除的文件
--delete-after 传输结束以后再删除
--ignore-errors 及时出现IO错误也进行删除
--max-delete=NUM 最多删除NUM个文件
--partial 保留那些因故没有完全传输的文件,以是加快随后的再次传输
--force 强制删除目录,即使不为空
--numeric-ids 不将数字的用户和组ID匹配为用户名和组名
--timeout=TIME IP超时时间,单位为秒
-I, --ignore-times 不跳过那些有同样的时间和长度的文件
--size-only 当决定是否要备份文件时,仅仅察看文件大小而不考虑文件时间
--modify-window=NUM 决定文件是否时间相同时使用的时间戳窗口,默认为0
-T --temp-dir=DIR 在DIR中创建临时文件
--compare-dest=DIR 同样比较DIR中的文件来决定是否需要备份
-P 等同于 --partial
--progress 显示备份过程
-z, --compress 对备份的文件在传输时进行压缩处理
--exclude=PATTERN 指定排除不需要传输的文件模式
--include=PATTERN 指定不排除而需要传输的文件模式
--exclude-from=FILE 排除FILE中指定模式的文件
--include-from=FILE 不排除FILE指定模式匹配的文件
--version 打印版本信息
--address 绑定到特定的地址
--config=FILE 指定其他的配置文件,不使用默认的rsyncd.conf文件
--port=PORT 指定其他的rsync服务端口
--blocking-io 对远程shell使用阻塞IO
-stats 给出某些文件的传输状态
--progress 在传输时现实传输过程
--log-format=formAT 指定日志文件格式
--password-file=FILE 从FILE中得到密码
--bwlimit=KBPS 限制I/O带宽,KBytes per second
-h, --help 显示帮助信息

原始文件夹a -> 目标文件夹 b

1,a和b中都有的文件或文件夹
1,1 没有变动 -》不变
1,2 变动了 -》 copy并覆盖b中此文件
2,只有a中有的文件或文件夹 -》copy到b中
3,只有b中有的文件或文件夹 -> 在b中删除

subversion

(import) 导入数据到仓库中
svn import mytree http://localhost/svn/myproject -m "" --usename abc --password abc
将会拷贝目录mytree到版本库的svn/myproject

(check out, co) 创建一个新的包含数据的“工作拷贝”
为了开始处理版本库数据,你需要创建一个新的包含数据的“工作拷贝”,这是一个私有工作区。从Subversion版本库里“check out”出一个myproject_work目录的工作拷贝:

$ svn checkout http:/localhost/svn/myproject/ myproject_work

现在在myproject_work目录里有了一个版本库的个人拷贝,你可以编辑你的工作备份中的文件,并且提交到版本库。

(commit, ci)将新版本的文件提交到仓库中



(update)更新本地

要同步文件仓库和本地的副本,您可以执行 update 子命令。先进入本地副本的文件夹,然后运行
svn的update命令。语法如下:

$ cd project_dir
$ svn update

samedi 12 juin 2010

Solidworks

Fichier .easm
eDrawings

vendredi 11 juin 2010

GParted

硬盘管理工具

Ubuntu之开机检测硬盘

Ubuntu默认的设置是每开机30次就检测硬盘一次,这个对于笔记本用户来说有点频繁,对于台式机也很不爽。彻底关掉也不好。解决的方法如下:

如果想下次开机不检测硬盘,可以创建如下一个空白的文件即可。
$sudo touch /fastboot

如果想下次开机检测硬盘,可以创建如下一个空白文件。
$sudo touch /forcefsck

如果想每开机60次检测一次硬盘,用下面的命令。
$sudo tune2fs -c 60 /dev/sda11

如果想一周检测一次硬盘,用下面的命令。
$sudo tune2fs -i 1w /dev/sda11

如果想知道更多tune2fs命令的内容,用下面的命令。
$man tune2fs

jeudi 10 juin 2010

Latex中双列双行显示图片的方法

latex单栏文档需要显示四张图片(图片大小相当),形如

1 2
3 4

我找到方法了
\usepackage[subfigure]{graphfig}

\begin{Figure}{caption is four pictures.}[label]
\graphfile*[34]{img1.PNG}[img1]
\graphfile*[34]{img2.png}[img2]\\
\graphfile*[34]{img3.PNG}[img3]
\graphfile*[34]{img4.png}[img4]
\end{Figure}

说明:必须是Figure,不是figure;

\graphfile[图宽/行宽×100]{图形名}[子图标题]

\graphfile*[图高/行宽×100]{图形名}[子图标题]

可以用命令 \ref{label} 或 \ref{label:a} 引用组图或者子图。该宏包还有一个选项:AllowH,表示图形应出现在图形命令处,不能浮动。

使用该宏包还有一个好处,就是可以自动将图形水平居中,无须添加 \centering 命令或 center 环境。另外,不用注明图形确切尺寸,只要给出与行宽的百分比即可。

mercredi 9 juin 2010

.emacs 20100610

(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(blink-cursor-mode nil)
)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)

;;-----------------------------------------------------------------------------
;; to enable highlighting when searching
(setq search-highlight t)
;;to highlight matches when using serch-and-replace
(setq query-replace-highlight t)
;;用win+space为set-mark键,留出ctrl+space热键作为输入法
(global-set-key (kbd "C-SPC") 'nil)
(global-set-key (kbd "s-SPC") 'set-mark-command)
;;设置字体大小
(set-default-font "DejaVu Sans Mono-8")
;;在窗口左侧显示行号
(global-linum-mode t)
;;在状态栏(mode line)上显示行号
(setq column-number-mode t)
(setq line-number-mode t)
;;鼠标自动避开指针,如当你输入的时候,指针到了鼠标的位置,鼠标有点挡住视线了
(mouse-avoidance-mode 'animate)
;;指针不要闪
(blink-cursor-mode -1)
(transient-mark-mode 1)
;;当指针到一个括号时,自动显示所匹配的另一个括号
(show-paren-mode 1)
;;去掉烦人的警告铃声
(setq visible-bell nil)
;;去掉Emacs和gnus启动时的引导界面
(setq inhibit-startup-message t)
(setq gnus-inhibit-startup-message t)
;; 显示时间
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(display-time)
;;当前行高亮
(require 'hl-line)
(global-hl-line-mode t)
;;滚动条在窗口右侧
'(scroll-bar-mode (quote right))
;;在窗口的标题栏上显示文件名称
(setq frame-title-format "%n%F/%b")
;;允许emacs和外部其他程序的粘
(setq x-select-enable-clipboard t)
;;支持中键粘贴
(setq mouse-yank-at-point t)
;;所有的问题用y/n方式,不用yes/no方式
(fset 'yes-or-no-p 'y-or-n-p)
;;go-line快捷键
(global-set-key (kbd "M-g") 'goto-line)
;; 在行首 C-k 时,同时删除该行。
(setq-default kill-whole-line t)
;;保存前,删除当前buffer中行尾空格和TAB等whitespace
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;;(setq ansi-color-for-comint-mode t)使用shell,shell中没有乱码
(ansi-color-for-comint-mode-on)
;;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;; Add the directories to your load path
(add-to-list 'load-path "~/.emacs.d/")
;;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;;------------------------------------------------------------------------------
;; 启动时的屏幕大小
;;第一种方法,需要根据不同的电脑屏幕大小进行修正
;;第二种方法,思路很好,但是垂直方向(vert)超过了显示范围,需要修正
;;------------------------------------------------------------------------------
;;第一种方法
(setq default-frame-alist
(append '((top . 0)(left . 0)(width . 175)(height . 45))
default-frame-alist))
;;第二种方法
;(defun my-maximized-horz ()
; (interactive)
; (x-send-client-message
; nil 0 nil "_NET_WM_STATE" 32
; '(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
;(defun my-maximized-vert ()
; (interactive)
; (x-send-client-message
; nil 0 nil "_NET_WM_STATE" 32
; '(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
;(defun my-maximized ()
; (interactive)
; (x-send-client-message
; nil 0 nil "_NET_WM_STATE" 32
; '(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
; (interactive)
; (x-send-client-message
; nil 0 nil "_NET_WM_STATE" 32
; '(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
;(my-maximized)
;;-----------------------------------------------------------------------------
;; cursor-chg.el
;;-----------------------------------------------------------------------------
(require 'cursor-chg) ; Load this library
(change-cursor-mode 1) ; On for overwrite/read-only/input mode
(toggle-cursor-type-when-idle 1) ; On when idle
;;-----------------------------------------------------------------------------
;;调用smart-compile
;;-----------------------------------------------------------------------------
(require 'smart-compile)
(global-set-key [f7] 'smart-compile)
;;-----------------------------------------------------------------------------
;; add emacs-wiki
;;-----------------------------------------------------------------------------
;; Add the directories to your load path
;(add-to-list 'load-path "~/.emacs.d/emacs-wiki-2.72")
;;调用emacs-wiki
;(require 'emacs-wiki)
;(require 'emacs-wiki-menu)
;(load "emacs-wiki")
;;----------------------------------------------------------------------------
;; 调用tabbar,在head中显示打开文件列表
;;-----------------------------------------------------------------------------
(require 'tabbar)
(tabbar-mode t)
;;全部分在同一组
(setq tabbar-buffer-groups-function
(lambda ()
(list "All")))
;;----------------------------------------------------------------
;; add a buffer modification state indicator in the tab label,
;; and place a space around the label to make it looks less crowd
;;----------------------------------------------------------------
(defadvice tabbar-buffer-tab-label (after fixup_tab_label_space_and_flag activate)
(setq ad-return-value
(if (and (buffer-modified-p (tabbar-tab-value tab))
(buffer-file-name (tabbar-tab-value tab)))
(concat " + " (concat ad-return-value " "))
(concat " " (concat ad-return-value " ")))))
;; called each time the modification state of the buffer changed
(defun ztl-modification-state-change ()
(tabbar-set-template tabbar-current-tabset nil)
(tabbar-display-update))
;; first-change-hook is called BEFORE the change is made
(defun ztl-on-buffer-modification ()
(set-buffer-modified-p t)
(ztl-modification-state-change))
(add-hook 'after-save-hook 'ztl-modification-state-change)
;; this doesn't work for revert, I don't know
;;(add-hook 'after-revert-hook 'ztl-modification-state-change)
(add-hook 'first-change-hook 'ztl-on-buffer-modification)
;;----------------------------------------------------------------------------
;; 使用一个简单的 Elisp 函数
;;:如果选定了区域,那么按 M-w 就复制这个区域;如果没有选定区域,那么 M-w 就复制一行
;;-----------------------------------------------------------------------------
(defun huangq-kill-ring-save (&optional n)
"If region is active, copy region. Otherwise, copy line."
(interactive "p")
(if mark-active
(kill-ring-save (region-beginning) (region-end))
(if (> n 0)
(kill-ring-save (line-beginning-position) (line-end-position n))
(kill-ring-save (line-beginning-position n) (line-end-position)))))

(global-set-key (kbd "M-w") 'huangq-kill-ring-save)

;;-----------------------------------------------------------------------------
;;备份设置
;;-----------------------------------------------------------------------------
;;emacs还有一个自动保存功能,默认在~/.emacs.d/auto-save-list里,
;;这个非常有用,具体可以参见Sams teach yourself emacs in 24hours(我简称为sams24)
;;启用版本控制,即可以备份多次
(setq version-control t)
;;备份最原始的版本两次,记第一次编辑前的文档,和第二次编辑前的文档
(setq kept-old-versions 2)
;;备份最新的版本五次,理解同上
(setq kept-new-versions 5)
;;删掉不属于以上7中版本的版本
(setq delete-old-versions t)
;;设置备份文件的路径
(setq backup-directory-alist '(("." . "~/.emacs.tmp")))
;;备份设置方法,直接拷贝
(setq backup-by-copying t)
;;-----------------------------------------------------------------------------
;; 快速在另外一个buffer中打开shell并cd 到当前 buffer 所在的目录
;;-----------------------------------------------------------------------------
(defun kid-switch-to-shell ()
(interactive)
(when (null (cdr (window-list)))
(split-window-horizontally))
(let ((file buffer-file-name))
(other-window 1)
(shell)
(when file
(end-of-buffer)
(when (looking-back shell-prompt-pattern)
(insert "cd " (file-name-directory file))
(call-interactively 'comint-send-input)))))
(global-set-key (kbd "") 'kid-switch-to-shell)
;;-----------------------------------------------------------------------------
;; occur
;;-----------------------------------------------------------------------------
(defun occur-fortran ()
(interactive )
(setq mawei "\\(?:\\\\|\\\\|\\\\|\\\\|\\\\|\\\\)")
(occur mawei)
;(occur (regexp-opt '("program""subroutine""function""call")))
)
(global-set-key (kbd "") 'occur-fortran)
;;-----------------------------------------------------------------------------
;; 每当我在 M-x shell启动shell,然后执行 exit 退出 shell 之后,buffer 并不自动关闭,很不爽,
;; 下面的指令,可以让其自动关闭。
;;-----------------------------------------------------------------------------
(add-hook 'shell-mode-hook 'wcy-shell-mode-hook-func)
(defun wcy-shell-mode-hook-func ()
(set-process-sentinel (get-buffer-process (current-buffer))
#'wcy-shell-mode-kill-buffer-on-exit)
)
(defun wcy-shell-mode-kill-buffer-on-exit (process state)
(message "%s" state)
(if (or
(string-match "exited abnormally with code.*" state)
(string-match "finished" state))
;(kill-buffer (current-buffer))))
(kill-buffer-and-window )))
;;-----------------------------------------------------------------------------
;; 当前buffer的文件名,前加“./”,后去掉后面4位数字,输入到minibuffer
;;-----------------------------------------------------------------------------
;(define-key minibuffer-local-map [f8]
;(lambda ()
;(interactive)
;(insert (concat "./") )
;(insert (substring (buffer-name (current-buffer-not-mini)) 0 -4 ))
;(insert (concat ".exe") )
;)
;)
;
;(defun current-buffer-not-mini ()
;"Return current-buffer if current buffer is not the *mini-buffer*
;else return buffer before minibuf is activated."
;(not (window-minibuffer-p)) (current-buffer)
;(if (eq (get-lru-window) (next-window))
;(window-buffer (previous-window)) (window-buffer (next-window))))

;;------------------------------------------------------------------------------
;; auto-complete
;; -----------------------------------------------------------------------------
;; Add the directories to your load path
(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete)
;;(global-auto-complete-mode t)
;; if only use the line above, auto-complete-mode does not work in a lot of modes
;; for example LaTeX-mode
(add-hook 'f90-mode-hook 'auto-complete-mode)
(add-hook 'emacs-lisp-mode-hook 'auto-complete-mode)
(add-hook 'LaTeX-mode-hook 'auto-complete-mode)
(add-hook 'latex-mode-hook 'auto-complete-mode)
;; Use C-n/C-p to select candidates
;;(define-key ac-complete-mode-map "\M-n" 'ac-next)
;;(define-key ac-complete-mode-map "\M-p" 'ac-previous)
;; you can stop completion by pressing M-/.
;;(define-key ac-complete-mode-map "\M-TAB" 'ac-stop)
;; Completion by TAB
;;
;; Add following code to your .emacs.
;;
(define-key ac-complete-mode-map "\t" 'ac-complete)
(define-key ac-complete-mode-map "\r" nil)

;; Do What I Mean mode
;; -------------------
;;
;; If DWIM (Do What I Mean) mode is enabled,
;; the following features is available:
;;
;; a. TAB (ac-expand) behave as completion (ac-complete)
;; when only one candidate is left
;; b. TAB (ac-expand) behave as completion (ac-complete)
;; after you select candidate
;; c. Disapear automatically when you
;; complete a candidate.
;;
;; DWIM mode is enabled by default.
;; You can enable this feature by
;; setting `ac-dwim' to t.
;;
(setq ac-dwim t)
;;------------------------------------------------------------------------------
;; quit a frame the same way no matter what kind of frame you are on"
;;------------------------------------------------------------------------------
;;This method, when bound to C-x C-c, allows you to close an emacs frame the
;;same way, whether it's the sole window you have open, or whether it's
;;a "child" frame of a "parent" frame. If you're like me, and use emacs in
;;a windowing environment, you probably have lots of frames open at any given
;;time. Well, it's a pain to remember to do Ctrl-x 5 0 to dispose of a child
;;frame, and to remember to do C-x C-x to close the main frame (and if you're
;;not careful, doing so will take all the child frames away with it). This
;;is my solution to that: an intelligent close-frame operation that works in
;;all cases (even in an emacs -nw session).
;;(global-set-key "\C-x\C-c" 'ic) ;forward reference
(defun ic ()
"quit a frame the same way no matter what kind of frame you are on"
(interactive)
(if (eq (car (visible-frame-list)) (selected-frame))
;;for parent/master frame...
(if (> (length (visible-frame-list)) 1)
;;close a parent with children present
(delete-frame (selected-frame))
;;close a parent with no children present
(save-buffers-kill-emacs))
;;close a child frame
(delete-frame (selected-frame))))
;;------------------------------------------------------------------------------
;; hithlight-80+:
;;------------------------------------------------------------------------------
;;(add-to-list 'load-path "~/.emacs.d/")
;;(global-highlight-80+-mode t)
(require 'highlight-80+)
(add-hook 'f90-mode-hook 'highlight-80+-mode)
;;------------------------------------------------------------------------------
;; 自动补全括号
;; 输入左边的括号,就会自动补全右边的部分.包括(), "", [] , {} , 等等。
;;------------------------------------------------------------------------------
(defun auto-pair ()
(interactive)
(make-local-variable 'skeleton-pair-alist)
(setq skeleton-pair-alist '(
(\"_"\"")
(\'_"'")
(\(")")
(\[_"]")
(\{_"}")
;(?\{?_"}")
))
(setq skeleton-pair t)
(local-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "'") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "[") 'skeleton-pair-insert-maybe))
(add-hook 'f90-mode-hook 'auto-pair)
(add-hook 'latex-mode-hook 'auto-pair)
(add-hook 'LaTeX-mode-hook 'auto-pair)
;;------------------------------------------------------------------------------
;; redo/undo
;;------------------------------------------------------------------------------
(require 'redo)
(global-set-key (kbd "C-/") 'undo)
(global-set-key (kbd "M-/") 'redo)

;;------------------------------------------------------------------------------
;; flyspell.el
;;
;; flyspell is an Emacs package that highlights misspelld words as you type;
;; Remark:
;; `flyspell-mode' uses `ispell-mode'. Thus all Ispell options are
;; valid. For instance, a personal dictionary can be used by
;; invoking `ispell-change-dictionary'.
;;
;; ispell-program-name = "aspell"
;; ispell-aspell-dict-dir = "/usr/lib/aspell"
;;------------------------------------------------------------------------------
;; enable flyspell-mode (minor mode) in latex-mode (major mode)
(add-hook 'latex-mode-hook 'flyspell-mode) ;; for latex
(add-hook 'LaTeX-mode-hook 'flyspell-mode) ;;for AUCtex
;; enable flyspell-prog-mode (minor mode) in f90-mode (major mode)
;; (add-hook 'f90-mode-hook 'flyspell-prog-mode)
(setq ispell-local-dictionary "american")
;;(setq ispell-local-dictionary "french")


;;------------------------------------------------------------------------------
;; for LaTeX-mode-hook, both latex and AUCtex
;;------------------------------------------------------------------------------

;; If you want to make AUCTeX aware of style files and multi-file
;; documents right away, insert the following in your `.emacs' file.
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)

;; To turn RefTeX Mode on and off in a particular buffer, use `M-x
;; reftex-mode'. To turn on RefTeX Mode for all LaTeX files, add the
;; following lines to your `.emacs' file:
(add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
(add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
(add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with Emacs latex mode

AUCTex outline-minor-mode

show-entry
hide-entry
显示或者隐藏鼠标所在的section, subsection, subsubsection本身

show-subtree
hide-subtree
显示或者隐藏鼠标所在的section, subsection, subsubsection以及其所包含的单元。

show-all
hide-body
显示或者隐藏整个文件

hide-other
隐藏其他部分,只显示鼠标所在的section, subsection, subsubsection

hide-leaves (=hide-entre)
显示或者隐藏鼠标所在的section, subsection, subsubsection本身

hide-subleves
只显示section, subsection, subsubsection名称,不显示细节

show-children
Show all direct subheadings of this heading.



install Emacs

use Synaptic Package Manager install:
Emacs 23
AUCtex

mardi 8 juin 2010

latex编译命令

for example thesis.tex

latex thesis.tex -> thesis.dvi
latex thesis.tex -> thesis.dvi
bibtex thesis
latex thesis.tex -> thesis.dvi
dvi2ps thesis.dvi ->thesis.ps
ps2pdf thesis.ps -> thesis.pdf

mercredi 2 juin 2010

Procedure to mount ISO images under Linux

Procedure to mount ISO images under Linux

1) You must login as a root user, if not root user then switch to root user using following command:
$ su -

2) Create the directory i.e. mount point:
# mkdir -p /mnt/disk

3) Use mount command as follows to mount iso file called disk1.iso:
# mount -o loop disk1.iso /mnt/disk

4) Change directory to list files stored inside an ISO image:
# cd /mnt/disk
# ls -l

mardi 1 juin 2010

Using Intel Compilers for Linux with Ubuntu


Published On : June 1, 2010 1:20 AM PDT

rev history:
29 April 2010: This guide also applies to Ubuntu 10.04.

rev history:
2009 November 3: added notes for Ubuntu 9.10

Note: Newer versions of this linux distribution may NOT be officially supported by Intel Compiler Professional Editions 11.1. Please see your ReleaseNotes document with your compiler to find the support Linux distributions and versions. These instructions are merely to help install the compiler, keep in mind that versions of this distribution NOT in the ReleaseNotes document are NOT tested nor supported. You are on your own here.

Introduction :


Using Intel(R) Compilers version 11.1 under Ubuntu (10.04, 9.10, 9.04, 8.04 and 8.10) Desktop and Debian Desktop

For older Ubuntu and Debian versions, see THIS ARTICLE. Make sure to use the latest Intel Compilers version 11.1. Older compilers will not be compatible with the latest Ubuntu distributions. For compatibility and supported versions always read the ReleaseNotes document for your compiler.

These notes apply to Ubuntu Desktop. Ubuntu Server was not tested but should be similar.

2 November 2009: Ubuntu 10.04 and 9.10

For users of Ubuntu 10 and 9.10, follow the instructions here. If you have 9.04 or older, skip ahead to the section titled "Ubuntu 9.04 and Older"

BEFORE YOU INSTALL Intel(R) Fortran for Linux or Intel(R) C++ for Linux on your fresh Ubuntu Desktop installation, you will first need to install several packages to prepare the system to serve as a development platform. First, open a Terminal window and become root:
sudo bash
(type your user password)

At this point, you should have a root shell. Test this with command 'whoami' which should return "root"

Check that gcc is installed. By default. Check this with:

gcc --version

It should return "gcc (Ubuntu 4.4.1-4ubuntu8) 4.4.1 (or some newer version - as long as it returns a version you have gcc installed)

If, for some reason, you do not have gcc installed, use Synaptic Package Manager (under 'System' -> 'Administration' menus) OR use apt-get to install gcc:


apt-get install gcc


Next, install the 'build-essential' package and package g++. This is not installed by default. Again, use Synaptic Package Manager or apt-get :

apt-get install build-essential

this should also install g++, but in test this with:
g++ --version

if g++ is not found, install it:

apt-get install g++

A few other packages are required:
apt-get install rpm
apt-get install ia32-libs (this is only required on 64bit Ubuntu/Debian systems)

To use the Intel IDB graphical debugger, you will also need the Java JRE 5 or 6 installed. One way to get this is through Synaptic package manager. Open Synaptic and for sources enable Ubuntu's partner repository. Once that is done, use Synaptic to fetch the package sun-java6-jre.

We also recommend fetching the Sun JRE directly from Sun: get the latest JRE from:

http://java.com/en/download/manual.jsp

OR you can use the OpenJDK from the distribution:

apt-get install openjdk-6-jre-headless

Next, Ubuntu 9.10 Desktop does not provide libstdc++5, which is required for the Intel Compilers. You will have to get the package for libstdc++5 from an older Debian or Ubuntu distribution ( 9.04 for example ). A repository is here:

http://packages.debian.org/stable/base/libstdc++5

On this page, you will see the title "The GNU Standard C++ Library V3". Scrolling down, find the table for "Download libstdc++5".

9.10: For 32bit Ubuntu i386 libstdc++5 Installation:
For 32bit Ubuntu systems you will need to install the 32bit version of libstdc++5, that is, the "i386" package.
Select the download for the libstdc++5 package for "i386". Pick a mirror site to begin the download. If you are using Firefox, you will be prompted if you want to "Open with GDebi Package Installer" - select OK to continue. Otherwise, save the deb package and use your favorite package manager to install. Install the i386 libstdc++ deb package. SKIP the Intel 64 Libstdc++5 (AMD64) directions below and find the section on installing the compiler after prerequisites are installed.


9.10: For Intel 64 / AMD64 (64bit Linux installation) Libstdc++5:
follow these instructions IF AND ONLY IF you have a 64bit Ubuntu installation.

Intel 64 installation: Select the download for the libstdc++5 package for "amd64". If you are using Firefox, you will be prompted if you want to "Open with GDebi Package Installer" - select OK to continue. Otherwise, save the deb package and use your favorite package manager to install. Install the amd64 libstdc++ deb package.

by default, the 64bit libstdc++.so.5 library will install in /usr/lib which is linked to /usr/lib64.

Now, you also will need the 32bit libstdc++.so.5 installed in /usr/lib32. Unfortunately, the "i386" version of the libstdc++5 package wants to install in /usr/lib which is your 64bit library directory and where you just installed the "amd64" libraries - so you DON'T want to download and install the "i386" package into the default location.
We'll need to download the "i386" package to a temporary directory, use dpkg to extract the contents to the temp directory, then manually copy the library to /usr/lib32 and create the symbolic link:

First, download libstc++5 package for "i386" - save to disk and do NOT launch a package manger to install it. Save it in your 'Downloads' folder or /tmp (or any other scratch directory).
Using your root terminal window, cd to the directory where you have downloaded the .deb package, it should have a name similar to 'libstdc++5_3.3.6-18_i386.deb'. The exact version is not important, but make sure it is a "i386" deb package.
Extract to the local directory:

dpkg --extract libstdc++5_3.3.6-18_i386.deb ./

Notice that a 'usr/' folder was created and the package contents extracted here. Now we'll copy the library to /usr/lib32

cd usr/lib
cp libstdc++.so.5.0.7 /usr/lib32
cd /usr/lib32
ln -s libstdc++.so.5.0.7 libstdc++.so.5


9.10: Installing the Compiler Now That Prerequisities are Installed (32 and 64bit):

Once you've completed the above, extract your compiler .tgz kit, cd to the compiler installation directory, and run ./install.sh

During the installation, you WILL get a warning message "Detected operating system Debian* (generic) is not supported", followed by
----------------------------------------------------------------- ---------------
Missing optional pre-requisite
-- operating system type is not supported.
-- system glibc or kernel version not supported or not detectable
-- binutils version not supported or not detectable
----------------------------------------------------------------- ---------------
"Would you like to perform an unsupported install of this product [yes/no] (no)?"

enter "yes"

This will complete the installation. Keep in mind, you will get this warning from the compiler installer until such time as this particular OS and version are supported. Once installed, you can read the ReadMe notes in ...installdir.../Documentation directory which has a list of the supported Linux distributions and versions.


Debugger Notes:

Known Intel® IDB Debugger issues under Ubuntu:
1) Ubuntu 9.x versions, IA32 and Intel64 platforms:

- When loading an executable, a startup dialog may appear that should not. If this dialog, "Unable to locate source file “…/start.S – Do you like to search for it manually?” appears, click ‘No’ and continue normal debugging.

- Avoid using debug commands such as ‘next’, ‘step’ on the Console Window of the Debugger GUI since this may lead to unexpected behavior of the debugger; use the corresponding options ‘Continue’, Step Into’ etc. from the Run menu instead.

2) Ubuntu 9.10, IA32 and Intel64 platforms:

- You need to set the environment variable GDK_NATIVE_WINDOWS=1 to avoid a known bug in Eclipse delivered with Ubuntu 9.10. Add export GDK_NATIVE_WINDOWS=1
to your ~/.bashrc file or execute this command on command line:
export GDK_NATIVE_WINDOWS=1



Ubuntu 9.04 and Older:

In order to use Intel(R) Compilers ( Fortran or C++ ) under Ubuntu 9.04, 8.04 or 8.10 you will need the latest 11.0 or 10.1 version of the Intel compiler(s). Older 10.0 and 9.1 versions of the compilers may not work properly under Ubuntu 9.04, 8.04 or 8.10. Keep in mind that new versions of Ubuntu/Debian may not be OFFICIALLY supported by the Intel Compilers. Please see your ReleaseNotes document with your compiler version for a list of officially supported distributions and versions.

If you have active support for your compiler, you can download the latest Intel compiler version from
https://registrationcenter.intel.com

BEFORE YOU INSTALL Intel(R) Fortran for Linux or Intel(R) C++ for Linux on your fresh Ubuntu Desktop installation, you will first need to install several packages to prepare the system to serve as a development platform:

Check that gcc is installed. By default. Check this with:

gcc --version

By default, Ubuntu 8.04 Desktop installs gcc 4.2.3-2ubuntu7. 8.10 should have gcc 4.3.2, 9.04 gcc 4.3.3

If, for some reason, you do not have gcc installed, use Synaptic Package Manager (under 'System' -> 'Administration' menus) OR use apt-get to install gcc:


apt-get install gcc


Next, install g++. This is not installed by default. Again, use Synaptic Package Manager or apt-get to install package "g++"

apt-get install build-essential
apt-get install g++


Next, you need to install the 32bit compatibility library libstdc++.so.5. To do this, use apt-get or Synaptic Package Manager to retrieve and install package "libstdc++5"

apt-get install libstdc++5

This package may require installing another package as a prerequisite,
"gcc-3.3-base"

If so, go ahead and install this older gcc package.

For x86-64 architecture, you will also need a number of other packages, including package 'ia32-libs' to install the 32bit versions of libstdc++.so.5 in /usr/lib32 as well as 32bit header files in libc6-dev-i386. These notes apply to Ubuntu 9.04 but should also apply to 8.10 and 8.04

apt-get install ia32-libs
apt-get install lib32stdc++6
apt-get install libc6-dev-i386
apt-get install gcc-multilib
apt-get install g++-multilib


Finally, there is an optional package to consider: The 11.0 version of the Intel Compiler for Linux has a graphical
debugger, a new graphical interface for the IDB debugger. If you want to use this debugger, please make sure to install the Java JRE version 1.5 or greater. This can be done at anytime after the installation of the compiler. However, you will get a warning message about 'missing prerequisite' for the JRE - simply ignore that message and proceed with the installation. OR to avoid that message and enable the graphical IDE, get the latest JRE from:

http://java.com/en/download/manual.jsp

Once installation of prerequisites is complete, you are ready to start the Intel compiler(s) installation. During the installation, you may get a message "Detected operating system Debian* (generic) is not supported", followed by
----------------------------------------------------------------- ---------------
Missing optional pre-requisite
-- operating system type is not supported.
-- system glibc or kernel version not supported or not detectable
-- binutils version not supported or not detectable
----------------------------------------------------------------- ---------------
"Would you like to perform an unsupported install of this product [yes/no] (no)?"

enter "yes"

This will complete the installation. Keep in mind, you will get this warning from the compiler installer until such time as this particular OS and version are supported. Once installed, you can read the ReadMe notes in ...installdir.../Documentation directory which has a list of the supported Linux distributions and versions.


Using the Compiler:

The next step after installing the compiler is to set up the user environment to use the compiler and libraries. First, locate your documentation: it is installed in /Documentation/en_US (currently, US English is the language supported in the documentation). Under this directory, read the /Documentation/en_US/getting_started_f.pdf or getting_started_c.pdf document. Read how to use iccvars.sh or ifortvars.sh (or the .csh equivalents) to set your environment to use the compiler(s). You may wish to put the 'source ifortvars.....' command into your home startup scripts.

Next, use a browser to open /Documentation/en_US/documentation_f.htm or documentation_c.htm which is an index to the rest of the online documents. Browse the documents to familiarize yourself with their locations and contents.

Finishing up: Usage

Once the compilers are installed, it is necessary to source the ifortvars.sh or ifortvars.csh file to properly set the user environment to use the Intel compilers. This (these) commands can be placed in a user's ~/.bashrc or other system login file (fortran 11.1.046 example shown below, bash user):

64bit compiler selection:
source /opt/intel/Compiler/11.1/046/bin/ifortvars.sh intel64

32bit compiler selection:
source /opt/intel/Compiler/11.1/046/bin/ifortvars.sh ia32

C/C++ users: substitute "iccvars" for "ifortvars" above.

Other versions: substitute your actual minor version for "046" above.
Also, if you are a CSH or TCSH user, use ifortvars.csh or iccvars.csh as appropriate.

Need more help? Join our User Forums:
Fortran: http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/
C/C++: http://software.intel.com/en-us/forums/intel-c-compiler/