Thursday, 13 December 2012

PAFEC: Axisymmetric piston with WEE termination.

tests/1.DAT




TITLE Constant displacement piston

CONTROL
c for sine only:
EDGE.ANALYSIS
ASYMMETRIC.COMPLEX.SOLUTION
FRONTAL.SINUSOIDAL.SOLUTION
c all types:
AXISYMMETRIC
SHOW.RESOLVED.PARAMETERS
CONTROL.END

PARAMETERS
'r1' = 1 c radius of piston
'r2' = <2 r1="r1">  c radius of FE
't1' = <'r1' + 'r2'> c thickness of WEE
'fmax' = 1000
'm' = INT<4 344="344" fmax="fmax" r1="r1">  c mesh count


NODES
NODE AXIS X Y
c structure
1  1 0 <'r1'>
2  1 0 0

c acoustic FE
11 1 0 <'r1'>
12 1 0 0
13 1 <'r1'> <'r1'>
14 1 <'r1'> 0
15 1 <0 .707=".707" r2="r2"> <0 .707=".707" r2="r2">
16 1 <'r2'> 0
17 1 <0 .707=".707" r2="r2" t1="t1"> <0 .707=".707" r2="r2" t1="t1">
18 1 <'r2' + 't1'> 0
19 1 0 <'r2'>
20 1 0 <'r2' + 't1'>
21 4 <'r2'> 67.5
22 4 <'r2'> 22.5
23 4 <('r2'+'t1')>  67.5
24 4 <('r2'+'t1')>  22.5

PAFBLOCKS
BLOCK TYPE GROUP ELEMENT PROP N1 N2 TOPO
  1    6    1      42130  12  <'m'>  0  1 2 c thin shell of revolution.
  2    1    2      29220  11  <'m'>  <'m'>  11 12 13 14 c FE
  3    1    2      29220  11  <'m'>  <'m'>  11 13 19 15 0 0 0 21 c FE
  4    1    2      29220  11  <'m'>  <'m'>  13 14 15 16 0 0 0 22 c FE
  5    1    3      29320  11  <'m'>  1  19 15 20 17 21 0 0 23 c WEE
  6    1    3      29320  11  <'m'>  1  15 16 17 18 22 0 0 24 c WEE

MATERIAL
MATERIAL BULK.MO RO
  11    <344> 1.18

PLATES.AND.SHELLS
PLATE.OR.SHELL  MATER THICKNESS
  12             12     1E-3

MATERIAL
MATERIAL E RO NU
  12     100E9 1E-10 0.33   c -> massless.

REPEATED.FREEDOMS
N1 PLANE DIRE
1    1    1

RESTRAINTS
NODE PLANE DIRE
 1    1   23456

c SINE modules
MASTERS
NODE DIRE
1   1

ENFORCED.HARMONIC.MOTION
c 1/2/3: disp/vel/accel
TYPE NODE DIRE TABLE
 1    1    1    1

TABLE
TABLE   BASIS VALUE
  1       1   1 0
  1     10000 1 0

FREQUENCIES.FOR.ANALYSIS
TYPE START FINISH NUMBER
 3   10    <'fmax'>   100

RESPONSE
TYPE
0

FULL.DYNAMICS.OUTPUT
TYPE  START  FINISH  STEP
  4   1   1E6 1

MODES.AND.FREQUENCIES
AUTO START MODES
 0 0 0

END.OF.DATA

tunes to buy

Air 2000 by Albion

or was it,

Love Shy by Kristine Blond?




Friday, 7 December 2012

Neat python file reading


with open("hello.txt") as f:
    for line in f:
        print line

shower pumps

www.showerpumpselector.co.uk

I want regenerative (as the pump is at the same level as storage tank), dual impeller to pump hot and cold.


On pump location:  loft is ok as long as there's some head from the cold water storage.
http://www.diynot.com/forums/viewtopic.php?t=111980


More instructions
http://www.salamander-pumps.com/how-to/install-a-loft-pump.html

linux sound

linuxaudio.org
http://rg42.org/start

Wednesday, 5 December 2012

matplotlib plot with latex rendering, pandas store, and rotated axis numbering and spacing


subplot(212); title('Narrowband transducer response.')
x = store['v8_g7e_SPL']; plot(x.index / 1000, x, label=r'$f_{0} = 19.6\,kHz$')
x = store['v8_g7n_SPL']; plot(x.index / 1000, x, label=r'$f_{0} = 19.6\,kHz$')
x = store['v8_g7m_SPL']; plot(x.index / 1000, x, label=r'$f_{0} = 21.5\,kHz$')
plt.setp(plt.xticks()[1], rotation=30)

xlabel(r'$Frequency\ (kHz)$'); ylabel(r'$dB\ SPL, d=10 cm, |V|=1 V$')
dmp = xticks([0, 10, 14.4, 16, 17, 19.6, 20, 21, 21.5],
   [0, 10, r'$f_{a_{min}}=14.4$', r'$f_{e}=16$', r'$f_{a}=17$', r'$f_{0}=19.6$', 20, r'$f_{a_{max}}=21$', r'$f_{0}=21.5$'])
dmp = yticks(arange(60, 115, 5))
xlim(14, 24); ylim(60, 110); legend(loc='best')

subplots_adjust(hspace=0.3)

Thursday, 29 November 2012

which version of ubuntu is this?

cat /etc/issue

Installing bits for ipython notebook.

sudo pip install tables

.. ERROR:: Could not find a local HDF5 installation.

sudo apt-get install libhdf5-serial-1.8.4 -> libhdf5-serial-1.8.4 is already the newest version.

sudo apt-get install hdf5-tools -> hdf5-tools is already the newest version.

sudo apt-get install libhdf5-serial-dev


fixed it.  Why do dev files need to be installed so often?!



Tuesday, 27 November 2012

testing code formatting:


this
   should
      be
         indented.

Monday, 26 November 2012

linux mail, crontab

Sort the internal email settings.

$ sudo dpkg-reconfigure postfix

I managed to tie system mail into mutt and my provider somehow, but forgot how!  :(

(1) local only. 2)  postfix config:    markst.free-online.co.uk, no root address, (ms, localhost.localdomain, localhost), sync force, local networks, 5120000, no local addr extension, all IP protocols. 3) sudo touch /var/mail/ms; sudo chown ms /var/mail/ms.

This may be required for crontab mails to get home....

/var/log/cronlog has details of results.

