Needs["pkg`"] is only evaluated for the first time!
Initialize the notebook:
If[Length[Names["`*"]]>0,Remove["`*"]];
If[$InputFileName === "",
SetDirectory[NotebookDirectory[]],
SetDirectory[DirectoryName[$InputFileName]]
];
Plot:
PlotBasicStyle[width_]:=Sequence[PlotTheme->{"Scientific","Monochrome"},
BaseStyle->{FontSize->10,FontFamily->"Times"},
LabelStyle->{FontSize->10,FontFamily->"Times"},
ImageSize->width/2.54*100,
AspectRatio->1/GoldenRatio
];
PlotExport[file_,plot_,width_]:=Module[{dir},
dir=DirectoryName[file];
dir=If[dir==="",NotebookDirectory[],dir];
If[!DirectoryQ[dir],CreateDirectory[dir,CreateIntermediateDirectories->True]];
Export[file,plot,ImageResolution->600,RasterSize->Round[width/2.54*600],Background->None]
];
figNum=1;
figWidth=8;
plot[figNum]=Plot[Sin[x],{x,0,1},Evaluate[PlotBasicStyle[figWidth]]]
PlotExport["plot.png",plot[figNum],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 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 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!
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
Display raw fields codes: Alt + F9
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