Subject: [FEniCS-book] [HG FEniCS-book] Comment out some chapter that prevent compilation.

From: [email-masked] (FEniCS book project)
Date: Fri, 23 Oct 2009 17:37:14 +0200 (CEST)

One or more new changesets pushed to the primary fenics-book repository.
A short summary of the last three changesets is included below.

changeset:   76:0d57f45ca990
tag:         tip
user:        "Garth N. Wells <[email-masked]>"
date:        Fri Oct 23 16:37:11 2009 +0100
files:       book.tex frontmatter/preamble.tex
description:
Comment out some chapter that prevent compilation.

changeset:   75:bf995fc21064
user:        "Marie E. Rognes ([email-masked])"
date:        Fri Oct 23 23:38:50 2009 +0200
files:       bibliography.bib chapters/rognes/chapter.tex chapters/rognes/eps/CG.eps chapters/rognes/eps/RT.eps frontmatter/preamble.tex pythonhighlight.sty
description:
Added rognes application chapter.

Had to make some modification in frontmatter to use with
pythonhighlight etc...

changeset:   74:637fc40f05b8
user:        Kent-Andre Mardal <[email-masked]>
date:        Mon Oct 19 18:40:12 2009 +0200
files:       book.tex chapters/mardal-4/chapter.tex
description:
added chapter on block preconditioning.

----------------------------------------------------------------------
For more details, visit http://www.fenics.org/hg/fenics-book

---

From: Anders Logg <[email-masked]>
Date: Mon, 26 Oct 2009 22:50:50 +0100

I'm also having problems compiling these chapters. Could the authors
have a look and see if they can fix the problems?

  [hake]:     stops with some strange undefined error
  [mardal-4]: problem with definition of \K, then of \curl

These two chapters make quite heavy use of \newcommand. It would be
good to try to avoid this as much as possible inside chapters since
the chapters are not compiled in isolation. One \newcommand will
affect all other following chapters.

--
Anders

On Fri, Oct 23, 2009 at 05:37:14PM +0200, FEniCS book project wrote:
> _______________________________________________
> FEniCS-book mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/fenics-book

---

From: Johan Hake <[email-masked]>
Date: Mon, 26 Oct 2009 23:31:05 +0100

> affect all other following chapters.

Here comes fixes for my part.

Marie out commented the command \python which screwed my chapter...

But it is now up an running!

Cheers!

Johan

> > files:       bibliography.bib chapters/rognes/chapter.tex
> > chapters/rognes/eps/CG.eps chapters/rognes/eps/RT.eps
> > frontmatter/preamble.tex pythonhighlight.sty description:
# HG changeset patch
# User "Johan Hake <[email-masked]>"
# Date 1256596105 -3600
# Node ID d2c90672d5d3c17a31c154528421ec897a3c502a
# Parent  0d57f45ca990e4dd5b247b66636df4deb8a1b4b9
Fixes for a removed \python command
  - update for newest PyDOLFIN version
  - Removed some newcommands

diff -r 0d57f45ca990 -r d2c90672d5d3 bibliography.bib
--- a/bibliography.bib	Fri Oct 23 16:37:11 2009 +0100
+++ b/bibliography.bib	Mon Oct 26 23:28:25 2009 +0100
@@ -8131,6 +8131,19 @@
   timestamp = {2009.06.06}
 }
 
