Hey, what's going on?

Archive for the ‘software & simulation’ Category

[SOLVED] Lenovo Laptop Stops Charging at 60%

Posted by Syeilendra Pramuditya on January 26, 2016

Symptom: Your Lenovo laptop somehow stops charging at 60%, it says “Plugged in, not charging”.

Step 1 – Enable .NET 3.5

Open Control Panel >> Programs >> Turn Windows features on and off

Then turn on/enable .NET Framework 3.5 (you need internet access to download it)

Step 2 – Install Energy Management Software

Download it from this official link, and just install it.

Restart the laptop.

Open the software from the icon tray (yellow car icon), then click “Battery Settings”.

~Problem Solved

Advertisements

Posted in software & simulation | Tagged: , , , | Leave a Comment »

Installing SRAC Code on Mandrivalinux 2010.0 x86_64

Posted by Syeilendra Pramuditya on January 18, 2016

SRAC: Standard Reactor Analysis Code, developed by Japan Atomic Energy Agency

SRAC code was developed long time ago, so there are problems when you try to install it on modern linux distros. The biggest problem of all is I think the original SRAC works only with F77/G77, whereas modern linux distros usually only provide gfortran.

Some installation tips:

Tip 1

Using the control panel, make sure that the following packages have been installed: gcc-cpp, gcc-c++, gcc-gfortran, tcsh, make, automake, ncompress, mscompress

Tip 2

Edit these 2 files:

SRAC/tool/install/SysDpnd/linux-g77/PrepInst.sh

SRAC/tool/install/SysDpnd/linux-g77/lmmake/lmmk/lmmk.sh

Open the files, you will see “set F77 = G77”, add a new line after that line: “set F77 = gfortran”

Now you just test run the code by executing SRAC/smpl/shr/Test.sh

Sample of input and output files are available here.

This has been tested and works for me.

*Of course you can just simply install SRAC 2006 which supports gfortran compiler.

Posted in nuclear engineering, software & simulation | Leave a Comment »

Revised Cheng-Todreas Correlations – Improvements in the Transition Flow Region

Posted by Syeilendra Pramuditya on April 8, 2014

Recently Cheng et al. published an article describing a revision to their correlations to improve the prediction of pressure drop coefficient in the transition flow region.

A computer code implementing the original correlations was developed and described in my previous post.

In the current post, I provide a modified code, in which the revision in the transition region has been incorporated.

 

Posted in nuclear engineering, software & simulation | Leave a Comment »

SPWebTemplate – A Flexible Template to Build Any Website

Posted by Syeilendra Pramuditya on September 1, 2013

SPWebTemplate

SPWebTemplate

This is a basic web template which can be used to develop any type of website.

It is written in PHP and HTML, and using MySQL database (to be precise, it also uses CSS and JavaScript).

The system has been derived from Pusat Data PPI Tokodai and PPI Jepang Publication (the author helped to initialize these two systems).

To install the template, follow these simple steps:

  1. unzip and copy all the files to your server
  2. create a MySQL database (you can use PHPMyAdmin interface to do this)
  3. edit a PHP file system/config.php according to your database setting
  4. with a web browser, open http://your-server-address.com/install
  5. that’s it.

Get the software here.

Posted in programming, software & simulation | Tagged: | Leave a Comment »

[Solved] Installing Mandrivalinux on HP ProLiant ML150 G6 Server

Posted by Syeilendra Pramuditya on May 24, 2013

This week I’ve been busy trying to install Linux OS on our new machine, HP ProLiant ML150 Server.

First I tried to put Mandrivalinux 2010 Spring 32 bit. Installation finished without any problem. But the OS couldn’t load at all.

The problem was exactly the same with the one discussed in this Mandriva forum.

Here are the error messages:

waiting for device cciss!c0d0p1 to appear (timeount 1min)
waiting for device cciss!c0d0p5 to appear (timeount 1min)
Could not find resume device (/dev/cciss/c0d0o5)
Could not resolve resume device (/dev/cciss/c0d0o5)
Creating root device.
Kernel panic - not syncing: Attempted to kill init!
Pid: 1, comm: init Not tainted 2.6.33.5-server-2mnb #1

So I tried their suggestions, bot no luck.

Some other Linux forum suggested to use so-called HP Easy Setup CD. I also tried it, but it works only for Windows installation, the is no option at all for Linux installation.

