Friday, September 27, 2013

Python Software Foundation - SfePy : GSoC 2013 : The Begining!

Hi Pythonistas,

GSoC finally comes to an end.
It was a wonderful experience.
My projects and docs are available on my repo.
It was an awesome experience going through the wonderful projects of other pythonistas.

Adios & Cheers!

Monday, September 16, 2013

Python Software Foundation - SfePy : GSoC 2013 : The Final Lap

Hi Pythonistas,

So finally I am heading into the final lap of GSoC 2013.
Just a few more steps away from complete integration and need to update the doc strings.

Pushed my latest codes.
Feeling awesome!


Liquid Fraction


Thursday, September 12, 2013

Python Software Foundation - SfePy : GSoC 2013 : Week 12 & 13

Hi Pythonistas,

PS: I will get a bit informal in today's report. Do forgive me for that.

Past 14 days have given me the best coding experience of my lifetime. After doing rigorous research I had formalized my problem statement earlier and started working on it. I realised the true intricacies in my problem when I started searching for methods by which phase change simulations are implemented. I had to change my earlier timeline and jump to my project problem directly. This field is a relatively new field and the algorithms have been developed surrounding the legacy SIMPLE algorithm by Patankar. From Brent, A.D., Voller, V.R. and Reid, K.J.(1988) to Chakraborty, P R and Dutta, P (2011), people have developed the enthalpy update scheme for accounting phase change keeping Patankar's algorithm as the base. I was familiar with SIMPLE algorithm earlier so I have developed a phase change solver for SfePy using Semi-Implicit Method for Pressure Linked Equations (Revised) or SIMPLER algorithm which is much more robust than SIMPLE algorithm.

The solver code is located here.
Download test problem file here.

Run python
You will get an output dir containing the vtk files which can be viewed using
./ <file>.vtk


The entire group can be loaded in Paraview and you can get the animation.

The code has been validated for the melting gallium experiment performed by Gau and Viskanta(1986) & Brent et al.(1988).

You can see that the code is following the trend and the difference is due to the slight change in thermophysical properties of Gallium taken in the code which might be different while performing the experiments.

Do leave your views in the comments below.


Phase Change Solver - SfePy GSoC 2013

Hi Pythonistas,

Here are some videos of the final result I obtained using the new solver I developed for Phase Change Effect Simulation.
A more detailed blogpost will follow soon.
Right now just enjoy the videos. :)


Tuesday, September 3, 2013

Python Software Foundation - SfePy : GSoC 2013 : Week 10 & 11

The final problem accounting convection-diffusion along with phase change has been defined below along with the governing equations and validation case studies.

Heat transfer in the processing of materials involving solid-liquid phase transformations (melting and solidification) is commonplace in such fields as metallurgy, crystal growth from melts and solutions, purification of materials, and solidification of metals. The associated density gradients in a gravitational field can induce natural convection flows. Convection in the liquid phase influences the process in two different ways, one of which is beneficial and the other of which can be detrimental. During melting convection increases the overall transport rate and, hence, the growth rate of the new phase, which is desirable. On the other hand, during solidification convection decreases the growth of the new phase and also seems to affect the morphology of the solid-liquid interface adversely. The nature of the solid is largely determined by what occurs in the vicinity of the solid-liquid interface. The heat release (absorption), density change, and other processes that take place in the vicinity of the transformation front result in nonuniformities along the front that cause its shape to change. The resulting density gradients in the liquid generate buoyancy-driven convection that can affect the transport of heat, constituent chemicals, and the growth rate.
The physical domain considered is shown in the figure. The vertical side walls of the enclosure are maintained at uniform temperatures, while the connecting horizontal walls are adiabatic. The govering equations are written for the entire domain assuming constant thermophysical properties, Boussinesq approximation, laminar, incompressible, and Newtonian two-dimensional flow. The solid-liquid interface motion due to volume change upon melting or solidification is neglected through the assumption ρs = ρl.









Specific heat capacity



Thermal conductivity



Thermal expansion coefficient



Latent heat of fusion






Volume fraction














Source term



















Governing Equations

The continuum relations:
gl + gs = 1
fl + fs = 1
fl = glρl ρ
fs = gsρs ρ
ρ = glρl + gsρs
u = flul + fsus
keff = glkl + gsks
cp = flcpl + fscps

