A bit about my trade…

Even while enjoying my writer’s block, I still won’t disappoint you. … My browsing has yielded some material, and I am going to share it with you.

It all began with googling for some notes on CFD. One thing led to another, and soon enough, I was at this page [^] maintained by Prof. Praveen Chandrashekhar of TIFR Bangalore.

Do go through the aforementioned link; highly recommended. It tells you about the nature of my trade [CFD]…

As that page notes, this article had first appeared in the AIAA Student Journal. Looking at the particulars of the anachronisms, I wanted to know the precise date of the writing. Googling on the title of the article led me to a PDF document which was hidden under a “webpage-old” sub-directory, for the web pages for the ME608 course offered by Prof. Jayathi Murthy at Purdue [^]. At the bottom of this PDF document is a note that the AIAA article had appeared in the Summer of 1985. … Hmm…. Sounds right.

If you enjoy your writer’s block [the way I do], one sure way to continue having it intact is to continue googling. You are guaranteed never to come out it. I mean to say, at least as far as I know, there is no equivalent of Godwin’s law [^] on the browsing side.

Anyway, so, what I next googled on was: “wind tunnels.” I was expecting to see the Wright brothers as the inventors of the idea. Well, I was proved wrong. The history section on the Wiki page [^] mentions Benjamin Robins and his “whirling arm” apparatus to determine drag. The reference for this fact goes to a book bearing the title “Mathematical Tracts of the late Benjamin Robins, Esq,” published, I gathered, in 1761. The description of the reference adds the sub-title (or the chapter title): “An account of the experiments, relating to the resistance of the air, exhibited at different times before the Royal Society, in the year 1746.” [The emphasis in the italics is mine, of course! [Couldn’t you have just guessed it?]]

Since I didn’t know anything about the “whirling arm,” and since the Wiki article didn’t explain it either, a continuation of googling was entirely in order. [The other reason was what I’ve told you already: I was enjoying my writer’s block, and didn’t want it to go away—not so soon, anyway.] The fallout of the search was one k-12 level page maintained by NASA [^]. Typical of the government-run NASA, there was no diagram to illustrate the text. … So I quickly closed the tab, came back to the next entries in the search results, and landed on this blog post [^] by “Gina.” The name of the blog was “Fluids in motion.”

… Interesting…. You know, I knew about, you know, “Fuck Yeah Fluid Dynamics” [^] (which is a major time- and bandwidth-sink) but not about “Fluids in motion.” So I had to browse the new blog, too. [As to the FYFD, I only today discovered the origin of the peculiar name; it is given in the Science mag story here [^].]

Anyway, coming back to Gina’s blog, I then clicked on the “fluids” category, and landed here [^]… Turns out that Gina’s is a less demanding on the bandwidth, as compared to FYFD. [… I happen to have nearly exhausted my monthly data limit of 10 GB, and the monthly renewal is on the 5th June. …. Sigh!…]

Anyway, so here I was, at Gina’s blog, and the first post in the “fluids” category was on “murmuration of starlings,” [^]. There was a link to a video… Video… Video? … Intermediate Conclusion: Writer’s blocks are costly. … Soon after, a quiet temptation thought: I must get to know what the phrase “murmuration of starlings” means. … A weighing in of the options, and the final conclusion: what the hell! [what else], I will buy an extra 1 or 2 GB add-on pack, but I gotta see that video. [Writer’s block, I told you, is enjoyable.] … Anyway, go, watch that video. It’s awesome. Also, Gina’s book “Modeling Ships and Space Craft.” It too seems to be awesome: [^] and [^].

The only way to avoid further spending on the bandwidth was to get out of my writer’s block. Somehow.

So, I browsed a bit on the term [^], and took the links on the first page of this search. To my dismay, I found that not even a single piece was helpful to me, because none was relevant to my situation: every piece of advice there was obviously written only after assuming that you are not enjoying your writer’s block. But what if you do? …

Anyway, I had to avoid any further expenditure on the bandwidth—my expenditure—and so, I had to get out of my writer’s block.

So, I wrote something—this post!


[Blogging will continue to remain sparse. … Humor apart, I am in the middle of writing some C++ code, and it is enjoyable but demanding on my time. I will remain busy with this code until at least the middle of June. So, expect the next post only around that time.]

[May be one more editing pass tomorrow… Done.]

[E&OE]

 

Papers must fall out…

Over the past couple of weeks or so, I’ve been going over SPH (smoothed particle hydrodynamics).

I once again went through the beginning references noted in my earlier post, here [^]. However, instead of rewriting my notes (which I lost in the last HDD crash), this time round, I went straight to programming. … In this post, let me recap recall what all I did.


First, I went through the great post “Why my fluids don’t flow” [^] by Tom Madams. … His blog has the title: “I am doing it wrong,” with the sub-text: “most of the time.” [Me too, Tom, me too!] This post gave a listing of what looked like a fully working C++ code. Seeing this code listing (even if the videos are no longer accessible), I had to try it.

So, I installed the Eclipse CDT. [Remember my HDD crash?—the OS on the new HDD had no IDEs/C++ compilers installed till now; I had thus far installed only Python and PyCharm]. I also installed MinGW, freeglut, Java JRE, but not all of them in the correct order. [Remember, I too do it wrong, most of the time.] I then created a “Hello World” project, and copy-pasted Tom’s code.

The program compiled well. [If you are going to try Tom’s code in Eclipse CDT + MinGW on Windows, the only issue you would now (in 2016) run into would be in the Project Settings, both in the compiler and linker settings parts, and both for OpenGL and freeglut. The latest versions of Eclipse & MinGW have undergone changes and don’t work precisely as explained even in the most helpful Web resources about this combination. … It’s not a big deal, but it’s not exactly what the slightly out-of-date online resources on this topic continue telling you either. … The options for the linker are a bit trickier to get than those for the compiler; the options for freeglut certainly are trickier to get than those for OpenGL. … If you have problems with this combination (Eclipse + MinGW on Windows 7 64-bit, with OpenGL and freeglut), then drop me a line and I will help you out.]

