Emacs, latex, and all that

GNU Emacs is great, superfun

You can play a lot with things like latex, and org-mode, and coding in emacs
I use emacs in windows and linux systems

Windows 10 WSL

I was used to the windows version of emacs 25 in windows 10, but WSL is a supernice tool, thus I recently switched to WSL Ubuntu 20.04, and installed emacs27 via the PPA repository. You may install the APP ubuntu 20.04 in Windows Store. See this post

In windows 10 new need a good X10 server for opening windows, I found that X410 works nicely (it is not freeware)

You need to modify your .bashrc and add

DISPLAY=localhost:0
export DISPLAY

The windows filesystem in the ubuntu WSL terminal is automatically mounted in /mnt/c/Users/

To install emacs27 in ubuntu 20.04 WSL

sudo add-apt-repository ppa:kelleyk/emacs
sudo apt update
sudo apt install emacs27

Ubuntu 20.04

Same as above, works fine

My emacs configuration

As for many Linux things, the nice feature in emacs and all that is that you can easily configure anything. The problem is that you may become addicted in continuously changing the settings, because you do not like the window size, the font, etc. The good news is that this is also true in emacs!

To configure emacs you can either change the file .emacs, whic you can put or find in your home directory. Or you may change the file .emacs.d/init.el where .emacs.d is a config directory that is also in the home. The two methods are exclusive, meaning that either you use .emacs, or .emacs.d/init.el. I prefer to used .emacs.d/init.el as it is more recent.

For example, if you want to change the font, you have to put the following line in .emacs.d/init.el

(set-face-attribute 'default (selected-frame) :height 100)

This may seem weird, as it is not something like fontsize=12, but it is a glimpse into the supersmart world of Lisp. Indeed emacs is written in Lisp, a proper Lisp, the “emacs-lisp” and that is the reason why emacs is so cool.

to be continued

The Game of Light

In memoriam: John Horton Conway

In 1970 an article by Martin Gardner appeared in Scientific American disclosing for the first time a “game” invented by John H. Conway: a matrix of ones and zeros changes with time according to simple rules inspired by biology. Cells (ones) survive or die because of overpopulation, or starvation. The simple rules surprisingly generate a variety of binary animals, named gliders, blocks, and spaceships, among others. By pen and paper, Conway demonstrated that complex dynamics spontaneously emerge in the game. Ultimately, Conway’s Game of Life turned out to be a universal Turing machine, and it is the most famous example of Cellular Automaton.

I was deeply inspired by the possibility of generating complexity with simple rules, like many others before me. In more than 50 years, Conway’s Game of Life inspired generations of scientists. “Life” is at the inner core of ideas that pervade nowadays machine learning, evolutionary biology, quantum computing, and many other fields. It also connects to the work of Wolfram and the development of Mathematica.

I was intrigued by the interaction between light and complexity and I wanted to combine the Game of Life with electromagnetic fields. I report below my original post on the topic (dating back to 2008). The article was rejected by many journals and finally published in a book dedicated to the 50 years of the GOL ( Game of Life Cellular Automata, Springer 2010).

The Enlightened Game of Life (EGOL)

The link between light and the development of complex behavior is as subtle as evident. Examples include the moonlight triggered mass spawning of hard corals in the Great Barrier, or the light-switch hypothesis in evolutionary biology, which ascribes the Cambrian explosion of biodiversity to the development of vision. Electromagnetic (EM) radiation drastically alters complex systems, from physics (e.g., climate changes) to biology (e.g., structural colors or bioluminescence). So far the emphasis has been given to bio-physical, or digital, models of the evolution of the eye with the aim of understanding the environmental influence on highly specialized organs. In this manuscript, we consider the way the appearance of photosensitivity affects the dynamics, the emergent properties and the self-organization of a community of interacting agents, specifically, of cellular automata (CA).

Quick and dirty implementation of the EGOL in a Python Notebook

https://github.com/nonlinearxwaves/gameoflife.git

Docker, mpi, fftw, fftw-mpi

Docker enables to create containers for your program with all the libraries installed.

This avoids to reinstall all the libraries (say mpich, fftw…) to any user and in new systems

The user just needs to pull the container from a repository. For example nonlinearxwaves/base

I write C++ scientific computing programs with mpich, fftw-mpi and random numbers libraries (as sprng5), which I need to run in both windows and linux systems. Docker simplifies a lot the deployment but also the development of the code.

nonlinearxwaves/base is a container with all of that

After installing Docker you run

docker login

Then you pull the docker image

docker pull nonlinearxwaves/base:0.1

You list the available images with

docker images -a

You identify the image id (in this example it is ec56f7250d5a)

REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
nonlinearxwaves/base 0.1 ec56f7250d5a 42 hours ago 1.13GB

You run the image with (you must replace the image id with your image id)

docker run -i -t ec56f7250d5a 

And you are in a shell with all the libraries installed and you may compile and run your mpi application in the usual way. In this image you will be the user “user”

user@2ff281ad4621:~$

The number 2ff281ad4621 is the container id that is now running (similar to a virtual machine)

This works with Windows and Linux (and also Mac, but I did not test)

You may also create your images with the Dockerfile

Is docker fast ? or is it better not to use a container? we will test …

emacs, auctex, Sumatra.pdf in Windows 10

On Windows 10 Pro

Install MiKTeX from https://miktex.org/

Download emacs zip file in the GNU mirror. I have chosen in http://mirror.lihnidos.org/GNU/ftp/gnu/emacs/windows/ the file in the folder emacs-26 http://mirror.lihnidos.org/GNU/ftp/gnu/emacs/windows/emacs-26/emacs-26.3-x86_64.zip

Unzip the emacs file in some folder for example Downloads folder, you will have a folder with name emacs-26.1-x86.4

Inside this emacs folder, click on runemacs

Now emacs is running, but you need to install auctex and Sumatra.pdf. You may create a shortcut to runemacs in the application bar by right clicking on it

To install auctex open emacs, then “M+x package-install auctex” and hit return

M+x package-install auctex

Sumatra.pdf enables to open multiple windows with the same pdf file. Acrobat blocks the compilation if the pdf is open.

Install Sumatra.pdf from https://www.sumatrapdfreader.org

Sumatra.pdf exe file will be in “C:\Program Files\SumatraPDF”

C:\Program Files\SumatraPDF

Now you need to configure emacs for using Sumatra.pdf, this is done by modifying the .emacs file

The .emacs file is the main configuration file for emacs

You find the .emacs file in the folder “C:\Users\<USER>\AppData\Roaming”

C:\Users\YourUserNameHere\AppData\Roaming

This is a hidden folder, you need to enable showing hidden folder in windows explorer (go to options in the folder menu)

Open .emacs and add the lines at the end of the file and save

(setq TeX-PDF-mode t)
(setq TeX-source-correlate-mode t)
(setq TeX-source-correlate-method 'synctex)
(setq TeX-view-program-list
'(("Sumatra PDF" ("\"C:/Program Files/SumatraPDF/SumatraPDF.exe\" -reuse-instance"
   (mode-io-correlate " -forward-search %b %n ") " %o"))))

(eval-after-load 'tex
 '(progn
   (assq-delete-all 'output-pdf TeX-view-program-selection)
   (add-to-list 'TeX-view-program-selection '(output-pdf "Sumatra PDF")))
 )
(server-start)

Now you are set to run auctex in emacs with forward search and Sumatra.pdf