Then I tried to put openSUSE 10.3 32bit, even worse, the OS won’t install. It says there is no physical HDD.

So seems that the machine’s HDD is simply too *advance* for the two Linux distros to handle ;).

Well, to be honest, my knowledge of server world is kind of limited since it’s just a hobby for me :D.

So, in desperation, this simple idea came across my head: if 32bit OSs don’t know what to do with *advance* HDD, why don’t try to install a 64bit OS?

So I tried to installed Mandrivalinux 2010.0 64bit, and it just worked perfectly! 🙂

Our new machine is now ‘ON‘, finally! Alhamdulillah.. 😀

Posted in software & simulation | Tagged: , , , | Leave a Comment »

ANSYS Workbench 13 Tutorial: 2D Meshing with prism layers (or boundary layers) on wall boundaries

Posted by Syeilendra Pramuditya on October 15, 2012

This post shows step-by-step how to create the following 2D mesh:

Posted in nuclear engineering, software & simulation | Tagged: , , , , , | Leave a Comment »

Laminar velocity profile in square flow channel

Posted by Syeilendra Pramuditya on October 13, 2012

In my previous article, I discussed about laminar velocity profile for 2D problem, the numerical solution technique is easily extendible to 3D problem. For example to solve isothermal laminar flow in a square channel problem, as illustrated below:

For this case, linear momentum equation takes the form:

The program is basically very similar to the 2D problem, just in the current case the calculated x-velocity is stored in 2D (or two-index) array. The Fortran code is shown below:

!     Laminar velocity profile in square flow channel
!     By Syeilendra Pramuditya - https://syeilendrapramuditya.wordpress.com
!     October 2012
      program main
      implicit none
      integer j,jmin,jmax,k,kmin,kmax,iter,itermax,conv,prnt
      parameter(jmin=0, jmax=40, kmin=0, kmax=40)
      real*8 mu,rho,Ly,Lz,uy1,uy2,uz1,uz2,errmax,Re,Dh,uinit,f,mdpdx,
     &alpha,uold(jmin:jmax,kmin:kmax),unew(jmin:jmax,kmin:kmax),dy,dz,
     &y(jmin:jmax),z(kmin:kmax),dy2,dz2,beta,err

      !input
      Ly=1.0d-2
      Lz=Ly !square channel
      uy1=0.0d0
      uy2=0.0d0
      uz1=0.0d0
      uz2=0.0d0
      itermax=5000
      errmax=1.0d-6
      Re=5.0d2

      !props
      mu=1.0d-3
      rho=1.0d3

      !calc internal vars
      Dh=4.0d0*(Ly*Lz)/(2.0d0*Ly+2.0d0*Lz)
      uinit=Re*mu/(rho*Dh)
      f=14.0d0/Re !friction factor
      mdpdx=(f/Dh)*0.5d0*rho*uinit*uinit ! -dp/dx
      alpha=mdpdx/mu

      !init all arrays
      do j=jmin,jmax
      do k=kmin,kmax
      uold(j,k)=0.0d0
      unew(j,k)=0.0d0
      end do
      end do

      !mesh
      dy=Ly/(jmax-jmin)
      dy2=dy*dy
      y(jmin)=0.0d0
      do j=jmin+1,jmax
      y(j)=y(j-1)+dy
      end do
      dz=Lz/(kmax-kmin)
      dz2=dz*dz
      z(kmin)=0.0d0
      do k=kmin+1,kmax
      z(k)=z(k-1)+dz
      end do

      beta=1.0d0/(2.0d0/dy2+2.0d0/dz2)

      !init guess of x-velocity
      do j=jmin+1,jmax-1
      do k=kmin+1,kmax-1
      uold(j,k)=uinit
      unew(j,k)=uinit
      end do
      end do

      !init boundary condition
      do k=kmin,kmax
      uold(0,k)=uy1
      uold(jmax,k)=uy2
      unew(0,k)=uy1
      unew(jmax,k)=uy2
      end do
      do j=jmin,jmax
      uold(j,0)=uz1
      uold(j,kmax)=uz2
      unew(j,0)=uz1
      unew(j,kmax)=uz2
      end do

      !calculate
      conv=0
      iter=0
      do while((conv.eq.0).and.(iter.le.itermax))
      conv=1
       !calc new u
       do j=jmin+1,jmax-1
       do k=kmin+1,kmax-1
       unew(j,k)=beta*(uold(j+1,k)+uold(j-1,k))/dy2 +
     &           beta*(uold(j,k+1)+uold(j,k-1))/dz2 + beta*alpha
       err=dabs(unew(j,k)-uold(j,k))/unew(j,k)
       if(err.ge.errmax) conv=0 !check convergence
       end do
       end do
       !update u
       do j=jmin,jmax
       do k=kmin,kmax
       uold(j,k)=unew(j,k)
       end do
       end do
      iter=iter+1
      end do

      !output result
      prnt=6
      write(prnt,*) 'Solution Converged in',iter,'iterations'
      write(prnt,*) ' '
      write(prnt,*) 'The result has been saved to the following files:'
      write(prnt,*) 'xveloc.dat -> calculated x velocity [m/s]'
      write(prnt,*) 'ypos.dat   -> y coordinate [m]'
      write(prnt,*) 'zpos.dat   -> z coordinate [m]'

      open(10,file="xveloc.dat")
      do j=jmin,jmax
      write(10,1000) (unew(j,k),k=kmin,kmax)
      end do
      close(10)
      open(10,file="ypos.dat")
      do j=jmin,jmax
      write(10,1000) y(j)
      end do
      close(10)
      open(10,file="zpos.dat")
      do k=kmin,kmax
      write(10,1000) z(k)
      end do
      close(10)

 1000 format(1P50E10.3)

      stop
      end