1. Continuity
(u) = 0

2. Momentum
ρ u t + u u = p + μ2u + ρgβ(T T ref) + Bu

Now the key lies in modelling the source term. The coefficient B which should tend to 0 as the liquid volume fraction gl approaches unity, and should become a large negative number to anhilate the motion in the fluid region at gl = 0. Whereas these asymtotic conditions can be satisfied by several functions, we adopt the suggestion of Brent et al. :
B = C(1 gl)2 (gl3 + b)

C = 1.6 × 106

b = 0.001

2. Energy
Writing a general equation for conservation of thermal energy for all the zones in the domain is facilitated by focusing on an element undergoing phase change. Below are the energy equation of solid and liquid phases under the thermal equilibrium condition Tl = Ts = T:
(ρsgsHs) t + (ρsgsusHs) = (gsksT) + Ss

(ρlglHl) t + (ρlglulHl) = (glklT) + Sl

where Ss and Sl are the interphase energy terms, having the same magnitude but being opposite in sign.
A single governing enthalpy equation results:
(ρHm) t + ρ(fsusHs + flulHl) = (keffT)

Hm = fsHs + flHl = Hs + fl(Hl Hs)

The latent heat content of the element is due to the fraction of liquid converted to, or from, the corresponding quantity of solid. Hence we write
ΔH = fl(Hl Hs) = flL

Hm = Hs + flL

Hs = cpT

Hl = Hs + L

where L is the latent heat of fusion.
The zones where T > Tmelt, the entire element is in the liquid state and fl = 1.
The zones where T < Tmelt, the entire element is in the liquid state and fl = 0.
It is the elements undergoing phase change at T = Tmelt, where fl varies between 0 and 1. Substituting Hm and Hl in equation we get
(ρH) t + (ρuH) = (keff cp H)Se

u = flul

Se = (ρΔH) t = ρL(fl) t

Initial Conditions
fl = 0 everywhere
T = Tint everywhere
u = 0 everywhere.

Boundary Conditions
fl = 1 Left wall
fl = 0 Right wall
fl[i][j] = fl[i 1][j] Top
fl[0][j] = fl[1][j] Bottom
T = Thot Left wall
T = Tcold Right wall
u = 0 Walls

Validation Cases
Melting Gallium : Gau and Viskanta
Melting Gallium : Brent et al.
Melting Calcium chloride : Zivkovic and Fujii

  1. Zivkovic, B., Fujii, I., 2001. “An Analysis of Isothermal Phase Change of Phase Change Material within Rectangular and Cylindrical Containers”. Solar Energy, 70, pp. 51-61.
  2. Brent, A.D., Voller, V.R., Reid, K.J., 1988. “Enthalpy-porosity Technique for Modeling Convection-diffusion Phase Change: Application to the Melting of a Pure Metal”. Numerical Heat Transfer, 13(3), pp. 297-318.
  3. Gau, C., Viskanta, R., 1986. “Melting and Solidification of a Pure Metal on a Vertical Wall”. Journal of Heat Transfer, 108(1), pp. 174-181.
  4. Rajeev, K., Das, S., 2010. “A Numerical Study for Inward Solidification of a Liquid Contained in Cylindrical and Spherical Vessel”. Thermal Science, 14(2), pp. 365-372.
  5. Vreeman, C. J., Krane, M. J. M., Incropera, F. P. , 2000. “The Effect of Free-Floating Dendrites and Convection on Macrosegregation in Direct Chill Cast Aluminum Alloys. Part 1: Model Development”. Int. J. Heat Mass Transfer, 43, pp. 677-686.
  6. Flemings, M. C., 1974. Solidification Processing. McGraw-Hill, New York.
  7. Kumar, A., Walker, M. J., Sundarraj, S., Dutta, P., 2011. “Grain Floatation During Equiaxed Solidification of an Al-Cu Alloy in a Side-Cooled Cavity: Part II-Numerical Studies”. Metallurgical and Materials Transactions, 42(B), pp. 783-799.
  8. Voller, V.R., 2006. Handbook of Numerical Heat Transfer, 2nd ed.. Wiley, New York, NY, pp. 593-622.

