# Earth Cubed

## Coriolis Forces

A derivation  for coriolis forces can be found be found on the wikipedia page for fictitious forces.

In general for an accelerating reference frame in rectangular coordinates the factious forces are given by:

$\mathbf{F}_{\mbox{fictitious}} =-m\ \mathbf{a}_{AB} -2m\ \sum_{j=1}^3 v_j \ \frac{d \mathbf{u}_j}{dt} - m\ \sum_{j=1}^3 x_j \ \frac{d^2 \mathbf{u}_j}{dt^2}\ .$

Where:

he first term is the Coriolis force, the second term is the centrifugal force, and the third term is the Euler force. When the rate of rotation doesn’t change, as is typically the case for a planet, the Euler force is zero.

Looking specifically at the Coriolis force:

$- 2 m \boldsymbol \omega \times \mathbf{v}$

which gives in (east-west,north-sourth, height) coordinates:

$\boldsymbol{ \Omega} = \omega \begin{pmatrix} 0 \\ \cos \varphi \\ \sin \varphi \end{pmatrix}\ ,$ $\boldsymbol{ v} = \begin{pmatrix} v_e \\ v_n \\ v_u \end{pmatrix}\ ,$

$\boldsymbol{ a}_C =-2\boldsymbol{\Omega \times v}= 2\,\omega\, \begin{pmatrix} v_n \sin \varphi-v_u \cos \varphi \\ -v_e \sin \varphi \\ v_e \cos\varphi\end{pmatrix}\ .$

Where $\phi$ is the latitudinal coordinate (equator=zero latitude).

In general the cross product for a coordinate with orthonormal direction vectors is given by:

$\boldsymbol{\Omega \times v} = \begin{vmatrix} \boldsymbol{i}&\boldsymbol{j}&\boldsymbol{k} \\ \Omega_x & \Omega_y & \Omega_z \\ v_x & v_y & v_z \end{vmatrix}\ = \begin{pmatrix} \Omega_y v_z - \Omega_z v_y \\ \Omega_z v_x - \Omega_x v_z \\ \Omega_x v_y - \Omega_y v_x \end{pmatrix}\ ,$
http://en.wikipedia.org/wiki/Coriolis_effect#Formula

since the basis direction vectors are orthogonal in hopkins and simmons coordinates write write:

$\boldsymbol{\Omega \times v} = \begin{vmatrix} \boldsymbol{e_{\sigma}}&\boldsymbol{e_{\mu}}&\boldsymbol{e_{\lambda}} \\ \Omega_{\sigma} & \Omega_{\mu} & \Omega_{\lambda} \\ W & V & U \end{vmatrix}\ = \begin{pmatrix} \Omega_{\mu} U - \Omega_{\lambda} V \\ \Omega_{\lambda} W - \Omega_{\sigma} U \\ \Omega_{\sigma} V - \Omega_{\mu} W \end{pmatrix}\ ,$

(note with regards to weather the system is right handed we can choose the direction of the logitudanal cordinate $\lambda$ to make it right handed.)

Just to recall from the post (Hoskins and Simmons (1974) Coordinate System):

$\mu = sin( \theta )$ where theta is the latitude.
$\sigma = pressure/P_*$ Where $P_*$ is the surface pressure and $\sigma$ is the vertical coordinate.
$\lambda$ is the longitude.

U is the longitudinal component of the velocity
V is the latitudinal component of the velocity
W is the vertical component of the veolicty (not used in Hopkins and Simmons 1974)

Now the angular velocity of the earth in Hopkins and Simmons is given by:

$\boldsymbol{ \Omega} = \omega \begin{pmatrix} \cos \varphi \\ \sin \varphi \\ 0 \end{pmatrix}\ = \omega \begin{pmatrix} \mp \sqrt{1-\mu^2} \\ \mu \\ 0 \end{pmatrix}\,$ $\boldsymbol{ v} = \begin{pmatrix} W \\ V \\ U \end{pmatrix}\ ,$

Where the sign of $\pm$ is positive for the northern hemisphere and negative for the southern hemisphere.

Therefore:

$\boldsymbol{\Omega \times v} = \begin{pmatrix} \mu U \\ \pm \sqrt{1-\mu^2} U \\ \mp \sqrt{1-\mu^2} V - \mu W \end{pmatrix} \$

The result obtained is essentialy the same result that one would get if, they took the(east west,north south, altitude) coordinate system and replaced $\phi$ with $asin(\mu)$ .

