Thursday, November 26, 2009

Installing Salome platfrom on Fedora (12 x86_64)

The salome platform is a good open source platform for FEA/CFD etc. It includes a good preprocessor to easily create geometries, mesh them in a variety of ways and also import/export various types of formats. I generally use it with OpenFOAM, which is a FVM library and collection of programs to solve various types of flows and also structures and other problems.
Check them out at http://www.salome-platform.org/ and http://www.openfoam.com/features/
So the main thing i'm writing this is as a reminder to me and to save hoursof other people's time who try installing salome-platform on any of the modern linux distros.

Step 1 > Download the package. If the package is not available for you distro choose debian or mandriva whichever is closer to your distro (both work in case of fedora)
Step 2 > Extract (tar -xvf filename) to a convenient location (your home or anywhere else doesn't matter. u can delete this later)
Step 3 > Change the file config_files/gcc-common.sh to match your installation of gcc. I replaced gcc_root="/usr/bin".
Step 4 > Run ./runInstall. Choose appropriate options in the gui and finish the wizard.
Step 5 > To run salome type:
$ . KERNEL_<version>/salome.sh
$ runSalome
Thats it
Step 6 > Now steps 1 to 5 are simple, anyone can do it without any help. Here comes the main point which took me hours despite me already having installed and used various versions of salome in previous fedora installations.
If you see an error message like

Configure parser: Warning : could not find user configuration file
runSalome running on localhost
Configure parser: Warning : could not find user configuration file
Searching for a free port for naming service: 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 - OK
Searching Naming Service ++++++++++Failed to narrow the root naming context
Traceback (most recent call last):
  File "/opt/salome_5.1.2/KERNEL_5.1.2/bin/salome/runSalome.py", line 648, in useSalome
    clt = startSalome(args, modules_list, modules_root_dir)
  File "/opt/salome_5.1.2/KERNEL_5.1.2/bin/salome/runSalome.py", line 429, in startSalome
    clt=orbmodule.client(args)
  File "/opt/salome_5.1.2/KERNEL_5.1.2/bin/salome/orbmodule.py", line 48, in __init__
    self.initNS(args or {})
  File "/opt/salome_5.1.2/KERNEL_5.1.2/bin/salome/orbmodule.py", line 81, in initNS
    sys.exit(1)
SystemExit: 1

on running salome then here's what you need to do.

1 > edit /etc/hosts (of course you need root for that) and make sure you have a line such as

127.0.0.1 <hostname>

in there. Most probably on a desktop system <hostname> will be localhost

2 > If you still get the same error then
delete any lines in /etc/hosts corresponding to IPv6, i.e. of the type

::1 localhost

This is the part that took me hours to figure out. So now you know, omniorb probably does not support IPv6 as of yet. Someone should hopefully fix it soon.

Sunday, November 15, 2009

Why i use Fedora linux

This question crops up fairly too often in my conversation with friends who use linux (most of them use ubuntu). So i decided to settle the matter once and for all.
My reason for using fedora is simple, its the same reason why some people like strawberry flavoured ice-creams and some hate it, its THEIR OWN PREFERENCE.
Also i first started with fedora because it was the first linux i ever saw (in my NSL computer lab for cs101 course). Yes, contrary to popular belief, i did not use linux from my childhood, the first computer in my home was 3 months before i joined IIT. And the first linux i saw was in IIT. I event learnt my first two languages C/C++ and Java by READING BOOKS, and even read the complete print copy of "Dive into Python" before actually diving into python!
The first linux i used was Knoppix live which came with a dvd of a magazine. I used it exclusively for 2 weeks as i didn't know how to install an os. Then after burning about 6-7 cds (i wasted a few) i installed my first linux, Fedora 5 Bordeaux and have installed every Fedora release ever since, and never felt the need to change my distro. Most of them are mostly the same from the inside.

However, just in case you want to make points, i'll list a few:
http://fedoraproject.org/wiki/Overview

  • Fedora (+RH) devs work hard on bringing new features in linux. Many of the new features in linux are brought by them. For example the latest features in linux have been developed by fedora/RH devs including but not limited to the NetworkManager, pulseaudio, packagekit,.pulseaudio and many more. Also check http://fedoraproject.org/wiki/Red_Hat_contributions
  •  The openness of fedora is what i really like and wish all the world were so open. By this open i do not mean open-source code, i mean openness of mind, acceptance of others, openness of governance, openness of activities, no hidden agenda.
  • The fedora features mention exactly what is there in a new fedora release (many of the things are own contributions). Compare http://fedoraproject.org/wiki/Releases/12/FeatureList with http://www.ubuntu.com/products/whatisubuntu/910features . I couldn't figure out what different from the previous release apart from firefox 3.5, openoffice 3.1 and ubuntuone.
  • Fedora stays closer to upstream and is generally more updated.
  • http://fedoraproject.org/wiki/Foundations
As someone put it somewhere on a blog, Fedora is about doing right, Ubuntu is about making things work. Of course you could make things work in short term by a few hacks,  but long term working requires doing the right thing :-)