Wednesday, August 28, 2013

Python Software Foundation - SfePy : GSoC 2013 : Week 8 & 9

Hi Pythonistas,

It has been quite busy lately and I have done some extensive research in this period to come up with the final set of equations of my problem.

Have a look at an awesome example I tried out which is a legacy 'mixing elbow' problem using SfePy.


Wednesday, August 14, 2013

Python Software Foundation - SfePy : GSoC 2013 : Week 7


This week was spent on midterm evaluation.
The next biweekly report (Week 8&9) is coming soon.


Saturday, August 10, 2013

Viral Content == Dirac Delta Function

Ever wondered how a viral content looks?
How can people go crazy over it and get over it in such a short time?

With the new Google Trends toolkit I visualized some of the most viral contents I could recall.

Some things which went viral regionally -
Harlem Shake vs Honey Bunny (Worldwide)

Harlem Shake vs Honey Bunny (India)

Vodafone vs Idea
Doesn't these graphs remind you of the Dirac Delta Function we studied in our undergrad?

PS. If you find any interesting Google Trends search, do share it in the comments below.

Saturday, August 3, 2013

The Fifth Estate

Burke said that there were three Estates in Parliament, but in the Reporters Gallery yonder, there sat a fourth Estate more important far than they all.
- Thomas Carlyle (1841)

In Britain, the three estates of government referenced Parliament: The House of Lords (the Lords Temporal and the Lords Spiritual - nobles and clergy) and the House of Commons were the earliest system of checks and balances, with each estate in place to ensure that neither of the other estates became too strong. The clergy couldn’t dominate — but then again, neither could the nobility, and neither could “the people,” whether they were people of wealth or people of more common means.

The americans established a unique, experimental and untested form of democracy, which divided the powers of government among three branches. This was a new concept of the “three estates.” They carefully crafted the legislative, the executive and the judiciary branches with an elaborate method of checks and balances. In a young nation which had just won its independence from an authoritarian British monarch, these checks and balances were of the highest priority.

But soon it turned out that three estates were not enough - Someone needed to keep an eye on the people in power. So the concept of a "Fourth Estate" — what we know today as the press (the "press" includes all news media, not just newspapers) emerged. Throughout the nineteenth and the twentieth century the freedom of press was debated, but it played a crucial role in influencing the msses. It was the only link they had with the Government. In the later half of the twentieth century the sanctity of the press became questionable due to commercialization and political influence. 

The Fourth Estate was toppling.

Charles Darwin once said -
It is not the strongest of the species that survives, nor the most intelligent that survives. It is the one that is the most adaptable to change.
It was high time we change, so we took the things in our own hands. In the past fifteen years, the spread of the Internet and other advanced technologies had a dramatic effect on the way people access and perceive information. One of the most revolutionary technological novelties that characterizes the modern "digital revolution" has been the explosion of the world wide web. It has impacted numerous facets of international politics including elections, media reporting from zones of conflict, and corporate and congressional policies. They also have potentially significant implications for policy making of the future and for national and global security. It has been suggested that the internet deserves the title of the "Fifth Estate".

As a matter of constitutional tradition, in the absence of evidence to the contrary, we presume that governmental regulation of the content of speech is more likely to interfere with the free exchange of ideas than to encourage it. The interest in encouraging freedom of expression in a democratic society outweighs any theoretical but unproven benefit of censorship.
-Justice John Paul Stevens, in Reno v. ACLU, 1997.

The current debates on internet censorship is nothing but analogous to the earlier debates held on curbing the power of press. Decades ago the press exposed the Bofurs gun scandal which involved the then Prime Minister Gandhi who was accused of receiving kickbacks from the Bofurs Company to the story of the Fodder scam which involved embezzlement from the treasury of the Indian state of Bihar. And today we have Wikileaks exposing the US Government. This is the prime reason internet censorship is being talked about. But supressing this new wave of the people is morally wrong.

Web censorship, is only part of the government's efforts to control information flow. The more freely information flows, the stronger the society becomes, because then citizens of countries around the world can hold their own governments accountable. They can begin to think for themselves. 
It is high time we say no to internet censorship.

Tuesday, July 30, 2013

Python Software Foundation - SfePy : GSoC 2013 : Week 6