The only differences are the order and sign of the components.  These are the only differences because both coordinate contain the same unit vectors.  In my example of a Hopkins and Simon’s like coordinate system I used a different order for the components then was used in my example for the (east-west, north south altitude) coordinate system. This will effect the sign in the cross product.

I wrote the z component of the angular velocity as $\mp \sqrt{1-\mu^2}$ to emphasize that the positive direction for the z component in Simpons coordinate system  is downward. However, the actual angular rotation of the earth in simons coordinate system still have a postive $\mu$ component depending on the which direction is defined as positive for the longitudinal  coordinate.

The order which we specify the coordinates determines the right handedness of the coordinate system.  Therefore, righthandedness is not inherently a geometric property because it depends on the order of the coordinates. For instance, in standard Cartesian coordinates $e_z \times e_y = -e_x$

In our case the first coordinat,e $\sigma$ , was specified in the downward direction, our second coordinate,  $\mu$, points south, now using the right hand  rule means that gives the positive direction for the third coordinate $\lambda$ in the east direction.

It is for these reasons that differences can arrise, and therefore it is very important when doing cross products to clearly express the postive direction of the coordinate unit vectors and the order of the coordinates.

August 29, 2009

## Vector Operations in Hoskins and Simmons Coordinates

In my post Hoskins and Simmons (1974) Coordinate System, I derived the following scaling quantities which will be used to derive the vector operations of Grad, Div and Curl in Hoskins Coordinate system.

$h_{\mu}= \left| \frac{r}{\sqrt{1-\mu^2}} \right|$
$h_{\lambda}=r \mu$
$h_{\sigma} =-\sigma \frac{mg}{RT}$

The coordinates in Hoskins coordinate system are dimensionless . (see nondimentionalization of Navier Stokes).

The gradient is defined as (see lectures on coordinate transforms):

$\nabla \phi = \frac{\vec e_{\mu}}{h_{\mu}} \frac{\partial \phi}{\partial \mu} + \frac{\vec e_{\lambda}}{h_{\lambda}}\frac{\partial \phi}{\partial \lambda}+\frac{\vec e_{\sigma}}{h_{\sigma}}\frac{\partial \phi}{\partial \sigma}=\left(\vec e_{\mu}\right)\frac{1-\mu^2}{r} \frac{\partial \phi}{\partial \mu} + \left(\vec e_{\lambda}\right)\frac{1}{r \mu}\frac{\partial \phi}{\partial \lambda}-\left(\vec e_{\sigma}\right)\frac{RT}{\sigma mg}\frac{\partial \phi}{\partial \sigma}$

The divergence is defined as:

$\nabla \cdot = \frac{1}{h_{\mu}} \frac{\partial }{\partial \mu} + \frac{1}{h_{\lambda}}\frac{\partial}{\partial \lambda}+\frac{1}{h_{\sigma}}\frac{\partial}{\partial \sigma}=\frac{1-\mu^2}{r} \frac{\partial}{\partial \mu} + \frac{1}{r \mu}\frac{\partial}{\partial \lambda}-\frac{RT}{\sigma mg}\frac{\partial}{\partial \sigma}$

The curl is defined by:

$\nabla \times \vec A = \frac{1}{h_{\sigma}h_{\mu}h_{\lambda}} \left| \begin{array}{ccc} \vec e_{\sigma} & \vec e_{\mu} & \vec e_{\lambda} \\ \frac{\partial}{\partial \sigma} & \frac{\partial}{\partial \mu} & \frac{\partial}{\partial \lambda} \\ A_{\sigma}h_{\sigma} & A_{\mu}h_{\mu} & A_{\lambda}h_{\lambda} \end{array} \right|$

(note, the direction of the longitudinal coordinate $\lambda$ is defined to obey the right hand rule)

This gives for the components

$\left[ \nabla \times \vec A \right]_{\sigma}=\frac{RT}{r \mu \sigma mg}\left(\sigma \frac{mg}{RT}\frac{\partial A_{\lambda}}{\partial \mu}+ r \mu\frac{\partial A_{\mu}}{\partial \lambda} \right)$

$\left[ \nabla \times \vec A \right]_{\mu}= -\frac{\sqrt{1-\mu^2}RT}{r\sigma mg}\left( \frac{r}{\sqrt{1-\mu^2}}\frac{\partial A_{\sigma}}{\partial \lambda}+\sigma \frac{mg}{RT} \frac{\partial A_{\lambda}}{\partial \sigma} \right)$