Wednesday, October 7, 2009

use more screen space in firefox

Many of my friends and not so friends have seemed to like google chrome browser in that it makes available more screen space for the web page to display. Of course its a good things, especially for laptops with wider screens and scant vertical space. However not many know that firefox has been customizable enough for long so that you can make available more space for you if you need. Though it cannot compete with chrome, you can still extract much more from it. Here's my compact menubar+addressbar+bookmarks bar in firefox all in a single line.
To do this right click on the menubar and click customize. Then modift the toolbars and menubars to your hearts content.

Here's my firefox compact look especially for notebooks. Also notice how the fastdial extension gives you access to most frequently used websites without the need of a separate bookmarks toolbar.


Notice what i did. Moved the addressbar, search bar and bookmarks bar into the menubar. Thats it.
Here's the customization screen


So enjoy the more real estate in firefox.

Saturday, October 3, 2009

thermal handler : protect your computer from overheat

So recently i started encoding some of the videos i had from dvds into compressed formats as the dvds are getting scratched and damaged. So i used the avidemux program for it. However my laptop gets overheated a lot during high cpu usage.
Other problems with overheating came when i had to run my dsmc and other assignments. Since they run for a looong time, my laptop overheats and i used to keep it hanging on its side during overnight runs. To my horror once when i compiled openfoam on my laptop overnight, i saw it shutdown in the morning with a failed compile and overheat. So here's my solution for all those who suffer from the problem of overheating computers (for linux users only).
Checkout the all new "thermal handler" from yours truly. The solution for all your computer overheat problems due to high cpu usage.
What it does:
Checks the temperature periodically and pauses processes using high cpu when a certain temperature is reached (default 90) and resumes them when the temperature falls below a certain value (default 65). None of your data crashes. The programs resume from the same state they were paused. No data loss. (Note that root processes cant be paused by the user)
What you need to do:
just run from a shell:

$ python thermal_handler.py [temp_lo [, temp_hi]]

Here's thermal handler at work:



Download it from here : http://home.iitb.ac.in/%7Epankajp/web/downloads/thermal_handler.py

EDIT: Thanks to Prashant Agrawal for reporting that the initial version didn't work on AMD cpus and helping me to test. I've updated the file to work on AMD cpus now. check it out

Friday, October 2, 2009

animate2

Now i present before you the much improved animate2.
Here are the major changes

  • Plot saving is fixed when multiple subplots are present
  • animate() is retained for compatibility, new users are expected to use animate2() with changed api for the function
  • Much more customizability
  • Plot frame traits (properties) can now be specified. Ex: plot title, axes labels, ticks, colors etc using extended traits notation to set the plot object properties
  • Each plot (line) can be customized. Plots can now be of various types such as scatted, line etc. Their properties can also be set such colors, thickness, style (dot-dash etc). Plots can also be labelled to add legends to the plot
  • Read the docstrings and the examples in __main__. They explain a lot of common uses.