gkrellm  shows there is mail.  Terminals do not.  On reading with, `mail' the mail is moved to ~/mbox

Add to .bashrc the following and new terminals will display the message.  Not on terminal creation, however:  only after hitting

Test with,

echo "test mail" | mail -s "test mail" $USER


export MAIL=/var/mail/$USER
export MAILCHECK=10


Test with,


echo "test mail" | mail -s "test mail" $USER

========

Then I copied old ~/.fetchmailrc, ~/fetchmailrcFreeonline, ~/.mailcap, ~/.msmtprc, ~/.muttrc

and mutt sprang to life!

Sunday, 25 November 2012

pentodes, triodes

http://www.decware.com/paper16.htm

Thursday, 8 November 2012

gmsh: points to define mesh sizes in surfaces.


Point(1) = {0, 0, 0, 0.1};
Point(2) = {1, 0, 0, 0.1};
Point(3) = {0, 1, 0, 0.1};
Point(4) = {1, 1, 0, 0.1};
Point(5) = {0.5, 0.1, 0, 0.005};
Line(1) = {3, 4};
Line(2) = {4, 2};
Line(3) = {2, 1};
Line(4) = {1, 3};
Line Loop(5) = {1, 2, 3, 4};
Plane Surface(6) = {5};
Point{5} In Surface{6};
~
~
~

Thursday, 4 October 2012

co.91.com

free game

Wednesday, 19 September 2012

Getting the UUID of a drive

From /etc/fstab:


# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).

Tuesday, 18 September 2012

archive with daily/weekly/monthly rotation

bin/dailyArchive


# Daily archive script.  There will be scripts for weekly and monthly too.
# Get the day name

today=`date +%A`

# Create todays snapshot archive.
for i in tex py ipynb DAT geo; do
   # create, verbose, bzip2, filename follows:
   find /home/me -name '*.$i' | tar cjvf /mnt/arc/$today$i.tar.bz2 --files-from - > /mnt/arc/$today.log;
   done

bin/weeklyArchive:
# Get the week number

today=`date +%A`
weekNumber=`date +%V`

# Tar todays snapshot archives into an archive
# called this week number.  Call this after the
# weekly archive has completed.

tar xvf /mnt/arc/$weeknumber.tar /mnt/arc/$today* > /mnt/arc/week$weekNumber$today.log

bin/monthlyArchive:
# Monthly archive script.  There will be scripts for daily and weekly too.
# Get the week number

today=`date +%A`
weekNumber=`date +%V`
monthName=`date +%B`

# Tar todays snapshot archives into an archive
# called this month name.  Call this after the
# weekly archive has completed.

tar xvf /mnt/arc/$monthName.tar /mnt/arc/$today* > /mnt/arc/$monthName.log
Do, $ crontab -e and update to,
# minute hour dateOfMonth Month dayOfWeek command # Every night, at 01:01, run the archiver: 01 01 * * * /home/me/bin/dailyArchive # Every Saturday at 17:01, run the weekly archiver. 01 17 * * 6 /home/me/bin/weeklyArchive # Every 1st day of the month, at 07:01, run the monthly archiver. 01 07 01 * * /home/me/bin/monthlyArchive

find all files that have changed in the last seven days


find $HOME -mtime 7 -exec ls -l {} \;

Thursday, 13 September 2012

rsync to readynas


export RSYNC_PASSWORD="password"
rsync -avzxr --progress localfiles rsync://username@192.168.1.1:/sharedFoldername/

mount using nfs:  (network file system, the linux standard)

sudo mount 192.168.1.1:/data /mnt/nas

This required,

sudo apt-get install nfs-common

on the machine attempting to connect to the nas.

Monday, 27 August 2012

recording video, realitime

ffmpeg -f alsa -ac 2 -i pulse -r 30 -f x11grab -s 1920x1200 -i :0.0 -vcodec libx264 gwMINE_footage_1.mkv

or now,

avconv \
-f x11grab -r 30 -s hd1080 -i :0.0 \
-f alsa -ac 2 -i pulse \
-vcodec libx264 -vf 'scale=-1:720' -pre:v lossless_ultrafast \
-acodec libmp3lame \
-y outfile.avi

Friday, 17 August 2012

rsync incremental backups

A directory holds incremental backups (I've mounted a remote directory locally to ease the command but ssh could also be used), in numerical order.  If the last backup number was 5, the next will be 6.  rsync is used to create the incremental backup:

$ crontab -e

Add this for nightly backup:


0 0 * * * i=`ls /mnt/Apollo/archive | tail -n 1`; i=${i%/}; j=$((i+1)); rsync -azm --delete --progress --include='*/' --include='*.tex *.dat *.DAT' --exclude='*' --link-dest=/mnt/Apollo/archive/$i/ /home/me/ /mnt/Apollo/archive/$j

which breaks down as,

0 0 * * *
  : at 0 minutes, 0 hours every day every month every year execute:

i=`ls /mnt/Apollo/archive | tail -n 1`
  : get listing of archive directory in increasing number order (I hope!)

 i=${i%/}
  : Remove the trailing slash from the directory name

j=$((i+1)) 
 : Add one to it and assign to j.

rsync:

-a
(rchive) : preserve file parameters (owner, read/write/execute etc)
-z
(ip) : compress during transmit.
-m
 : do not create empty directories on the backup.
--delete
  : if a file is deleted on the source, remove it on the backup (I hope from the incremental!)

--include='*/' 
 : required to get this to work!
--include='*.tex *.dat *.DAT'
   : files to archive.
--exclude='*' 
  : don't archive anything else.
--link-dest=/mnt/Apollo/archive/$i
    : the reference archive directory used to generate deltas from.
/home/me/
   : start point for information to be backed up.
/mnt/Apollo/archive/$j 
  :  target for incremental data.



Friday, 27 July 2012

home reading

http://27bslash6.com/monkey.html
http://www.amazon.com/gp/product/B001SRFW3Y?ie=UTF8&tag=ubersite&linkCode=as2&camp=1789&creative=9325&creativeASIN=B001SRFW3Y

Sunday, 1 July 2012

0/files

From http://www.cfd-online.com/Forums/openfoam/90301-interfoam-simulation-blowing-up-2.html

0/epsilon:


boundaryField {
    inlet   {  type  fixedValue;  value           uniform 0.0000824; }
    outlet  type  inletOutlet;   inletValue      uniform 0.0000824; value uniform 0.0000824; }
    upperwall  { type inletOutlet; inletValue  uniform 0.0000824;  value  uniform 0.0000824; }
    walls type epsilonWallFunction; value  uniform 0.0000824; }
    frontAndBackPlanes type            empty; }
    }

0/k:

boundaryField {
    inlet  { type            fixedValue;  value           uniform 0.000384; }
    outlet {  type            inletOutlet;   inletValue      uniform 0.000384;  value           uniform 0.000384; }
    upperwall {  type  inletOutlet; inletValue      uniform 0.000384; value           uniform 0.000384; }
    walls type kqRWallFunction; value  uniform 0.000384; }
    frontAndBackPlanes  type empty; }
    }

0/nut:

boundaryField {
    inlet { type            calculated;  value           uniform 0; }
    outlet  { type            inletOutlet; inletValue      uniform 0; value           uniform 0; }
    upperwall { type            inletOutlet; inletValue      uniform 0; value           uniform 0; }
    walls { type  nutUWallFunction; value           uniform 0;}
    frontAndBackPlanes { type            empty; }
    }

0/nuTilda:

boundaryField {
    inlet  {  type    fixedValue; value           uniform 0;}
    outlet   type   inletOutlet;  inletValue      uniform 0; value           uniform 0;  }
    upperwall  {  type            inletOutlet; inletValue      uniform 0; value           uniform 0; }
    walls { type            zeroGradient; }   
    frontAndBackPlanes   type   empty; }
    }

0/U:

boundaryField {
    walls  { type            fixedValue;  value           uniform (0 0 0); }
    baffle  { type            fixedValue;  value           uniform (0 0 0);    }
    inlet   {  type            fixedValue;  value           uniform (0.16 0 0);  }
    outlet  {  type            inletOutlet;  inletValue      uniform (0 0 0);  value           uniform (0 0 0); }
    upperwall {  type            pressureInletOutletVelocity;  value           uniform (0 0 0);
    // type  zeroGradient;
    }
    defaultFaces { type            empty; }
    }


0/p_rgh:

boundaryField {
    walls { type            zeroGradient; //buoyantPressure;
        //value           uniform 0;
      }
    baffle  { type            zeroGradient;  //value           uniform 0;
    }
    inlet  { type            zeroGradient;  }
   outlet  {
        type            totalPressure;//zeroGradient;
        p0              uniform 0;
        U               U;
        phi             phi;
        rho             rho;
        psi             none;
        gamma           1;
        value           uniform 0; }
    upperwall {
        type            totalPressure;//zeroGradient;
        p0              uniform 0;
        U               U;
        phi             phi;
        rho             rho;
        psi             none;
        gamma           1;
        value           uniform 0; }
    defaultFaces { type            empty;}
    }


p_rgh: all wall and inlet should be " buoyantPressure", not zeroGradient.


outlet should not be a totalPressure like your upperwall (not consistent), but try zeroGradient here. But if your upperwall is a wall, then -> buoyantPressure, and outlet: totalPressure.

k,epsilon: try zeroGradient for the upperwall (if this is a free atmosphere. In case this is a wall, then ok)

nut: wall = nut wall function ok, all other (inlet/outlet/top: calculated).







Saturday, 23 June 2012

chroot jail with ssh

from https://help.ubuntu.com/community/BasicChroot
make the chroot structure somewhere.  




$ sudo debootstrap --variant=buildd --arch amd64 precise /home/me/chroot/ http://ubuntu.virginmedia.com/archive/

Then, follow http://forums.gentoo.org/viewtopic-t-374757.html

sudo apt-get install libpam-chroot

sudo vi /etc/security/chroot.conf.  Add user and chroot directory created above, for example,

# to make user `chrooted' get sent to jail in /home/me/chroots/chroot1
chrooted /home/me/chroots/chroot1  

