Bifrost¶
Bifrost is a massively parallel code developed for tridimensional numerical experiments of stellar atmospheres (Gudiksen et al. 2011). In order to explicitly solve the standard partial differential equations of magnetohydrodynamics (MHD), its core uses a staggered mesh in cartesian coordinates (x,y,z)
. The positioning of the variables in the mesh is as follows: the scalar variables, e.g., the density ρ
, are defined in the center of the numerical cells; the components of the basic vector fields, namely, the magnetic field B_i
and linear momentum p_i
, are located at the center of the cell faces; and the cross product or curl of those vectors, like (vxB)_i
or J_i
, are defined on the cell edges.
The numerical scheme is a classic method of lines (MOL). It is based on a sixth order operator for the spatial derivatives. Since Bifrost uses a staggered mesh, it is not possible to avoid the use of interpolations to re-collocate the variables in space during the computations. Those interpolations are of fifth order. The time derivatives can follow a predictor-corrector scheme of third order described by Hyman (1979) or a third order Runge Kuttta method. In both cases, the timestep is controlled by the Courant-Friedrichs-Lewy (CFL) criterion (Courant et al. 1928).
In spite of using high-order methods, the numerical codes are diffusive by their own nature due to the discretization of the equations. To ensure stability, Bifrost employs a diffusive operator that consists of two main terms: a small global diffusive term and the so called hyperdiffusion term inspired by Nordlund & Galsgaard (1995). The latter is a location-specific diffusion that acts in small regions of large gradients or jumps in the variables, like in current sheets or shocks.
The advantage of using the Bifrost code is that it includes different modules that provide relevant physics for the solar atmosphere.
Bifrost literature¶
In the following, we list the papers that describe the main modules of Bifrost:
- Equation of state: Gustafsson et al. (1975)
- Injection of magnetic field through the bottom boundary of the convection zone: Martínez-Sykora et al. (2008)
- Radiative transfer solver with coherent scattering: Skartlien (2000) and Hayek et al. (2010)
- Nonequilibrium ionization of Hydrogen: Leenaarts et al. (2011)
- Radiative transfer in the chromosphere: Carlsson and Leenaarts (2012)
- Generalized Ohm's Law: Martínez-Sykora et al. (2012)
- Nonequilibrium ionization of optically thin ions: Olluri et al. (2013)
- Nonequilibrium ionization of Helium: Golding et al. (2016)
- Lagrangian Tracing module: Leenaarts (2018)
- New ambipolar diffusion module: Nóbrega-Siverio et al. (2020)
Installation¶
Getting Bifrost¶
Bifrost is located on github. The repository is private, meaning you should be logged in with your github username to see it at:
To get started with the new repository, you'll need to have git (pre-installed in most machines) and configure it to use your name and email address you registered with github, by doing something like:
git config --global user.name "Your name"
git config --global user.email username@example.com
You can clone the repository through HTTPS like this:
git clone https://username@github.com/ITA-Solar/Bifrost.git
replacing "username" with your github username.
Terminal configuration¶
It can be useful to create (or modify) your .login (in csh/tcsh) or .zlogin (in zsh) file in your home directory to add a Bifrost system variable.
In case of working with zsh:
export BIFROST="/folder/Bifrost"
setenv BIFROST "/folder/Bifrost"
To use the IDL routines of Bifrost, modify your .zlogin file to add the following system variables. In case of working with tcsh:
export BIFROST_IDL=$BIFROST"/IDL"
BIFROST
is a system variable for your Bifrost repository (see Bifrost section).
Then, modifiy your IDL_PATH
to the the Bifrost IDL folder:
export IDL_PATH="/Applications/exelis/idl85/bin"":+"$BIFROST_IDL
It is also necessary to define a system variable called OSC_CSTAGGER
, which
depends on your operative system.
- If you use a Linux system:
export OSC_CSTAGGER=$BIFROST_IDL"/cstagger/linux"
- In case of a intelmac:
export OSC_CSTAGGER=$BIFROST_IDL"/cstagger/intelmac"
The next step is to go to your stagger folder, typing in your terminal
cd $OSC_CSTAGGER
and then
make
That would create the following six files:
- cstagger.pro
- cstagger.c
- cstagger.o
- init_stagger.o
- inverse.o
- cstagger.so
which are necessary for stagger operations.
After all this steps, create a IDL startup file. This file is going to be executed automatically each time IDL is started. For example, you can create it in your IDLWorkspace and then add a similar line in your .login file (in case of using tcsh) with the location:
export IDL_STARTUP="/Users/yourname/IDLWorkspace85/startup.pro"
.r $OSC_CSTAGGER/cstagger
I also have the following useful lines in startup.pro
br_select_idlparam, idlparam
d=obj_new('br_data', idlparam)
br_getsnapind, idlparam, snaps
PRINT, '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
PRINT, ' Project : ', idlparam, ' ', strtrim(string(min(snaps)),2), '-',strtrim(string(max(snaps)),2)
PRINT, '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
PRINT, '
so everytime I run IDL within a folder containing a numerical experiment carried out with
Bifrost, I get the object to load Bifrost variables (d
), the name of the simulation
(idlparam
) and all the snapshots I have in that folder (snaps
). Then I print
on the screen some of that information.