So what are you waiting for. Try the latest animate2. Dont forget to check out the demo sample usage in the '__main__' section of the file
Check out the video below



Video with subtitles explaining the video is available here:
http://home.iitb.ac.in/%7Epankajp/web/downloads/animate2.mkv


Requirements:
To run this you will need the Enthought tool suite ETS (only traits with wx backend and chaco are required)
Hope this is useful for someone.
You can get the code animate.py from here that is:
http://home.iitb.ac.in/%7Epankajp/web/downloads/animate.py

Wednesday, September 23, 2009

Animate simulations in python

I've recently written a nice short code in python to animate the results (plots) of a simulation using chaco (part of Enthought ETS)
It is not actually very difficult, but i've just made up this one for myself, and it also has some cool features, so i thought i'd share it with others may as well benefit from it.

  • This if useful for you if you ever do coding in python and need to plot somethings which may change with time. Example lets say you are plotting the evolution of temperature over a rod with time or solving a 1D Euler equation (say shock tube problem)
  • This code provides a simple function to do it easily.
  • You can play-pause the code (simulation) at any time.
  • You can zoom-pan theplot
  • You can plot multiple subplots in a single window (Example the velocity, density and pressure in a shock tube problem)
  • You can edit axis labels, font, grids using gui
  • You can save the plots
Usage:
This is the only function defined in the file  you need to know:
def animate(func, delay=0.1, total_time=0.0, time_factor=1.0, size=(800, 600), title='Plot'):
    '''function to animate the values returned by a function
   
    func : function which returns a tuple of x,y values to animate on each call
        x is shape (N,), y is shape (N,) or (p,N), N is number of points, p is number of plots (properties)
    delay is the time interval in which to call the func after the previous func has returned(seconds)
    total_time is the time at which to stop the animation
            animation will stop when total_time > self.time / time_factor
            total_time <= 0 will continue indefinitely
    time_factor is the time to display as title (displayed_time=time/time_factor)
    In the plot window:
        pressing 'p' key will toggle animation play-pause
        pressing Ctrl-S will open a dialog to save a rendering of the plot
        pressing 'ESC' will reset the zoom level of the plot
        double clicking on some parts of the plot allows you to edit them in a gui,
            (axis titles, grids, ticks etc)
        if the window becomes unresponsive, pause the animation for a while
    '''


The docstring explains most of the things you need to know.
Here's how you could use it:
First we see how to animate a single plot (A moving sine wave in this case)
from animate import animate
from numpy import linspace, sin
x = linspace(-10, 10, 101)
i = 0.0
def get_data():
    global i
    i += 0.1
    return x + i, sin(x + i)
animate(func=get_data)

The above code snippet will generate a nice moving animation window. Here's a plot from the same


Plotting multiple values is just as simple. You only need to pass on a tuple of the y values:
from animate import animate
from numpy import linspace, sin, cos
x = linspace(-10, 10, 101)
i = 0.0
def get_data2():
    global i

    i += 0.1
    return x + i, (1 / (1 + x ** 2), sin(x + i), cos(x + i), sin(x + i), cos(x + i),)

animate(func=get_data2)
Here's a plot from the above snippet:

As you can see i have tried to make it as easy as possible without losing out on functionality.

Requirements:
To run this you will need the Enthought tool suite ETS (only traits with wx backend and chaco are required)
Hope this is useful for someone.
You can get the code animate.py from here that is:
http://home.iitb.ac.in/%7Epankajp/web/downloads/animate.py

Friday, September 18, 2009

cutie kitten


cutie kitten, originally uploaded by pankaj86.
Such a lovely pair of kitten.
So much contrast yet so much togetherness.
Friendship knows no barriers.
Hope men could learn.

