wiki:SimultaneousSolutions

We've encountered some situations in our own research lately that benefit substantially from simultaneous solution, e.g.,

\begin{align*}
\partial_t \phi &= \nabla\cdot\{D_{\phi\phi} (\phi, T) \nabla \phi\} + \nabla\cdot\{D_{\phi T} (\phi, T) \nabla T\} \\
\partial_t T &= \nabla\cdot\{D_{T\phi} (\phi, T) \nabla \phi\} + \nabla\cdot\{D_{TT} (\phi, T) \nabla T\}
\end{align*}

would normally be solved with

eq_phi = TransientTerm() == DiffusionTerm(coeff=Dphiphi) + ...
eq_T = TransientTerm() == ... + DiffusionTerm(coeff=DTT)

where the ... is ideally some ConvectionTerm, but which might be an explicit (DphiT * T.getFaceGrad()).getDivergence() and so on if w can't easily factor out the dependence of $D_{\phi T} (\phi, T)$ on $\phi$.

It can be advantageous, though, to create a new master variable $\xi$ where $\xi[1,\ldots,N] = \phi[1,\ldots,N]$ and $\xi[N+1,\ldots,2N] = T[1,\ldots,N]$ and to compose a master equation to simultaneously represent both the $\phi$ equation and the $T$ equation.

Daniel presently has a functional (but arguably brutish) implementation of this, but we've been brainstorming a way to make this more general and more elegant. The idea that we are currently playing with is to use the __call__() method of a Term to change it from a generic operator like it is now into an operator applied to a specific CellVariable, i.e. $\nabla\cdot(D \nabla \phi)$ instead of $\nabla\cdot(D \nabla)$.

  • The current syntax will remain valid. DiffusionTerm(coeff=D) will continue to represent $\nabla\cdot (D \nabla)$. You must call solve(var=phi) or sweep(var=phi) to apply the operator to the variable $\phi$.
  • If, instead, you write DiffusionTerm(coeff=D)(phi), this will represent $\nabla\cdot (D \nabla \phi)$. There will be no need to pass a variable to sweep() or solve(). In fact, it might be an error to do so.

In this new syntax, we would write

eq = (TransientTerm()(phi) + TransientTerm()(T) 
      == (DiffusionTerm(coeff=Dphiphi)(phi) + DiffusionTerm(coeff=DphiT)(T) 
          + DiffusionTerm(coeff=DTphi)(phi) + DiffusionTerm(coeff=DTT)(T)))

and then call solve(), either without a var argument, or perhaps with a var argument that must only contain a tuple of phi and T. I'm inclined to prohibit the var argument, because the list of solution variables is already implicitly determined by the Terms, so its value is proscribed.

It should also be possible (and maybe a bit clearer) to write

eq_phi = TransientTerm()(phi) == (DiffusionTerm(coeff=Dphiphi)(phi) + DiffusionTerm(coeff=DphiT)(T) 
eq_T = TransientTerm()(T) == DiffusionTerm(cofeff=DTphi)(phi) + DiffusionTerm(coeff=DTT)(T)

eq = eq_phi + eq_T

We had originally talked about writing eq = eq_phi & eq_T, but as I write this up, I now don't think there's any reason to introduce this new syntax.

There remains an issue of what to do about boundary conditions.

  • One option is to make boundary conditions also take a __call__() method, so FixedValue(...) would apply to whatever variable was passed to eq.solve(var=...), but FixedValue(...)(phi) would explicitly mean
    TracMath macro processor has detected an error. Please fix the problem before continuing.


    The command:

    '/usr/bin/pdflatex -interaction=nonstopmode 1f813afef156a65c06324451cc2eb533f668af9c.tex'
    failed with the following output:
    "This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)\nentering extended mode\n(./1f813afef156a65c06324451cc2eb533f668af9c.tex\nLaTeX2e <2009/09/24>\nBabel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh\nyphenation, loaded.\n(/usr/share/texmf-texlive/tex/latex/base/article.cls\nDocument Class: article 2007/10/19 v1.4h Standard LaTeX document class\n(/usr/share/texmf-texlive/tex/latex/base/size10.clo))\n(/usr/share/texmf-texlive/tex/latex/base/inputenc.sty\n(/usr/share/texmf-texlive/tex/latex/base/utf8.def\n(/usr/share/texmf-texlive/tex/latex/base/t1enc.dfu)\n(/usr/share/texmf-texlive/tex/latex/base/ot1enc.dfu)\n(/usr/share/texmf-texlive/tex/latex/base/omsenc.dfu)))\n(/usr/share/texmf-texlive/tex/latex/cmap/cmap.sty)\n(/usr/share/texmf/tex/latex/cm-super/type1ec.sty\n(/usr/share/texmf-texlive/tex/latex/base/t1cmr.fd))\n(/usr/share/texmf-texlive/tex/latex/base/fontenc.sty\n(/usr/share/texmf-texlive/tex/latex/base/t1enc.def)<<t1.cmap>>)\n(/usr/share/texmf-texlive/tex/latex/amsmath/amsmath.sty\nFor additional information on amsmath, use the `?' option.\n(/usr/share/texmf-texlive/tex/latex/amsmath/amstext.sty\n(/usr/share/texmf-texlive/tex/latex/amsmath/amsgen.sty))\n(/usr/share/texmf-texlive/tex/latex/amsmath/amsbsy.sty)\n(/usr/share/texmf-texlive/tex/latex/amsmath/amsopn.sty))\n(/usr/share/texmf-texlive/tex/latex/amscls/amsthm.sty)\n(/usr/share/texmf-texlive/tex/latex/amsfonts/amssymb.sty\n(/usr/share/texmf-texlive/tex/latex/amsfonts/amsfonts.sty))\n(/usr/share/texmf-texlive/tex/latex/tools/bm.sty)\n(/usr/share/texmf/tex/latex/preview/preview.sty\n(/usr/share/texmf/tex/latex/preview/prtightpage.def))\nNo file 1f813afef156a65c06324451cc2eb533f668af9c.aux.\nPreview: Fontsize 10pt\nPreview: PDFoutput 1\n<<ot1.cmap>> (/usr/share/texmf-texlive/tex/latex/amsfonts/umsa.fd)\n(/usr/share/texmf-texlive/tex/latex/amsfonts/umsb.fd)\nPreview: Tightpage -32891 -32891 32891 32891\n[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]\n(./1f813afef156a65c06324451cc2eb533f668af9c.aux) ){/usr/share/texmf/fonts/enc/d\nvips/cm-super/cm-super-t1.enc}\n!pdfTeX error: /usr/bin/pdflatex (file ecrm0700): Font ecrm0700 at 600 not foun\nd\n ==> Fatal error occurred, no output PDF file produced!\n"
    "\nkpathsea: Running mktexpk --mfmode / --bdpi 600 --mag 1+0/600 --dpi 600 ecrm0700\nmkdir: cannot create directory `././.texmf-var': Permission denied\nmktexpk: /usr/share/texmf/web2c/mktexdir /.texmf-var/fonts/pk/ljfour/jknappen/ec failed.\nkpathsea: Appending font creation commands to missfont.log.\n"

    .
  • Another option is to wait for our planned boundary condition reform and to require all boundary conditions to either be applied directly to CellVariables or to be incorporated as SourceTerms in the equation, as discussed in the new FAQ.

We welcome suggestions of how users would like this to look and behave.

Last modified 6 years ago Last modified on 02/02/09 11:07:15