+@article{pytrilinos,
+ author = {Sala, Marzio and Spotz, W. F. and Heroux, M. A.},
+ title = {PyTrilinos: High-performance distributed-memory solvers for Python},
+ journal = {ACM Trans. Math. Softw.},
+ volume = {34},
+ number = {2},
+ year = {2008},
+ issn = {0098-3500},
+ pages = {1--33},
+ doi = {http://doi.acm.org/10.1145/1326548.1326549},
+ publisher = {ACM},
+ address = {New York, NY, USA},
+ }
 @UNPUBLISHED{www:featflow,
   title = {{FEATFLOW} software package},
   note = {\url{http://www.featflow.de}},
diff -r 0d57f45ca990 -r d2c90672d5d3 book.tex
--- a/book.tex	Fri Oct 23 16:37:11 2009 +0100
+++ b/book.tex	Mon Oct 26 23:28:25 2009 +0100
@@ -56,7 +56,7 @@
 \includechapter{lopes}
 \includechapter{shan}
 \includechapter{alnes-4}
-%\includechapter{hake}
+\includechapter{hake}
 \includechapter{lezar}
 \includechapter{oelgaard-1}
 \includechapter{nikbakht}
diff -r 0d57f45ca990 -r d2c90672d5d3 chapters/hake/chapter.tex
--- a/chapters/hake/chapter.tex	Fri Oct 23 16:37:11 2009 +0100
+++ b/chapters/hake/chapter.tex	Mon Oct 26 23:28:25 2009 +0100
@@ -1,36 +1,20 @@
 \newcommand{\Ca}{\ensuremath{\mbox{Ca}^{2+}}\xspace}
 \newcommand{\CaC}{\ensuremath{\left[\mbox{Ca}^{2+}\right]}\xspace}
 \newcommand{\Na}{\ensuremath{\mbox{Na}^{+}}\xspace}
-\newcommand{\NaC}{\ensuremath{\left[\mbox{Na}^{+}\right]}\xspace}
-\newcommand{\K}{\ensuremath{\mbox{K}^{+}}\xspace}
-\newcommand{\HC}{\ensuremath{\left[\mbox{H}^{+}\right]}\xspace}
-\renewcommand{\H}{\ensuremath{\mbox{H}^{+}}\xspace}
-\newcommand{\KC}{\ensuremath{\left[\mbox{K}^{+}\right]}\xspace}
 \newcommand{\Cl}{\ensuremath{\mbox{Cl}^{-}}\xspace}
-\newcommand{\ClC}{\ensuremath{\left[\mbox{Cl}^{-}\right]}\xspace}
 \newcommand{\Mg}{\ensuremath{\mbox{Mg}^{2+}}\xspace}
 \newcommand{\MgC}{\ensuremath{\left[\mbox{Mg}^{2+}\right]}\xspace}
 
 \newcommand{\T}{\ensuremath{\mathcal{T}}\xspace}
 
 % positional numbers
-\newcommand{\ith}{\ensuremath{i^{\scriptscriptstyle\text{th}}}\xspace}
 \newcommand{\kth}{\ensuremath{k^{\scriptscriptstyle\text{th}}}\xspace}
-\newcommand{\lth}{\ensuremath{l^{\scriptscriptstyle\text{th}}}\xspace}
 \newcommand{\nth}{\ensuremath{n^{\scriptscriptstyle\text{th}}}\xspace}
-\newcommand{\mth}{\ensuremath{m^{\scriptscriptstyle\text{th}}}\xspace}
 
 \newcommand{\Ltwo}[1]{\ensuremath{\|#1\|_{L^2}\xspace}}
 
-%\newcommand{\dt}{\ensuremath{\Delta{}\tau}}
 \newcommand{\Dt}{\ensuremath{\Delta{}t}}
-\newcommand{\Dx}{\ensuremath{\Delta{}x}}
-\newcommand{\Dy}{\ensuremath{\Delta{}y}}
-\newcommand{\Dz}{\ensuremath{\Delta{}z}}
-\newcommand{\Dr}{\ensuremath{\Delta{}r}}
 \newcommand{\Ds}{\ensuremath{\Delta{}s}}
-\newcommand{\DS}{\ensuremath{\Delta{}S}}
-\newcommand{\DV}{\ensuremath{\Delta{}V}}
 \newcommand{\Rset}{\ensuremath{\mathbb{R}}}
 \newcommand{\diff}[2][{}]{\dfrac{\partial #1}{\partial #2}}
 
@@ -113,7 +97,7 @@
 \end{equation}
 Here $\dot{c}$ is the time derivative of $c$.\par
 
-The strength of $\psi$ is defined by the amount of charge at the cell membrane and by the combined screening effect of all the ions in the dyadic cleft. In addition to \Ca, the intracellular solution also contains \K, \Na, \Cl, and \Mg. Following the previous approach by \citet{LangnerCafisoEtAl1990} and \citet{SoellerCannell1997}, these other ions will be treated as being in steady state. The cell membrane is assumed to be planar and effectively infinite. This assumption allows us to use an approximation of the electric potential in the solution,
+The strength of $\psi$ is defined by the amount of charge at the cell membrane and by the combined screening effect of all the ions in the dyadic cleft. In addition to \Ca, the intracellular solution also contains \ensuremath{\mbox{K}^{+}}, \Na, \Cl, and \Mg. Following the previous approach by \citet{LangnerCafisoEtAl1990} and \citet{SoellerCannell1997}, these other ions will be treated as being in steady state. The cell membrane is assumed to be planar and effectively infinite. This assumption allows us to use an approximation of the electric potential in the solution,
 \begin{equation}
   \label{eq:electric_potential}
   \psi(z) = \psi_0\e^{-\kappa{}z}.
@@ -424,7 +408,7 @@
 
 \subsection*{Time stepping algorithm}
 \label{sec:event-driven-simulator}
-To simplify the presentation of the time stepping algorithm we only consider one continuous variable, this could for example be the \Ca field. The framework presented here can be expanded to also handle several continuous variables. We define a base class called \texttt{DiscreteObject}, which defines the interface for all discrete objects. A key function of a discrete object is to know when its \textit{next event} is due at. The \texttt{DiscreteObject} that has the smallest next event time, gets to define the size of the next \Dt. In \python this is easily done by making the \texttt{DiscreteObject}s sortable with respect to their next event time. All \texttt{DiscreteObject}s is then collected in a list, \texttt{discrete\_objects} see Fig.~\ref{fig:time-stepping-algorithm}. The \texttt{DiscreteObject} with the smallest next event time is then just \texttt{min(discrete\_objects)}.\par
+To simplify the presentation of the time stepping algorithm we only consider one continuous variable, this could for example be the \Ca field. The framework presented here can be expanded to also handle several continuous variables. We define a base class called \texttt{DiscreteObject}, which defines the interface for all discrete objects. A key function of a discrete object is to know when its \textit{next event} is due at. The \texttt{DiscreteObject} that has the smallest next event time, gets to define the size of the next \Dt. In \packagefont{Python} this is easily done by making the \texttt{DiscreteObject}s sortable with respect to their next event time. All \texttt{DiscreteObject}s is then collected in a list, \texttt{discrete\_objects} see Fig.~\ref{fig:time-stepping-algorithm}. The \texttt{DiscreteObject} with the smallest next event time is then just \texttt{min(discrete\_objects)}.\par
 
 An event from a \texttt{DiscreteObject} that does not have an impact on the continuous solution will be ignored for example a Markov chain model transition that is not a channel transition. A transition needs to be realized before we can tell if it is a channel transition or not. This is done by \textit{stepping} the \texttt{DiscreteObject}, i.e., calling the object's \texttt{step()} method. If the method returns \texttt{False}, it will not affect the \Ca field, and we enter the while loop, and a new \texttt{DiscreteObject} is picked, see Fig.~\ref{fig:time-stepping-algorithm}. If the object returns \texttt{True} when stepped, we exit the loop and continue. Next, we have to update the other discrete objects with the chosen \Dt, solve for the \Ca field, broadcast the solution and last but not least execute the discrete event that is scheduled to happen at \Dt.\par
 
@@ -443,7 +427,7 @@
 \subsection*{\texttt{diffsim}: an example}
 \index{\texttt{diffsim}}
 \index{event driven simulator}
-\texttt{diffsim} is a versatile event driven simulator that incorporates the time stepping algorithm presented in the previous section together with the infrastructure to solve models with one or more diffusional domains, defined by a computational mesh. Each such domain can have several diffusive ligands. Custom fluxes can easily be included through the framework. The sub module \texttt{dyadiccleft} implements some published Markov models that can be used to simulate the stochastic behaviour of a dyad and some convenient boundary fluxes. It also implements the field flux from the lipid bi-layer discussed in Section~\ref{sec:ca-diffusion}. In Fig.~\ref{fig:diffsim_test} a runnable script is presented, which simulates the time to release, also called the latency, for a dyad. The two Markov models that is presented in Section \ref{sec:stochastic-models} are here used to model the stochastic dynamics of the RyRs and the LCCs. The simulation is driven by a so called dynamic voltage clamp. The data that defining the voltage clamp is read from a file using utilities from the \numpy \python packages.\par
+\texttt{diffsim} is a versatile event driven simulator that incorporates the time stepping algorithm presented in the previous section together with the infrastructure to solve models with one or more diffusional domains, defined by a computational mesh. Each such domain can have several diffusive ligands. Custom fluxes can easily be included through the framework. The sub module \texttt{dyadiccleft} implements some published Markov models that can be used to simulate the stochastic behaviour of a dyad and some convenient boundary fluxes. It also implements the field flux from the lipid bi-layer discussed in Section~\ref{sec:ca-diffusion}. In Fig.~\ref{fig:diffsim_test} a runnable script is presented, which simulates the time to release, also called the latency, for a dyad. The two Markov models that is presented in Section \ref{sec:stochastic-models} are here used to model the stochastic dynamics of the RyRs and the LCCs. The simulation is driven by a so called dynamic voltage clamp. The data that defining the voltage clamp is read from a file using utilities from the \numpy \packagefont{Python} packages.\par
 
 \section{Discussion}
 We have presented a computational model of the \Ca dynamics of the dyadic cleft in heart cells. It consists of a coupled stochastic and continuous system. We have showed how one can use \pydolfin to discretise and solve the continuous system using a finite element method. The continuous system is an advection-diffusion equation that produce unstable discretizations. We investigate how one can use the streamline upwind/Petrov-Galerkin method to stabilize the discretized system. We use three different meshes and find an L$^2$-optimal global stabilization parameters $\tau$ for each mesh.\par
diff -r 0d57f45ca990 -r d2c90672d5d3 chapters/hake/code/matrix_assemble.py
--- a/chapters/hake/code/matrix_assemble.py	Fri Oct 23 16:37:11 2009 +0100
+++ b/chapters/hake/code/matrix_assemble.py	Mon Oct 26 23:28:25 2009 +0100
@@ -10,8 +10,9 @@
 u = TrialFunction(Vs)
 
 # Defining the electric field-function
-a = Function(Vv,["0.0","0.0","phi_0*valence*kappa*sigma*exp(-kappa*x[2])"],
-             {"phi_0":-2.2,"valence":2,"kappa":1,"sigma":1.e5})
+a = Expression(["0.0","0.0","phi_0*valence*kappa*sigma*exp(-kappa*x[2])"],
+               defaults = {"phi_0":-2.2,"valence":2,"kappa":1,"sigma":1.e5},
+               V = Vv)
 
 # Assembly of the K, M and A matrices
 K = assemble(inner(grad(u),grad(v))*dx)
diff -r 0d57f45ca990 -r d2c90672d5d3 chapters/hake/code/stabilization.py
--- a/chapters/hake/code/stabilization.py	Fri Oct 23 16:37:11 2009 +0100
+++ b/chapters/hake/code/stabilization.py	Mon Oct 26 23:28:25 2009 +0100
@@ -1,9 +1,11 @@
 # Defining the stabilization using local Peclet number
-cppcode = """class Stab: public Function {
+cppcode = """class Stab : public Expression {
 public:
-  Function* field; uint _dim; double sigma;
-  Stab(boost::shared_ptr<FunctionSpace> V): Function(V)
-    {field = 0; sigma=1.0e5;}
+  Expression* field; double sigma;
+  Stab(): Expression(3), field(0), sigma(1.0e5)
+  {
+    value_shape.push_back(3);
+  }
   void eval(double* v, const Data& data) const {
     if (!field)
       error("Attach a field function.");
@@ -19,7 +21,7 @@
     for (uint i = 0;i < geometric_dimension(); ++i)
       v[i] *= 0.5*h*tau/field_norm;}};
 """
-stab = Function(Vv,cppcode); stab.field = a
+stab = Expression(cppcode, V = Vv); stab.field = a
 
 # Assemble the stabilization matrices
 E_stab = assemble(div(a*u)*inner(stab,grad(v))*dx)

---

From: Anders Logg <[email-masked]>
Date: Mon, 26 Oct 2009 23:42:39 +0100

> But it is now up an running!

Yes! Thanks.

--
Anders

---

From: Kent Andre <[email-masked]>
Date: Tue, 27 Oct 2009 09:40:57 +0100

I've used the following (re)newcommands: 

\renewcommand{\L}{\mathcal{L}}
\newcommand{\K}{\mathcal{K}}
\newcommand{\A}{\mathcal{A}}
\newcommand{\B}{\mathcal{B}}
\renewcommand\curl{\operatorname{curl}}

Are these something to put in frontmatter? I could always perform some
query-replaces. 

Kent

---

From: Johan Hake <[email-masked]>
Date: Tue, 27 Oct 2009 09:46:52 +0100

> Are these something to put in frontmatter? I could always perform some

I removed some of my more general macros (\K, \KC) using query and replace. So 
your \K should be fine now. However I would suggest you use your own \curl 
command as this command might be used by others. eg. 

 \newcommand{\kentsveryspecialcurlwithaverylongname}{\operatorname{curl}}

;)

Johan

> > > One or more new changesets pushed to the primary fenics-book
> > > repository. A short summary of the last three changesets is included
> > > below.
> > >

---

From: "Garth N. Wells" <[email-masked]>
Date: Tue, 27 Oct 2009 09:36:08 +0000

>  \newcommand{\kentsveryspecialcurlwithaverylongname}{\operatorname{curl}}

Yes, it would be good if people prefix their user-defined commands with 
their initials.

Garth

---

From: Anders Logg <[email-masked]>
Date: Tue, 27 Oct 2009 11:03:38 +0100

> Yes, it would be good if people prefix their user-defined commands with

Even better: prefix with the name of the chapter. The same thing
should be done for equation and figure labels. To make this work in
LaTeX (which doesn't like '-' in labels), we need to change the
chapter labels from foo-n to foon. So, labels should be named

  \label{eq:kirby3:foo}
  \label{fig:kirby3:foo}
  \label{tab:kirby3:foo}
  \label{sec:kirby3:foo}

--
Anders

---

From: Kent Andre <[email-masked]>
Date: Tue, 27 Oct 2009 11:08:46 +0100

> Yes, it would be good if people prefix their user-defined commands with 

It might be a good idea that we all use the same curl command. Do we
write curl as text or is it \nabla\times. 

I prefer curl as text, for no obvious reason. 

Kent

---

From: Anders Logg <[email-masked]>
Date: Tue, 27 Oct 2009 11:11:00 +0100

> I prefer curl as text, for no obvious reason.

I like curl as text, but then we need to do div as text for
consistency, and the Laplacian, which may look a bit ugly?

--
Anders

---

From: Anders Logg <[email-masked]>
Date: Tue, 27 Oct 2009 11:12:07 +0100

On Tue, Oct 27, 2009 at 08:07:23PM +0100, Marie Rognes wrote:
> Anders Logg wrote:
> Did you mean
>    \label{kirby3:eq:foo}
> ? Or is this a deliberate change from the README file?

No, not a deliberate change. I thought \label{eq:kirby3:foo} felt
natural now. I can't figure out which one is the best. Is there any
practical advantage with one over the other?

--
Anders

---

From: Marie Rognes <[email-masked]>
Date: Tue, 27 Oct 2009 20:07:23 +0100

Did you mean

    \label{kirby3:eq:foo}

>> ------------------------------------------------------------------------
>>

---

From: Marie Rognes <[email-masked]>
Date: Tue, 27 Oct 2009 11:18:57 +0100

> practical advantage with one over the other?

I find it easier to to query-replace with the 
\label{chapter:labeltype:foo} ...

--
Marie

---

From: Anders Logg <[email-masked]>
Date: Tue, 27 Oct 2009 11:23:05 +0100

> \label{chapter:labeltype:foo} ...

ok, let's do that then.

--
Anders