$\left[ \nabla \times \vec A \right]_{\lambda}= \frac{\sqrt{1-\mu^2}RT}{r^2 \mu }\left( r \mu\frac{\partial A_{\mu}}{\partial \sigma}-\frac{r}{\sqrt{1-\mu^2}} \frac{\partial A_{\sigma}}{\partial \mu} \right)$

Which Simplifies to:

$\left[ \nabla \times \vec A \right]_{\sigma}= \frac{1}{r\mu}\frac{\partial A_{\lambda}}{\partial \mu}+ \frac{RT}{\sigma m g}\frac{\partial A_{\mu}}{\partial \lambda}$

$\left[ \nabla \times \vec A \right]_{\mu}= -\frac{RT}{\sigma m g}\frac{\partial A_{\sigma}}{\partial \lambda}- \frac{\sqrt{1-\mu^2}}{r} \frac{\partial A_{\lambda}}{\partial \sigma}$

$\left[ \nabla \times \vec A \right]_{\lambda}= \frac{\sqrt{1-\mu^2}RT}{r}\frac{\partial A_{\mu}}{\partial \sigma}-\frac{RT}{r\mu} \frac{\partial A_{\sigma}}{\partial \mu}$

August 29, 2009 Posted by | Uncategorized | 1 Comment

## API/Object Viewers/Memory Mapping/

The more code a programmer can reuse the more efficient they can be. In windows this could mean reusing com/ole components and other APIs. Here are two useful programs for viewing APIs:

OLE/COM Object Explorer 1.1

Windows API Viewer
http://www.activevb.de/rubriken/apiviewer/index-apiviewer.html

I was inquiring about how to manage the transfer of large amounts of data between programs and I was pointed to two interesting concepts:

All modern operating systems include a facility called “memory mapping,” which maps a range of addresses in the program’s virtual address space to a file. If you read from those addresses, you’ll get data from the file. It is up to the operating system to determine whether to load the data into RAM all at once, or to read it from the disk in chunks as necessary.
…….
If you’re trying to share large amounts of memory between two programs running on the same computer, you should note that all modern operating systems provide mechanisms for shared memory. These shared memory segments can be mapped into the virtual address space of multiple programs simultaneously. Two or more programs can read or write to the shared memory exactly as if it were normal, private memory. (But you should include some thread-safety mechanisms, like mutexes, to make sure your programs won’t step on each other’s toes.)

If you’re trying to share large amounts of memory between programs running on separate computers, use MPI or some other multi-processing library.

Here is what wikipedia has to say about memory maps:

The primary benefit of memory mapping a file is increased I/O performance, especially when used on small files. Accessing memory mapped files is faster than using direct read and write operations for two reasons. Firstly, a system call is orders of magnitude slower than a simple change of program’s local memory. Secondly, in most operating systems the memory region mapped actually is the kernel’s file cache, meaning that no copies need to be created in user space. Using system calls would inevitably involve the time consuming operation of memory copying.

Certain application level memory-mapped file operations also perform better than their physical file counterparts. Applications can access and update data in the file directly and in-place, as opposed to seeking from the start of the file or rewriting the entire edited contents to a temporary location. Since the memory-mapped file is handled internally in pages, linear file access (as seen, for example, in flat file data storage or configuration files) requires disk access only when a new page boundary is crossed, and can write larger sections of the file to disk in a single operation.

A possible benefit of memory-mapped files is a “lazy loading”, thus using small amounts of RAM even for a very large file. Trying to load the entire contents of a file that is significantly larger than the amount of memory available can cause severe thrashing as the operating system reads from disk into memory and simultaneously pages from memory back to disk. Memory-mapping may not only bypass the page file completely, but the system only needs to load the smaller page-sized sections as data is being edited, similarly to demand paging scheme used for programs.

http://en.wikipedia.org/wiki/Memory-mapped_file#Benefits

The windows utility to do this is called CreateFileMapping
http://msdn2.microsoft.com/en-us/library/aa366537.aspx

As for multi-processing library the following was recommended:
http://scv.bu.edu/documentation/tutorials/MPI/MPI_text.html

I haven’t found much but the following wikipedia link seems relevant:
http://en.wikipedia.org/wiki/Cluster_(computing)

August 29, 2009 Posted by | Computer Science and Modeling | 2 Comments