# The effect of anisotropic viscosity on the nonlinear kink instability This repository stores the data analysis and image generation scripts/notebooks for the titled paper. ## The data The data is generated by the 3D magnetohydrodynamics code Lare3d. It is assumed the user of this analysis has already installed and can run Lare3d. We also assume the user has installed the python interface for lare3d's file format `sdf`. The original code can be found via [this link](https://warwick.ac.uk/fac/sci/physics/research/cfsa/people/tda/larexd/). Our version of the code with only the anisotropic viscosity added can be found [here](https://github.com/JamieJQuinn/lare3d) and the branch including the nonlinear kink instability initial and boundary conditions can be found [here](https://github.com/JamieJQuinn/lare3d/tree/run/kink-instability). The specific runs can be recreated by running the scripts from the `run_scripts` directory of the `run\kink-instability` branch of our version of lare3d. These scripts must be edited, moved to the appropriate place (in a folder on the same level as lare3d) and run from inside the folder in which the simulations will be run. The scripts consist of 4 individual scripts: `archie_copy.sh` will copy the entire lare3d folder and change the appropriate files in the way required for a parameter run, specific run, etc. This should be heavily edited. `archie_build.sh` will build the passed folders including the correct viscosity model, detected via the folder name. `-isotropic` will use isotropic viscosity and `-switching` will use switching. This can be read to ascertain other options available. `archie_start.sh` will submit the given folder to the archie west queue. This is included for completeness. `archie_set_restart.sh` is used to restart a simulation after it has completed, with a longer runtime. The most important script for recreation of our data is within `archie_copy`. It should be relatively clear how to edit this script to recreate out simulations but if not, please get in touch. ## Pre-requisites There are several parts to the analysis: 1. Slices In folder `python-slices` is the notebook for plotting 2D slices through the data. It should be self-explanatory. 2. Field line plots In the folder `field_line_plots` is a collection of tools to plot field lines and current density contours via the visualisation tool, [visit](https://wci.llnl.gov/simulation/computer-codes/visit). This is done by passing visit a plot.py script telling visit which files to visualise and precisely how. We do not go into detail how this is done but it should be reasonably obvious from the scripts, although the plot.py file is rather long. 3. Analysis of field line-integrated quantities We have produced a tool to integrate certain quantities along field lines which can be found [here](https://github.com/JamieJQuinn/field-line-integrator). In this paper it is used to calculated connectivity, which is then analysed to give a measure of reconnection. It is also used to calculate the integrated parallel magnetic field, a more common measure of reconnection. The following command was run on each of the sdf files produced in the detailed run of the paper to generate the graphs of reconnection rate. ```fish python twist_calc.py --integration_variable parallel_electric_field --input input.sdf --output output.npy --grid_width 700 ``` Connectivity was calculated by changing the integration variable as follows. The full analysis can be found in the notebook `analysis.ipynb`. ``` --integration_variable connectivity ``` 4. Analysis of continuous energy output Lare3d outputs en.dat files, containing a continuous measure of various kinds of energy for every time step. We provide a tool to import that data into python in the `print_energy.py` script. This can be used as a stand-alone plotting tool (run with `--help` to use) or as a library to be used from notebooks. The latter is used in this analysis.