The calculated result can be plotted using the following Matlab m-file:

y=dlmread('ypos.dat',' ');
z=dlmread('zpos.dat',' ');
[Y,Z]=meshgrid(y,z);
VX = dlmread('xveloc.dat',' ');
surf(Y,Z,VX)
shading interp
title('x-Velocity [m/s]')
xlabel('y (cm)'),ylabel('z (cm)'),zlabel('x-Velocity [m/s]')
axis tight;
colorbar;
view(0,90);

And here is the resulting plot:

x-Velocity profile at Re = 1000

The real power of numerical solution methods is their ability to approximate the solution of a given mathematical equation for complex geometry. So let’s make this problem a bit more interesting by making the geometry a bit more complex, and we do this by “putting” an immersed rectangular solid object into the flow channel. This is achieved simply by applying a zero-velocity boundary condition at the object’s location. The modified code is available here, and the result is shown below:

x-Velocity profile with immersed solid rectangular object inside the flow channel

Posted in nuclear engineering, software & simulation | Tagged: , | Leave a Comment »

Problem Solving Series – Laminar Velocity Profile Between Infinite Parallel Plates

Posted by Syeilendra Pramuditya on October 12, 2012

The Document

The Code

!     Laminar velocity profile between infinite parallel plates
!     By Syeilendra Pramuditya - https://syeilendrapramuditya.wordpress.com
!     October 2012
      program main
      implicit none
      integer j,jmin,jmax,iter,itermax,conv,prnt
      parameter(jmin=0, jmax=10)
      real*8 uold(jmin:jmax),unew(jmin:jmax),L,uinit,dy,errmax,
     &mu,rho,Re,f,mdpdx,alpha,err,ubot,utop,y(jmin:jmax),
     &umath(jmin:jmax)

      !input
      L=1.0d-2
      ubot=0.0d0
      utop=0.0d0
      itermax=1000
      errmax=1.0d-6
      Re=5.0d2

      !props
      mu=1.0d-3
      rho=1.0d3

      !calc internal vars
      uinit=Re*mu/(rho*L) !average x-veloc
      f=24.0d0/Re !friction factor
      mdpdx=(f/L)*0.5d0*rho*uinit*uinit ! -dp/dx
      alpha=0.5d0*mdpdx/mu

      !init all arrays
      do j=jmin,jmax
      uold(j)=0.0d0
      unew(j)=0.0d0
      end do

      !mesh
      dy=L/(jmax-jmin)
      y(jmin)=0.0d0
      do j=jmin+1,jmax
      y(j)=y(j-1)+dy
      end do

      !init guess of x-velocity
      do j=jmin+1,jmax-1
      uold(j)=uinit
      end do

      !init boundary condition
      uold(jmin)=ubot
      uold(jmax)=utop
      unew(jmin)=ubot
      unew(jmax)=utop

      !calculate
      conv=0
      iter=0
      do while((conv.eq.0).and.(iter.le.itermax))
      conv=1
       !calc new u
       do j=jmin+1,jmax-1
       unew(j)=0.5d0*(uold(j+1)+uold(j-1))+alpha*dy*dy
       err=dabs(unew(j)-uold(j))/unew(j)
       if(err.ge.errmax) conv=0 !check convergence
       end do
       !update u
       do j=jmin,jmax
       uold(j)=unew(j)
       end do
      iter=iter+1
      end do

      !exact solution for static walls
      do j=jmin,jmax
      umath(j)=0.5d0*(1.0d0/mu)*mdpdx*(L*y(j)-y(j)*y(j))
      end do

      !result
      prnt=6
      write(prnt,*) 'Re =',Re
      write(prnt,*) 'Solution Converged in',iter,'iterations'
      write(prnt,*) ' '
      write(prnt,*) '      y [m]      u[m/s]  umath[m/s]'
      do j=jmin,jmax
      write(prnt,1000) real(y(j)),real(unew(j)),real(umath(j))
      end do
      write(prnt,*) ' '
      write(prnt,*) 'Result has been saved to fort.10 file'
      prnt=10
      write(prnt,*) 'Re =',Re
      write(prnt,*) 'Solution Converged in',iter,'iterations'
      write(prnt,*) ' '
      write(prnt,*) '      y [m]      u[m/s]  umath[m/s]'
      do j=jmin,jmax
      write(prnt,1000) real(y(j)),real(unew(j)),real(umath(j))
      end do

 1000 format(1P20E12.3)

      stop
      end