When `chrooted' logs in they will be jailed as above.

sudo vi /etc/pam.d/login.  Add,

# I added the following from 
# http://forums.gentoo.org/viewtopic-t-374757.html
# to turn on PAM chroot jail logins
# /etc/security/chroot.conf, etc/pam.d/login, /etc/pam.d/su also need editing.
session required /lib/security/pam_chroot.so debug

Now,

sudo vi /etc/pam.d/su

#add this line: 
session    required             pam_chroot.so debug




This doesn't work.  :(  The jailed user on login can navigate up above the new home.

There's a program called, `makejail'.  Install it.  Try it.


Or try 
http://www.howtoforge.com/chrooted-ssh-sftp-tutorial-debian-lenny


Thursday, 21 June 2012

system/fvSchemes: ok but epsilon blows slowly.


FoamFile{version 2.0; format ascii; class dictionary; location "system"; object fvSchemes;}

snGradSchemes {
    default         limited 0.7;  // limited 0.7; for bad meshes;
                                // corrected; for good meshes;
                                // must fit to laplacianSchemes
    }

laplacianSchemes {default none;
   //laplacian(nuEff,U) Gauss linear corrected;          // for good meshes
   laplacian(nuEff,U) Gauss linear limited 0.7;      // for bad meshes

    //laplacian((1|A(U)),p) Gauss linear corrected;      // for good meshes
    laplacian((1|A(U)),p) Gauss linear limited 0.7;  // for bad meshes
//  for turbulent flow only:
//    laplacian(DkEff,k) Gauss linear corrected;
    laplacian(DepsilonEff,epsilon) Gauss linear corrected;
    laplacian(DREff,R) Gauss linear corrected;
//    laplacian(DnuTildaEff,nuTilda) Gauss linear corrected; // SA only
}

fluxRequired {
    default         no;
    p              ;
    phi             ;
    }

gradSchemes { // Gradient calculation.  Gauss linear first, cell Limited Gauss linear 1; for better stability with poor meshes.
    default  Gauss linear;  // Gauss linear or leastSquares
    grad(p)         faceLimited leastSquares 0 1;  
    grad(U)         Gauss linear;              
    }

interpolationSchemes {default  linear;     // linear is fine
   U               linear;
//   interpolate(U) reconCentral phi cellLimited leastSquare 1.0; // new tet mesh interpolator. Use with reconCentral in divSchemes
}

divSchemes {default none; div(phi,U)      Gauss upwind;               // stable: Gauss upwind
//div(phi,U)      Gauss linearUpwind Gauss; // faster linearUpwind Gauss
//    div(phi,U)      Gauss reconCentral cellLimited leastSquares 1.0;    // new, tets mesh setting
//    div(phi,k)      Gauss upwind;             // for turbulent flow only
    div(phi,epsilon) Gauss upwind;            // for turbulent flow only
    div(phi,R)      Gauss upwind;             // for turbulent flow only
    div(R)          Gauss linear;             // for turbulent flow only
//    div(phi,nuTilda) Gauss upwind;            // for turbulent SA flow only
div((nuEff*dev(grad(U).T()))) Gauss upwind; // this scheme is not used for
//div((nuEff*dev(grad(U).T()))) Gauss linear; // this scheme is not used for
                                                // steady and laminar flow, but
                                                // it is read by the solver, so
                                                // it must be defined.
//div((nuEff*dev(T(grad(U))))) Gauss linear; // not advised, taken from motorbike case
div((nuEff*dev(T(grad(U))))) Gauss upwind; // not advised, taken from motorbike case
}

ddtSchemes {default steadyState;}    // no time dependence her

Wednesday, 20 June 2012

reconstructPar then remove

i=`ls processor0`; reconstructPar; for j in $i; do rm -r proc*/$j; done

circular cylinder / sphere analysis with recommendations.

http://www.cfd-online.com/Forums/openfoam-solving/59413-recommended-setup-flow-over-cylinder.html

parallel loading paraView for openFoam

http://www.openfoamwiki.net/index.php/Contrib_Parallelized_Native_OpenFOAM_Reader_for_ParaView

probes

in controlDict:

functions ( probes1 {
        type probes; functionObjectLibs ("libsampling.so");
        outputControl timeStep; // or every N iterations
        outputInterval 1;
        probeLocations (
            ( 0 0 0.1 )
            );
    fields ( U );  // fields to check.
    }
);


This could be interesting; it may replace sample.  Sample needs reconstructPar before use:  time-consuming.
This might not.

bash scripting

A great guide:

http://mywiki.wooledge.org/BashGuide

Monday, 18 June 2012

chroot jail stuff

http://www.cyberciti.biz/tips/howto-linux-unix-rssh-chroot-jail-setup.html

https://help.ubuntu.com/community/BasicChroot

is shorter

sudo apt-get install dchroot debootstrap

sudo mkdir chroot

sudo vi /etc/schroot/schroot.conf


Add:



[precise]
description=Ubuntu Precise
location=/home/me/chroot
priority=3
users=me
groups=sbuild
root-groups=root


sudo debootstrap --variant=buildd --arch 686 precise /home/ms/chroot/ http://mirror.url.com/ubuntu

Surely, I can add a new user, take all its privileges?  This chroot approach uses a new operating system!
It took less than ten minutes anyway.

Enter the jail by,


sudo chroot /home/me/chroot

and note that the root directory is not the root of the machine but things are working ok.  So far.

/etc/passwd:   list of users - user system nuymbers.
/etc/group:  list of groups and system group numbers.


http://www.yolinux.com/TUTORIALS/LinuxTutorialManagingGroups.html

access control lists may be what I'm looking for.

http://www.vanemery.com/Linux/ACL/linux-acl.html

Sunday, 17 June 2012

cfd links to follow up

http://www.cfd-online.com/Forums/openfoam-solving/71733-pisofoam-floating-point-error-gamg.html

Oracle's grid engine sounds interesting.

Friday, 15 June 2012

Working fvSolution with parallel solver

Jobs were running in serial but not in parallel.  Following advice from http://www.cfd-online.com/Forums/openfoam-solving/101321-interfoam-blows-parallel-run.html#post366627 I changed the GAMG smoother from GaussSeidel to DILUGaussSeidel and the job worked immediately.

For completeness I also changes all the relTols to zero and changed the epsilon and R solvers to smoothSolver (with the same smoother as above) from PBiCG.


FoamFile{version 2.0; format ascii; class dictionary; location "system"; object fvSolution;}

SIMPLE {
    nNonOrthogonalCorrectors 4; convergence 1e-5;
    pRefCell 0;  pRefValue 0;
    residualControl{p 1E-5; U 1E-5; R 1E-7; epsilon 1E-7;}
    }

relaxationFactors { // 0.3 good mesh p, 0.7 good mesh U etc.
    p 0.1; U 0.3; R 0.1; epsilon 0.1;
    }

solvers {
   U {
      solver smoothSolver; smoother DILUGaussSeidel; // Essential for parallel.
      tolerance 1e-06; relTol 0; nSweeps 1; maxIter 100; }

   p {
      solver GAMG; tolerance 1e-07; relTol 0;
      minIter 3; maxIter 100; 
      smoother DICGaussSeidel; // Essential for parallel solution.
      nPreSweeps 1;              // 1 for p, set to 0 for all other
      nPostSweeps 2; nFinestSweeps 2; scaleCorrection true;                               
      directSolveCoarsestLevel false; 
      cacheAgglomeration on; // off if dynamic mesh refinement
      nCellsInCoarsestLevel 500; // 500 or sqrt(number of cells)
      agglomerator    faceAreaPair; mergeLevels     1; 
      }
    // epsilon{solver PBiCG; preconditioner DILU; tolerance 1E-9; relTol 0; minIter 1;} 
    epsilon{solver smoothSolver; smoother DILUGaussSeidel; tolerance 1E-6; relTol 0; nSweeps 1; maxIter 100;}
    //    R{solver PBiCG; preconditioner DILU; tolerance 1E-9; relTol 0;}
    R{solver smoothSolver; smoother DILUGaussSeidel; tolerance 1E-6; relTol 0; nSweeps 1; maxIter 100;}
    }