Hi Pythonistas,

This week I spent coupling steady Navier Stokes Equation with the Energy Equation.
First Navier-Stokes Eq is solved to get the velocity field then this result is used to calculate the temperature field.


Sunday, July 28, 2013

The Flip Side #2 : The Fourth Estate

Thomas Carlyle in his book On Heroes and Hero Worship:
Burke said there were Three Estates in Parliament; but, in the Reporters' Gallery yonder, there sat a Fourth Estate more important far than they all.

It was 1980s when journalism actively emerged in India. From creating the first and most influential piece on the Bofurs gun scandal which involved the then Prime Minister Gandhi who was accused of receiving kickbacks from the Bofurs Company to the story of the Fodder scam which involved embezzlement from the treasury of the Indian state of Bihar. There was a time when the fourth estate played a prominent role in enlightening the commons. But it seems those days are gone - be it a national daily or an international newsroom, shoddy journalism is at its peak and it is degrading further every day. You can find a transcript below which provides a flip side of the fourth estate.

Shoddy Journalism [1]

Appalling journalism. Absolute blasphemy! As I watch the news from home, I am dumbfounded to see Barkha Dutt of NDTV break every rule of ethical journalism in reporting the Mumbai mayhem.

Take a couple of instances for example:
  • In one instance she asks a husband about his wife being stuck, or held as a hostage. The poor guy adds in the end about where she was last hiding. Aired! My dear friends with AK-47s, our national news is helping you. Go get those still in. And be sure to thank NDTV for not censoring this bit of information.
  • In another instance, a General sort of suggests that there were no hostages in Oberoi Trident. (Clever.) Then, our herione of revelations calls the head of Oberoi, and the idiot confirms a possibility of 100 or more people still in the building. Hello! Guys with guns, you’ve got more goats to slay. But before you do, you’ve got to love NDTV and more precisely Ms. Dutt. She’s your official intelligence from Ground zero. You do not need to be a journalist to understand the basic premise of ethics, which starts with protecting victims first; and that is done by avoiding key information from being aired publicly — such as but not limited to revealing the number of possible people still in, the hideouts of hostages and people stuck in buildings.

Imagine you’re one of those sorry souls holed-up in one of those bathrooms, or kitchens. A journalist pulls your kin outside and asks about your last contact on national television, and other prying details. In a bout of emotion, if they happen to reveal more details, you are sure going to hell. Remember these are hotels, where in all likelihood, every room has a television. All a terrorist needs to do is listen to Ms. Barkha Dutt’s latest achievement of extracting information from your relative, based on your last phone-call or SMS. And you’re shafted —courtesy NDTV.

If the terrorists don’t manage to shove you in to your private hell, the journalists on national television will certainly help you get there. One of the criticisms about Barkha Dutt on Wikipedia reads thus:
During the Kargil conflict, Indian Army sources repeatedly complained to her channel that she was giving away locations in her broadcasts, thus causing Indian casualties.
Looks like the idiot journalist has not learnt anything since then. I join a number of bloggers pleading her to shut the f*** up.

Update: In fact, I am willing to believe that Hemant Karkare died because these channels showed him prepare (wear helmet, wear bullet-proof vest.) in excruciating detail live on television. And they in turn targeted him where he was unprotected. The brave officer succumbed to bullets in the neck.
Update 2 [28.Nov.2300hrs]: Better sense appears to have prevailed in the latter half of today— either willfully, or by Government coercion2, and Live broadcasts are now being limited to non-action zones. Telecast of action troops and strategy is now not being aired live. Thank goodness for that.
Update 3 [30.Nov.1900hrs]: DNA India reports about a UK couple ask media to report carefully:
The terrorists were watching CNN and they came down from where they were in a lift after hearing about us on TV.
— Lynne Shaw in an interview.

1. Oh, they have a lame excuse pronouncing that the television connections in the hotel has been cut, and therefore it is okay to broadcast. Like hell!
2. I’m thinking coercion, since Government has just denied renewing CNN’s rights to air video today; must’ve have surely worked as a rude warning to the Indian domestic channels.
Instead of apologizing, and introspecting on how to improve, this is the kind of crap we get in response to shoddy journalism.
Radhika Sahasranaman rips the guts of that response on a 3000 strong, and growing Facebook group, whose title couldn't have sent signals any clearer:

