Setup
This page describes how to set up fireworks and atomate.
This page is intended to help you get set-up the first time you are using fireworks and atomate so you can learn how these softwares work. This set-up is not ideal for most research applications. Please refer to Fireworks: Advanced Usage if you are looking for practical advice and tips on how to run calculations once you understand the basics of fireworks.
Note: These instructions are based on the original version of atomate. atomate2 is a rising code that is still in development. Generally these research codes are under continuous improvement, so if something isn't working here please ask! It is likely the documentation needs to be updated.

Set up an environment:

Create the conda environment:
NERSC
Savio
Lawrencium
module load python
conda create -n cms python=3.9
module load python/3.8
conda create -n cms python=3.9
module load python/3.8
conda create -n cms python=3.9
Note: cms is an abbreviation for "computational materials science," but feel free to pick your own environment name!
Activate the environment and install the base libraries:
source activate cms
conda install numpy scipy matplotlib pandas
To install atomate on the environment, use one of the following:
If you are just using atomate and fireworks, with no plans to develop code/ workflows, use the following:
pip install atomate
For developers:
source activate cms
cd ~/.conda/envs/cms
mkdir code
cd code
git clone https://github.com/materialsproject/pymatgen.git
git clone https://github.com/materialsproject/pymatgen-db.git
git clone https://github.com/materialsproject/fireworks.git
git clone https://github.com/materialsproject/custodian.git
git clone https://github.com/hackingmaterials/atomate.git
cd pymatgen
python setup.py develop
pip install -r requirements.txt
cd ..
cd pymatgen-db
python setup.py develop
pip install -r requirements.txt
cd ..
cd fireworks
python setup.py develop
pip install -r requirements.txt
cd ..
cd custodian
python setup.py develop
pip install -r requirements.txt
cd ..
cd atomate
python setup.py develop
pip install -r requirements.txt
cd ..

Getting Started Fireworks Configuration:

Create Fireworks configuration files

Note: You will want to follow the steps in this section on both your local computer and the supercomputer where you will be running your calculations (e.g. making a fw_config folder in your home directory that contains the 3 files: FW_config.yaml, db.json, and my_launchpad.yaml) so you can easily interface with fireworks from both your local computer and the supercomputer.
Make directory in your home directory called fw_config:
cd ~
mkdir fw_config
cd fw_config
Now create 3 files: FW_config.yaml, db.json, and my_launchpad.yaml with the following contents. Make sure you replace YOUR_USERNAME with your username; on NERSC you will also need to find your home folder, which is typically under another higher folder with the name of the FIRST LETTER of your username. Note: you can view your filesystem online. Also, consider setting up access to your NERSC filesystem locally on your computer: Check out "Mounting NERSC's file system locally" here:running-jobs-on-nersc

FW_config.yaml (fireworks configuration file)

NERSC
Savio
Lawrencium
Local
CONFIG_FILE_DIR: /global/homes/FIRST_LETTER/YOUR_USERNAME/fw_config
QUEUE_UPDATE_INTERVAL: 5
ECHO_TEST: "cms fw_config activated"
CONFIG_FILE_DIR: /global/home/users/YOUR_USERNAME/fw_config
QUEUE_UPDATE_INTERVAL: 5
ECHO_TEST: "cms fw_config activated"
CONFIG_FILE_DIR: /global/home/users/YOUR_USERNAME/fw_config
QUEUE_UPDATE_INTERVAL: 5
ECHO_TEST: "cms fw_config activated"
CONFIG_FILE_DIR: /HOME_DIRECTORY_PATH/fw_config
QUEUE_UPDATE_INTERVAL: 5
ECHO_TEST: "cms fw_config activated"

db.json (Database file)

{
"host": "mongodb07.NERSC.gov",
"port": 27017,
"database": "fw_db_name",
"collection": "tasks",
"admin_password": "<admin_password>",
"admin_user": "<admin_username>",
"readonly_password": "<readonly_password>",
"readonly_user": "<readonly_username>",
"aliases_config": null
}