Posted in nuclear engineering, software & simulation | Tagged: , , | Leave a Comment »

Liquid Sodium Thermodynamic and Transport Properties

Posted by Syeilendra Pramuditya on February 8, 2012

The program can be accessed from this link.

Source code can be downloaded from this link. (or from here)

Related link:

Posted in nuclear engineering, software & simulation | Tagged: , , , , , , , | Leave a Comment »

Free Time CFD Coding

Posted by Syeilendra Pramuditya on July 6, 2011

Shortlink: http://wp.me/p61TQ-Fn

Ketika sedang mencari bahan2 bacaan mengenai CFD, saya menemukan ebook gratis keluaran Los Alamos National Laboratory (LANL). Menurut saya ebook ini lumayan bagus sebagai panduan untuk memahami CFD melalui pendekatan learning by doing: belajar CFD dengan cara membuat code.

Ebook bisa di download di link ini.

Untuk melakukan riset serius memang secara umum adalah bukan ide yang bagus untuk membuat code CFD sendiri, karena sudah ada beberapa code CFD open source yang sudah cukup proven. Tetapi tidak ada salahnya juga untuk menulis code sendiri di waktu2 luang (apalagi kalau anda memang hobby programming), yang sederhana2 saja, lumayan juga untuk lebih meresapi konsep2 dasar CFD, karena itu artikel ini saya beri judul Free Time CFD Coding :).

So, iseng2 untuk mengisi waktu kalau saya kebetulan tidak terlalu sibuk, saya tulis beberapa code berdasarkan ebook tersebut, beberapa source code and contoh output saya pasang di artikel ini, lumayan itung2 sebagai personal archive :).

Subroutine2 FORTRAN bisa di download di link ini: Some FORTRAN Subroutines

[_code | result] 1D heat conduction, explicit

[_code | result] 1D heat conduction, implicit by Gaussian elimination

[_code | result] 1D heat conduction, implicit by general Jacobi iteration

[_code | result] 1D heat conduction, implicit by tridiagonal Jacobi iteration

[_code | result] 1D heat conduction, implicit by general Gauss-Seidel iteration

[_code | result] 1D heat conduction, implicit by tridiagonal Gauss-Seidel iteration

Method
Running time
Memory requirement
Direct matrix inversion by Gauss elimination
1.14
15.43
General Jacobi iteration
9.16
15.43
Tridiagonal Jacobi iteration
1.03
1.00
General Gauss-Seidel iteration
6.78
15.43
Tridiagonal Gauss-Seidel iteration
1.00
1.00
  • Space domain: 50 real cells + 2 ghost (boundary) cells, dx = 1 m
  • Time domain: 1000 s, dt = 0.02 s
  • Running time is total elapsed time (user+system), normalized to minimum value
  • Memory requirement is an estimated value, based on array dimensions of the main variables (8 bytes per double precision variable), normalized to minimum value