Tom’s program not only compiled well, but it also worked beautifully. Quite naturally, I had to change something about it.

So I removed his call to glDrawArrays(), and replaced the related code with the even older glBegin(GL_POINTS), glVertex2d(), glEnd() sort of a code. As I had anticipated,  there indeed was no noticeable performance difference. If the fluid in the original code required something like a minute (of computer’s physical time) to settle down to a certain quiescent state, then so did the one with the oldest-style usage of OpenGL. The FPS in the two cases were identical in almost all of the release runs, and they differed by less than 5–7% for the debug runs as well, when the trials were conducted on absolutely fresh cold-starts (i.e. with no ready-to-access memory pages in either physical or virtual memory).

Happy with my change, I then came to study Tom’s SPH code proper. I didn’t like the emitters. True to my core engineering background, what I wanted to simulate was the dam break. That means, all the 3000 particles would be present in the system right from the word go, thereby also having a slower performance throughout, including in the beginning. But Tom’s code was too tied up with the emitters. True to my software engineering background, rather than search and remove the emitters-related portion and thus waste my time fixing the resulting compiler errors, I felt like writing my own code. [Which true programmer doesn’t?]

So I did that, writing only stubs for the functions involving the calculations of the kernels and the accelerations. … I, however, did implement the grid-based nearest-neighbor search. Due to laziness, I simply reused the STL lists, rather than implementing the more basic (and perhaps slightly more efficient) “p->next” idiom.

Then I once again came back to Tom’s code, and began looking more carefully at his SPH-specific computations.

What I now didn’t like was the variables defined for the near-density and the near-pressure. These quantities didn’t fit very well into my preconceived notions of how a decent SPH code ought to look like.

So, I decided to deprove [which word is defined as an antonym of “improve”] this part, by taking this 2010 code from its 2007 (Becker et al.) theoretical basis, to a 2003 basis (Muller et al., Eurographics).

Further following my preconceived notions, I also decided to keep the values of the physical constants (density, gas stiffness, viscosity, surface tension) the same as those for the actual water.

The code, of course, wouldn’t work. The fluid would explode as if it were a gas, not water.

I then turned my learner’s attention to David Bindel’s code (see the “Resources” section at the bottom of his page here [^]).

Visiting Bindel’s pages once again, this time round, I noticed that he had apparently written this code only as a background material for a (mere) course-assignment! It was not even an MS thesis! And here I was, still struggling with SPH, even after having spent something like two weeks of full-time effort on it! [The difference was caused by the use of the realistic physical constants, of course. But I didn’t want to simply copy-paste Tom’s or Bindel’s parameter values; I wanted to understand where they came from—what kind of physical and computational contexts made those specific values give reasonable results.]

I of course liked some of the aspects of Bindel’s code better—e.g. kernels—and so, I happily changed my code here and there to incorporate them.

But I didn’t want to follow Bindel’s normalize_mass routine. Two reasons: (i) Once again according to my preconceived notions, I wanted to first set aside a sub-region of the overall domain for the fluid; then decide with how many particles to populate it, and what lattice arrangement to follow (square? body centered-cubic? hexagonal close-packed?); based on that, calculate each particle’s radius; then compute the volume of each particle; and only then set its mass using the gross physical density of the material from which it is composed (using the volume the particle would occupy if it were to be isolated from all others, as an intermediate step). The mass of a particle, thus computed (and not assumed) would remain fixed for all the time-steps in the program. (ii) I eventually wanted a multi-phase dam-break, and so wasn’t going to assume a global constant for the mass. Naturally, my code wouldn’t be able to blindly follow Bindel on all counts.

I also didn’t like the version of the leapfrog he has implemented. His version requires you to maintain additional quantities of the velocities at the half time-steps (I didn’t mind that), and also to implement a separate leapfrog_start() function (which I did mind—an additional sequence of very similar-looking function calls becomes tricky to modify and maintain). So, I implemented the other version of the leapfrog, viz., the “velocity Verlet.” It has exactly the same computational properties (of being symplectic and time-reversible), the same error/convergence properties (it too is second-order accurate), but it comes with the advantage that the quantities are defined only at the integer time-steps—no half-time business, and no tricky initialization sequence to be maintained.

My code, of course, still  didn’t work. The fluid would still explode. The reason, still, was: the parameter values. But the rest of the code now was satisfactory. How do I know this last part? Simple. Because, I commented out the calls to all the functions involving all other accelerations, and retained only the acceleration due to gravity. I could then see the balls experiencing the correct free-fall under gravity, with the correct bouncing-back from the floor of the domain. Both the time for the ball to hit the floor as well as the height reached after bouncing were in line with what physics predicts. Thus I knew that my time integration routines would be bug-free. Using some debug tracings, I also checked that the nearest-neighbour routines were working correctly.

I then wrote a couple of Python scripts to understand the different kernels better; I even plotted them using MatPlotLib. I felt better. A program I wrote was finally producing some output that I could in principle show someone else (rather than having just randomly exploding fluid particles). Even if it was doing only kernel calculations and not the actual SPH simulation. I had to feel [slightly] better, and I did.

At this stage, I stopped writing programs. I began thinking. [Yes, I do that, too.]


To cut a long story short, I ended up formulating two main research ideas concerning SPH. Both these ideas are unlike my usual ones.

Usually, when I formulate some new research idea, it is way too conceptual—at least as compared to the typical research reported in the engineering journals. Typically, at that stage (of my formulation of a new research idea), I am totally unable to see even an outline of what kind of a sequence of journal papers could possibly follow from it.

For instance, in the case of my diffusion equation-related result, it took me years before an outline for a good conference paper—almost like really speaking, at par with a journal paper—could at all evolve. I did have the essential argument ready. But I didn’t know what all context—the specifically mathematical context—would be expected in a paper based on that idea. I (and all the mathematicians I contacted) also had no idea as to how (or where) to go hunting for that context. And I certainly didn’t have any concrete idea as to how I would pull it all together to build a concrete and sufficiently rigorous argument. I knew nothing of that; I only knew that the instantaneous action-at-a-distance (IAD) was now dead; summarily dead. Similarly, in case of QM, I do have some new ideas, but I am still light-years away from deciding on a specific sequence of what kind of papers could be written about it, let alone have a good, detailed idea for the outline of the next journal paper to write on the topic.