Saturday, 2 June 2012

ongoing

Case 22 solved ok and is stable but epsilon is very large at 45 degrees or so: 38518. Maybe this is ok. It implies a small length scale. The cells ARE very small in the region of high epsilon. It implies a very low turbulence viscosity at this point.

-----------------------------------------------------
FoamFile{version 2.0; format ascii; class dictionary; 
    object transportProperties;}

transportModel Newtonian;
nu nu [0 2 -1 0 0 0 0] 1.5E-5; 
// kinematic viscosity.  We are incompressible so no density required.
// The kinematic pressures generated must be multiplied by density to 
// get actual pressures.

-----------------------------------------------------
FoamFile{version 2.0; format ascii; class dictionary; 
    object RASProperties;}
// Use erroneous RASModel to get list of available models.
RASModel LaunderGibsonRSTM;
// RASModel kOmegaSST;
printCoeffs on;
turbulence on;
// Can define non-standard coeffs.
-----------------------------------------------------
FoamFile{version 2.0; format ascii; class volScalarField; object epsilon;}
internalField uniform 1;
boundaryField{
    in  { type freestream; freestreamValue uniform 0.05; value uniform 0.05; }
    out { type freestream; freestreamValue uniform 0.05; value uniform 0.05; }
    sym { type symmetryPlane; }
    top { type symmetryPlane; }
    wall { type zeroGradient; }
    emptyf { type empty; }
    emptyb { type empty; }
}
--------------------------------------------------------
FoamFile{version 2.0; format ascii; class volScalarField; object k;}
boundaryField {
   in{type freestream; freestreamValue uniform 0.05;}
   out{type freestream; freestreamValue uniform 0.05;}
   top{type symmetryPlane;}
   wall{type zeroGradient;} // zeroGradient? calculated?  fixedValue; value uniform 0? 1E-10?
   sym{type symmetryPlane;}
   emptyf{type empty;}
   emptyb{type empty;}
}
internalField uniform 0;
dimensions [0 2 -2 0 0 0 0];
--------------------------------------------------------
FoamFile{version 2.0; format ascii; class volScalarField; object p;}
boundaryField {   in{type freestreamPressure;}  //  zeroGradient
   out{type freestreamPressure;} // fixedValue; value uniform 0
   top{type symmetryPlane;}
   wall{type zeroGradient;}
   sym{type symmetryPlane;}
   emptyf{type empty;}
   emptyb{type empty;}
}
internalField uniform 0;
dimensions [0 2 -2 0 0 0 0];
-----------------------------------------------------
FoamFile{version 2.0; format ascii; class volVectorField; object U;}

boundaryField{
      wall{  type fixedValue; value uniform (0 0 0);}
      top{  type symmetryPlane;}
      sym{  type symmetryPlane;}
      emptyf{  type empty;}
      emptyb{  type empty;}
      in{  type freestream; freestreamValue uniform (10 0 0); } // fixedValue; value uniform (10 0 0);}
      out{  type freestream; freestreamValue uniform (10 0 0);} // zeroGradient;}
   }
internalField uniform (10 0 0);
dimensions [0 1 -1 0 0 0 0];
-----------------------------------------------------                              
FoamFile{version 2.0; format ascii; class volSymmTensorField; object R;}
boundaryField{
      wall{  type zeroGradient; } // fixedValue; value uniform (0 0 0 0 0 0);}
      top{  type symmetryPlane;}
      sym{  type symmetryPlane;}
      emptyf{  type empty;}
      emptyb{  type empty;}
      in{  type freestream; freestreamValue uniform (0 0 0 0 0 0); } // fixedValue; value uniform (10 0 0);}
      out{  type freestream; freestreamValue uniform (0 0 0 0 0 0);} // zeroGradient;}
   }
internalField uniform (0 0 0 0 0 0);
dimensions [0 2 -2 0 0 0 0];
------------------------------------------------------
FoamFile{version     2.0; format ascii; class dictionary; location    "system"; object fvSolution;}
SIMPLE {
    nNonOrthogonalCorrectors 4;         // Unpredictable. 0/1/2 blows. 3,4,5,6 ok with 2D.
    convergence         1e-5;           // convergence criteria steady state
       pRefCell            0;           // ref cell is 0 in the airfoil tutorial
      pRefValue            0;           // ref value is 0 in the airfoil case.
  residualControl{p 1E-5; U 1E-5; R 1E-7; epsilon 1E-7;}      // added due to airfoil case.
}
relaxationFactors {
    // Critical section.  Steady solutions will diverge with the default
    // 1 setting for a value to make sure they're all in here.
    // p is usually just under 1/2 of U, k, omega.  Not sure about
    // R and epsilon.  p 0.3, U 0.7 for good case.  p 0.1, U 0.3 considered
    // a bad setting by some but slow and steady beats fast and blown...
    p              0.1;                // 0.3 is stable, decrease for bad mesh
    U              0.3;                // 0.7 is stable, decrease for bad mesh
    R              0.1;
    epsilon        0.1;
}
solvers {
    U {                                  // linear equation system solver for U
        solver       smoothSolver;  // solver type.  smoothSolver is more
                                    // robust than some.
        // smoother   GaussSeidel;    // smoother type.  OK serial. Bad parallel.
        smoother DILUGaussSeidel;     // Good parallel.    
        tolerance       1e-06;          // 
        relTol          0.01;           // Some say this should = 0
        nSweeps         1;              // setting for smoothSolver
        maxIter         100;            // limitation of iterations number
    }
    p                                  // linear equation system solver for p
    {
        solver          GAMG;           // very efficient multigrid solver
        tolerance       1e-07;          // solver finishes if this
        relTol          0.001;          // or this is reached 
        // some suggest this should be zero.  Others say 0.1 or 0.01 for
        // poor convergence cases.
        minIter         3;              // minimum number of iterations
        maxIter         100;            // limitation of iterions number
        smoother        DIC;            // setting for GAMG.
        // smoother     DICGaussSeidel; // Good for parallel runs.
        nPreSweeps      1;              // 1 for p, set to 0 for all other!
        nPostSweeps     2;              // 2 is fine
        nFinestSweeps   2;              // 2 is fine
        scaleCorrection true;           // true is fine
        directSolveCoarsestLevel false; // false is fine
        cacheAgglomeration on;          // on is fine; set to off, if dynamic
                                        // mesh refinement is used!
        nCellsInCoarsestLevel 500;      // 500 is fine,
                                        // otherwise sqrt(number of cells)
        agglomerator    faceAreaPair;   // faceAreaPair is fine
        mergeLevels     1;              // 1 is fine
    }
    //epsilon{solver PBiCG; preconditioner DILU; tolerance 1E-9; relTol 0;}
    //R{solver PBiCG; preconditioner DILU; tolerance 1E-9; relTol 0;}
    epsilon{solver smoothSolver; smoother DILUGaussSeidel; tolerance 1E-9; 
        relTol 0; nSweeps 1; maxIter 100;}
    R{solver smoothSolver; smoother DILUGaussSeidel; tolerance 1E-9; 
        relTol 0; nSweeps 1; maxIter 100;}
    }
-------------------------------------------------------------
FoamFile{version 2.0; format ascii; class dictionary; 
    location "system"; object fvSchemes;}
snGradSchemes {  // surface normal gradient on faces calculation methods.
    default         limited 0.7;  // limited 0.7; for bad meshes;
                                  // corrected; for good meshes;
                                  // must fit to laplacianSchemes
    }