(Courtesy Suchit, this pic was taken by Suchit http://suchit-de-fundae.blogspot.com/ using his mobile cam in the mess of hostel 6)

Flickr

This is a test post from flickr, a fancy photo sharing thing.

Wednesday, September 2, 2009

No smoking

All the junta out there, listen, please STOP smoking. Ya thats right, stop smoking, stop it NOW.
FREEZE,
Now throw away that cigarette in your hand and empty you wallets of the packets.
Now repeat with me thrice
    I will not smoke
    I will not smoke
    I will not smoke
If you are feeling withdrawal symptoms, contact me, i can help you and take you to rehab. Don't worry, its not worse than dying of choked lungs and killing many others in the process. Its also better than some fanatic like me shooting your brain at point blank range just for that single smoke.

join us in the mission, spread the word
http://www.thetruth.com/

Tuesday, September 1, 2009

Blend it like Blender

Few days back this summer, i decided to be a bit creative and joined a free (as in freedom) workshop on blender in my college. I attended only a few days, but blender was really impressive. The main aim of the workshop was to teach sufficient blender to enable you to create educational content. As such it was not meant to teach character animation. So in just a few days, i learnt a lot of basics of 3D modeling. Most of the initial time was taken up in learning the interface, but i can assure you that once you learn it, it enables you to be highly productive.
So here's a sample of what i did after just 3 days of learning blender. Of course as you know what happens in life, i've never been able to spend any time on blender since then...


The blend files can be downloaded from here Blender .blend file, Textures
Hope sometime i do get time to learn all the cool features of blender

Tuesday, August 25, 2009

back on my feet

Yahoo,
Today i am back on my feet. I walked on my own two feet for the first time in a month. There was still some swelling and pain in the feet, which has subsided enough that i walked to lectures today without the crutches. It feels great. Thought my gait is still awkward, and it still pains somewhat. I found out that my fracture which was at the base of the 5th metatarsal of the left foot, is also known as jones fracture, and takes longer time to heal. Hopefully i'd be jumping and dancing soon :-)
Today we also had two quizzes (a better name for class tests) for vibrations course and aircraft design lab. I should say i didn't do much good in both, but then its a routine for me :-)

Saturday, August 22, 2009

eclipse+ for python (pydev)

This semester i have taken a course in particle methods for fluid flow, whose instructor is a big fan of python, and has written large applications in python. So most of my classmates have indeed chosen to use python for the assignments. As they mostly use MS Windows, it is easier to install some python bundle such as EPD or python(x,y). I'd like to recommend python(x,y) for windows users. Though i myself don't use windows (i use Fedora 11 x64 fyi), i did try python(x,y) at my home this summer. (I know epd since much before that). The only reason for this is that python(x,y) includes eclipse with pydev, and it make much more sense to use an ide in the learning phase than using the silly notepad on windows (or any other advanced notepad). For those who are beginning afresh, here are a few clues why you should use an ide.

  • Code formatting is easily performed in pydev. Try commenting out a 20 line function your editor. (pydev hint: source->comment menu)
  • Syntax checking: You don't need to run you module to find out that you missed a semicolon after an if statement, the annotations in the editor will help you. Many more annotations to guide you to catch errors.
  • Code completion: Do you remember if the function inverse tan (arc tan) in math is called arctan or atan? (pydev hint: try math. and check if its arctan or atan)
    Do you remember the arguments of the asarray function of numpy or whether it makes a copy of the array? (pydev hint: check the documentation by hovering the mouse on the function)
  • Refactoring: Though pydev does not have the awsome refactoring capabilities of the statically typed languages (its difficult in python) it can still rename attributes and methods across modules with sufficient accuracy.
  • Templates: Do you find yourself bored typing the bolierplate code for classes or unittests or new modules? The templates are you friends. Example the new pydev module dialog box will help you easily create boilerplate code for classes and unittests. Typing 'main' in the editor will complete it to "if __name__ == '__main__':" block
  • Debugger: This cannot be emphasised enough. If you are not using a debugger, you have not been coding enough. It simplifies the task of locating the errors in a program. You can pause, continue, step through the code and check the values of any variable defined in the program. You can create conditional breakpoints and watch arbitrary expressions. Hovering over any attribute displays its value, selecting an expression displays its values. You can also switch to any frame. The debugger is probably the biggest benefit of using an ide like pydev.
Ok so all this was just to make programming beginners have a look at pydev ide. If you find anything unclear or want a short guide to do something please leave your comments and i'll try to help if possible.
In future i'd like to post a short note on beginners use of pydev and the common tasks you need to know. Tell me if you'd like to have it soon rather than later

conclude yourself

A few days back i posted about my fractured leg. Now i have the plaster of Paris on my leg removed. I'm so rejoiced. Anyway, if you did read my previous post, its time for my theory to be put to test. So if you are in India (more specifically Mumbai) then check out the status of the rains. And if my theory indeed turns out to be correct, please don't mind for me holding out the monsoons :-)