my_launchpad.yaml (Fireworks LaunchPad file)

host: mongodb07.NERSC.gov
port: 27017
name: 'fw_db_name'
username: '<admin_username>'
password: ‘<admin_password>’
logdir: null
Istrm_lvl: DEBUG
user_indices: []
wf_user_indices: []

Create Fireworker and Queue Launchers:

Fireworker file (my_fworker.yaml)

NERSC
Savio
Lawrencium
NERSC-Perlmutter-GPU
name: NERSC_fworker
category: ''
query: '{}'
env:
db_file: /global/homes/FIRST_LETTER/YOUR_USERNAME/fw_config/db.json
vasp_cmd: 'srun -n 64 -c 4 --cpu_bind=cores vasp_std'
gamma_vasp_cmd: 'srun -n 64 -c 4 --cpu_bind=cores vasp_gam'
scratch_dir: /global/cscratch1/sd/YOUR_USERNAME
incar_update:
name: savio_fworker
category: ''
query: '{}'
env:
db_file: /global/home/users/YOUR_USERNAME/fw_config/db.json
vasp_cmd: 'mpirun --bind-to core vasp_std'
gamma_vasp_cmd: 'mpirun --bind-to core vasp_gam'
scratch_dir: /global/scratch/YOUR_USERNAME/
incar_update:
name: lrc_fworker
category: ''
query: '{}'
env:
db_file: /global/home/users/YOUR_USERNAME/fw_config/db.json
vasp_cmd: 'mpirun --bind-to core vasp_std'
gamma_vasp_cmd: 'mpirun --bind-to core vasp_gam'
scratch_dir: /global/scratch/YOUR_USERNAME/
incar_update:
name: gpu_fworker
category: ''
query: '{}'
env:
db_file: /global/homes/FIRST_LETTER/YOUR_USERNAME/fw_config/db.json
vasp_cmd: 'srun -n 4 -c 16 --gpu-bind=single:1 vasp_std'
gamma_vasp_cmd: 'srun -n 4 -c 16 --gpu-bind=single:1 vasp_gam'
scratch_dir: /pscratch/sd/FIRST_LETTER/YOUR_USERNAME
incar_update:

Queue Adapter (my_qadapter.yaml):

NERSC
Savio
Lawrencium
NERSC-Perlmutter-GPU
_fw_name: CommonAdapter
_fw_q_type: SLURM
rocket_launch: rlaunch -w /global/homes/FIRST_LETTER/YOUR_USERNAME/fw_config/my_fworker.yaml singleshot
nodes: 1
walltime: '24:00:00'
account: matgen
job_name: knl_launcher
qos: regular
constraint: 'knl'
pre_rocket: |
source activate cms
module load vasp-tpc/5.4.4-knl
export OMP_PROC_BIND=true
export OMP_PLACES=threads
export OMP_NUM_THREADS=1
_fw_name: CommonAdapter
_fw_q_type: SLURM
rocket_launch: rlaunch -w /global/home/users/YOUR_USERNAME/fw_config/my_fworker.yaml singleshot
nodes: 1
walltime: '24:00:00'
account: co_lsdi
job_name: knl_launcher
queue: savio2_knl
qos: lsdi_knl2_normal
ntasks: 64
pre_rocket: |
source activate cms
module load vasp
export OMP_PROC_BIND=true
export OMP_PLACES=threads
export OMP_NUM_THREADS=1
post_rocket: null
_fw_name: CommonAdapter
_fw_q_type: SLURM
rocket_launch: rlaunch -w /global/homes/FIRST_LETTER/YOUR_USERNAME/fw_config/perlmutter/my_fworker.yaml singleshot
nodes: 1
walltime: '06:00:00'
account: matgen_g
job_name: gpu_launcher
qos: regular
constraint: 'gpu'
pre_rocket: |
source activate cms
module load vasp/6.2.1-gpu
export SLURM_CPU_BIND="cores"
unset MPICH_GPU_SUPPORT_ENABLED
_fw_name: CommonAdapter
_fw_q_type: SLURM
rocket_launch: rlaunch -w /global/homes/FIRST_LETTER/YOUR_USERNAME/fw_config/perlmutter/my_fworker.yaml singleshot
nodes: 1
walltime: '06:00:00'
account: matgen_g
job_name: gpu_launcher
qos: regular
constraint: 'gpu'
pre_rocket: |
source activate cms
module load vasp/6.2.1-gpu
export SLURM_CPU_BIND="cores"
unset MPICH_GPU_SUPPORT_ENABLED
Available queues, partitions, and qos descriptions can be found at the following links:
Note: specifying singleshot in the queue adapter will limit each reserved job to running only one firework (even if other fireworks are ready and could run with your remaining wall time). This can be changed to rapidfire but this may result in lost runs (fireworks that do not complete because they run out of wall time).

