Codes

Wolfram Mathematica

Needs["pkg`"] is only evaluated for the first time!

Initialize the notebook:


If[Length @ Names["`*"] > 0,
	Remove["`*"]
];

If[StringContainsQ[$InputFileName, "ForWolframLanguageForJupyter.wl"],
	
	SetDirectory @ Directory[]
	,
	If[$InputFileName === "",
		SetDirectory @ NotebookDirectory[]
		,
		SetDirectory @ DirectoryName[$InputFileName]
	]
]

Plot:


PlotBasicStyle[figWidth_, fontSize_] :=
	Sequence[PlotTheme -> {"Scientific", "Monochrome"}, BaseStyle -> {FontSize
		 -> fontSize / 72 * 100, FontFamily -> "Times"}, LabelStyle -> {FontSize
		 -> fontSize / 72 * 100, FontFamily -> "Times"}, ImageSize -> figWidth
		 / 2.54 * 100, AspectRatio -> 1 / GoldenRatio];

PlotExport[exportFile_, plot_, figWidth_] :=
	Module[{dir},
		dir = DirectoryName[exportFile];
		dir =
			If[dir === "",
				If[StringContainsQ[$InputFileName, "ForWolframLanguageForJupyter.wl"
					],
					Directory[]
					,
					If[$InputFileName === "",
						NotebookDirectory[]
						,
						DirectoryName[$InputFileName]
					]
				]
				,
				dir
			];
		If[!DirectoryQ[dir],
			CreateDirectory[dir, CreateIntermediateDirectories -> True]
		];
		Export[exportFile, plot, ImageResolution -> 600, RasterSize -> Round[
			figWidth / 2.54 * 600], Background -> None]
	];

fontSize = 8;

figWidth = 8;

plot=Plot[Sin[x],{x,0,1},Evaluate[PlotBasicStyle[figWidth,fontSize]]]

PlotExport["plot.png",plot,figWidth];

Collect coefficients:


Collect[eq,{Cos[_],Sin[_],a[_],b[_]},Simplify]

Vscode setting:


{
  "wolfram.systemKernel": "/usr/local/Wolfram/WolframEngine/14.3/Executables/WolframKernel",
  "wolfram.systemKernel": "/usr/local/Wolfram/Wolfram/14.3/Executables/WolframKernel",
  "[wolfram]": {"editor.formatOnSave": false},
}

Matlab

Matlab install in linux:


sudo apt install unrar

unrar x MathWorks.part1.rar 

xhost +SI:localuser:root

sudo -H ./install

xhost -SI:localuser:root

Add matlab app:


sudo vim /usr/share/applications/matlab.desktop


[Desktop Entry]

Type=Application
Terminal=False
Exec=/usr/local/MATLAB/R2025b/bin/matlab -desktop
Name=MATLAB R2025b
Icon=/usr/local/MATLAB/R2025b/ui/install/installer_login/images/bg_global_logo.jpg


sudo chmod +x /usr/share/applications/matlab.desktop

OpenFOAM

OpenFOAM install in linux:


#!/bin/bash

cd $HOME/OpenFOAM/

sudo rm -rf OpenFOAM-v2512
sudo tar -xzf OpenFOAM-v2512.tgz

sudo rm -rf ThirdParty-v2512
sudo tar -xzf  ThirdParty-v2512.tar.gz

sudo chmod -R 777 OpenFOAM-v2512
sudo chmod -R 777 ThirdParty-v2512

cd OpenFOAM-v2512

source ./etc/bashrc

foamSystemCheck

./Allwmake -with-bear -j 4 -s -q -l


alias of2512='source ~/openfoam/OpenFOAM-v2512/etc/bashrc'

Test dynamicMeshDict:


#!/bin/bash

foamCleanTutorials

blockMesh

moveDynamicMesh -noFunctionObjects

Apply linear motion before rotational motion to make rotational origin attached to the body.

Paraview install in linux:


sudo apt-get install libxcb-cursor-dev

Add paraview app:


sudo vim /usr/share/applications/paraview.desktop


[Desktop Entry]
Version=1.0
Name=ParaView 6.0.1
Exec=$HOME/paraview/ParaView/bin/paraview
Terminal=false
Icon=$HOME/paraview/ParaView-6.0.1/share/icons/hicolor/96x96/apps/paraview.png
Type=Application


sudo chmod +x /usr/share/applications/paraview.desktop

The interfaceHeight position can not overlap the decomposeParDict mesh boundaries!

Bash Scripts

Git config:


git config --global user.name "Peng Peng"

git config --global user.email "211110103110@stu.just.edu.cn"

Git uppercase to lowercase:


git mv Uppercase lowercase

Compress pdf:


ghostscript -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH \
    -sOutputFile=out.pdf file.pdf

Convert mp4 to gif:


ffmpeg -i file.mp4 file.gif

Proxy for WSL2:


export all_proxy="socks5://$(awk '/nameserver/ {print $2}' /etc/resolv.conf):${Port:-7890}"

git config --global proxy.https "${all_proxy:-}"

Vscode proxy setting:


{
  "http.proxyStrictSSL": false,
  "http.proxy": "http://ipconfig-IPv4 Address:7890",  
}

mpirun test:


mpirun -np 4 hostname

For desktop, WSL2 mirror network may affect mpirun!

Unable to mount: wrong fs type

    
sudo apt install ntfs-3g

sudo ntfsfix -d /dev/sda3

LaTeX

Convert tikz to png:


#!/bin/bash

tikz2png(){
    local filename=$1
    local page=$2
    local outname=$3
    convert -density 600 -units pixelsperinch -quality 100 -alpha remove "$filename.pdf[$page]" -trim "$outname.png"
}

# source ../../template/tikz.sh

tikz2png pde-tikz 0 transport-equation


\documentclass[tikz]{standalone}

\tikzstyle{basic}=[font=\fontsize{8}{10}\selectfont]

\begin{document}

% Fig. 1: transport equation

\begin{tikzpicture}[basic]

\end{tikzpicture}

\end{document}


\documentclass{article}

% \usepackage{import}

% \import{../template/}{article}

\usepackage{amsmath} % math formulas
\usepackage{amsthm} % proof
\usepackage{amssymb} % \mathbb{R}
\usepackage{mathtools} % dcases
\usepackage{graphics} % \includegraphics
\usepackage{float} % figure[H]
\usepackage{booktabs} % three-line table
\usepackage{biblatex} % \autocite{}
\usepackage[left=1.57cm,right=1.57cm,top=0.95cm,bottom=2.54cm]{geometry}

\numberwithin{equation}{section}
\numberwithin{figure}{section}
\numberwithin{table}{section}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{definition}{Definition}[section]
\theoremstyle{definition}
\newtheorem{example}{Example}[section]
\newtheorem{exercise}{Exercise}[section]

\addbibresource{../Library.bib}

\title{Partial Differential Equations}
\author{Peng Peng}
\date{Created: March 22 2026, Version: \today}

\begin{document}

\maketitle

\tableofcontents

\section{Four Fundamental Linear PDEs}

\printbibliography

\end{document}

Fortran

Vscode config:


sudo apt install gdb

Microsoft Word

Display raw fields codes: Alt + F9

OBS

OBS setting:


settings -> Video -> General:
  Base and Output Resolution: 2560*1440;
  Common FPS Values: 10

settings -> Output -> Recording:
  Recording Format: MPEG-4 (.mp4);
  Recording Quality: High Quality, Medium File Size

Home page