Theoretical Electrochemistry

February 10, 2012

Calculating Normal Vectors of Boundaries in COMSOL

Filed under: COMSOL — Murali Venkatraman @ 12:45 pm

Calculation of normal vectors on a surface can be tricky. This is how I understand it. Please feel free to correct me.

COMSOL uses “topological” or “surface” coordinates rather than actual coordinates to calculate the normal vectors. In 2D the topological coordinate is one-dimensional (since it is an edge) and in 3D it is 2-dimensional (since it is a surface).

In my opinion, the best way to calculate normal vectors on the surface seems to be a combination of the following commands:

1. flgeomud – Get up-down sub-domain numbering of geometry faces
2. flgeomfd – Get coordinates and derivatives for geometry faces
3. flgeomfn – Get normals from face derivatives

!! Important !!

POSTINTERP command works well for obtaining normal vector information on edges, however returns “NaN” for many face-normal vectors in 3D simulations. Hence I do not recommend POSTINTERP.

Now the philosophy behind calculating normal vectors :

Let number of subdomains be nd. The empty space outside the model is numbered 0.

Commands “flgeomfd” and “flgeomfn” can easily provide us with the face-normal information. But when we talk of normal vector on a surface it becomes mandatory to know how it is directed. For example if domains 1 and 2 share a face number 3, and if the normal vector say [1, 0, 0] on this surface is calculated from the the commands “flgeomfd” and “flgeomfn”, we still do not have the information as to whether this normal is directed from domain 1 to domain 2 or domain 2 to domain 1. In other words, the normal vector information provided by these 2 commands lacks ‘direction’ information.

This is where the command “flgeomud” comes handy. flgeomud is a matrix of size (nd+1) x nf where nf = number of faces. Thus the information from a geometry g obtained using flgeomud looks like this:

>updown = flgeomud (g)

1 1 2 … ( This row is for “up” domain )
0 0 1 … ( This row is for “down” domain )

This means :

a) the normal of the face 1 is directed from sub-domain 0 (empty space) to the sub-domain 1
b) the normal of the face 2 is directed from sub-domain 0 (empty space) to the sub-domain 1
c) the normal of the face 3 is directed from sub-domain 1 to the sub-domain 2

Thus the normal vector [1,0,0] of the shared face 3 we obtained earlier points out “from” domain 1 “to” domain 2. Thus it is an “outward” pointing normal for face 1 when domain 1 is concerned and “inward” pointing normal when domain 2 is concerned.

To illustrate this I shall give an example here which presumes that there is only only one subdomain. Thus, we have

empty space : 0
subdomain : 1 = nd

A simple example is a parallelepiped (cuboid) which has six faces. This geometry has faces that are “shared” with the empty space only. Let us think of a situation where there is some heat generated inside this box and that we want to calculate the total heat energy that escapes through all the walls. For this we need to find all the face normal vectors which point “outward” from the box “into” the empty space.

==============================

% Create a simple cubic block

>b=block3(10,20,30);

>clear s
s.objs={b};
s.name={‘Block’};
s.tags={‘Block’};
fem.draw=struct(‘s’,s);
fem.geom=geomcsg(fem);

% Obtain number of faces (boundaries)

>nb = (geominfo(b, ‘out’,{‘no’},’od’,0:3))(3)

nb =

6

% Obtain up-down info

>updown = flgeomud(b)

updown =

1 1 1 0 0 0
0 0 0 1 1 1

% Print normal vector information as obtained by flgeomfd and flgeomfn commands

>for i = 1:nb
[coord,facederiv{i},c] = flgeomfd(b,i,[0.5;0.5]); % Obtain face derivative at mid-surface
normal{i} = flgeomfn(facederiv{i}); % Obtain normal from face-dreivative
end

>normal

normal =

[0 0 1] [1 0 0] [0 1 0] [0 0 1] [1 0 0] [0 1 0]

% The above information lacks direction. Combine with up-down information and
% convert all inward pointing normals into outward pointing normal vectors

>for i = 1:nb
if (updown(1,i)==1) % if inward pointing normal
normal{i}=-normal{i}; % make it outward pointing normal
end
nx(i) = normal{i}(1); % Store in separate vectors (optional)
ny(i) = normal{i}(2);
nz(i) = normal{i}(3);
end

>normal

normal =

[0 0 -1] [-1 0 0] [0 -1 0] [0 0 1] [1 0 0] [0 1 0]

=============

Now that all the outward normal vectors of all the faces have been attained, the total heat energy escaping the box through walls can be easily calculated.

Hope this helps.

April 15, 2010

Fundamentals of Electrochemistry

