Sunday, July 4, 2010

9. Derivation of the Continuity Equation in Spherical Coordinates

We start by selecting a spherical control volume dV. As shown in the figure below, this is given by
where r, θ, and φ stand for the radius, polar, and azimuthal angles, respectively. The azimuthal angle is also referred to as the zenith or colatitude angle.

The differential mass is


We will represent the velocity field via


In an Eulerian reference frame mass conservation is represented by accumulation, net flow, and source terms in a control volume.

Accumulation

The accumulation term is given by the time rate of change of mass. We therefore have

The net flow through the control volume can be divided into that corresponding to each direction.

Radial Flow

Starting with the radial direction, we have
The inflow area Ain is a trapezoid whose area is given by
The key term here is the sine term. Note that the mid segment is the average of the bases (parallel sides). Upon expansion of Ain, and in the limit of vanishing dθ, we have
substitution into Ain yields
where high order terms have been dropped.

The outflow in the radial direction is
but
where
and
By only keeping the lowest (second & third) order terms in the resulting expression, we have
Note, that in the expression for Aout, we kept both second order and third order terms. The reason for this is that this term will be multiplied by "dr" and therefore, the overall order will be three. In principle, one must carry all those terms until the final substitution is made, and only then one can compare terms and keep those with the lowest order.

At the outset, the net flow in the radial direction is given by

Polar Flow (θ)

The inflow in the polar direction is
where

The outflow in the θ direction is
where
Upon expansion, and keeping both second and third order terms, we get

Finally, the net flow in the polar direction is

Azimuthal Flow (φ)

The inflow in the azimuthal direction is given by
with
while the outflow is
and

At the outset, the net flow in the polar direction is

Continuity Equation

Now, by collecting all mass fluxes we have
which, upon dividing by dV and combining terms, reduces to

Cite as:
Saad, T. "9. Derivation of the Continuity Equation in Spherical Coordinates". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2010/02/9-derivation-of-continuity-equation-in.html

Some Words to Avoid in Scientific Papers and Manuscripts

Avoid using emotional and vague words. Avoid unnecessary fillers. Be precise, specific, and objective. Define all your words and use quantitative numbers as much as possible. Here's a list:
plenty, very much, a lot, short (define what short is!), long (define that as well!), really, heavy, light, somehow, sort of, kind of, in a sense, for sure, simply, obvious, unfortunately, hopefully, remarkable, impossible, lovely, interesting, miraculous, nice, fun, happy...
Some expressions that should never be used in an article (and that really "grind my gears" in every day conversations):
bottom line, brute force approach, the best, cutting edge, nonsense, tip of the iceberg, scratch the surface, state of the art, loaded to the teeth...
I will keep this list updated as I find new words. Feel free to contribute.

(This image is copyrighted, © xkcd.com)

Cite as:
Saad, T. "Some Words to Avoid in Scientific Papers and Manuscripts". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2010/07/some-words-to-avoid-in-scientific.html

My Journey into Open Source and Cross Platform Independence

When you advance in your career as a scientist, the choices that you make to accomplish certain research tasks become of crucial importance. If you spend a year collecting data and analyzing in Excel for instance, creating all sorts of plots and customizations, it will be very hard to make the switch to another software, say OpenOffice. Data analysis is not the only crucial component of a successful research endeavour. Your entire digital world is at stake here. The way you manage your emails, code, graphics, presentations etc... will have an impact to the way you handle things. From sharing data with collaborators, to publishing in journals, to accessing your files from anywhere on the planet; the way you do things can make all this truly enjoyable and lasting.

Part of the problem lies in the fact that there are no unified standards to doing things, especially when the tasks become "high level", such as a graphic presentation. Let me give you an example. If you are writing a piece of code in C, then you can rest assured that your code can be made to run on any type of computer. I call this type of approach "low level". In contrast, say that you are preparing a high quality presentation in PowerPoint or KeyNote. Your presentation is full of graphics and animations. Then it can be safe to say that yours will only work using the software that you used to create it. Of course, keynote can read pptx, but you'll spend more time fixing the presentation that you may as well just do it from scratch. This type of task is high level because of the advanced nature of the software and proprietary nature of some of its features.

For these reasons, and many others as well, I have decided to align my choices with three premises: (1) Low Level Approach, (2) Open Source, (3) Platform Independence. Here are the choices that I made

Operating System(s)

I use all of the following: Windows, MacOSX, and Linux. Because I am heading towards open standards, I have had very little problems handling files across these platforms.

The Cloud: Email, Calendar...

  1. Google goodness: I use almost all google services. In particular, I use gmail to handle all my mail accounts and Google calendar for events. I only use the browser to check & send mail. I have not used an email client since 2009.
  2. Live Mesh, Sync: I keep a copy of all my research files online AND across all my computers. For that purpose, i've been quite happy with Windows Live Mesh and Windows Live Sync. When go beyond the storage limitations, I may just move to drop box or some similar service.