laplacianSchemes {   // Diffusion schemes.
    default none; 
    // --------------- The following is my current favourite.
    // default Gauss linear corrected; // low non-orthogonality (<30 deg?)
    // default Gauss linear limited 0.5; // medium non-orthogonality (30 < 45 deg)
    // default Gauss linear limited 0.33; // low non-orthogonality (>45 deg)
 // --------------- or use the following.
    // laplacian(nuEff,U) Gauss linear corrected;          // for good meshes
    laplacian(nuEff,U) Gauss linear limited 0.7;      // for bad meshes
    //laplacian((1|A(U)),p) Gauss linear corrected;      // for good meshes
    laplacian((1|A(U)),p) Gauss linear limited 0.7;  // for bad meshes
    //  for turbulent flow only:
    //  laplacian(DkEff,k) Gauss linear corrected;
    laplacian(DepsilonEff,epsilon) Gauss linear corrected;
    laplacian(DREff,R) Gauss linear corrected;
    // laplacian(DnuTildaEff,nuTilda) Gauss linear corrected; // SA only
    }
fluxRequired {
    default         no;
    p              ;
    phi             ;
    }
gradSchemes {
    default         Gauss linear;  // Gauss linear or leastSquares
    grad(p)         faceLimited leastSquares 0 1;
    grad(U)         Gauss linear;               
    // grad(U)      cellLimited Gauss linear 1;  // Poor quality mesh.
    }
interpolationSchemes { // interpolation used to calculate values on cell faces.
    default  linear;
    U               linear;
    // interpolate(U) reconCentral phi cellLimited leastSquare 1.0; // new tet mesh interpolator. Use with reconCentral in divSchemes
    }
divSchemes { 
    default none; 
    div(phi,U)      Gauss upwind;               // stable: Gauss upwind
    // div(phi,U)    Gauss linearUpwind Gauss; // faster linearUpwind Gauss
    // div(phi,U)    Gauss linearUpwindV Gauss linear; // *
    // div(phi,U)      Gauss reconCentral cellLimited leastSquares 1.0;    // new, tets mesh setting
    // div(phi,k)      Gauss upwind;             // for turbulent flow only
    // div(phi,omega)  Gauss upwind;             // for turbulent flow only
    div(phi,epsilon) Gauss upwind;            // for turbulent flow only
    div(phi,R)      Gauss upwind;             // for turbulent flow only
    div(R)          Gauss linear;             // for turbulent flow only
    // div(phi,nuTilda) Gauss upwind;            // for turbulent SA flow only
    div((nuEff*dev(grad(U).T()))) Gauss linear; // this scheme is not used for
                                                // steady and laminar flow, but
                                                // it is read by the solver, so
                                                // it must be defined.
    div((nuEff*dev(T(grad(U))))) Gauss linear; // not advised, taken from motorbike case
    }
ddtSchemes {default steadyState;}    // no time dependence here
-------------------------------------------------------
In case 23 I calculated k and epsilon for 1% ti. It blew. In case 24 I increased input epsilon from 0.05 to 0.06. Finish epsilon changed from 38800 to 38500. It decreased as I increased the input value. I calculated a new input epsilon using the cylinder diameter instead of the tunnel as 0.017. 24 was updated and restarted at 0.04 s. The out region is not forcing the value after all; it is marked as,
    out
    {
        type            freestream;
        freestreamValue uniform 0.017;
        value           nonuniform List
70
(
17.1646
16.6899
16.1215
15.448
... more items
) ;
)
varying from 18 to 5E-15; so it IS being calculated in spite of me specifying a freeStream value for it. That is the point of the freeStream, perhaps. Outflow is calculated, inflow is specified. The maximum epsilon increased as the input was decreased. -------------------------------------------------------------- I think this is ok. However, starting with other values of k and epsilon resulted in the solution blowing up. Perhaps different solvers would help. Also, what about the k value used at the wall? Zero blows the solution; 1E-6 as used here results in ok results sometimes. First of all, try dropping it to 1E-10 in 25. I'm using smoothSolver for U but PBiCG for epsilon and R. Why not smoothsolver for all? Also, I believe FLUENT uses cellLimited approaches; this might be interesting. Try later. case 25 is as case 24 but with 1E-10 for k on the wall. Inspection of k on the wall shows it is NOT being set; it is being calculated. So that's another experiment gone. Take then, the unstable solution and try with different solvers; looking for stability. 25: ----------------------------------------- Copied from 23 which blew by 0.0005. Solver changes:
epsilon{solver PBiCG; preconditioner DILU; tolerance 1E-9; relTol 0;}

->

epsilon{solver smoothSolver; smoother GaussSeidel; tolerance 1e-6; relTol 0.001; nSweeps 1; maxIter 100;}
This blew by 0.00367. Use same tolerances:
epsilon{solver smoothSolver; smoother GaussSeidel; tolerance 1e-9; relTol 0; nSweeps 1; maxIter 100;}
This blew at 0.000223. Earlier than the relaxed tolerance case. Do the same for R:
R{solver PBiCG; preconditioner DILU; tolerance 1E-9; relTol 0;}

->