[_code | result] 1D Lagrangian fluid dynamics, compressible, explicit – piston problem

[_code | result] 1D Lagrangian fluid dynamics, compressible, explicit – shock tube problem

[_code | result] 1D Eulerian fluid dynamics, compressible, explicit – piston problem

[_code | result] 1D Eulerian fluid dynamics, compressible, explicit – shock tube problem

Lagrangian method produces sharper shock profile compare to Eulerian method

[_code | result] 2D Eulerian fluid dynamics, incompressible, semi-implicit

[_code | result] 2D Eulerian fluid dynamics with heat transfer, incompressible, semi-implicit

[_code | result] 2D Eulerian fluid dynamics, compressible, semi-implicit

[_code | result] 2D Eulerian fluid dynamics with k-epsilon turbulence transport model

Mohon beritahu saya kalau anda menemukan bug di dalam code2 tsb, trimakasih 🙂

Posted in software & simulation | Tagged: , , , , , , , , | Leave a Comment »

Some simple Delphi graphic subroutines

Posted by Syeilendra Pramuditya on February 14, 2011

I just realized that Delphi does not have functions to draw circle and equilateral-triangle which fit my need. So I just wrote some subroutines to do this.

Subroutine to initialize drawing area

{Subroutine to initialize drawing area}
procedure bitmap_init(image1:TImage);
begin
Bitmap:=TBitmap.create;(*Create a bitmap object*)
Bitmap.width:=500;(*Assign dimensions*)
Bitmap.height:=500;
image1.Picture.Graphic:=Bitmap;
end;

Subroutine to draw circle

{Subroutine to draw circle}
procedure DrawCircle(x,y,radius:real;image1:TImage;LineColor:array3int;BrushColor:array3int);
{
Passed parameters:
x,y        = coordinate of circle's center [pixel]
radius     = circle radius [pixel]
LineColor  = line color in RGB format
BrushColor = brush color in RGB format
}
var
x1,y1,x2,y2:integer;
begin
x1:=round(x-radius);
y1:=round(y-radius);
x2:=round(x+radius);
y2:=round(y+radius);

with image1.Picture.Bitmap.Canvas do
begin
pen.Color:=rgb(LineColor[1],LineColor[2],LineColor[3]);
brush.Color:=rgb(BrushColor[1],BrushColor[2],BrushColor[3]);
ellipse(x1,y1,x2,y2);
end;

end;

Subroutine to draw equilateral triangle

{Subroutine to draw equilateral triangle}
procedure DrawEquiTri(x,y,LSide,angle:real;image1:TImage;LineColor:array3int;BrushColor:array3int);
{
Passed parameters:
x,y = coordinate of triangle's center
LSide = side length [pixel]
angle = triangle's direction [degree]
LineColor  = line color in RGB format
BrushColor = brush color in RGB format
}
var
radius:real;
x1,y1,x2,y2,x3,y3:integer;
begin
radius:=(LSide/2)/cos(pi/6);

x1:=round( x+radius*cos(0+angle*pi/180) );
y1:=round( y+radius*sin(0+angle*pi/180) );
x2:=round( x+radius*cos(2*pi/3+angle*pi/180) );
y2:=round( y+radius*sin(2*pi/3+angle*pi/180) );
x3:=round( x+radius*cos(4*pi/3+angle*pi/180) );
y3:=round( y+radius*sin(4*pi/3+angle*pi/180) );

with image1.Picture.Bitmap.Canvas do
begin
pen.Color:=rgb(LineColor[1],LineColor[2],LineColor[3]);
brush.Color:=rgb(BrushColor[1],BrushColor[2],BrushColor[3]);
Polygon([Point(x1,y1),Point(x2,y2),Point(x3,y3)]);
end;

end;

Subroutine to draw rectangle (with user-specified inclination angle)