NDTV's response is in itself a giveaway of misplaced notions: "In the absence of any instructions on site and in the absence of any such framework we broke NO rules" ("convenient transference of responsibility" or what?); and the entire argument, she concludes, amounts to "which television journalist tops the charts or falls to the bottom" (is that how they keep score?). It is important that we don't shoot the messenger but when the messenger loses the message, there is something to be done. Which is why, for once, I will take Barkha's advice. Use the remote control when emote control doesn't work

-Radhika Sahasranaman

Here's another:
TV news would no doubt argue that most other critiques of 26/11 coverage have been answered, too. Shoving mikes in front of distressed people? They wanted to share. Too close to the theatre of operation? If someone told us we would have moved away. And just in case anyone still has doubts,
Narayana Murthy and Suketu Mehta, among many others, rated 26/11 coverage as first class.
Maybe the Government goofed up not laying down rules of coverage. Does that end all questions on journalistic responsibility? Think about it. If journalists, especially senior editors, say they need the government to tell them how to do their business, they are opening a door many politicians would love to never shut again.
— Saubhik Chakrabarti on Indian Express

The choice could not have been simpler: you either kick the idiocy, and if that does not work, then
kick the idiot out.
Update: Oh, by the way, there is a framework (Self-Regulation Guidelines for the Broadcasting
Sector [pdf]) for anyone who cares— and has been in existence for more than a year.
Update 2: NSG says media got in the way, wants guidelines.
Update 3: Presstalk: In the name of fair and balanced.
Update 4: The Hoot: "Those who argue that viewers can use the remote to not watch what they find
unethical or irresponsible should note that many in India did, people went to offices and went to
vote but the TV all the same managed to give important information to the backers of the terrorists
who were glued to their screens. The remote is not the solution to such irresponsibility."
Harini Calamur: "Week 1-Post 26/11-Quo Vadis News Media?"
The above transcript you read was written by Chetan Kunte on his blog and within a few days he was silenced where NDTV probably sent Kunte a legal notice, asking him to pull the post down, apologize, never write about them again, and pay an absurdly massive amount of money.

The percentage of truth in this post is surely questionable, but I wonder why Barkha Dutt and NDTV took it so seriously. After all he was just another common man who posted it in his personal blog.

To answer this question you need to look into Dr Nayef R.F. Al-Rodhan's paper[2]
where he talks about the concept of The Fifth Estate :
In the past fifteen years, the spread of the Internet and other advanced technologies has had a dramatic effect on the way people access and perceive information. One of the most revolutionary technological novelties that characterizes the modern "digital revolution" has been the explosion of weblogs. Blogs have impacted numerous facets of international politics including elections, media reporting from zones of conflict, and corporate and congressional policies. They also have potentially significant implications for policy making of the future and for national and global security. This has led to the claim that blogs deserve the title of the "fifth estate," following an analogy with the other four estates that influence modern policy shaping: executive, legislative, and judicial branches of the state and the media.
Today blogs have become the reality check for policy makers, opinion shapers, and interest groups. With the fall of the reliability on the Fourth Estate today a Fifth Estate led by the commons have started to play a major role in making an impact in this society. With its disturbingly alarming growth we still can't predict whether it will be good for our society in the long run or not, but the real question is - Do we have any option?   

PS. After writing this post I realised that the latest film on Wikileaks is also named The Fifth Estate.

Monday, July 22, 2013

Python Software Foundation - SfePy : GSoC 2013 : Week 4&5

Hi Pythonistas,

Week 4&5 went of really well.

- Firstly after huge amount of discussions we finalised the Navier-Stokes solver and have started development on it.

- In parallel, working on the coupled convective-diffusive problem that I have selected: Laminar Heat Transfer to a Steady Couette Flow
between parallel plates. Where first the Navier Stokes Equation will be solved to determine the velocity and pressure field and then that will be used to determine the temperature field using the Energy Equation.

- I have also added new examples:

  • Steady Axial convection and diffusion in parabolic flow with maximum velocity U in an insulated pipe.

Commit - 1 2

  • Also benchmarked our solver based on the four cases mentioned in the paper Laminar Heat Transfer to a Steady Couette Flow
    between parallel Plates
    • Case A

    •  Case B

    • Case C

    • Case D

