virtual machine for Quantum Espresso

Perform these steps to install a virtual machine for Quantum Espresso on your computer:

  • Install the VirtualBox software on your computer (go here, select the operating system (‘platform’) of your computer, and an installation package will be downloaded (≅120 Mb).
  • Run this downloaded installation package for VirtualBox.
  • Download and install the VirtualBox Oracle VM VirtualBox Extension Pack (go here, same download for all platforms).

Now you have the software to run a virtual machine, but you don’t have the virtual machine itself yet. Whence the next step:

  • Download from here a virtual machine for Quantum Espresso (click the link to ‘https://…readthedocs…’ and use the bit.ly download link you find there. Attention: 4.0 Gb ! don’t do this over your phone). It will emulate an Ubuntu Linux operating system. This virtual machine file is created and maintained by the Quantum Espresso developers (GitHub page for this project).

Tell VirtualBox where it can find this virtual machine file:

  • Open VirtualBox, select ‘File’, then ‘Import Appliance’, point it to the place where you downloaded the virtual machine file, and press ‘enter’ a few times. The import process starts, which can take a few minutes.
  • Click on the name of the ‘Quantum Mobile’ virtual machine that appears in the list at the left, such that it is highlighted (don’t launch it yet).
  • Click on the gear symbol (‘settings’) in the menu bar, and then select ‘Display’. Untick the option ‘enable 3D acceleration’. Click ‘OK’. [note: if that tick box is greyed out, it probably means you had already started the virtual machine and left it in sleep mode. Start the virtual machine again, and quit it by shutting it down. Then you will be able to untick that box.]

Now you can launch the virtual machine:

  • open VirtualBox (if not yet done)
  • right-click on the ‘Quantum Mobile’ virtual machine you see now in the list, and select ‘start’ (‘normal start’)
  • a new window will open, and after running start-up processes during 1-2 minutes, you have your virtual machine — a new computer inside your computer

You close the virtual machine via ‘File / Close’. You can choose to close it completely (comparable to the ‘power off’ setting of a computer) or to save the current state for later reuse (comparable to the ‘hibernate’ setting of a computer).

If after installing Quantum Mobile you find that your virtual machine has a different keyboard layout than your actual keyboard, then go to the FAQ of Quantum Mobile (‘how do I change the keyboard layout…‘) and follow the instructions over there. Restart the virtual machine to make the change effective.

If you are used to press ‘alt Tab’ to switch between apps, you may notice it does not work with Virtualbox. You can enable ‘alt Tab’ by pressing the Host Key. Follow these instructions to define which key is the Host Key (look at the answer by granada29).

It may happen that you get an error message when launching the virtual machine, telling that you don’t have virtual machine rights enabled in your BIOS. If that message is “VT-x is disabled in the BIOS for both all CPU modes”, you may find a solution here or (as a video) here (and here is another set of explanations, for Intel as well as AMD processors, and here and here there are yet other ones). The same solution may help if you start Virtualbox and nothing seems to happen. If you have another error message, Google for the exact message you got, and follow the instructions you find that way. Whether or not these rights in the BIOS are given by default, depends on your computer vendor.

Note for Apple users not using a M1: some more or less common issues when installing VirtualBox on Apple are listed here, with a link to a solutions:

The virtual machine you just installed contains more software than just Quantum Espresso. We will use some of that later in the course. One piece of software that is not yet available is cif2cell. You can install it easily by typing

pip install cif2cell

(this needs to be done only once).

The last step you have to take, is to create a shared folder :

A virtual machine runs in its own silo, totally isolated from the rest of your computer. That’s good, that’s safe. Nevertheless, you will want to pass on files between your computer and the virtual machine. To allow such communication, we are going to set up now a folder that is shared between your computer and the virtual machine. Every file you put there on your computer, will be visible from within the virtual machine, and vice versa.

Short instructions to create a shared folder are available at the FAQ of Quantum Mobile (‘how do I set up a shared folder between the VM and my host?‘). Detailed instructions (yet not specifically for Quantum Mobile) are available here. A step-by-step explanation is given underneath. This explanation is general, whereas the explicit instructions between square brackets are for the case of your computer running under Windows.

  • Create a folder on your local computer, with any name (no spaces, no upper case, no special symbols). In this example, we’ll assume it has been given the name ‘shared’. [Windows: for the sake of example, we assume this local folder is at the location C:\My Documents\compmatphys\shared]. Put a simple text file inside that folder, as an example.
  • Open VirtualBox, but do not start the virtual machine yet. Select ‘Machine/settings/shared folders’. Use the green ‘+’ at the right to open the shared folder dialog box. Use the drop-down menu (‘other’) to select the previously created folder on your local computer (=the folder called ‘shared’ which you just created). [Windows: the first field ‘path to folder’ should read according to our example ‘C:\My Documents\compmatphys\shared’] The second field ‘name of folder’ must read ‘host’ (strictly lower case). Do check the ‘automount’ box, and do not specify a mount point. Click OK to close the dialog box, and another time OK to close the settings box.
  • That’s it. Your shared folder is created and enabled. Let’s now test whether it works, and demonstrate how to use it:
  • Start the virtual machine. Open a terminal (third icon from the top, the black one with the “>” symbol in it), and type the following commands:
    cd /media/sf_host
    touch testfile.txt
    ls
  • The name of the example file you had put in the folder ‘shared’ on your local computer should be displayed now on the virtual machine (the linux command ‘touch’ creates and empty file with the given name, while ‘ls’ lists the files that are present within a folder). Everything you put in the folder with the name ‘shared’ on your local computer, will appear in the folder /media/sf_host’ of the virtual machine, and vice-versa. You can verify that by looking in the folder on your local machine, which should now have apart from the file you had put there initially also the new empty file ‘testfile.txt’.
  • Assuming you are doing your calculations in a folder /home/max/work/mycalculation, this is how you can copy files from the shared folder to your calculation folder:
    • if the folder ‘work’ did not yet exist, create it and descend into it as follows:

cd 
mkdir work cd work pwd
    • idem to create the ‘mycalculation’ folder, should it not yet exist:
mkdir mycalculation
cd mycalculation
pwd
    • Now you are in the folder /home/max/work/mycalculation. Copy a file from the shared folder to this calculation folder:
cp /media/sf_host/testfile.txt ./
ls
    • To test the other way around, create an empyt file ‘myoutput.txt’ in the calculation folder and copy it to the shared folder:
touch myoutput.txt
cp myoutput.txt /media/sf_host
    • If you go to the shared folder on your local machine, you will see the file myoutput.txt there (an empty file).

That’s it.  Your shared folder is enabled, and you know how to use it. You can close this tab now and go on with the next item in the course.

Scroll to Top