Sunday, July 26, 2009

new sem

Once in a while, there come moments which jolt you and wake you up from your dreamland into reality, and you realise the true worth of life and regret all the moments you lost to your inertia to do things as you want. Now few days back i experienced such a thing. Though a fracture is not really a BIG deal, its still a pretty big deal.
Ok so i've fractured the base of my 5th MT (metatarsal) of the left leg (simply put, my foot). Hopping around in crutches is not good, especially in the rain. Actually i had a hypothesis, it rained so less this year just to protect me from getting wet in the rain (you know, the plaster of Paris cast on my leg shudn't get wet, and with crutches in my hands i cant even hold an umbrella). Anyway, one of the predictions of this theory is that it will start raining well again when the cast from my leg goes away. Hope the theory is really correct :-)
This has really been a life changing experience for me. I've really found out my true friends, who'd go to great lengths to make me feel comfortable. Separated the wheat from the chaff :-) Also i have begun to appreciate life much more than before. Too bad it take such a thing to wake us up to reality...

Wednesday, February 25, 2009

Phoenix is an open hardware (circuit layout freely available) started by Inter University Accelerator Centre, with the objective of improving the laboratory facilities at Indian Universities, and growing with the support of the user community. Basically it is an electronic kit interfaced with a computer which has the following features:

Hardware Features
  • 4 Analog Inputs (10 bit resolution)
  • 1 Analog Output ( 8 bit)
  • 4 Digital Inputs
  • 4 Digital Outputs
  • Frequency Counter
  • Square wave generator
  • Constant Current Source (1 mA)
  • 2 Inverting Amplifiers (gain set plugin resistors)
  • 1 Non-inverting Amplifier
  • 2 Level Shifting Amplifiers
  • RS232 / USB interface
  • ATmega16 micro-controller
Basically its design use was as a helper for performing educational/scientific experiment though is can be used for many things only bounded by your imagination. Phoenix provides Analog and Digital Input/Output capabilities to a computer through the sockets on the top panel. Experiments are designed utilizing these I/O capabilities and suitable sensor elements to convert physical parameters into voltage signals. The program running on the micro-controller makes the measurements as per the commands send from the PC through RS232 or USB links. Users can access all these features by calling functions from a Python library. Python language is chosen due to its simplicity and ease of doing scientific computation and graphics using it.
The figure below shows an actual phoenix kit. Also there is a plot of diode (red LED) characteristics as obtained by connecting to the kit. Also it shows the nice monochrome lcd display which can be used to display small texts. Also visible is a snippet of the code for the same. Notice how easy it is to use, because it was mainly targetted for science students and not hor expert hackers.


Phoenix kit screenshot+photo : http://homepages.iitb.ac.in/~pankajp/web/?Things_you_may_find_useful:Electrical%2FElectronics:Phoenix_Kit&normal