R{solver smoothSolver; smoother GaussSeidel; tolerance 1e-9; relTol 0; nSweeps 1; maxIter 100;}
This blew at 0.000233. Time-step continuity errors. Epsilon spent 100 iterations at time=0.000222 and the time-step continuity became poor. I'll try changing nSweeps to 2 for all smooth solved parameters. It ran for longer, to 0.000292. Still blew though. Perhaps it's the p that needs attention...... fvSolution:SIMPLE had residualControl{p 1E-5;} Changed to 1E-7. Blew at the same point. So we still have: high epsilon, low k start and cellLimited solution. The smoother was changed from GaussSeidel to DILUGaussSeidel after an attempt to use the `better with poor meshes, DICGaussSeidel'. This blew, but slowly. Good! cellLimited: This is a change to fvSchemes. interpolationSchemes{default linear; U linear;} was changed to {default linear;} It was not possible to limit this. Note: grad(p) is faceLimited leastSquares 0 1; why? This simulation worked ok with specific turbulence parameters: epsilon in = 0.05; k in = 0.0015; It blew with epsilon in = 0.0007; k in = 0.005, That's progress. Drop k in, increase epsilon in to stabilise.

0/k

FoamFile { version 2.0; format binary; class volScalarField; location "0"; object k; }
dimensions [ 0 2 -2 0 0 0 0 ];
internalField uniform 1;
boundaryField { 
   wall { type compressible::kqRWallFunction; value uniform 1; }
   in  { type turbulentIntensityKineticEnergyInlet; intensity 0.01; value uniform 1; }
   out { type inletOutlet; inletValue uniform 1; value uniform 1; }
   sym { type symmetryPlane; }
   }

0/epsilon

Epsilon is the dissipation factor. Initial epsilon and input epsilon: Set initial epsilon as high to help stability. Calculate epsilon from {http://www.openfoam.org/docs/user/cavity.php#x5-290002.1.7} and http://en.wikipedia.org/wiki/Turbulence_kinetic_energy as,
# turbulent ke
k = lambda ux, uy, uz, ti: 0.5*((ti * ux)**2 + (ti*uy)**2 + (ti*uz)**2) 

# turbulence damping based on mixing length.
epsilon = lambda l, k, Cmu:  Cmu ** 0.75 * k ** 1.5 / l;  

# mu_t http://www.cfd-online.com/Wiki/Standard_k-epsilon_model
turbViscosity = lambda rho, Cmu, k, epsilon: rho * Cmu * k**2 / epsilon 
-------------Calculations-------------------------------
k(10, 0, 0, 0.05) # input turbulent kinetic energy at 5% ti, 10m/s
# 0.125
k(10, 0, 0, 0.01) # input turbulent kinetic energy at 1% ti, 10m/s
# 0.005

Cmu = 0.09 # a constant.
l = 0.07* 0.4; # turbulent mixing length, say 0.07 of the width of the tunnel from the link above.
epsilon(l, k(10, 0, 0, 0.05), Cmu)  # epsilon in noisy tunnel (5% ti)
# 0.26
epsilon(l, k(10, 0, 0, 0.01), Cmu)  # epsilon in quiet tunnel (1% ti)
# 0.0021
l=0.07*0.05 # cylinder diameter.
epsilon(l, k(10, 0, 0, 0.01), Cmu)  # epsilon in quiet free-space using cylinder diameter (1% ti)
# 0.017

So the 1% quiet tunnel has 25 times lower k but 124 times lower epsilon
than the 5% noisy one.  Using the cylinder diameter instead of the
tunnel diameter resulted in epsilon increasing by factor 8.
-----------Examples----------------------------------------------
dimensions [0 2 -3 0 0 0 0];
internalField uniform 1;
boundaryField { 
   in { type fixedValue; value uniform 1; }
   in { type turbulentMixingLengthDissipationRateInlet; value uniform 0.1;}
   out { type fixedValue; value uniform 1; }
   sym { type symmetryPlane; }
   wall { type compressible::epsilonWallFunction; value uniform 1; }
   }
The following converged ok with circularCylinder case 22.
FoamFile{version 2.0; format ascii; class volScalarField; object epsilon;}

boundaryField {
   in{type freestream; freestreamValue uniform 0.05;}
   out{type freestream; freestreamValue uniform 0.05;}
   top{type symmetryPlane;}
   wall{type zeroGradient;} // zeroGradient? calculated?  fixedValue; value uniform 0? 1E-10?
   sym{type symmetryPlane;}
   emptyf{type empty;}
   emptyb{type empty;}
}
internalField uniform 1;
dimensions [0 2 -3 0 0 0 0];

Wednesday, 30 May 2012

Python pip for package management

Unlike easy_install, pip features an uninstall command. :) I was able to install pip after python-setuptools as,
cd ~/downloads
git clone https://github.com/pypa/pip.git
cd pip/
sudo python setup.py install # root required.
This allowed a nice installation of ipython, removal of broken matplotlib, reinstallation of matplot lib including some compiling. I wonder if it plays nicely with numpy and scipy.... Ares showed,
sudo pip install scipy --upgrade
worked but that the BLAS libraries are not available. So close.... :| Also missing:
 f77blas,cblas,atlas.
Yet,
sudo pip install atlas
did work. tests failed though

system/fvSolution

From http://www.foamcfd.org/Nabla/guides/UserGuidese15.html
Equation solvers, tolerances and algorithms.

solvers {  // specify the linear solver.
   p       ICCG  1e-06 0;  // Incomplete-Cholesky preconditioned conjugate gradient for symmetric sparse matrices.   
   p       DCG   1e-06 0;  // Diagonally preconditioned conjugate gradient for symmetric sparse matrices.      
   p       AMG   1e-06 0 100;  // Algebraic multi-grid for symmetric sparse matrices.    

   U       BICCG 1e-05 0; // Incomplete-Cholesky preconditioned biconjugate gradient for asymmetric sparse matrices.   
   U       BDCG  1e-05 0; // Diagonally preconditioned biconjugate gradient for asymmetric sparse matrices.   
   U       BICCG 1e-05 0 2; // Gauss-Seidel for asymmetric sparse matrices.    


   U { solver smoothSolver; smoother GaussSeidel; tolerance 1e-06; relTol 0.01; nSweeps 1; maxIter 100; }
   k       BICCG 1e-05 0.1;

   epsilon BICCG 1e-05 0.1;
   epsilon{solver PBiCG; preconditioner DILU; tolerance 1E-9; relTol 0;}

   nuTilda BICCG 1e-05 0.1;

   R{solver PBiCG; preconditioner DILU; tolerance 1E-9; relTol 0;}

   }

Solution stops when tol or relTol are reached.  The tolerance is the difference between the lhs and rhs of the equation being solved.
 is often 0.

AMG:  Quick solution on coarse mesh; map results; second solution on fine mesh.




relaxationFactors { 
   p       0.3;
   U       0.7;
   k       0.7;
   epsilon 0.7;
   R       0.7;
   nuTilda 0.7;
   }

// ---------------------

PISO { // Pressure Implicit Split Operator
   nCorrectors 2;
   nNonOrthogonalCorrectors 0;
   }

OR

SIMPLE { // Semi-implicit method for pressure-linked equations.
   nNonOrthogonalCorrectors 0;  // I've have best residuals with 1 with structured 2D mesh; blow with 2; good with 3, 4, 5.
   }

SIMPLE makes one correction to an initial solution; PISO requires more but usually < 4.
This sets nCorrectors.  nNonOrthogonalCorrectors is used to compensate for a face not
being normal to the cell centre.
// ---------------------------

Friday, 25 May 2012

OpenFoam: ill defined primitiveEntry starting at keyword

Usually indicates the lack of a space between the keyword and the following parenthesis.

Tuesday, 22 May 2012

vnc

Server: $ sudo apt-get install tightvncserver $ vi ~/.vnc/xstartup and replace /etc/X11/Xsession & with fluxbox & then, $ tightvncserver Displays new display number. Client: $ sudo apt-get install xtightvncserverviewer $ xtightvncviewer ipaddress:1 where `1' is the display number.

Thursday, 17 May 2012

Decimating (and more) CFD results with Python

This two liner removes all time directories for times smaller than 0.1ms. It's native Python. import os, shutil d = '/home/me/CFD/tilt3D_9/p50'; a = os.listdir(d); b = [i for i in a if len(i) in [7,8] and i[0] in ['0','1','2','3','4','5','6','7','8','9']]; [shutil.rmtree(d + '/' + i) for i in b]

Wednesday, 16 May 2012

Enabling boot logging on ubuntu

Edit /etc/default/bootlogd Change BOOTLOGD_ENABLE=No to BOOTLOGD_ENABLE=yes

Friday, 4 May 2012

listing the unique login user name attempts

:$ zgrep ssh /var/log/auth*|grep "Invalid user"|cut -d ' ' -f 8|sort|uniq -c|sort -n|tail -n 17

I've got,

       1 router
       1 sido
       1 test
       1 ubuntu
       3 oracle
 2381 user

Great script, that....

Saturday, 28 April 2012

ipython markdown

http://daringfireball.net/projects/markdown/basics

http://notes.zatvia.com/notes-md.html

Four tildes to set verbatim on and off.

Friday, 27 April 2012

Circular cylinder howto

This page describes one of my efforts to simulate the flow around a circular cylinder with openFoam. Comments are most welcome. This is not all my own work; I've used several articles from foamwiki and others but this is a work in progress. I'll credit eventually...

The process here is:
1) Specify the mesh.
2) Set flow / material parameters.
3) Solution control:
3a) Set turbulence modelling approach.
3b) Specify solution schemes / types.
3c) Specify solution parameters.
3d) Specify software settings (save rate, start time etc)
4) Create the mesh.
5) Solve.

The turbulent analysis benefits from a laminar pre-solution to set the initial field for the turbulent analysis and progressively complex turbulence models benefit from progressively more accurate initial conditions. For this reason, a Reynolds Stress analysis may benefit from an initial laminar solution, then say a k-epsilon solution to generate the initial field. That's another post, anyway. This post runs from scratch with turbulence.

1) Create the mesh: Convergence studies suggested little change was occurring with further refinement to the boundary layer mesh. The file,
constant/polyMesh/blockMeshDict

FoamFile{version 2.0; format ascii; class dictionary; object blockMeshDict;}

convertToMeters 0.05;

// Vertex dimensions are in diameters!

// space between `vertices' and `(' is required.
vertices (  
   (0.5 0 0)                // cylinder wall
   (1 0 0)                  // b/l
   (20 0 0)                 // exit
   (20 0.707107 0)
   (0.707107 0.707107 0)
   (0.353553 0.353553 0)
   (20 10 0)
   (0.707107 10 0)
   (0 10 0)
   (0 1 0)
   (0 0.5 0)
   (0.5 0 0.5)
   (1 0 0.5)
   (20 0 0.5)               // downstream exit at 2
   (20 0.707107 0.5)
   (0.707107 0.707107 0.5)
   (0.353553 0.353553 0.5)
   (20 10 0.5)
   (0.707107 10 0.5)
   (0 10 0.5)
   (0 1 0.5)

   (0 0.5 0.5)

   (-0.5 0 0)
   (-1 0 0)
   (-10 0 0)
   (-10 0.707107 0)
   (-0.707107 0.707107 0)
   (-0.353553 0.353553 0)
   (-10 10 0)
   (-0.707107 10 0)
   (-0.5 0 0.5)
   (-1 0 0.5)
   (-10 0 0.5)
   (-10 0.707107 0.5)
   (-0.707107 0.707107 0.5)
   (-0.353553 0.353553 0.5)
   (-10 10 0.5)
   (-0.707107 10 0.5)
   );