Manuscript Preparation

  1. Word Processing: I ONLY use LaTeX to prepare my documents (even short letters). The last document that I have in Word is my CV which I am now converting to LaTeX. However, many scholars (especially in engineering) prefer to use Word, therefore I keep a copy of OpenOffice on all my computers in case I need to use it or I use Google docs.
    My policy on this is simple: If I am leading a project, I will exclusively use LaTeX to document our findings. If someone else wants me to help with their project, I will use whatever they have prepared their report in.
  2. Reference Management: I use Mendeley. It keeps a bibtex library constantly updated so that I only reference that in all my LaTeX documents.
  3. Graphics: I use InkScape! That was one of my most valued discoveries this year. It is cross platform and uses an open source graphics format called SVG. SVG stands for Scalable Vector Graphics. So you would expect really hight quality graphics in your PDFs!
  4. Plotting: Here's one problem I have not resolved yet. I now use OriginLab and I find it to be a very good piece of software given all its programming capabilities. Unfortunately, it is not platform independent. So far, I have not found a decent replacement for OriginLab and I may have to stick with for a while. I have looked at plotting with PSTricks, PGF/TikZ, and GnuPlot, but was not satisfied with the process.

Presentations

  1. So far, I am quite stuck with Powerpoint. I am very impressed by its capabilities and will find it quite hard to move to an open source presentation software. Because this type of work is high level, it may be hard to adopt a simple open standard approach.

Scientific Software

  1. C/C++/Java etc... Just need an editor! I use different editors on different platforms.
  2. Mathematica: This is one piece of great software that I would not get rid of. I have looked at open source alternatives such as Sage, but found that it lacks several features related to symbolic analysis. Mathematica's symbolic capabilities are the main reason for me using it.
I may have missed a few points, but will add them later. If you have any suggestions or know of any software that would handle plotting and symbolics, please let me know.

Finally, here's a message from good ol' uncle Sam



Cite as:
Saad, T. "My Journey into Open Source and Cross Platform Independence". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2010/07/my-path-into-open-source-and-cross.html

Saturday, July 3, 2010

Integrating Exact Differentials

Often times I am faced with the integration of a system of differential equations of the form
This system describes the behaviour of the primitive function "p". In fact, these equations stem from the total differential of p
Two cases arise in this situation. If "dp" is an exact differential, then the system is integrable independent of the path of integration. A differential equation "dp" is said to be an exact differential if the primitive function "p" exists. A necessary and sufficient condition for "dp" to be an exact differential if "p" is continuous and twice differentiable. In other words, when the mixed derivatives of "p" exist and are equal. For example, given
then, "dp" is an exact differential if, and only if,
If the total differential is not exact, then the integration can only be carried out along a specified path of the domain.

Integration of an Exact Differential

The typical approach to integrating the system of differential equations is to first integrate in one coordinate direction, add a function of the remaining coordinates, substitute into the remaining equations and so on.

However, there is another technique that only requires the following three steps:
  1. Integrate each equation with respect to its coordinate without adding any integration constants
  2. Add the results
  3. Subtract the common part
Here's an example. Consider
Integrating in each direction, we get
Then, the primitive function is
or
While this methods works, I have not seen any proof of why it does. Therefore, in this post, I will provide an independent proof. To simplify the process, I will only present this in two dimensions. I will also provide two methods for proving this. The words integral and primitive will be used interchangeably. Furthermore, I will refer to the individual differentials of a function as its constitutive differentials. For example,
are called the constitutive differentials of "p".


Method 1:

A differential system of equations can be written in general as

and let "p1" and "p2" denote the integrals of the above equations without the addition of an integration constant. Thus
Now let us first integrate in the "x" direction
or
Note the addition of the integration constant "N(y)". Substituting into the second differential, we get
or
(Note that it is assumed here that dN/dy is a function of y ONLY, so that the right hand side of the above equation will evaluate of a function of y and only y). Integrating with respect to "y", we recover
or
substituting "N(y)" into the equation for "p(x,y)", we have
So far, we have shown that the primitive function is the sum of the integrals in each direction (i.e. p1 and p2) minus some term denoted by M(x,y). It remains to show that M(x,y) represents a part that is common to both "p1" and "p2". To arrive at this, we invoke the fact that the this system's total differential is exat, i.e.
or
collecting terms, we get
This is true if
with T(x,y) being continuous and twice differentiable. Given this, we rewrite M(x,y) as
Finally, we now rewrite "p1" and "p2" using T(x,y)
It is therefore clear that M(x,y) is actually a common term for "p1" and "p2" and the primitive is given by
Q.E.D.

Note: One can now verify that the integration constant N(y) is a function of y, and only y. Reconsider the equation for dN/dy
writing in terms of T(x,y), we have
or

Method 2:

Consider a real continuous and twice differentiable function "p(x,y)". In general, this function can be written as
where "c" is a constant and the component functions are also real, continuous, and twice differentiable. Now form the total differential of "p"
where
The key component of this derivation are the derivatives of "q" in both differentials. We now define the integrals of the above system without adding an integration constant. We get
but we know that
When written in terms of "p1" and "p2", one recovers
where q(x,y) is the common part.
Q.E.D.

This shows that the primitive of an exact differential is equal to the sum of primitives of its constitutive functions minus the common part. Integration of the constitutive differentials is carried out without adding integration constants.

Summary:
While I have shown that the method of separate integrations works, one must remember that this technique is applicable ONLY to exact differentials. Therefore, the mixed derivatives test must be first applied before carrying out this type of integration. In my next post, I will discuss how to handle inexact differentials.

Cite as:
Saad, T. "Integrating Exact Differentials". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2010/07/integrating-totalexact-differentials.html

How to Wrap Text in CSS

Try this in your class definition
word-wrap:break-word;

Voila!

Cite as:
Saad, T. "How to Wrap Text in CSS". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2010/07/how-to-wrap-text-in-css.html