实习笔记三—-一种比md5更快的哈希算法。
实习笔记二----Mac一些处理崩溃的相关工具
实习笔记二—-Mac一些处理崩溃的相关小工具的用法介绍。
实习笔记一----Mac os 和ios内核学习笔记(mach exception相关)
实习笔记一—-学习Mac OS内核中对mach端口相关知识进行的整理总结
一个简单的面向对象有限元程序的开发
本程序使用C++编写,GUI界面使用Qt库,线性代数运算使用Eigen库,实现了二维桁架结构、钢架结构的通用有限元程序,能够计算静载荷下的位移,以及固有频率和固有振型。
一道结构动力学问题的多种方法求解
本文对一道悬臂梁的动力学响应问题进行了研究,分别实现了时域方法、时域和频域结合的方法、纯频域方法等多种数值方法,并对不同方法进行了比较。
哈密顿系统及保辛数值算法
It is natural to look forward to those discrete systems which preserve as much as possible the intrinsic properties of the continuous system. (Feng Kang 1985)
哈密顿系统与刘维尔定理
哈密顿系统通常可以写成这样的形式:
其中$p$为广义动量,$q$为广义坐标(这里为了简化没有写成向量的黑体)。
假设哈密顿系统是可分离的,也就是说,哈密顿函数可以写成下面的形式 \begin{equation} H(p,q)=T(p)+V(q) \end{equation} 这个是可以在大部分的哈密顿系统中满足,其中$T$就是动能,而$V$就是势能。
刘维尔定理:哈密顿系统的相流保持相体积不变。要证明刘维尔定理,只需要证明常微分方程组的散度为0,而这个是易证的。具体证明过程可以参考阿诺尔德的教材《经典力学的数学方法》,这里就不给出详细的证明过程了。那么我们还可以得到结论:哈密顿方程组在相空间中不可能有渐进稳定的点和渐进稳定的极限环。由刘维尔定理还可以推出庞加莱回归定理,具体表述也可以参考阿诺尔德的教材。
数值积分算法
我之前的讨论讨论了许多常用的积分算法,但是这些算法对于哈密顿系统而言有一个缺点:并不保辛。可以用一个直观的图片来反应这个现象: 像这样的一个哈密顿系统,起初在相流当中有一个图形,根据刘维尔定理经过变换后的图形的面积应该和原图形相等,然而欧拉算法、龙格库塔算法却没有出现这样的现象,因此我们需要保辛的算法。
分块龙格库塔算法
对于哈密顿方程,可以使用分块的龙格库塔算法: \begin{equation} P_i=p_0+h\sum_j a_{ij}k_j\quad Q_i=q_0h\sum_j \hat a_{ij}l_j \end{equation} \begin{equation} p_1=p_0+h\sum_i b_ik_i\quad q_1=q_0+h\sum_i \hat b_il_i \end{equation} \begin{equation} k_i=-\pypx{H}{Q}{P_i,Q_i}\quad l_i=\pypx{H}{p}(P_i,Q_i) \end{equation} 对于分块龙格库塔算法,有如下定理:如果上式中的系数满足: \begin{equation} b_i=\hat{b_i} \end{equation} \begin{equation}\label{cond1} b_i\hat a_{ij}+\hat b_j a_{ji}-b_i\hat b_j=0 \end{equation} 那么算法是保辛的。进一步,若哈密顿系统是可分离的,那么如果系数满足式(\ref{cond1})就说明算法是保辛的。因此,我们可以将系数用如下方式简化:
并令
则可以满足式(\ref{cond1}),直观的可以写成表格: 算法形式:
特殊情况是当$s=1$时,有分块欧拉方法 \begin{equation} p_1=p_0-h\pypx{U}{q}(q_0)\quad q_1=q_0+h\pypx{T}{p}(p_1) \end{equation} 交换$p,q$还可以得到 \begin{equation} q_1=q_0+h\pypx{T}{p}(p_0)\quad p_1=p_0-h\pypx{U}{q}(q_1) \end{equation} 上面两种算法是保辛且互为伴随的。
三阶的系数可以取
四阶的系数可以取
参考文献
【1】Symplectic integrator - Wikipedia感觉好像有地方有错
【2】Ernst Hairer, Syvert P. Nørsett, and Gerhard Wanner, Solving Ordinary Differential Equations I: Nonstiff Problems, 2nd ed. (Springer, Berlin, 2009).
【3】B.И.阿诺尔德, 阿诺尔德, 齐民友. 经典力学的数学方法[M]. 高等教育出版社, 2006.
【4】Haruo Yoshida, “Construction of higher order symplectic integrators,” Physics Letters A 150, no. 5 (November 12, 1990): 262-268.
【5】Forest, E.; Ruth, Ronald D. (1990). “Fourth-order symplectic integration”. Physica D. 43: 105.
用LaTeX画足球场与阵型
This post is showing how to draw a football field in LaTeX. The contents are all unoriginal.本文展示如何用LaTeX画足球场。(非原创)
谷歌到的关于这个的结果很少,但还是得到了答案。没有专门的宏包来绘制这个东西,不过可以用tikz宏包。
鸭子形状的球员
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{positioning, ducks}
\usepackage{tikzducks}
\newcommand{\croacia}[3]{
\begin{scope}[shift={#3}, xscale=-.4, yscale=.4]
\duck
\path[preaction={fill=red}, pattern=checkerboard, pattern color=white] \duckpathjacket;
\node[font=\sffamily\bfseries] at ([xshift=5mm]wing) {#1};
\node[font=\sffamily\bfseries] at (1.1,-.22) {#2};
\end{scope}
}
\newcommand{\france}[3]{
\begin{scope}[shift={#3}, scale=.4]
\duck[jacket=blue]
\node[font=\sffamily\bfseries] at ([xshift=5mm]wing) {#1};
\node[font=\sffamily\bfseries] at (1.1,-.22) {#2};
\end{scope}
}
\definecolor{field}{RGB}{0,156,0}
\newcommand\area[2]{
\begin{scope}[shift={(#1)}, transform shape, rotate=#2]
\node[minimum width=.55cm,minimum height=1.832cm, anchor=west] (small#2) at (0,0) {};
\node[minimum width=1.65cm,minimum height=4.032cm, anchor=west] (big#2) at (0,0) {};
\node[minimum width=.244cm, minimum height=.732cm, anchor=east] (goal#2) at (0,0) {};
\node[inner sep=.3mm, circle, fill=white] (penalty#2) at (1.1,0) {};
\begin{scope}
\tikzset{every path/.style={}}
\clip (big#2.south east) rectangle ++ (1,5);
\draw[white, very thick] (penalty#2) circle (0.915cm);
\end{scope}
\end{scope}
}
\begin{document}
\begin{tikzpicture}
\begin{scope}[%
every node/.style={draw=white, very thick, inner sep=0, outer sep=0},
every path/.style={draw=white, very thick},
]
\fill[field] (-1,-1) rectangle (13,10);
\node[minimum width=12cm, minimum height=9cm] (contour) at (6,4.5) {};
%\draw (contour.south west) grid (contour.north east);
% Center
\draw (contour.north) -- (contour.south);
\draw (contour.center) circle (0.915cm);
\fill[white] (contour.center) circle (.5mm);
% Areas
\area{contour.west}{0}
\area{contour.east}{180}
% Corners
\foreach \corner [count=\xi starting from 0] in {south west, south east, north east, north west}{
\begin{scope}[rotate around={90*\xi:(contour.\corner)}]
\draw ([xshift=1mm]contour.\corner) arc (0:90:1mm);
\end{scope}
}
\end{scope}
\croacia{23}{Subasic}{(1.25,4.25)}
\croacia{3}{Strinic}{(2.6,7.2)}
\croacia{21}{Vida}{(2.3,5.3)}
\croacia{6}{Lovren}{(2.3,2.9)}
\croacia{2}{Virsalijko}{(2.6,1)}
\croacia{11}{Brozovic}{(3.5,4.25)}
\croacia{4}{Perisic}{(4.5,7.2)}
\croacia{7}{Rakitic}{(4.5,5.25)}
\croacia{10}{Modric}{(4.5,3)}
\croacia{18}{Rebic}{(4.5,1)}
\croacia{17}{Mandzukic}{(5.6,4.25)}
\france{1}{Lloris}{(10.75,4.25)}
\france{2}{Pavard}{(9.5,7.2)}
\france{4}{Varane}{(9.5,5.3)}
\france{5}{Umtiti}{(9.5,2.9)}
\france{21}{Lucas}{(9.5,1)}
\france{13}{Kante}{(8.5,6)}
\france{6}{Pogba}{(8.5,2.3)}
\france{10}{Mbappe}{(7,7)}
\france{7}{Griezman}{(7.8,4.25)}
\france{14}{Matuidi}{(7,1.5)}
\france{9}{Giroud}{(6.4,4.25)}
\end{tikzpicture}
\end{document}
正常外形的球员
用的是tikzpeople
.这个不太容易给克罗地亚的队服加上格子花纹了。
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{positioning}
\usepackage{tikzmarmots}
\newcommand{\croacia}[3]{ \begin{scope}[shift={#3}, scale=.5] \marmot \path[preaction={fill=red}, pattern=checkerboard, pattern color=white] (1.35,0.71) .. controls (1.35,0.41) and (1.17,0.37) .. (0.92,0.37) .. controls (0.69,0.37) and (0.48,0.41) .. (0.48,0.71) .. controls (0.48,1.01) and (0.67,1.26) .. (0.91,1.26) .. controls (1.15,1.26) and (1.3 5,1.01) .. (1.35,0.71) -- cycle; \node[font=\sffamily\bfseries] at (0.95,0.82) {#1}; \node[font=\sffamily\bfseries] at (1.1,-.22) {#2}; \end{scope} }
\newcommand{\france}[3]{ \begin{scope}[shift={#3}, scale=.5] \marmot[body=brown!80!yellow] \path[fill=blue] (1.35,0.71) .. controls (1.35,0.41) and (1.17,0.37) .. (0.92,0.37) .. controls (0.69,0.37) and (0.48,0.41) .. (0.48,0.71) .. controls (0.48,1.01) and (0.67,1.26) .. (0.91,1.26) .. controls (1.15,1.26) and (1.3 5,1.01) .. (1.35,0.71) -- cycle; \node[font=\sffamily\bfseries] at (0.95,0.82) {#1}; \node[font=\sffamily\bfseries] at (1.1,-.22) {#2}; \end{scope} }
\definecolor{field}{RGB}{0,156,0}
\newcommand\area[2]{
\begin{scope}[shift={(#1)}, transform shape, rotate=#2]
\node[minimum width=.55cm,minimum height=1.832cm, anchor=west] (small#2) at (0,0) {};
\node[minimum width=1.65cm,minimum height=4.032cm, anchor=west] (big#2) at (0,0) {};
\node[minimum width=.244cm, minimum height=.732cm, anchor=east] (goal#2) at (0,0) {};
\node[inner sep=.3mm, circle, fill=white] (penalty#2) at (1.1,0) {};
\begin{scope}
\tikzset{every path/.style={}}
\clip (big#2.south east) rectangle ++ (1,5);
\draw[white, very thick] (penalty#2) circle (0.915cm);
\end{scope}
\end{scope}
}
\begin{document}
\begin{tikzpicture}
\begin{scope}[%
every node/.style={draw=white, very thick, inner sep=0, outer sep=0},
every path/.style={draw=white, very thick},
]
\fill[field] (-1,-1) rectangle (13,10);
\node[minimum width=12cm, minimum height=9cm] (contour) at (6,4.5) {};
%\draw (contour.south west) grid (contour.north east);
% Center
\draw (contour.north) -- (contour.south);
\draw (contour.center) circle (0.915cm);
\fill[white] (contour.center) circle (.5mm);
% Areas
\area{contour.west}{0}
\area{contour.east}{180}
% Corners
\foreach \corner [count=\xi starting from 0] in {south west, south east, north east, north west}{
\begin{scope}[rotate around={90*\xi:(contour.\corner)}]
\draw ([xshift=1mm]contour.\corner) arc (0:90:1mm);
\end{scope}
}
\end{scope}
\croacia{23}{Subasic}{(0.25,4.25)}
\croacia{3}{Strinic}{(1.6,7.2)}
\croacia{21}{Vida}{(1.3,5.3)}
\croacia{6}{Lovren}{(1.3,2.9)}
\croacia{2}{Virsalijko}{(1.6,1)}
\croacia{11}{Brozovic}{(2.5,4.25)}
\croacia{4}{Perisic}{(3.5,7.2)}
\croacia{7}{Rakitic}{(3.5,5.25)}
\croacia{10}{Modric}{(3.5,3)}
\croacia{18}{Rebic}{(3.5,1)}
\croacia{17}{Mandzukic}{(4.6,4.25)}
\france{1}{Lloris}{(10.75,4.25)}
\france{2}{Pavard}{(9.5,7.2)}
\france{4}{Varane}{(9.5,5.3)}
\france{5}{Umtiti}{(9.5,2.9)}
\france{21}{Lucas}{(9.5,1)}
\france{13}{Kante}{(8.5,6)}
\france{6}{Pogba}{(8.5,2.3)}
\france{10}{Mbappe}{(7,7)}
\france{7}{Griezman}{(7.8,4.25)}
\france{14}{Matuidi}{(7,1.5)}
\france{9}{Giroud}{(6.4,4.25)}
\end{tikzpicture}
\end{document}
七人制的一个阵型
只需要改一下一些坐标就行了。
绘制球场
\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, calc}
\definecolor{field}{RGB}{0,156,0}
\tikzset{
every node/.style={draw=white, very thick, inner sep=0, outer sep=0},
every path/.style={draw=white, very thick},
}
\newcommand\area[2]{
\begin{scope}[shift={(#1)}, transform shape, rotate=#2]
\node[minimum width=.55cm,minimum height=1.832cm, anchor=west] (small#2) at (0,0) {};
\node[minimum width=1.65cm,minimum height=4.032cm, anchor=west] (big#2) at (0,0) {};
\node[minimum width=.244cm, minimum height=.732cm, anchor=east] (goal#2) at (0,0) {};
\node[inner sep=.3mm, circle, fill=white] (penalty#2) at (1.1,0) {};
\begin{scope}
\tikzset{every path/.style={}}
\clip (big#2.south east) rectangle ++ (1,5);
\draw[white, very thick] (penalty#2) circle (0.915cm);
\end{scope}
\end{scope}
}
\newcommand\showmeasures{
\begin{scope}
\tikzset{every node/.style={draw=none,fill=field, inner sep=2pt, sloped}}
\draw[black, {Latex}-{Latex}] ($(contour.north west)+(0,.5)$) -- ($(contour.north east)+(0,.5)$) node[midway] {\textbf{Sideline:} min 90m - max 120m};
\draw[black, {Latex}-{Latex}] ($(contour.south west)+(-.6,0)$) -- ($(contour.north west)+(-.6,0)$) node[midway] {\textbf{Goal line:} min 45m - max 90m};
\draw[black, -{Latex}] (penalty0) --++ (-15:0.915cm) node[midway, above, font=\scriptsize, fill=none, yshift=2pt] {r = 9.15m};
\draw[black, {Latex}-{Latex}] ($(small0.south east)+(-.2,0)$) -- ($(small0.north east)+(-.2,0)$) node[midway,above, fill=none,font=\scriptsize] {18.32m};
\draw[black] ($(small0.north west)+(0,.2)$) -- ($(small0.north east)+(0,.2)$) node[midway, above, font=\scriptsize, fill=none, xshift=3pt] {5.50m};
\draw[black] (contour.south east) --++ (135:1mm) node[anchor=south east] {r = 1m};
\draw[black, {Latex}-{Latex}] ($(big180.south east)+(-.5,0)$) -- ($(big180.north east)+(-.5,0)$) node[midway,above, rotate=180,fill=none,font=\scriptsize] {40.32m};
\draw[black, {Latex}-{Latex}] ($(big180.south west)+(0,.2)$) -- ($(big180.south east)+(0,.2)$) node[midway,above,fill=none,font=\scriptsize] {16.50m};
\draw[black] (contour.east) --++ (-11mm,0) node[midway,above, fill=none,font=\scriptsize] {11m};
\node[font=\small, rotate=-90, yshift=5mm] at (goal180) {\textbf{Goal:} 7.32m $\times$ 2.44m};
\draw[black, -{Latex}] (contour.center) --++ (0:0.915cm) node[midway, above, fill=none,font=\scriptsize, yshift=2pt] {r = 9.15m};
\end{scope}
}
\begin{document}
\begin{tikzpicture}
\fill[field] (-1,-1) rectangle (13,10);
\node[minimum width=12cm, minimum height=9cm] (contour) at (6,4.5) {};
% Center
\draw (contour.north) -- (contour.south);
\draw (contour.center) circle (0.915cm);
\fill[white] (contour.center) circle (.5mm);
% Areas
\area{contour.west}{0}
\area{contour.east}{180}
% Corners
\foreach \corner [count=\xi starting from 0] in {south west, south east, north east, north west}{
\begin{scope}[rotate around={90*\xi:(contour.\corner)}]
\draw ([xshift=1mm]contour.\corner) arc (0:90:1mm);
\end{scope}
}
\showmeasures
\end{tikzpicture}
\end{document}