// Defined anti-clockwise on front face, then back face.
blocks(
   // cylinder wall, 0 to 45 deg.  radial, circumferential.
   hex(5 4 9 10 16 15 20 21) (80 10 1) simpleGrading (10 1 1) 

   // cylinder wall, 45 to 90 deg. radial, circumferential.
   hex(0 1 4 5 11 12 15 16) (80 10 1) simpleGrading (10 1 1)  

   // downstream, behind cylinder.
   hex(1 2 3 4 12 13 14 15) (160 10 1) simpleGrading (15 1 1) 
   
   // downstream, upper 1/4
   hex(4 3 6 7 15 14 17 18) (160 60 1) simpleGrading (15 14 1)

   // above cylinder, 45 to 90 deg. 
   hex(9 4 7 8 20 15 18 19) (10 60 1) simpleGrading (1 14 1)  

   // cylinder wall, 90 to 135 deg. radial, circumferential
   hex(10 9 26 27 21 20 34 35)  (80 10 1) simpleGrading (10 1 1) 

   // cylinder wall, 135 to 180 deg. radial, circ.
   hex(27 26 23 22 35 34 31 30) (80 10 1) simpleGrading (10 1 1) 

   // above cylinder, 90 to 135 deg.
   hex(23 26 25 24 31 34 33 32) (10 60 1) simpleGrading (1 14 1) 

   // upstream, upper 1/4
   hex(26 29 28 25 34 37 36 33) (60 60 1) simpleGrading (14 14 1) 

   // directly upstream of cylinder. 
   hex(26 9 8 29 34 20 19 37)   (10 60 1) simpleGrading (1 14 1)  
   );

edges(
   arc 0 5 (0.469846 0.17101 0)
   arc 5 10 (0.17101 0.469846 0)
   arc 1 4 (0.939693 0.34202 0)
   arc 4 9 (0.34202 0.939693 0)
   arc 11 16 (0.469846 0.17101 0.5)
   arc 16 21 (0.17101 0.469846 0.5)
   arc 12 15 (0.939693 0.34202 0.5)
   arc 15 20 (0.34202 0.939693 0.5)

   arc 22 27 (-0.469846 0.17101 0)
   arc 27 10 (-0.17101 0.469846 0)
   arc 23 26 (-0.939693 0.34202 0)
   arc 26 9 (-0.34202 0.939693 0)
   arc 30 35 (-0.469846 0.17101 0.5)
   arc 35 21 (-0.17101 0.469846 0.5)
   arc 31 34 (-0.939693 0.34202 0.5)
   arc 34 20 (-0.34202 0.939693 0.5) );

// patches ( type name (nodes)
// These are GEOMETRY effect, not flow etc.
// So flow inlet is a patch in this file,
//  while physical walls are wall.
patches(
   patch inlet(( 28 25 33 36 )
               ( 25 24 32 33 ))

   patch outlet((6 3 14 17)
                (3 2 13 14))

   symmetry symmetry((24 23 31 32)
                     (23 22 30 31)
                     (0 1 12 11)
                     (1 2 13 12))

   wall top((28 29 37 36)
            (29 8 19 37)
            (8 7 18 19)
            (7 6 17 18))

   wall wall((22 27 35 30)
             (27 10 21 35)
             (10 5 16 21)
             (5 0 11 16))

   empty emptyf((28 29 26 25)
                (29 8 9 26)
                (26 9 10 27)
                (26 27 22 23)
                (25 26 23 24)
                (8 7 4 9)
                (7 6 3 4)
                (9 4 5 10)
                (4 3 2 1)
                (4 1 0 5))

   empty emptyb((36 37 34 33)
                (37 19 20 34)
                (34 20 21 35)
                (34 35 30 31)
                (33 34 31 32)
                (19 18 15 20)
                (18 17 14 15)
                (20 15 16 21)
                (15 14 13 12)
                (15 12 11 16)));
mergePatchPairs();