Configure Bash profile:

Append the following lines to the .bashrc or .bashrc.ext file, which is located in your home directory, e.g. /global/homes/s/sivonxay:
NERSC
Savio
Lawrenicum
Local
NERSC-Perlmutter-GPU
module load python
export PMG_VASP_PSP_DIR='/project/projectdirs/matgen/POTCARs'
export FW_CONFIG_FILE='/global/homes/FIRST_LETTER/YOUR_USERNAME/fw_config/FW_config.yaml'
alias cdconfig='cd ~/fw_config'
module load python/3.8
export PMG_VASP_PSP_DIR=/clusterfs/mp/software/POTCARs
export FW_CONFIG_FILE='/global/home/users/YOUR_USERNAME/fw_config/FW_config.yaml'
alias cdconfig='cd ~/fw_config'
TBD
export FW_CONFIG_FILE='/HOME_DIRECTORY_PATH/fw_config/FW_config.yaml'
alias cdconfig='cd ~/fw_config'
module load python
export PMG_VASP_PSP_DIR='/global/cfs/cdirs/matgen/POTCARs'
export FW_CONFIG_FILE='/global/homes/FIRST_LETTER/YOUR_USERNAME/fw_config/FW_config.yaml'
alias cdconfig='cd ~/fw_config'
Note: the line alias cdconfig='cd ~/fw_config' is optional but is recommended so you can more easily locate the directory with your configuration files stored by typing cdconfig into the command line.

Setup API key and Add POTCAR Directory to pymatgen

Go to materialsproject.org and get an API key. Make sure you are using the environment setup above to run these commands in terminal with your cms python environment activated.
NERSC
Savio
Lawrencium
pmg config --add PMG_MAPI_KEY <USER_API_KEY>
pmg config --add PMG_VASP_PSP_DIR /project/projectdirs/matgen/POTCARs
pmg config --add PMG_MAPI_KEY <USER_API_KEY>
pmg config --add PMG_VASP_PSP_DIR /clusterfs/cloudcuckoo/POTCARs
TBD
Running these commands will create a .pmgrc.yaml file (if it doesn’t exist already) containing these configuration settings in your home directory

Using Fireworks and Atomate:

The Materials Project Workshop has some great sessions introducing how to use fireworks and atomate. It might be helpful to watch the youtube recordings before trying out launching your own calculations!

Initializing Fireworks Database:

First, let's confirm that you have your fireworks configuration set-up correctly to point to the right MongoDB database for your launchpad. Check your default fireworks configuration file with echo.
echo $FW_CONFIG_FILE
Copy the file path printed out and check the contents of the specified FW_config.yaml file to find your FW_CONFIG_DIR using cat.
cat /HOME_DIRECTORY_PATH/fw_config/FW_config.yaml
You should see something like this printed out. Copy the file path specified by CONFIG_FILE_DIR.
CONFIG_FILE_DIR: /HOME_DIRECTORY_PATH/fw_config
QUEUE_UPDATE_INTERVAL: 5
ECHO_TEST: "cms fw_config activated"
Print out the contents of the my_launchpad.yaml file in your CONFIG_FILE_DIR using cat.
cat YOUR_FW_CONFIG_FILE_PATH/my_launchpad.yaml
If you do not see something that resembles your my_launchpad.yaml file written earlier, there may be something wrong with your fireworks configuration that needs to be resolved before moving forward.
BE EXTREMELY CAREFUL WHEN RUNNING THIS RESET COMMAND. It will wipe all existing entries in your fireworks database in the fireworks, workflows, and launches collections. You must activate your python environment where fireworks is installed before running this command in terminal.
lpad reset