Except for one plot in Case D (Psi = 0.200) all other graphs obtained were in accordance with the paper.

Commit -  Link

This week I will focus on obtaining the result of coupling the equations.

Tuesday, July 16, 2013

Compass Box Killer

'Akurle is just the first to die.
To find out who is next, find me first.'

One muggy afternoon in Mumbai, a senior police officer is found murdered at his desk. When Inspector Virkar from the Crime Branch arrives at the scene, he finds a cryptic note that spills out of a student’s compass box. Then begins a series of killings and in each, a tell-tale compass box reveals more clues.

Accompanied by the attractive, ambitious TV reporter, Raashi Hunerwal, Virkar has to race against time to catch the killer before the bodies pile up. As the investigation shuttles from Mumbai to Khandala to Belgaum, Virkar is taken deep into a labyrinth of backroom deals that lead to shocking revelations about the ruthless killer’s motives. Slick plot twists and high-adrenaline action mark the story where Virkar finally confronts the killer himself.

Piyush Jha's films are noted for the unconventionality of the subject matter and treatment. For instance, Chalo America is about young college boys and emigration. Similarly, Sikandar has young teenagers as the leads, while King of Bollywood has a British Documentary filmmaker through whose eyes the story unfolds.

Similarly, his book also unfolds the story in a rather unconventional manner. It is a remarkable crime thriller story set with Mumbai as its backdrop, but I felt it lacked depth in the plot/characters/emotions. It is a fascinating read, but it won't leave you craving for more. None of the characters are so well developed to make you fall in love with them, except Inspector Virkar who is tough, daring and relentless in his pursuit of justice, a policeman one wishes every city had.


I wish the author had spent some more time on refining his work emotionally by sharing some more flashback sequences showing the development of bond between Tracy and Hari. That way the readers might have connected to Hari emotionally to understand his feelings.


It is fast paced and gripping one time read.
You can definitely visualize the entire story unfolding in front of you as a Mumbaistan movie.

The book was received as part of Reviewers Programme on The Tales Pensieve.

Tuesday, July 9, 2013

I Saw, I Learnt

When I was a kid my mother used to switch off the lights and fans of the rooms we were not using. I used to wonder what is the big deal if we switch it off for an hour and two. Then one day she made me calculate the hours we save in a year and then I realised the importance of saving the resources we take for granted. Slowly I developed this habit and learnt my lesson.

My dad is a doctor and when I was a kid I used to ask him why doesn't he worship God like others do.
Do you not believe in him?
He told me he does and that he worships his work. Being a doctor the best worship you can do is my saving lives and he did it everyday.
That day I learnt a great lesson.

I am sharing what 'I Saw and I Learnt' at in association with

Sunday, July 7, 2013

Python Software Foundation - SfePy : GSoC 2013 : Week 3

Hi Pythonistas,

This week kicked off with the hunt for a robust Navier-Stokes solver for SfePy.
I went through huge amount of resources.

To summarise the journey:

For our Navier-Stokes currently we use the Newton method with backtracking line-search. in OpenFoam and most of the CFD code the linearization approach is based on Patankar's SIMPLE algorithm.[1][2]
I talked to my professor who told me that SIMPLE is used in commercial softwares like FLUENT too.

I found few papers which tells us some other approaches:


I did some more digging from the implementation point of view and came across some interesting things:

This tutorial demonstrates the solution of Incompressible Navier-Stokes Equations using Fenics. it uses Chlorin's method[3] to solve the problem.

Other Implementations:

Here is a list of Open Source CFD codes. Maybe we can fork a repo and use it or learn from it:

According to people iNavier and dolphyn are promising:

Someone was using PyAMG to develop Jacobian-Free Newton-Krylov code to solve the Navier Stokes equations :!topic/pyamg-user/HXrXTyvXPpw


This is everything I could harness this week. There is a lot of things to take care to lock the final solver to be used which I would do the current week. Also I am currently narrowing down and rigorously searching a way to implementing SIMPLE in the FE context.

On a side note I have also been working on a SfePy version for Python 3 and benchmarking the simulation results.

This journey is surely turning out to be awesome!