{Subroutine to draw rectangle (with user-specified inclination angle)}
procedure DrawRect(x,y,lside,sside,theta:real;image1:TImage;LineColor:array3int;BrushColor:array3int);
{
Passed parameters:
x,y        = coordinate of rectangle’s center [pixel]
lside      = length of the longer side [pixel]
sside      = length of the shorter side [pixel]
theta      = angle
LineColor  = line color in RGB format
BrushColor = brush color in RGB format

The "Math" unit must be included in the main program
}
var
x1,y1,x2,y2,x3,y3,x4,y4:integer;
radius,theta2:real;
begin
theta:=theta*pi/180;
radius:=sqrt(sqr(lside/2)+sqr(sside/2));
theta2:=arctan(sside/lside);
DrawCircle(x,y,5,image1,LineColor,BrushColor);
x1:=round(x-radius*cos(theta2+theta));
y1:=round(y-radius*sin(theta2+theta));
x2:=round(x+radius*cos(theta2-theta));
y2:=round(y-radius*sin(theta2-theta));
x3:=round(x+radius*cos(theta2+theta));
y3:=round(y+radius*sin(theta2+theta));
x4:=round(x-radius*cos(theta2-theta));
y4:=round(y+radius*sin(theta2-theta));

with image1.Picture.Bitmap.Canvas do
begin
pen.Color:=rgb(LineColor[1],LineColor[2],LineColor[3]);
brush.Color:=rgb(BrushColor[1],BrushColor[2],BrushColor[3]);
polygon([point(x1,y1),point(x2,y2),point(x3,y3),point(x4,y4)]);
end;

end;

Subroutine to generate color bar

{Subroutine to generate color bar}
procedure DrawColorBar(x1,y1,xsize,ysize,bgcolor:integer;minval,maxval:real;image1:TImage);
{
x1,y1 = leftmost and topmost coordinate of the color bar
xsize = width of the color bar [pixel]
ysize = height of the color bar [pixel]
bgcolor = background color, 0=white and 1=black
minval = minimum value of the data
maxval = maximum value of the data
}
var
i,j,r,g,b,istep:integer;
freq,fstep:real;
stext:string;

begin
{
bgcolor=0, text will be written in black
bgcolor=1, text will be written in lime
}
fstep:=(maxval-minval)/5;
istep:=round(fstep*ysize/(maxval-minval));

freq:=2*pi/(2*ysize);

with image1.Picture.Bitmap.Canvas do
begin

for i:=0 to ysize do
begin
r:=round(127.5+(127.5*sin(freq*i+0.0*pi-0.50*pi)));
g:=round(0.000+(255.0*sin(freq*i+0.5*pi-0.50*pi)));
b:=round(127.5+(127.5*sin(freq*i+1.0*pi-0.50*pi)));
r:=255-r;
b:=255-b;
pen.Color:=rgb(r,g,b);
moveto(x1,y1+i);
lineto(x1+xsize,y1+i);
end;

if bgcolor=0 then
begin
pen.color:=clblack;
font.color:=clblack;
end
else if bgcolor=1 then
begin
pen.color:=cllime;
font.color:=cllime;
end;

for j:=0 to 5 do
begin
moveto(x1+xsize,y1+j*istep);
lineto(x1+xsize+5,y1+j*istep);
font.Size:=8;
stext:=FormatFloat('0.000', maxval-j*fstep);
textout(x1+xsize+10,y1+j*istep-5,stext);
end;

end;

end;

How to use these subroutines?

First define a global variable type:

type array3int=array[1..3]of integer; {you need this array to define colors in RGB format}

Then define  a global variable (I named it “Bitmap”):

var Bitmap:TBitmap; {you need this variable to identify drawing object}

Then from your main program, you first invoke the initialization subroutine:

bitmap_init(image1);

After this, you can directly invoke the drawing subroutines, it should be look like this:

DrawEquiTri(400,250,100,0,image1,LineColor,BrushColor);

A free sample code can be downloaded here.

So why bother with these stuffs? well, it’s kind of personal, currently my life is just full of circles and triangles! :mrgreen: My work is about thermal hydraulic analysis of Sodium-cooled Fast Reactor (SFR) subassembly by subchannel analysis method. Unfortunately, the subchannel code I am using now does not have any data visualization capability, it just keeps giving me bunch of numbers, quite a lot of it! By using the above simple subroutines, eventually now I can generate this kind of data plot:

Sodium Temperature Profile

Simply speaking, it’s all about DATA VISUALIZATION, man!

Posted in software & simulation | Tagged: , , , , , , , , | 1 Comment »

Installing LAPACK/BLAS on Mandriva 2010

Posted by Syeilendra Pramuditya on January 19, 2011