Using Atomate to Create a Workflow

The following code blocks are python code that should be run in jupyter or via python from the terminal. Make sure you have the environment setup above activated. The computer running the code should have access to mongodb07.NERSC.gov; this can be disregarded when running directly on NERSC or when connected to to the LBNL intranet. For computers outside of LBNL, a VPN will need to be used.
Run the following python code in a jupyter notebook or by creating a file named make_workflow.py and running the command python make_workflow.py in terminal:
from pymatgen.ext.matproj import MPRester
from fireworks import LaunchPad
from atomate.vasp.workflows.presets.core import wf_static
from atomate.vasp import powerups
mpr = MPRester()
structure = mpr.get_structure_by_material_id("mp-145")
wf = wf_static(structure)
wf = powerups.add_common_powerups(wf, {"scratch_dir":">>scratch_dir<<"})
lp = LaunchPad.from_file('YOUR_FW_CONFIG_FILE_PATH/fw_config/my_lp.yaml')
lp.add_wf(wf)
This adds a static energy calculation for Hexagonal Lu to your job database.
To check if this workflow has been added to your launch pad, run this command in terminal:
lpad get_fws -s READY
You can also check if this workflow has been added successfully by looking at your MongoDB fireworks collection or the launchpad webgui.

Launching a Workflow

Use qlaunch command to reserve jobs with SLURM’s scheduler. qlaunch has 3 modes: singleshot, rapidfire, and multi. Singleshot is used to launch one job, rapidfire is used to launch multiple jobs in quick succession, and multi creates one job with multiple fireworks runs. You’ll probably want to use rapidfire (where it is important to add the --nlaunches flag to specify how many fireworks to run). Here is example code for launching one job from the command line.
Note: Make sure you are in the directory you want your calculations to be run from before you run these commands, you may want to create a new folder for this. Do not run these commands from your home directory.
Singleshot
Rapidfire
conda activate cms
echo $FW_CONFIG_FILE
qlaunch singleshot
conda activate cms
echo $FW_CONFIG_FILE
qlaunch rapidfire --nlaunches 1

Monitoring Your Launchpad (Fireworks Database)

Terminal Commands

Status of running fireworks can be determined by using the command:
lpad get_fws -s RUNNING
If a firework has failed or fizzled, you can rerun it by returning its state to ready to be launched again.
Rerun a Specific Firework
Rerun All Fizzled Fireworks
lpad rerun_fws -i <fw_id>
lpad rerun_fws -s FIZZLED

Launchpad Web GUI

Many prefer to view their jobs in the web GUI using the following command on their local computer in terminal with your python environment activated. Note this requires having your FW_CONFIG_FILE variable set-up to point correctly to your MongoDB database through the my_launchpad.yaml file. Otherwise you must run this command in a folder contain your my_launchpad.yaml file.
lpad webgui
If you have not yet made a local copy your my_launchpad.yaml file, you can download it.
scp <username>@dtn01.NERSC.gov:~/fw_config/my_launchpad.yaml .

Viewing Database and Outputs:

Download and install Robo 3T from the following link

Setup connection using mongodb credentials

Connection settings in Robo 3T
Authentication settings in Robo 3T
For security reasons, if you want to connect to the database, you will either:
  • Have to connect via the NERSC network, e.g. enter your details in the "SSH" tab and connect via a data transfer node such as dtn01.nersc.gov.
  • Have to connect via the LBL network, e.g. by being on-site or using the LBL VPN. In this case you will have to add -ext to your database addressed, for example mongodb03-ext.nersc.gov
Special thanks to the original authors of this page: Eric Sivonxay, Julian Self, Ann Rutt, and Oxana Andriuc