However, in this case—this research on SPH—my ideas happen to be more like what [other] people typically use when they write papers for [even very high impact] journals those which lie behind the routine journal papers. So, papers should follow easily, once I work on these ideas.


Indeed, papers must follow those ideas. …There is another reason to it, too.

… Recently, I’ve come to develop an appreciation, a very deep kind of an appreciation, of the idea of having one’s own Google Scholar page, complete with a [fairly] recent photo, a verified email account at an educational institution (preferably with a .edu, or a .ac.in (.in for India) domain, rather than a .org or a .com domain), and a listing of one’s own h-index. [Yes, my own Google Scholar page, even if the h-Index be zero, initially. [Time heals all wounds.] I have come to develop that—an appreciation of this idea of having a Google Scholar page. … One could provide a link to it from one’s personal Web site, one could even cite the page in one’s CV, it could impress UGC/NBA/funding folks…. There are many uses to having a Google Scholar page.

…That is another reason why [journal] papers must come out, at least now.

And I expect that the couple of ideas regarding SPH should lead to at least a couple of journal papers.

Since these ideas are more like the usual/routine research, it would be possible to even plan for their development execution. Accordingly, let me say (as of today) that I should be able to finish both these papers within the next 4–5 months. [That would be the time-frame even if I have no student assistant. [Having a student assistant—even a very brilliant student studying at an IIT, say at IIT Bombay—would still not shorten the time to submission, neither would it reduce my own work-load any more than by about 10–20% or so. That’s the reason I am not planning on a student assistant on these ideas.]

But, yes, with all this activity in the recent past, and with all the planned activity, it is inevitable that papers would fall out. Papers must, in fact, fall out. …. Journal papers! [Remember Google Scholar?]


Of course, when it comes to execution, it’s a different story that even before I begin any serious work on them, I still have to first complete writing my CFD notes, and also have to write a few FDM, FVM and VoF/LevelSet programs scripts or OpenFOAM cases. Whatever I had written in the past, most of it was lost in my last HDD crash. I thus have a lot of territory to recover first.

Of course, rewriting notes/codes is fast. I could so rapidly progress on SPH this year—a full working C++ code in barely 2–3 weeks flat—only because I had implemented some MD (molecular dynamics) code in 2014, no matter how simple MD it was. The algorithms for collision detection and reflections at boundaries remain the same for all particles approaches: MD with hard disks, MD with LJ potential, and SPH. Even if I don’t have the previously written code, the algorithms are no longer completely new to me. As I begin to write code, the detailed considerations and all come back very easily, making the progress very swift, as far as programming is concerned.

When it comes to notes, I somehow find that writing them down once again takes almost the same length of time—just because you had taken out your notes earlier, it doesn’t make writing them down afresh takes any less time.

Thus, overall, recovering the lost territory would still take quite some effort and time.

My blogging would therefore continue to remain sparse even in the near future; expect at the most one more post this month (May 2016).

The work on the journal papers itself should begin in the late-June/early-July, and it should end by mid-December. It could. Nay, it must. … Yes, it must!

Papers must come out of all these activities, else it’s no research at all—it’s nothing. It’s a zero, a naught, a nothing, if there are no papers to show that you did research.

Papers must fall out! … Journal papers!!


A Song I Like:

(Western, Instrumental) “The rain must fall”
Composer: Yanni


[May be one quick editing pass later today, and I will be done with this post. Done on 12th May 2016.]

[E&OE]

Micro-level water-resources engineering—6: Evaporation

As compared to the last year, public awareness about water resources has certainly increased this year. It has been a second drought-year straight in a row. None can miss it—the water issue—now. [Not even the breweries.]

There are several NGO initiatives involved in the awareness campaigns, as always. Even celebrities, now. Also politicians.

The heartening part this year is that there also is now a much greater participation of the common people.

Indeed, water conservation schemes are these days receiving quite a broad-based support, cutting across all political party-lines. People are actively getting into the building nallah-bunds, farm-ponds, and all. Good.

Good? … This is India, so how can anything be so straight-forwardly good?

With that question mark, I began taking a second look at this entire scene. It all occurred to me during a show that I saw on TV last week or so.

Well, that way, I don’t watch TV much. At least in India, TV has gone beyond being a stupor- or passivity-inducing device; it has become an active noise generator. So, the most I can put up with is only some channel-flipping, once in a while. [In my case it is typically limited to less than 15 minutes at a time, less than 7 times a week]. In one such episode [of flipping through the channels], I happened to catch a few minutes of a chat that some Marathi journos were having with Aamir Khan and Satyajit Bhatkal. [They should have been in awe of Bhatkal, but instead were, of Aamir Khan. [Journos.]]

Both Khan and Bhatkal were being all earnest and also trying to be all reasonable on that show, and in that vein, at one point, Bhatkal mentioned that there have been hundreds (or thousands) of KT-weirs, nallah-bunds and all, which have been implemented by the successive Maharashtra State governments. These are the structures or works which now have become defunct because of a lack of maintenance. Mentioning this point, he then added something like the following: [not his precise words, but as my casual impression of what he effectively was saying]:

For the best or the most optimum utilization of the available money, it would be better to begin with a revival or maintenance (like silt-removal/wall-repairs) of these thousands of the already existing structures, rather than building everything anew, because the latter would cost even more money.

Looks like quite sensible an approach to take, doesn’t it?

Well, yes, on the face of it. But not so, once you begin to think like an engineer about it. In fact, I do want to raise one flag here—one very big, red flag. [No, I am not a communist, just in case you have begun reading this blog only now.]

Let’s look at some hard facts—and also some simplest physical principles—first.


The only primary source of water is: the rainfall.

The two means of conserving water are: (i) surface storage, and (ii) ground-water recharge.

The two big [physical] enemies of water conservation are: (i) run-off and (ii) evaporation.

Run-off means: Rain-water running off the earth’s surface as floods (may be as flash-floods), without getting intercepted or stored anywhere. Evaporation means: the loss of the stored water due to ambient heat.

It’s good that people have gotten aware about the first part—the runoff factor. The by-now popular Marathi slogan: “paaNee aDavaa, paaNee jirawaa” [English: “block water, percolate water”] refers to this first factor. Unfortunately, it has come to refer to only the first factor.

People must also become fully aware about the second factor—namely, evaporation. It too is just as important in India, particularly in places like Maharashtra.

Evaporation is not always an acute concern in the cooler climates (think USA, Canada, Europe, Japan, Australia, New Zealand). But it is, in the hotter climates (think most of the third world). My focus is exclusively on India, mostly on Maharashtra. Since most of the advanced countries happen to lie in the cooler regions, and since in India we habitually borrow our engineering common-sense from the advanced countries rather than developing it individually here, I want to once again stress this point in this series.


As I mentioned in my last post in this series [^]:

“Evaporation is a really bad factor in hot climates like India. At the level of large-scale dams and even for check dams, there is precious little that can be done about it.”

There is a technological reason behind it: You can’t sprinkle some powder or so to cover the surface of a water body, and thereby arrest or slow down the evaporation losses, without also polluting water body in the process.

These days, you often see a layer of water hyacinth in dams/rivers. Thought the plant contiguously covers the water body, contrary to the naive expectation, it in fact accelerates evaporation. The plant sucks water from below and perspires it out via leaves. This rate of perspiration happens to be higher than that of the plain evaporation. Further, water hyacinth has big leaves. The total surface area of the leaves is many times greater than the area of the water body that the plant covers.

But, yes, the simple-minded idea is right, in a way. If instead of the water-sucking water-hyacinth, something else—something chemically inert and opaque—were to cover the water body, then it would cut down on the evaporation losses. People have tried finding such a material, but without success. Any suggested solutions are either not scalable, not economical, or both. That’s why, evaporation is a fact that we must simply learn to live with.


Let me continue quoting from my aforementioned post:

“Evaporation maps for Maharashtra show losses as high as 1.5 m to even 2.5 m per year. Thus, if you build a check-dam with a 3 m high wall, expect to lose more than half of the [stored] water to evaporation alone.

For the same reason of evaporation, most nallah-bunding and contour-trenching works [such as] those typically undertaken under the socialist programs like MNREGA don’t translate to anything at all for storage, or for that matter, even for seepage. Typically, the bunds are less than 1 m tall, and theoretically, water in them is expected to plain evaporate out right before December. Practically, that anyway is the observation! […] It is a waste of money and effort.”

That’s what I had said, about a year ago. It needs to be repeated.

Most people currently enthusiastic about water conservation simply don’t seem to have any appreciation as to how huge (and how hugely relevant) this factor of evaporation is. Hence this post.


To repeat: In Maharashtra, the range of evaporation losses is as high as 1.5–2.5 m. That is, about 5–8 feet, in terms of the height of water lost.

Thus, if you build or repair a nullah-bund that is about 10 feet tall (which is the typical height of a house), then you should expect to lose about 75% of the stored water to evaporation alone. Perhaps even 90% or more. After all, nullahs and rivers typically have a progressively smaller width as we go deeper, and so, the volume of the water body remaining at the bottom after evaporation is even smaller than what a simple height-based calculation tells you.

Coming back to the Khans and Bhatkals, and Patekars and Anaspures: If the small check-dam or Kolhapur-type of bund/weir you are repairing this summer is, say, 7–8 feet high, then what you should expect to see in the next March or April is: a dry river-bed with a few puddles of water perhaps still lingering here and there. Picture a stray dog trying to satisfy his thirst from a puddle that is relatively cleaner from among them, but with a vast patch of a darkish brown, rocky or parched land filling the rest of your visual field. In no case should you picture a large body of clean water extending a couple of kilometers or more upstream of the bund. The fallen rain-water would have got blocked by that bund, sure, but if your bund is only 7–8 feet tall, then all of it would have disappeared [literally] in the thin air through evaporation alone, by the time the summer arrives. [We are not even counting seepage here. And realize, not all seepage goes towards meaningful groundwater recharge. More on it, may be, later.]

Now, the fact of the matter is, many, many KT weirs and bunds, as built in Maharashtra, are hardly even 5–6 feet tall. (Some are as low as just 3–4 feet tall.) They are, thus, not even one (Marathi/Sanskrit word) “puruSh” deep. …

The next time you go for an outing, keep an eye for the bunds. For instance, if you are in Pune, take an excursion in the nearby Purandar taluka, and check out the series of the bunds built by the PWD/Irrigation department on the Neera river. Most of them are just 3–5 feet tall. None is as big as a “puruSh” tall. None ever shows any water left after December. [But don’t therefore go and talk to the PWD/Irrigation engineers about it. These engineers are smart. They will tell you that those are flood-control structures, not water-storage structures. You will thus come back non-plussed. You are warned.]

… In case you didn’t know what “puruSh” means: Well, it’s a traditionally used unit of depth/height in India. It is defined as the uppermost reach of a man when he stands upright and stretches his arms up. Thus, one “puruSh” is about 7–8 feet. Typically, in earlier times, the unit would be used for measuring the depth of a well. [During my childhood, I would often hear people using it. People in the rural areas still continue using it.]

So keep the following capsule in mind.

In most parts of Maharashtra, expect the evaporation losses to be about one “puruSh” deep.

If the water-body at a nallah-bund/check-dam/farm-pond is one “puruSh” deep during the monsoon, then expect its water body to completely dry up by the time the summer arrives the next year.

Therefore, an urgent word of advice:

If you are building farm-ponds or undertaking repairs of any bunds or KT weirs structures this year, then drop from your planning all those sites whose walls are not at least 2.0 “puruSh” tall. [If a wall is 2.0 purush tall, the water body will be about 1.5 purush deep.] Evaporation losses will make sure that your social-work/activity would be a complete waste of money. The successive governments—not just politicians but also social workers, planners, bureaucrats and engineers—have already wasted money on them. Let the wastage stop at least now. Focus from now on only on the viable sites—the sites where the depth of the water-body would be at least 12–15 feet or so.

If the nullah is not naturally deep, and if the local soil type is right, then you may think of deepening it (to a sufficient minimum depth), perhaps with machinery and all.

But in any case, keep the factor of evaporation in mind.


As pointed out in my earlier posts in this series, given the geological type of the top layers in most parts of Maharashtra, seepage is not a favorable option for water conservation planning.

The only exception is the patch that runs across Dhule, Jalgaon through Wardha, Nagpur. There, the top-layer is sufficiently sandy (as in Rajasthan.) Mr. Suresh Khanapurkar has done a lot of seepage-related work in this patch, and groundwater recharge indeed is a viable option there.

But remember: seepage is not viable for most of the remaining parts of Maharashtra (and in fact, it also is not, over very large patches of India). So, if your idea is to build shallower bunds with the expectation that it would help improve groundwater levels via seepage during and soon after monsoon (i.e., before evaporation kicks in the months following the monsoon), then that idea is not so much on the target, as far as Maharashtra is concerned. Engineering for seepage can be viable only if the local geology favors it.

For the general-purpose water conservation, in most parts of Maharashtra, we have to look for storage, not seepage. Therefore, evaporation becomes a more important factor. So, avoid all shallower sites.

In particular, when it comes to farm-ponds, don’t build the shallower ones even if government gives you subsidy for building them (including for the blue plastic sheet which they use in the farm-ponds to prevent the wasteful seepage). If your pond is shallow, it would once again be a waste of money, pure and simple. Evaporation would make sure of that.

That’s all for now, folks.


Yes, I have been repetitive. I don’t mind. I want to be repetitive, until the time that social workers and engineers begin to show a better understanding of the engineering issues involved in water conservation, esp. the factor of evaporation. Currently, an appreciation of this factor seems to be non-existent.


My blogging in the upcoming weeks will be sparser, because I have to re-write my CFD course notes and research related notes, simulation programs, etc. I lost them all during my last HDD crash. I want to complete that part first. So excuse me even if I don’t come back for some 3–4 weeks or more for now. I will try to post a brief note or two even if not a blog post, but no promises. [And, yes, I have now begun my weekly backups, and am strictly following the policy—the notifications from the operating system.]

Bye for now.


[May be one more editing pass, later today or tomorrow… Done.]

[E&OE]

Summer, boredom, city skyline, etc.

Boredom. That’s what my life has become of late. … Boredom. … Pure boredom.

Life is boring.

Nothing interests me. Don’t feel like writing anything.

No, it’s not called a writer’s block. To have a writer’s block, first you need to be a writer. And my problem is that I don’t even want to be a writer. Not even just a plain reader. Both are boring propositions.

Life, somehow, has become boring to that great an extent.

Summers always do that to me.


While at IIT Madras, we (a few friends of mine and I) had begun using a special term for that: (Sanskrit) “glaani.”

Usage pattern:

“Did you work out those lab calculations?”

“.” [No answer from me.]

“Ajit, did you complete those lab calculations?”

“.” [No answer.]

“Machchaa…”

“.” [Still no answer.]

The fellow turns around, lethargically. [He, too, doesn’t have much energy left to pursue anything; the heat has been that bad…] … Begins to drag his feet back to his room.

“glaani.” [One attempts some answer, some explanation.]

The fellow does not even care to look back.

The use-case scenario is over.

Currently, it’s summer time, and this year in particular, I am finding it even more lethargy-inducing and boring than it usually is…


Here is an idea I had. I wanted to expand it in a blog post. But since everything has become so summer-ly boring, I am not going to do that. Instead, I will just mention the idea, and let it go at that.

How do you visually estimate the water requirements of a human settlement, say, a city? Say a city with skyscrapers, like Mumbai? (Skyscrapers? In Mumbai? OK, let’s agree to call them that.)

Start with a decent estimate of per capita water requirement. Something like, say, 135 liters/day/person. That is, 1.35 \times 10^2 \times 10^{-3} = 1.35 \times 10^{-1} cubic meters. For one year, it translates to 0.135 \times 365 = 49.275 \approx 50 cubic meters.

An average room in an average apartment is about 10 feet X 12 feet. With a standard height of 10 feet, its volume, in cubic meters, is: 3.048 \times 3.6576 \times 3.048 = 33.98 \approx 35 cubic meters.

Of course, 135 liters/day is an estimate on a slightly higher side; if what I recall is right, the planning estimates range from even as low as 50 liters/day/person. So, taking a somewhat lower estimate for the daily per capita requirement (figure out exactly how much), you basically arrive at this neat nugget:

Think of one apartment room, full of water. That much volume each person needs, for the entire year.

If one person lives in one room (or if a family of four people lives in a 2BHK apartment), then the volume of that apartment is their yearly water requirement.

Hardly surprising. In the traditional water-harvesting in Rajasthan, they would have single-storied houses, and roughly the same volume for an underground reservoir of water. Last year, I blogged quite a bit about water resources and water conservation; check out tags like “water resources” [^].

So, the next time you look at a city skyline, mentally invert it: imagine a dam-valley that is just as deep as the skyline’s height, containing water for that skyline. That would be the residential water requirement of that city.

Of course, if the population density is greater, if one apartment room accommodates 2, 3 (or even more number of) people (as is the common in Mumbai), then the visualization fails. I mean to say: You then have to imagine a deeper (or wider) dam valley.

… I used to be skeptical of residential water harvesting schemes. I used to think that it was a typical NGO type of day-dreaming, not backed up by hard data. I used to think that even if every 3-story apartment building covered its entire plot area (and not just the built-up area) with a 1 to 2 story-deep tank beneath it, it wouldn’t last for even a couple of months. But when I did the actual calculations (as above), I became convinced of the utility of the residential water harvesting schemes—if the storage is big enough.


Of course, as one often hears these days, if common people are going to look after everything from electricity (portable gen-sets, batteries and inverters), water (residential water harvesting), garbage (composting in the house/terrace garden), even security (gated communities with privately paid watchmen), then what the hell is the government for?

If your anger has subsided, realize that only the last (security) falls under the proper functions of government; the rest should actually be services rendered by private businesses. And if government gets out of every thing but the defense, the police and the courts, the economic progress would so humongous that none would bother reading or writing blog posts on residential water conservation schemes—there would be very competent businesses with private dams and private canals to deliver you clean water very cheaply (also via private trains, if the need be)… But then, I am not going to write about it.  Writing is boring. Life is boring. …. So, just look up Ayn Rand if you want, OK?

… Yawns. Life is boring.

BTW, did you notice that boring also means digging, and I was somehow talking about inverting the skyline, i.e., imagining wells and valleys. Kindaa double meaning, the word “boring” happens to have, and I happen to have used it in both senses, haven’t I?

Oh well. But really, really speaking, I meant it only in the simplest, most basic sense.

Life is boring. … Yawns….

[E&OE]

 

 

“Math rules”?

My work (and working) specialization today is computational science and engineering. I have taught FEM, and am currently teaching both FEM and CFD.

However, as it so happens, all my learning of FEM and CFD has been through self-studies. I have never sat in a class-room and learnt these topics that way. Naturally, there were, and are, gaps in my knowledge.


The most efficient way of learning any subject matter is through traditional formal learning—I mean to say, our usual university system. The reason is not just that a teacher is available to teach you the material; even books can do that (and often times, books are actually better than teachers). The real advantage of the usual university education is the existence of those class-mates of yours.

Your class-mates indirectly help you in many ways.

Come the week of those in-semester unit tests, at least in the hostels of Indian engineering schools, every one suddenly goes in the studies mode. In the hostel hallways, you casually pass someone by, and he puts a simple question to you. It is, perhaps, his genuine difficulty. You try to explain it to him, find that there are some gaps in your own knowledge, too. After a bit of a discussion, some one else joins the discussion, and then you all have to sheepishly go back to the notes or books or solve a problem together. It helps all of you.

Sometimes, the friend could be even just showing off to you—he wouldn’t ask you a question if he knew you could answer it. You begin answering in your usual magnificently nonchalant manner, and soon reach the end of your wits. (A XI standard example: If the gravitational potential inside the earth is constant, how come a ball dropped in a well falls down? [That is your friend’s question, just to tempt you in the wrong direction all the way through.]… And what would happen if there is a bore all through the earth’s volume, assuming that the earth’s core is solid all the way through?) His showing off helps you.

No, not every one works in this friendly a mode. But enough of them do that one gets [too] used to this way of studying/learning.

And, it is this way of studying which is absent not only in the learning by pure self-studies alone, but also in those online/MOOC courses. That is the reason why NPTEL videos, even if downloaded and available on the local college LAN, never get referred to by individual students working in complete isolation. Students more or less always browse them in groups even if sitting on different terminals (and they watch those videos only during the examination weeks!)

Personally, I had got [perhaps excessively] used to this mode of learning. [Since my Objectivist learning has begun interfering here, let me spell the matter out completely: It’s a mix of two modes: your own studies done in isolation, and also, as an essential second ingredient, your interaction with your class-mates (which, once again, does require the exercise of your individual mind, sure, but the point is: there are others, and the interaction is exposing the holes in your individual understanding).]

It is to this mix that I have got too used to. That’s why, I have acutely felt the absence of the second ingredient, during my studies of FEM and CFD. Of course, blogging fora like iMechanica did help me a lot when it came to FEM, but for CFD, I was more or less purely on my own.

That’s the reason why, even if I am a professor today and am teaching CFD not just to UG but also to PG students, I still don’t expect my knowledge to be as seamlessly integrated as for the other things that I know.

In particular, one such a gap got to the light recently, and I am going to share my fall—and rise—with you. In all its gloriously stupid details. (Feel absolutely free to leave reading this post—and indeed this blog—any time.)


In CFD, the way I happened to learn it, I first went through the initial parts (the derivations part) in John Anderson, Jr.’s text. Then, skipping the application of FDM in Anderson’s text more or less in its entirety, I went straight to Versteeg and Malasekara. Also Jayathi Murthy’s notes at Purdue. As is my habit, I was also flipping through Ferziger+Peric, and also some other books in the process, but it was to a minor extent. The reason for skipping the rest of the portion in Anderson was, I had gathered that FVM is the in-thing these days. OpenFOAM was already available, and its literature was all couched in terms of FVM, and so it was important to know FVM. Further, I could also see the limitations of FDM (like requirement of a structured Cartesian mesh, or special mesh mappings, etc.)

Overall, then, I had never read through the FDM modeling of Navier-Stokes until very recent times. The Pune University syllabus still requires you to do FDM, and I thus began reading through the FDM parts of Anderson’s text only a couple of months ago.

It is when I ran into having to run the FDM Python code for the convection-diffusion equation that a certain lacuna in my understanding became clear to me.


Consider the convection-diffusion equation, as given in Prof. Lorena Barba’s Step No.8, here [^]:

\dfrac{\partial u}{\partial t} + u \dfrac{\partial u}{\partial x} + v \dfrac{\partial u}{\partial y} = \nu \; \left(\dfrac{\partial ^2 u}{\partial x^2} + \dfrac{\partial ^2 u}{\partial y^2}\right)  \\  \dfrac{\partial v}{\partial t} + u \dfrac{\partial v}{\partial x} + v \dfrac{\partial v}{\partial y} = \nu \; \left(\dfrac{\partial ^2 v}{\partial x^2} + \dfrac{\partial ^2 v}{\partial y^2}\right)

I had never before actually gone through these equations until last week. Really.

That’s because I had always approached the convection-diffusion system via FVM, where the equation would be put using the Eulerian frame, and it therefore would read something like the following (using the compact vector/tensor notation):

\dfrac{\partial}{\partial t}(\rho \phi) +  \nabla \cdot (\rho \vec{u} \phi)  = \nabla \cdot (\Gamma \nabla \phi) + S
for the generic quantity \phi.

For the momentum equations, we substitute \vec{u} in place of \phi, \mu in place of \Gamma, and S_u - \nabla P in place of S, and the equation begins to read:
\dfrac{\partial}{\partial t}(\rho \vec{u}) +  \nabla \cdot (\rho \vec{u} \otimes \vec{u})  = \nabla \cdot (\mu \nabla \vec{u}) - \nabla P + S_u

For an incompressible flow of a Newtonian fluid, the equation reduces to:

\dfrac{\partial}{\partial t}(\vec{u}) +  \nabla \cdot (\vec{u} \otimes \vec{u})  = \nu \nabla^2 \vec{u} - \dfrac{1}{\rho} \nabla P + \dfrac{1}{\rho} S_u

This was the framework—the Eulerian framework—which I had worked with.

Whenever I went through the literature mentioning FDM for NS equations (e.g. the computer graphics papers on fluids), I more or less used to skip looking at the maths sections, simply because there is such a variety of reporting NS, and those initial sections of the papers all are covering the same background material. (Ferziger and Peric, I recall off-hand, mention of some 72 ways of writing down the NS equations.)  The meat of the paper comes only later.


The trouble occurred when, last week, I began really reading through (as in contrast to rapidly glancing over) Barba’s Step No. 8 as mentioned above. Let me copy-paste the convection-diffusion equations once again here, for ease of reference.

\dfrac{\partial u}{\partial t} + u \dfrac{\partial u}{\partial x} + v \dfrac{\partial u}{\partial y} = \nu \; \left(\dfrac{\partial ^2 u}{\partial x^2} + \dfrac{\partial ^2 u}{\partial y^2}\right)  \\  \dfrac{\partial v}{\partial t} + u \dfrac{\partial v}{\partial x} + v \dfrac{\partial v}{\partial y} = \nu \; \left(\dfrac{\partial ^2 v}{\partial x^2} + \dfrac{\partial ^2 v}{\partial y^2}\right)

Look at the left hand-side (LHS for short). What do you see?

What I saw was an application of the following operator—an operator that appears only in the Lagrangian framework:

\dfrac{\partial}{\partial t} + (\vec{u} \cdot \nabla)

Clearly, according to what I saw, the left hand-side of the convection-diffusion equation, as written above, is nothing but this operator, as applied to \vec{u}.

And with that “vision,” began my fall.

“How can she use the Lagrangian expression if she is going to use a fixed Cartesian—i.e. Eulerian—grid? After all, she is doing FDM here, isn’t she?” I wondered.

If it were to be a computer graphics paper using FDM, I would have skipped over it, presuming that they would sure transform this equation to the Eulerian form some time later on. But, here, I was dealing with a resource for the core engineering branches (like mech/aero/met./chem./etc.), and I also had a lab right this week to cover this topic. I couldn’t skip over it; I had to read it in detail. I knew that Prof. Barba couldn’t possibly make a mistake like that. But, in this lesson, even right up to the Python code (which I read for the first time only last week), there wasn’t even a hint of a transformation to the Eulerian frame. (Initially, I even did a search on the string: “Euler” on that page; no beans.)

There must be some reason to it, I thought. Still stuck with reading a Lagrangian frame for the equation, I then tried to imagine a reasonable interpretation:

Suppose there is one material particle at each of the FDM grid nodes? What would happen with time? Simplify the problem all the way down. Suppose the velocity field is already specified at each node as the initial condition, and we are concerned only with its time-evolution. What would happen with time? The particles would leave their initial nodal positions, and get advected/diffused away. In a single time-step, they would reach their new spatial positions. If the problem data are arbitrary, their positions at the end of the first time-step wouldn’t necessarily coincide with grid points. If so, how can she begin her next time iteration starting from the same grid points?

I had got stuck.

I thought through it twice, but with the same result. I searched through her other steps. (Idly browsing, I even looked up her CV: PhD from CalTech. “No, she couldn’t possibly be skipping over the transformation,” I distinctly remember telling myself for the nth time.)

Faced with a seemingly unyielding obstacle, I had to fall back on to my default mode of learning—viz., the “mix.” In other words, I had to talk about it with someone—any one—any one, who would have enough context. But no one was available. The past couple of days being holidays at our college, I was at home, and thus couldn’t even catch hold of my poor UG students.

But talking, I had to do. Finally, I decided to ask someone about it by email, and so, looked up the email ID of a CFD expert, and asked him if he could help me with something that is [and I quote] “seemingly very, very simple (conceptual) matter” which “stumps me. It is concerned with the application of Lagrangian vs. Eulerian frameworks. It seems that the answer must be very simple, but somehow the issue is not clicking-in together or falling together in place in the right way, for me.” That was yesterday morning.

It being a week-end, his reply came fairly rapidly, by the yesterday afternoon (I re-checked emails at around 1:30 PM); he had graciously agreed to help me. And so, I rapidly wrote up a LaTeX document (for equations) and sent it to him as soon as I could. That was yesterday, around 3:00 PM. Satisfied that finally I am talking to someone, I had a late lunch, and then crashed for a nice ciesta. … Holidays are niiiiiiiceeeee….

Waking up at around 5:00 PM, the first thing I did, while sipping a cup of tea, was to check up on the emails: no reply from him. Not expected this soon anyway.

Still lingering in the daze of that late lunch and the ciesta, idly, I had a second look at the attached document which I had sent. In that problem-document, I had tried to make the comparison as easy for the receiver to see, and so, I had taken care to write down the particular form of the equation that I was looking for:

\dfrac{\partial u}{\partial t} + \dfrac{\partial u^2}{\partial x} + \dfrac{\partial uv}{\partial y} = \nu \; \left(\dfrac{\partial ^2 u}{\partial x^2} + \dfrac{\partial ^2 u}{\partial y^2}\right)  \\  \dfrac{\partial v}{\partial t} + \dfrac{\partial uv}{\partial x} + \dfrac{\partial v^2}{\partial y} = \nu \; \left(\dfrac{\partial ^2 v}{\partial x^2} + \dfrac{\partial ^2 v}{\partial y^2}\right)

“Uh… But why would I keep the product terms u^2 inside the finite difference operator?” I now asked myself, still in the lingering haze of the ciesta. “Wouldn’t it complicate, say, specifying boundary conditions and all?” I was trying to pick up my thinking speed. Still yawning, I idly took a piece of paper, and began jotting down the equations.

And suddenly, way before writing down the very brief working-out by hand, the issue had become clear to me.

Immediately, I made me another cup of tea, and while still sipping it, launched TexMaker, wrote another document explaining the nature of my mistake, and attached it to a new email to the expert. “I got it” was the subject line of the new email I wrote. Hitting the “Send” button, I noticed what time it was: around 7 PM.

Here is the “development” I had noted in that document:

Start with the equation for momentum along the x-axis, expressed in the Eulerian (conservation) form:

\dfrac{\partial u}{\partial t} + \dfrac{\partial u^2}{\partial x} + \dfrac{\partial uv}{\partial y} = \nu \; \left(\dfrac{\partial ^2 u}{\partial x^2} + \dfrac{\partial ^2 u}{\partial y^2}\right)

Consider only the left hand-side (LHS for short). Instead of treating the product terms $u^2$ and $uv$ as final variables to be discretized immediately, use the product rule of calculus in the same Eulerian frame, rearrange, and apply the zero-divergence property for the incompressible flow:

\text{LHS} = \dfrac{\partial u}{\partial t} + \dfrac{\partial u^2}{\partial x} + \dfrac{\partial uv}{\partial y}  \\  = \dfrac{\partial u}{\partial t} + u \dfrac{\partial u}{\partial x} + u\dfrac{\partial u}{\partial x} + u \dfrac{\partial v}{\partial y} + v \dfrac{\partial u}{\partial y}  \\  = \dfrac{\partial u}{\partial t} + u \dfrac{\partial u}{\partial x} + u \left[\dfrac{\partial u}{\partial x} + \dfrac{\partial v}{\partial y} \right] + v \dfrac{\partial u}{\partial y}  \\  = \dfrac{\partial u}{\partial t} + u \dfrac{\partial u}{\partial x} + u \left[ 0 \right] + v \dfrac{\partial u}{\partial y}; \qquad\qquad \because \nabla \cdot \vec{u} = 0 \text{~if~} \rho = \text{~constant}  \\  = \dfrac{\partial u}{\partial t} + u \dfrac{\partial u}{\partial x} + v \dfrac{\partial u}{\partial y}

We have remained in the Eulerian frame throughout these steps, but the final equation which we got in the end, happens to be identical in its terms to that for the Lagrangian frame—when the flow is incompressible.

For a compressible flow, the equations should continue looking different, because \rho would be a variable, and so would have to be accounted for with a further application of the product rule, in evaluating \frac{\partial}{\partial t}(\rho u), \frac{\partial}{\partial x}(\rho u^2) and \frac{\partial}{\partial x}(\rho uv) etc.

But as it so happens, for the current case, even if the final equations look exactly the same, we should not supply the same physical imagination. We don’t imagine the Lagrangian particles at nodes. Our imagination continues remaining Eulerian throughout the development, with our focus not on the advected particles’ positions but on the flow variables u and v at the definite (fixed) points in space.


Sometimes, just expressing your problem to someone else itself pulls you out of your previous mental frame, and that by itself makes the problem disappear—in other words, the problem gets solved without your “solving” it. But to do that, you need someone else to talk to!


But how could I make such stupid and simple a mistake, you ask? This is something even a UG student at an IIT would be expected to know! [Whether they always do, or not, is a separate issue.]

Two reasons:

First: As I said, there are gaps in my knowledge of computational mechanics. More gaps than you would otherwise expect, simply because I had never had class-mates with whom to discuss my learning of computational  mechanics, esp., CFD.

Second: I was getting deeper into the SPH in the recent weeks, and thus was biased to read only the Lagrangian framework if I saw that expression.

And a third, more minor reason: One tends to be casual with the online resources. “Hey it is available online already. I could reuse it in a jiffy, if I want.” Saying that always, and indefinitely postponing actually reading through it. That’s the third reason.


And if I could make so stupid a mistake, and hold it for such a long time (a day or so), how could I then see through it, even if only eventually?

One reason: Crucial to that development is the observation that the divergence of velocity is zero for an incompressible flow. My mind was trained to look for it because even if the Pune University syllabus explicitly states that derivations will not be asked on the examinations, just for the sake of solidity in students’ understanding, I had worked through all the details of all the derivations in my class. During those routine derivations, you do use this crucial property in simplifying the NS equations, but on the right hand-side, i.e., for the surface forces term, in simplifying for the Newtonian fluid. Anderson does not work it out fully [see his p. 66] nor do Versteeg and Malasekara, but I anyway had, in my class… It was easy enough to spot the same pattern—even before jotting it down on paper—once it began appearing on the left hand-side of the same equation.

Hard-work pays off—if not today, tomorrow.


CFD books always emphasize the idea that the 4 combinations produced by (i) differential-vs-integral forms and (ii) Lagrangian-vs-Eulerian forms all look different, and yet, they still are the same. Books like Anderson’s take special pains to emphasize this point. Yes, in a way, all equations are the same: all the four mathematical forms express the same physical principle.

But seen from another perspective, here is an example of two equations which look exactly the same in every respect, but in fact aren’t to be viewed as such. One way of reading this equation is to imagine inter-connected material particles getting advected according to that equation in their local framework. Another way of reading exactly the same equation is to imagine a fluid flowing past those fixed FDM nodes, with only the nodal flow properties changing according to that equation.

Exactly the same maths (i.e. the same equation), and of course, also the same physical principle, but a different physical imagination.

And you want to tell me “math [sic] rules?”


I Song I Like:

(Hindi) “jaag dil-e-deewaanaa, rut jaagee…”
Singer: Mohamad Rafi
Music: Chitragupt
Lyrics: Majrooh Sultanpuri

[As usual, may be another editing pass…]

[E&OE]