Download the source file from the web. I downloaded version 3.3.0 (lapack-3.3.0.tgz). Save it to /usr/local/ (you need to use root account). Make sure (change if necessary) that the “owner” and the “group” are your linux user name.

  1. By using root account, extract the file: gunzip -c lapack-3.30.tgz | tar xvf –
  2. Type: cd lapack-3.3.0
  3. Type: chown yourusername *.* * -R
  4. Type: chgrp yourusername *.* * -R
  5. Exit the root account and just use your user account
  6. Type: cp make.inc.example make.inc (by default, gfortran compiler will be used, otherwise you need to edit this make.inc file)
  7. Type: make blaslib
  8. Type: make lapacklib
  9. Type: cp blas_LINUX.a libblas.a
  10. Type: cp lapack_LINUX.a liblapack.a
  11. Finish

Now you need to run a sample case, I took the following code from Ref. 3:

c This code is written in Fortran
      Program LinearEquations
c solving the matrix equation A*x=b using LAPACK
      Implicit none
c declarations, notice single precision
      Real*4 A(3,3), b(3)
      integer i, j, pivot(3), ok
c define matrix A
      A(1,1)=3.1
      A(1,2)=1.3
      A(1,3)=-5.7
      A(2,1)=1.0
      A(2,2)=-6.9
      A(2,3)=5.8
      A(3,1)=3.4
      A(3,2)=7.2
      A(3,3)=-8.8
c define vector b, make b a matrix and you can solve multiple
c equations with the same A but different b
      b(1)=-1.3
      b(2)=-0.1
      b(3)=1.8
c find the solution using the LAPACK routine SGESV
      call SGESV(3, 1, A, 3, pivot, b, 3, ok)
c
c parameters in the order as they appear in the function call
c order of matrix A, number of right hand sides (b), matrix A,
c leading dimension of A, array that records pivoting,
c result vector b on entry, x on exit, leading dimension of b
c return value
c
c print the vector x
      do i=1, 3
      write(*,*) b(i)
       end do
      end

To compile and link, type: gfortran -o main.unix main.f -L/usr/local/lapack-3.3.0 -llapack -lblas

To run type: ./main.unix

The answer should be [1.0 , 1.0 , 1.0]

References:

  1. NETLIB
  2. LLNL
  3. ORST
  4. UTAH

Posted in software & simulation | Tagged: , , , , , | Leave a Comment »

NECTAR Code – A Steady State Thermal Hydraulics Solver

Posted by Syeilendra Pramuditya on January 4, 2011

Shortlink: http://wp.me/p61TQ-zt

Software License Agreement

This software is given “as is”. The author holds its copy rights, one can download, copy, use, modify, and spread it free of charge, provided that the original sources (the author and this webpage) are properly cited. The author assumes no responsibility, implicit or explicit, for any possible loss or damage due to the use of this software.

By downloading the software, you agree to accept this agreement.


Download code package:

Preview:

Posted in nuclear engineering, software & simulation | Leave a Comment »

Some FORTRAN Subroutines

Posted by Syeilendra Pramuditya on December 30, 2010

Shortlink: http://wp.me/p61TQ-zb

Some standard libraries:

Some compact subroutines:

  • [ download ] MATINV – Subroutine for matrix inversion
  • [ download ] GETDET – Function to calculate matrix determinant
  • [ download ] TRIDAG – Subroutine to solve tridiagonal matrix system (source | mirror)
  • [ download ] MATMTP – Subroutine for matrix multiplication
  • [ download ] JACOBI – Subroutine to solve general linear equation system by Jacobi method
  • [ download ] JCBTRI – Subroutine to solve tridiagonal linear equation system by Jacobi method

You can download all the subroutines here (zipped).

Let me know if the links don’t work.

See also Fortran code to calculate water thermodynamic properties (density, specific heat capacity, thermal conductivity, dynamic viscosity, and saturation temperature) as functions of temperature.

Posted in software & simulation | Tagged: , , , , , , , | 2 Comments »

Thermal-Hydraulics of Single Phase Flow in Multi-Channel Systems

Posted by Syeilendra Pramuditya on September 23, 2010

Shortlink: http://wp.me/p61TQ-wo

A free computer code is available on http://wp.me/p61TQ-zt

Posted in nuclear engineering, software & simulation | Leave a Comment »