Flute and kink instabilities in a dynamically twisted flux tube with anisotropic plasma viscosity: Analysis code
This repository contains the analysis scripts used in the production of the paper "Flute and kink instabilities in a dynamically twisted flux tube with anisotropic plasma viscosity". Most of the data analysed by the included scripts are generated by the 3D magnetohydrodynamics code Lare3d. Due to the size of the data it is not stored, however it can be easily (though perhaps not quickly) reproduced using the parameters and specific code versions specified in the appendix of the thesis. The remainder of this README describes the folder layout, how to reproduce the simulation data and how to run the analysis.
This material is adapted from my thesis hence why there is a shared folder. This contains:
energy.py- functions for manipulating and plotting the continuous energy outputs fromlare3dstored inen.datfilesfan_plane_integrator.py- functions for integrating around the fan plane in chapter 6 (null_point_khi)field_line_integrator.py- functions for integrating along field lines in chapters 5 and 6parameters.py- holds relevant physical parameters used in the simulationsplotting.py- functions for plottingsdf_helper.py- functions for manipulating SDF files
The kink_instability_from_straight folder contains analysis scripts specific to this paper:
exploratory_data_analysis.Rmd- exploratory analysismain.Rmd- production of all figuressdf_file_subsampler.Rmd- notebook used to extract and save parts of the SDF files for more efficient analysisplotting_parameters.py- settings relevant for plottingfield_line_plots- scripts used to plot field lines using VisIt
Required
- MPI (for the SDF library)
Optional
- VisIt (for field line plotting)
These steps set up the SDF library and python requirements and link the SDF python bindings
Ensure SDF submodule and all its submodules are set up:
[in /]
git submodule update --init --recursive
Make SDF's C interface:
[in SDF/C]
make
Install virtual environment and python requirements via pipenv:
[in /]
pipenv install
Make and link SDF's python interface inside pipenv environment:
[in /]
pipenv shell
cd SDF/utilities
./build -3 -s
Run notebook:
[in /kink_instability_from_straight]
pipenv run jupyter <notebook>
The field lines are not plotted in jupyter notebooks. These are, instead, plotted using the package VisIt. The plotting scripts can be found in the field_line_plots folder. A field line plot is produced by specifying the input SDF files in the fill_filelist.sh script and calling make. This runs VisIt with the plotting script plot.py. This script is mostly constructed from the output from VisIt's Macro feature which records the user's actions in the GUI and represents them programatically. Saving this output in plot.py allows quick reproduction of a figure.
The code which implements only the anisotropic viscosity module can be found in its github repository in the feature/anisotropic_viscosity branch and it should be a simple process to merge the changes into another version of Lare3d for future research. The specific boundary conditions, basic parameters and initial conditions can be found in the branch run/kink-from-straight-field. The specific parameters used in each individual simulation can be found in the methods sections of the corresponding paper.