Filed under: Electrochemistry — Murali Venkatraman @ 6:26 pm
  1. The Electrochemical Interface and the potential difference
  2. When a metal comes in contact with a solution, the double layer gets formed due to charge separation at the interface. This establishes a potential across the interface (Refer to Chapter 6 Bockris for more details). At equilibrium, the interface potential difference thus established due to the charge separation is termed the equilibrium potential difference given by the symbol E_{eq} (Prof. Oldham prefers to call this E_n or the null potential where there is no flow of charge). Experimentally this potential is immeasurable (see chapter 1 and 2 of Oldham for explanation on why it is immeasurable). When we say an interface is in equilibrium there is no net action. (The word net is important since such an equilibrium has been found to be dynamic and not static). Thus, this potential E_{eq} by its own virtue, is incapable of causing a net transport of charges across the interface. Hence as with any system, if the interface is disturbed from the equilibrium, it would allow action which in our case is the transfer of electrons across the interface. This disturbance that the system experiences is called polarization. The disturbance could be natural (as in corrosion) or man-made (as in electrolysis). More scientifically natural is termed spontaneous and man-made is applied. As with any system in equilibrium, the disturbance or the polarization can be positive (anodic) or negative (cathodic). Hence if the polarization of the interface is performed to the extent that the potential difference across the interface has a value E, the departure of the interface from the equilibrium or null value is given byE-E_{eq} which is also called the overpotential of the system and given by the symbol [math]\eta [/math]. This overpotential could be a result of activation, concentration and/or ohmic (See Oldham book for more explanation). This departure from equilibrium of an electrode is characterized by a current flow through it, that is a net charge transfer across the interface.

  3. Measuring E_{eq}
  4. Note that E_{eq} of an isolated electrode was deemed immeasurable. However, one can easily recognize that the value of E_{eq} is dependent on the two materials, their physical state (for example, concentration) and other operating conditions like temperature, pressure etc. and hence is different for different interfaces. Thus there arises a need for quantifying E_{eq} so that we can usefully compare interfaces. However, one also does recognize that there are infinite possibilities of having an interface even for the same 2 materials. For example, a solution of 1M \rm Zn^{2+} ions in contact with a zinc electrode would have a much different E_{eq} value than one in which say 0.01 M since charge separation characteristics would be different. Thus we have three issues concerning E_{eq}: They are:

    1. E_{eq} of an interface is not measurable
    2. E_{eq} of the interfaces differ considerably and depend strongly upon the materials that constitute the interface
    3. Even with the same materials that make the interface, E_{eq} depends strongly on the composition of the materials

    But one recognizes that if at least the value of E_{eq} for one system is known, the others can somehow be compared with it. Or in other words, the difference is what matters. Hence, to alleviate such difficulties, it was proposed to define the E_{eq} of one of the interfaces, the constituents and the composition of which are known, to be zero arbitrarily. The value at other interfaces would then be obtained in reference to this chosen interface.

  5. The Standard Hydrogen Electrode – Reference
  6. This happens to be the Standard Hydrogen Electrode (SHE) in which 1M H+ ions are in equilibrium with hydrogen gas bubbled at 1 atm pressure at 25 deg C on a platinised platinum electrode. Note that this value is taken to be zero and not absolutely zero. However, electrochemistry concerns itself only with differences in potentials and hence this definition of reference E_{eq} comes extremely handy in calculations. (refer to Bockris for an interesting discussion on absolute value of potential of this interface). The reference E_{eq} of the SHE is given a special symbol E_{{{\rm{H}}^ + }/{{\rm{H}}_2}}^0 . However, one does recognize that the sign ofE_{eq} depends on the spatial direction that whether the field is directed from the solution to the metal or from the metal to the solution. Hence, once again arbitrarily reduction direction is taken to be positive. That is at the metal/solution interface, the electric field is taken to be positive in that direction which favors the reduction of the ion in the solution. In case of H+ ions in the solution, the reaction can be written as:

    \rm{2H^{+} + 2e^{-}\underset{{{k_b}}}{\overset{{{k_f}}}{ \rightleftharpoons}} H_2}

Testing Mathtype/Latex and equations in WordPress

Filed under: Ramblings — Murali Venkatraman @ 3:08 pm

x=2 (1)

{{\partial {C_i}} \over {\partial t}} =  - \nabla  \cdot {{\bf{N}}_i} (2)

The general flux expression for any species i in solution is given by Fick’s First law.

{{\partial {C_i}} \over {\partial t}} =  - \nabla  \cdot \left( { - {D_i}\nabla {C_i}} \right) = {D_i}{{{\partial ^2}{C_i}} \over {\partial {x^2}}} (3)

\begin{vmatrix} 1 & 2  \\ 3 & 4  \\ \end{vmatrix}

\frac{a}{b}

\frac{a}{b\bigl(\begin{smallmatrix}1 & 2\\ 3 & 4\end{smallmatrix}\bigr)}

Blog at WordPress.com.