This file creates some skewed cells; these will require
nNonOrthogonalCorrectors = 4
or greater. This was found experimentally. This parameter may effect the number of iterations of the pressure solver, per `time-step'.

2) Specify the fluid properties as kinematic viscosity. Specify nu where nu = mu / rho with mu, the viscosity and rho the density. mu = 1.78E-5 kg/(m s) = 1.78E-5 Pa s at 15 degrees centigrade. Air density is 1.225 kg/m3 at this temperature. nu therefore is, 1.78E-5 kg/(ms) / 1.225 kg/m3 = 1.45E-5 m2 s-1. (recall that viscosity, mu sets the proportionality between the force required to move two parallel, massless plates with fluid between them; and the plate area, their relative velocity and separation. F = mu A u/y (well, du/dy). Its units are prescribed by 1/mu = A u / (y F) -> 1/(m2 m s-1 m-1 N-1) = m-2 s N = Pa s). Of similar interest for this study, the Reynolds number Re = u D rho / mu = u D / nu with velocity, u; and diameter, D. For a 0.05m cylinder in 10m/s flow, the Reynolds number is 10m/s 0.05m 1.225 kg m-3 / (1.78E-5 kg m-1 s-1) = 34400. This cylinder will display transition in shear layer behaviour (Zdravkovitch) so the boundary layer will be laminar when it separates and separation will occur around 80 degrees.
constant/transportProperties
FoamFile{version 2.0; format ascii; class dictionary;object transportProperties;}
transportModel Newtonian;
nu nu [0 2 -1 0 0 0 0] 1.45E-5;

3) Solution control. 3a) Set the turbulence treatment for RAS. Create
constant/RASProperties
Set as laminar for now (turbulence off):
FoamFile{version 2.0; format ascii; class dictionary; object RASProperties;}
RASModel LaunderGibsonRSTM;
turbulence off;
3b) Solution types / schemes are specified in
 system/fvSchemes 
FoamFile{version 2.0; format ascii; class dictionary; location "system"; object fvSchemes;}

snGradSchemes{
    // limited 0.7; for bad meshes, corrected for good meshes.
    // must fit to laplacianSchemes
    default         limited 0.7;                                
    }

laplacianSchemes{
   default none;  // If something is missing, tell me.

   // for good meshes
   //laplacian(nuEff,U) Gauss linear corrected;    
   // for bad meshes  
   laplacian(nuEff,U) Gauss linear limited 0.7;    

   // for good meshes
   //laplacian((1|A(U)),p) Gauss linear corrected; 
   // for bad meshes 
   laplacian((1|A(U)),p) Gauss linear limited 0.7; 
   
   // for turbulent flow involving k only:
   // laplacian(DkEff,k) Gauss linear corrected;

   // for turbulent flow involving epsilon only:
   laplacian(DepsilonEff,epsilon) Gauss linear corrected;

   // for turbulent flow including Reynolds stress only:
   // Needed for LRR. corrected or limited.
   laplacian(DREff,R) Gauss linear corrected; 

   // for turbulent flow requiring nuTilda only, ie SA   
   // laplacian(DnuTildaEff,nuTilda) Gauss linear corrected;
 
   // These are from $FOAM_TUTORIALS/incompressible/simpleFoam/airFoil2D
   // SA not kE
   // laplacian(nuEff,U) Gauss linear corrected; // got it
   // laplacian((1|A(U)),p) Gauss linear corrected; // got it

   // Why not limited? nuTilda for SA only.
   // laplacian(DnuTildaEff,nuTilda) Gauss linear corrected; 

   // didnt have it.   limited?
   // laplacian(1,p)  Gauss linear corrected;  
   }

fluxRequired{
    default no; 
    p; 
    //phi;
    }

gradSchemes{
   // Gauss linear or leastSquares
   default   Gauss linear;  
   
   grad(p)   faceLimited leastSquares 0 1;   
   
   grad(U)   Gauss linear;             
   }

interpolationSchemes{
   default  linear;     // linear is fine
   U               linear;

   // new tet mesh interpolator. Use with reconCentral in divSchemes.
   // This is not available in vanilla openFoam yet.  There is an extended
   // version.  I'll try compile it in another article.
   // I've read articles where people stated it gave little benefit,
   // but none that stated it helped.
   // interpolate(U) reconCentral phi cellLimited leastSquare 1.0; 
   }

divSchemes{
   default none;
   
   // stable: Gauss upwind
   div(phi,U)      Gauss upwind;               
   // faster linearUpwind Gauss
   // div(phi,U)      Gauss linearUpwind Gauss; 
   
   // new, tets mesh setting:
   // div(phi,U)      Gauss reconCentral cellLimited leastSquares 1.0;    

   // for turbulent flow only
   // div(phi,k)      Gauss upwind;             

   // for turbulent flow only
   div(phi,epsilon) Gauss upwind;              

   // for turbulent flow only
   div(phi,R)      Gauss upwind;               

   // for turbulent flow only
   div(R)          Gauss linear;               
   
   // for SA turbulent flow only.
   // div(phi,nuTilda) Gauss upwind;           

   // this scheme is not used for steady and laminar flow, but
   // it is read by the solver.  (I haven't tested this)
   div((nuEff*dev(grad(U).T()))) Gauss linear; 
                                               
   // not advised, taken from motorbike case
   div((nuEff*dev(T(grad(U))))) Gauss linear; 

   // from airFoil2D:
   // default         none;  // same
   // div(phi,U)      Gauss linearUpwind grad(U);
   
   // set above but this I think is the fast version.  SA only
   // div(phi,nuTilda) Gauss linearUpwind grad(nuTilda);  
   
   // I think this is the same as the term above.
   // div((nuEff*dev(T(grad(U))))) Gauss linear; 
   }

ddtSchemes{
   default steadyState;
   // ddt(epsilon)
   }
3c) Specify the solution parameters. Create
system/fvSolution
FoamFile{version 2.0; format ascii; class dictionary; location "system"; object fvSolution;}

SIMPLE{
   // 0 is fine for perfect mesh; increase to 1 or 2 for non orthogonal mesh
   nNonOrthogonalCorrectors 2;         

   // convergence criteria steady state
   convergence         1e-7;           
   
   // ref cell is 0 in the airfoil tutorial
   pRefCell               0;           
   
   // ref value is 0 in the airfoil case.
   pRefValue              0;           
   residualControl{
      p 1E-5; 
      U 1E-5; 
      k 1E-5; 
      epsilon 1E-5;
      }                               
   }

relaxationFactors{
   // 0.3 is stable, decrease for bad mesh
   p        0.1;                

   // 0.7 is stable, decrease for bad mesh
   U        0.3;                

   // 0.7 is stable, decrease for bad mesh
   //k        0.3;                

   // Not sure yet about R relaxation.
   //R        0.1;

   // Not sure yet about epsilon relaxation.                
   //epsilon  0.3;
   }

solvers{
   // linear equation system solver for U
   U{
      // solver type
      solver          smoothSolver;
      
      // smoother type
      smoother        GaussSeidel;
   
      // solver finishes if either absolute or relative 
      // tolerance is reached. airFoil2D uses 1E-8
      tolerance       1e-06;          
      relTol          0.01;           

      // smoothSolver setting.
      //: airFoil uses 2 sweeps with 0.1 relTol.
      nSweeps         1;
      maxIter         100;
      }

   // linear equation system solver for p
   p{                                 
      // very efficient multigrid solver
      solver          GAMG;           

      // solver finishes if either absolute or relative 
      // tolerance is reached.  
       // airFoil2D uses relTol 0.1, tol 1E-6
      tolerance       1e-07;          
      relTol          0.001;

      // a minimum number of iterations
      minIter         3;              
      
      // limitation of iterions number
      maxIter         100;            

      // setting for GAMG. airFoil2D uses GaussSeidel.
      smoother        DIC;            

      // 1 for p, set to 0 for all other!  airfoil2D uses 0
      nPreSweeps      1;              

      // 2 is fine.  airfoil2D uses 2
      nPostSweeps     2;              

      // 2 is fine
      nFinestSweeps   2;              
      
      scaleCorrection true;
      directSolveCoarsestLevel false;
      // on unless dynamic mesh refinement is used.
      cacheAgglomeration on;          

      // 500 or sqrt(cell count)
      nCellsInCoarsestLevel 1000;

      agglomerator    faceAreaPair;  
      mergeLevels     1;
      }

   //epsilon{solver PBiCG; preconditioner DILU; tolerance 1E-9; relTol 0;}
   //R{solver PBiCG; preconditioner DILU; tolerance 1E-9; relTol 0;}
   }
3d) Create the control dictionary: file system/controlDict
FoamFile{version 2.0; format ascii; class dictionary; object controlDict;}
application simpleFoam;
startFrom latestTime; // latestTime / startTime
startTime 0;
stopAt endTime;  endTime 100000; 
deltaT 1;
writeControl timeStep; writeInterval 300; purgeWrite 0;
writeFormat ascii; writePrecision 6; writeCompression uncompressed;
timeFormat general;timePrecision 6; 
runTimeModifiable yes;
4) Create the mesh by typing,
$ blockMesh
5) Solve with a single processor by typing,
 $ nohup simpleFoam > log &
or in parallel with
$ mpirun -np 4 simpleFoam -parallel > log &

X11 connection rejected because of wrong authentication.

rm -rf ~/.Xauthorit*

gmsh sinusoidal mesh density

Point (1) = {0, 0, 0};  
Point (2) = {1, 0, 0};  
Point (3) = {2, 0, 0};  
Point (5) = {1, 1, 0};  
Point (9) = {1, -1, 0}; 

Line(1) = {1, 2}; 
Line(2) = {2, 3}; 
Line(3) = {3, 5}; 
Line(5) = {5, 1}; 
Line(7) = {5, 2}; 

Line Loop(8) = {1, -7, 5}; Plane Surface (9) = {8}; 
Line Loop(10) = {7, 2, 3}; Plane Surface (11) = {10}; 

Line(12) = {1, 9}; 
Line(13) = {9, 2}; 
Line(14) = {9, 3};

Line Loop(15) = {1, -13, -12}; Plane Surface(16) = {15}; 
Line Loop(17) = {2, -14, 13}; Plane Surface(18) = {17}; 

// Sets the element size in the left region (9) 
Field[1] = MathEval; Field[1].F = "0.011+0.009*Sin(x*12)"; 

Field[6] = Restrict; Field[6].IField = 1; 
Field[6].FacesList = {16}; 
Background Field = 6;



Friday, 13 April 2012

http://engits.eu/wiki/index.php/Tutorials/Version1.2/Unstructured_Grids_for_OpenFOAM_With_Blender_and_enGrid

Wednesday, 11 April 2012

gmsh min function

minab = (a < b) ? a : b;

Sunday, 8 April 2012

ssh security measures

After a failed login attempt, refuse attempts to log in from that ip address for one minute:

$ iptables -A INPUT -p tcp -m state --syn --state NEW --dport 22 -m limit --limit 1/minute --limit-burst 1 -j ACCEPT

$ iptables -A INPUT -p tcp -m state --syn --state NEW --dport 22 -j DROP

Does this need to be re-specified on each restart?

Sunday, 1 April 2012

rotating log files

from http://ubuntuforums.org/showthread.php?t=676837

/var/log/news/* {
daily
rotate 7
olddir /var/log/news/oldnews
missingok
postrotate
kill -1 `cat /var/run/syslogd.pid`
endscript
compress
}


I bet this can be updated to rotating archival.....

Saturday, 31 March 2012

installing ipython notebook

Install ZMQ manually:

tar xvf zeromq-2.1.11.tar.gz
cd zeromq-2.1.11/
./configure
make
sudo make install
sudo ldconfig

Then install ipython with zmq:

sudo easy_install ipython[zmq,test]

There was an error on completion but zmq bindings were installed and

ipython notebook

works.

Now install matplotlib:

sudo apt-get install python-dev libfreetype6-dev --- yes. This seems correct.
sudo easy_install matplotlib ---- No: this attempted to compile, and failed.

sudo apt-get install python-matplotlib # that was easy....


$ ipython notebook --pylab=inline