Search This Blog

Saturday, October 29, 2016

How to install OpenFOAM3+ on Ubuntu 16


  1. Compilers (default): gcc and openmpi
  2. Go to home directory and make "OpenFOAM" directory
    • cd
    • mkdir -p OpenFOAM
    • cd OpenFOAM
  3. Download: OpenFOAM-v3.0+.tgz HERE
  4. Unzip
    • tar -xzf OpenFOAM-v3.0+.tgz
    • cd OpenFOAM-v3.0+
  5. Disable graphics compiling part
    1. Open
      • vi src/postProcessing/functionObjects/Allwmake
    2. Comment out the last line
      • # ./graphics/Allwmake
  6. Take care of conflict due to flex++ version
    1. Open the following files
      1. $WM_PROJECT_DIR/src/triSurface/triSurface/interfaces/STL/readSTLASCII.L
      2. $WM_PROJECT_DIR/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L
      3. $WM_PROJECT_DIR/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L
      4. $WM_PROJECT_DIR/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
      5. $WM_PROJECT_DIR/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L
    2. Make change
      • from
        • #if YY_FLEX_SUBMINOR_VERSION < 34
        • extern "C" int yywrap()
        • #else
        • int yyFlexLexer::yywrap()
        • #endif
      • to
        • // #if YY_FLEX_SUBMINOR_VERSION < 34
        • // extern "C" int yywrap()
        • // #else
        • int yyFlexLexer::yywrap()
        • // #endif
  7. Set up compiling environment
    • source OpenFOAM/OpenFOAM-v3.0+/etc/bashrc
    • echo " alias of30plus='source OpenFOAM/OpenFOAM-v3.0+/etc/bashrc'" >> $HOME/.bahsrc
  8. Compile
    • ./Allwmake

Friday, July 8, 2016

to reset KDE screen

cp -a ~/.kde/share/apps/kscreen ~/.kde/share/apps/kscreen.bak

rm -f ~/.kde/share/apps/kscreen/*

sudo update-grub

shutdown -r now

Thursday, May 19, 2016

Emacs short-cut




M-x
org-emphasize
org-mode
 

You can make words *bold*, /italic/, _underlined_, =verbatim= and ~code~, and, if you must, ‘+strike-through+’. Text in the code and verbatim string is not processed for Org mode specific syntax, it is exported verbatim.

Wednesday, March 23, 2016

Adding latex template in Ubuntu




Make a new directory for

Class files under
/usr/share/texlive/texmf-dist/tex/latex/

BST files under
/usr/share/texlive/texmf-dist/bibtex/bst/


STY files under
/usr/share/texlive/texmf-dist/tex/latex/

Tuesday, October 6, 2015

Friday, September 18, 2015

pdfcrop with margins



http://askubuntu.com/questions/124692/command-line-tool-to-crop-pdf-files

If you wish to crop a pdf with left, top, right and bottom margins of 5, 10, 20, and 30 pt (points), then run
pdfcrop --margins '5 10 20 30' input.pdf output.pdf
in terminal. To actually crop something away, use negative values in the argument for crop. For example,
pdfcrop --margins '-50 -50 -50 -50' input.pdf output.pdf
crops 50 pts from the left, top, right, bottom (in this order).
If you run only the command pdfcrop input, it will output a file titled input-crop.pdf with zero margins. I find this very handy when including pdf illustrations in documents.
Cropping multiple files
Unfortunately, pdfcrop cannot crop multiple files at the time. It is however easy to write a script that will crop all pdfs in the folder the script is located in.
Create a new empty file, and call it something.sh. Open it with a text editor and insert the following:
#!/bin/bash

for FILE in ./*.pdf; do
  pdfcrop "${FILE}"
done
Save it, and close. Then right click the file, go to Properties > Permissions and check the field Allow executing file as program. Now close the dialog. Run the script by double clicking it and choosingRun in Terminal. And new, zero-margin cropped version of all pdfs with suffix -crop will now be printed in the folder. If you want margins or other things, you can of course just open the script and add arguments after pdfcrop.

Saturday, September 12, 2015

linear regression matlab script

function [p,Rsq] = LinearRegression (Xin,Yin)
% LinearRegression example
% x=0:1:9;
% y=3.0 * x + 7 + rand(1,length(x)) ;
% [p,Rsq] = LinearRegression (x,y) ;
% yfit = p(1)*x + p(2) ;
% plot(x,y,"o",x,yfit) ;
p = polyfit(Xin,Yin,1);
Yfit =  p(1) * Xin + p(2);
Yresid = Yin - Yfit;
SSresid = sum(Yresid.^2);
SStotal = (length(Yin)-1) * var(Yin);
Rsq = 1 - SSresid/SStotal;

Labels

Bacteria

Loading...