Path: blob/main/latex-templates/templates/plasma-physics/mhd.tex
51 views
unlisted
\documentclass[11pt,a4paper]{article}1\usepackage[utf8]{inputenc}2\usepackage[T1]{fontenc}3\usepackage{amsmath,amssymb}4\usepackage{graphicx}5\usepackage{booktabs}6\usepackage{siunitx}7\usepackage{geometry}8\geometry{margin=1in}9\usepackage{pythontex}10\usepackage{hyperref}11\usepackage{float}1213\title{Magnetohydrodynamics: Plasma Confinement and Stability}14\author{Plasma Physics Research Group}15\date{\today}1617\begin{document}18\maketitle1920\begin{abstract}21Magnetohydrodynamics (MHD) describes the macroscopic behavior of electrically conducting fluids, treating plasma as a single conducting fluid coupled to electromagnetic fields. This report presents computational analysis of fundamental MHD wave modes, stability boundaries, and magnetic reconnection dynamics. We solve the MHD dispersion relation for Alfvén and magnetosonic waves, compute growth rates for kink and sausage instabilities in cylindrical plasmas, and model Sweet-Parker magnetic reconnection. The analysis demonstrates how magnetic field tension stabilizes plasma columns, how plasma beta determines wave propagation characteristics, and how resistivity controls reconnection rates. Results include Alfvén velocities of 500–5000 km/s for fusion-relevant parameters, instability growth times of 10–100 $\mu$s for laboratory plasmas, and reconnection timescales of milliseconds to seconds depending on magnetic Reynolds number.22\end{abstract}2324\section{Introduction}2526Magnetohydrodynamics unifies fluid dynamics with Maxwell's equations by treating plasma as a single conducting fluid with infinite electrical conductivity (ideal MHD) or finite resistivity (resistive MHD). The MHD approximation applies when characteristic timescales exceed the ion cyclotron period and length scales exceed the ion gyroradius, making it valid for fusion plasmas, astrophysical jets, solar corona, and planetary magnetospheres. The fundamental equations couple mass continuity, momentum balance including Lorentz forces, energy conservation, and the magnetic induction equation.2728MHD supports three distinct wave modes: shear Alfvén waves that propagate along magnetic field lines with velocity $v_A = B/\sqrt{\mu_0 \rho}$, fast magnetosonic waves that compress both plasma and magnetic field, and slow magnetosonic waves that exhibit anti-correlation between thermal and magnetic pressure. Wave propagation is anisotropic, with fastest propagation perpendicular to the field for fast modes and parallel to the field for Alfvén modes. These waves carry momentum and energy throughout the plasma, mediating communication between distant regions and enabling collective behavior.2930Plasma confinement in toroidal devices like tokamaks and stellarators relies on MHD equilibrium and stability. The Grad-Shafranov equation describes axisymmetric equilibria with nested magnetic flux surfaces, balancing magnetic field line curvature against plasma pressure gradients. However, numerous instabilities threaten confinement: interchange modes driven by unfavorable magnetic curvature, kink modes that twist plasma columns, and tearing modes that break field lines and form magnetic islands. Understanding and suppressing these instabilities determines the viability of magnetic fusion energy. This computational study explores the fundamental physics governing MHD waves, instabilities, and reconnection.3132\begin{pycode}3334import numpy as np35import matplotlib.pyplot as plt36from scipy import optimize, integrate37from scipy.special import jv, jn_zeros38plt.rcParams['text.usetex'] = True39plt.rcParams['font.family'] = 'serif'4041# Physical constants42mu_0 = 4 * np.pi * 1e-7 # Vacuum permeability (H/m)43proton_mass = 1.67e-27 # kg4445# Store computed values for conclusion46computed_results = {}4748\end{pycode}4950\section{MHD Wave Dispersion}5152The linearized MHD equations yield the dispersion relation for small-amplitude waves propagating at angle $\theta$ to the magnetic field:53\begin{equation}54\omega^4 - k^2(\omega^2)(v_A^2 + c_s^2) + k^4 v_A^2 c_s^2 \cos^2\theta = 055\end{equation}56where $v_A = B/\sqrt{\mu_0 \rho}$ is the Alfvén velocity and $c_s = \sqrt{\gamma p / \rho}$ is the sound speed. Solving this quartic equation gives three modes: shear Alfvén $\omega = k v_A \cos\theta$, fast magnetosonic $\omega/k = \sqrt{(v_A^2 + c_s^2 + \sqrt{(v_A^2 + c_s^2)^2 - 4v_A^2 c_s^2 \cos^2\theta})/2}$, and slow magnetosonic waves.5758\begin{pycode}59# MHD wave dispersion calculation60def compute_mhd_dispersion(magnetic_field, density, temperature, k_wavenumber):61"""62Compute MHD wave phase velocities for given plasma parameters.6364Parameters:65- magnetic_field: Magnetic field strength (T)66- density: Mass density (kg/m^3)67- temperature: Plasma temperature (eV)68- k_wavenumber: Wave vector magnitude (m^-1)69"""70# Alfven velocity71alfven_velocity = magnetic_field / np.sqrt(mu_0 * density)7273# Sound speed (gamma = 5/3 for adiabatic plasma)74gamma = 5.0/3.075pressure = density * temperature * 1.602e-19 / proton_mass76sound_speed = np.sqrt(gamma * pressure / density)7778# Plasma beta79magnetic_pressure = magnetic_field**2 / (2 * mu_0)80thermal_pressure = pressure81plasma_beta = thermal_pressure / magnetic_pressure8283return alfven_velocity, sound_speed, plasma_beta8485# Fusion-relevant parameters86B_field = 2.0 # Tesla (tokamak-scale)87n_density = 1e20 # m^-3 (typical fusion density)88mass_density = n_density * 2.5 * proton_mass # deuterium-tritium mix89T_plasma = 1000 # eV (edge plasma temperature)9091v_A, c_s, beta = compute_mhd_dispersion(B_field, mass_density, T_plasma, 0)92computed_results['alfven_velocity'] = v_A / 1e3 # km/s93computed_results['sound_speed'] = c_s / 1e394computed_results['plasma_beta'] = beta9596# Dispersion relation for different propagation angles97theta_angles = np.array([0, 30, 45, 60, 90]) * np.pi / 18098k_range = np.linspace(1e3, 1e5, 200) # m^-199100fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 6))101102for theta in theta_angles:103# Fast magnetosonic mode104omega_fast_squared = 0.5 * k_range**2 * (v_A**2 + c_s**2 +105np.sqrt((v_A**2 + c_s**2)**2 - 4*v_A**2*c_s**2*np.cos(theta)**2))106v_fast = np.sqrt(omega_fast_squared) / k_range107108# Slow magnetosonic mode109omega_slow_squared = 0.5 * k_range**2 * (v_A**2 + c_s**2 -110np.sqrt((v_A**2 + c_s**2)**2 - 4*v_A**2*c_s**2*np.cos(theta)**2))111v_slow = np.sqrt(omega_slow_squared) / k_range112113# Alfven mode (only for non-perpendicular propagation)114if theta < np.pi/2:115v_alfven = v_A * np.abs(np.cos(theta)) * np.ones_like(k_range)116ax1.plot(k_range/1e3, v_alfven/1e3, '--', linewidth=1.5,117label=f'Alfvén, $\\theta={int(np.degrees(theta))}^\\circ$' if theta == 0 else '')118119ax1.plot(k_range/1e3, v_fast/1e3, '-', linewidth=2,120label=f'Fast, $\\theta={int(np.degrees(theta))}^\\circ$')121ax2.plot(k_range/1e3, v_slow/1e3, '-', linewidth=2,122label=f'Slow, $\\theta={int(np.degrees(theta))}^\\circ$')123124ax1.set_xlabel('Wavenumber $k$ (rad/mm)', fontsize=12)125ax1.set_ylabel('Phase Velocity (km/s)', fontsize=12)126ax1.set_title('Fast Magnetosonic and Alfvén Modes', fontsize=13)127ax1.legend(fontsize=9)128ax1.grid(True, alpha=0.3)129ax1.set_ylim(0, 1500)130131ax2.set_xlabel('Wavenumber $k$ (rad/mm)', fontsize=12)132ax2.set_ylabel('Phase Velocity (km/s)', fontsize=12)133ax2.set_title('Slow Magnetosonic Mode', fontsize=13)134ax2.legend(fontsize=9)135ax2.grid(True, alpha=0.3)136137plt.tight_layout()138plt.savefig('mhd_wave_dispersion.pdf', dpi=150, bbox_inches='tight')139plt.close()140\end{pycode}141142\begin{figure}[H]143\centering144\includegraphics[width=0.98\textwidth]{mhd_wave_dispersion.pdf}145\caption{MHD wave dispersion relations showing fast magnetosonic (left), slow magnetosonic (right), and shear Alfvén modes for propagation angles $\theta = 0^\circ$ to $90^\circ$ relative to the magnetic field. Parameters: $B = 2$ T, $n = 10^{20}$ m$^{-3}$, $T = 1$ keV, giving Alfvén velocity $v_A = \py{int(computed_results['alfven_velocity'])}$ km/s and sound speed $c_s = \py{int(computed_results['sound_speed'])}$ km/s. Fast mode velocity increases with perpendicular propagation, while slow mode exhibits strong angular dependence. Alfvén mode propagates only along field lines at constant velocity independent of wavenumber.}146\end{figure}147148\section{Magnetic Field Topology and Pressure Balance}149150Magnetic field line geometry determines plasma confinement and stability. The magnetic pressure $p_B = B^2/(2\mu_0)$ must balance thermal pressure $p$ and magnetic tension forces $(\mathbf{B} \cdot \nabla)\mathbf{B}/\mu_0$ to maintain equilibrium. Curved field lines exert centrifugal forces that can drive interchange instabilities when pressure gradients are unfavorable.151152\begin{pycode}153# Magnetic field visualization - dipole field with plasma pressure154def magnetic_field_dipole(x, y, B0=1.0, moment_strength=1.0):155"""Compute magnetic field components for a dipole field."""156r = np.sqrt(x**2 + y**2)157r = np.where(r < 0.1, 0.1, r) # Avoid singularity158159# Dipole field components160Bx = 3 * moment_strength * x * y / r**5161By = moment_strength * (2*y**2 - x**2) / r**5162163B_magnitude = np.sqrt(Bx**2 + By**2)164return Bx, By, B_magnitude165166# Grid for field calculation167x_grid = np.linspace(-3, 3, 60)168y_grid = np.linspace(-3, 3, 60)169X, Y = np.meshgrid(x_grid, y_grid)170171Bx, By, B_mag = magnetic_field_dipole(X, Y, moment_strength=5.0)172173# Magnetic pressure174magnetic_pressure = B_mag**2 / (2 * mu_0 * 1e6) # Normalized175176# Compute plasma beta distribution (higher near magnetic null)177thermal_pressure_dist = 1.0 * np.exp(-0.3 * (X**2 + Y**2))178local_beta = thermal_pressure_dist / (magnetic_pressure + 1e-10)179180fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 6))181182# Magnetic field lines183cs1 = ax1.contourf(X, Y, magnetic_pressure, levels=25, cmap='plasma')184strm = ax1.streamplot(X, Y, Bx, By, color='white', linewidth=1.2,185density=1.5, arrowsize=1.2)186cbar1 = plt.colorbar(cs1, ax=ax1)187cbar1.set_label('Magnetic Pressure (normalized)', fontsize=11)188ax1.set_xlabel('$x$ (normalized)', fontsize=12)189ax1.set_ylabel('$y$ (normalized)', fontsize=12)190ax1.set_title('Magnetic Field Lines and Pressure', fontsize=13)191ax1.set_aspect('equal')192193# Plasma beta distribution194cs2 = ax2.contourf(X, Y, np.log10(local_beta + 1e-6), levels=25, cmap='RdYlBu_r')195ax2.streamplot(X, Y, Bx, By, color='black', linewidth=0.8,196density=1.2, arrowsize=1.0)197cbar2 = plt.colorbar(cs2, ax=ax2)198cbar2.set_label('$\\log_{10}(\\beta)$', fontsize=11)199ax2.set_xlabel('$x$ (normalized)', fontsize=12)200ax2.set_ylabel('$y$ (normalized)', fontsize=12)201ax2.set_title('Plasma Beta Distribution', fontsize=13)202ax2.set_aspect('equal')203204plt.tight_layout()205plt.savefig('mhd_magnetic_topology.pdf', dpi=150, bbox_inches='tight')206plt.close()207208# Store max beta for conclusion209computed_results['max_beta'] = np.max(local_beta)210\end{pycode}211212\begin{figure}[H]213\centering214\includegraphics[width=0.98\textwidth]{mhd_magnetic_topology.pdf}215\caption{Magnetic field topology for a dipole configuration showing field lines (streamlines) and magnetic pressure distribution (left panel). Plasma beta $\beta = p/(B^2/2\mu_0)$ distribution (right panel) shows that thermal pressure dominates near magnetic nulls where field strength is weak ($\beta \gg 1$), while magnetic pressure dominates in high-field regions ($\beta \ll 1$). This $\beta$ gradient drives pressure-driven instabilities and determines wave propagation characteristics. Peak local beta reaches $\beta_{\text{max}} = \py{f'{computed_results["max_beta"]:.2f}'}$ in low-field regions.}216\end{figure}217218\section{MHD Instabilities: Kink and Sausage Modes}219220Cylindrical plasma columns with axial current and azimuthal magnetic field are susceptible to kink instabilities (helical perturbations, $m=1$) and sausage instabilities (axisymmetric pinching, $m=0$). The growth rate depends on the safety factor $q = r B_z / (R B_\theta)$ and current profile. For a sharp-boundary cylindrical pinch:221\begin{equation}222\gamma_{\text{kink}} = k_z v_A \sqrt{1 - (k_z a)^2} \quad \text{for } k_z a < 1223\end{equation}224where $a$ is the plasma radius and $k_z$ is the axial wavenumber.225226\begin{pycode}227# Kink and sausage instability growth rates228def kink_growth_rate(k_axial, plasma_radius, alfven_velocity):229"""230Compute kink instability growth rate for cylindrical Z-pinch.231232Unstable when k*a < 1 (Kruskal-Shafranov criterion).233"""234ka = k_axial * plasma_radius235236# Growth rate (imaginary frequency)237if ka < 1.0:238growth_rate = k_axial * alfven_velocity * np.sqrt(1 - ka**2)239else:240growth_rate = 0.0 # Stable241242return growth_rate243244def sausage_growth_rate(k_axial, plasma_radius, alfven_velocity,245pinch_parameter=0.5):246"""247Compute sausage (m=0) instability growth rate.248249Pinch parameter beta_pinch determines stability boundary.250"""251ka = k_axial * plasma_radius252253# Simplified model: unstable for long wavelengths254if ka < pinch_parameter:255growth_rate = k_axial * alfven_velocity * np.sqrt(pinch_parameter**2 - ka**2)256else:257growth_rate = 0.0258259return growth_rate260261# Plasma parameters for Z-pinch262a_pinch = 0.05 # 5 cm radius263B_theta_pinch = 0.5 # Tesla (azimuthal field from current)264n_pinch = 5e19 # m^-3265rho_pinch = n_pinch * 2.5 * proton_mass266v_A_pinch = B_theta_pinch / np.sqrt(mu_0 * rho_pinch)267268k_z_range = np.linspace(0.1, 100, 300) # m^-1269270# Calculate growth rates271gamma_kink = np.array([kink_growth_rate(k, a_pinch, v_A_pinch) for k in k_z_range])272gamma_sausage = np.array([sausage_growth_rate(k, a_pinch, v_A_pinch, 0.6)273for k in k_z_range])274275# Growth time = 1/gamma276growth_time_kink = 1.0 / (gamma_kink + 1e-10)277growth_time_sausage = 1.0 / (gamma_sausage + 1e-10)278279# Find maximum growth rate280max_gamma_kink = np.max(gamma_kink)281k_max_kink = k_z_range[np.argmax(gamma_kink)]282computed_results['kink_growth_time'] = 1.0 / max_gamma_kink * 1e6 # microseconds283computed_results['kink_wavelength'] = 2*np.pi / k_max_kink * 100 # cm284285fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 6))286287# Growth rates288ax1.plot(k_z_range, gamma_kink / 1e6, 'r-', linewidth=2.5, label='Kink mode ($m=1$)')289ax1.plot(k_z_range, gamma_sausage / 1e6, 'b--', linewidth=2.5, label='Sausage mode ($m=0$)')290ax1.axvline(1.0/a_pinch, color='gray', linestyle=':', linewidth=1.5, label='$k_z = 1/a$')291ax1.set_xlabel('Axial wavenumber $k_z$ (m$^{-1}$)', fontsize=12)292ax1.set_ylabel('Growth rate $\\gamma$ (MHz)', fontsize=12)293ax1.set_title('MHD Instability Growth Rates', fontsize=13)294ax1.legend(fontsize=11)295ax1.grid(True, alpha=0.3)296ax1.set_xlim(0, 50)297298# Growth times (only for unstable modes)299gamma_kink_plot = np.where(gamma_kink > 1e-10, gamma_kink, np.nan)300gamma_sausage_plot = np.where(gamma_sausage > 1e-10, gamma_sausage, np.nan)301302ax2.plot(k_z_range, 1e6 / gamma_kink_plot, 'r-', linewidth=2.5, label='Kink mode')303ax2.plot(k_z_range, 1e6 / gamma_sausage_plot, 'b--', linewidth=2.5, label='Sausage mode')304ax2.set_xlabel('Axial wavenumber $k_z$ (m$^{-1}$)', fontsize=12)305ax2.set_ylabel('Growth time $1/\\gamma$ ($\\mu$s)', fontsize=12)306ax2.set_title('Instability Growth Timescales', fontsize=13)307ax2.legend(fontsize=11)308ax2.grid(True, alpha=0.3)309ax2.set_xlim(0, 50)310ax2.set_ylim(0, 100)311312plt.tight_layout()313plt.savefig('mhd_instability_growth.pdf', dpi=150, bbox_inches='tight')314plt.close()315\end{pycode}316317\begin{figure}[H]318\centering319\includegraphics[width=0.98\textwidth]{mhd_instability_growth.pdf}320\caption{Growth rates (left) and characteristic timescales (right) for kink ($m=1$, helical) and sausage ($m=0$, axisymmetric) MHD instabilities in a cylindrical Z-pinch plasma. Parameters: $a = 5$ cm, $B_\theta = 0.5$ T, $n = 5 \times 10^{19}$ m$^{-3}$, giving $v_A = \py{int(v_A_pinch/1e3)}$ km/s. Kink mode becomes stable when $k_z a > 1$ (Kruskal-Shafranov criterion). Maximum growth occurs at $\lambda = \py{f'{computed_results["kink_wavelength"]:.1f}'}$ cm with growth time $\tau = \py{f'{computed_results["kink_growth_time"]:.1f}'}$ $\mu$s, requiring active stabilization or wall proximity for confinement.}321\end{figure}322323\section{Magnetic Reconnection Dynamics}324325Magnetic reconnection converts magnetic energy to kinetic energy and heat by breaking and reconnecting magnetic field lines in regions where resistivity is non-zero. The Sweet-Parker model predicts reconnection rate $v_{\text{in}} / v_A \sim S^{-1/2}$ where $S = \mu_0 L v_A / \eta$ is the Lundquist number. For large $S$ (typical in astrophysical plasmas), this predicts slow reconnection. Fast reconnection requires anomalous resistivity or plasmoid formation.326327\begin{pycode}328# Sweet-Parker magnetic reconnection model329def sweet_parker_reconnection(magnetic_field, density, resistivity,330reconnection_length):331"""332Compute Sweet-Parker reconnection rate and timescale.333334Returns reconnection inflow velocity and Lundquist number.335"""336alfven_velocity = magnetic_field / np.sqrt(mu_0 * density)337338# Lundquist number339lundquist_number = mu_0 * reconnection_length * alfven_velocity / resistivity340341# Reconnection rate (normalized to Alfven speed)342reconnection_rate = 1.0 / np.sqrt(lundquist_number)343344# Inflow velocity345v_inflow = reconnection_rate * alfven_velocity346347# Reconnection time348reconnection_time = reconnection_length / v_inflow349350return lundquist_number, reconnection_rate, v_inflow, reconnection_time351352# Solar corona parameters353B_corona = 0.01 # 100 Gauss354n_corona = 1e15 # m^-3355rho_corona = n_corona * proton_mass356L_corona = 1e7 # 10,000 km (coronal loop size)357eta_corona = 1e-2 # Ohm·m (anomalous resistivity)358359S_corona, rate_corona, v_in_corona, t_recon_corona = \360sweet_parker_reconnection(B_corona, rho_corona, eta_corona, L_corona)361362computed_results['lundquist_number'] = S_corona363computed_results['reconnection_rate'] = rate_corona364computed_results['reconnection_time'] = t_recon_corona365366# Vary resistivity to explore reconnection regimes367eta_range = np.logspace(-4, 2, 100) # Ohm·m368S_array = np.zeros_like(eta_range)369rate_array = np.zeros_like(eta_range)370time_array = np.zeros_like(eta_range)371372for i, eta in enumerate(eta_range):373S, rate, v_in, t_r = sweet_parker_reconnection(B_corona, rho_corona,374eta, L_corona)375S_array[i] = S376rate_array[i] = rate377time_array[i] = t_r378379fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 6))380381# Reconnection rate vs Lundquist number382ax1.loglog(S_array, rate_array, 'b-', linewidth=2.5)383ax1.loglog(S_array, S_array**(-0.5), 'r--', linewidth=2, label='$S^{-1/2}$ scaling')384ax1.axvline(S_corona, color='green', linestyle=':', linewidth=2,385label=f'Solar corona ($S = {S_corona:.1e}$)')386ax1.set_xlabel('Lundquist number $S$', fontsize=12)387ax1.set_ylabel('Reconnection rate $v_{\\mathrm{in}}/v_A$', fontsize=12)388ax1.set_title('Sweet-Parker Reconnection Rate', fontsize=13)389ax1.legend(fontsize=10)390ax1.grid(True, alpha=0.3, which='both')391392# Reconnection timescale393ax2.loglog(eta_range, time_array, 'b-', linewidth=2.5)394ax2.axhline(100, color='gray', linestyle='--', linewidth=1.5, label='100 s')395ax2.axhline(1000, color='gray', linestyle=':', linewidth=1.5, label='1000 s')396ax2.axvline(eta_corona, color='green', linestyle=':', linewidth=2,397label=f'$\\eta = {eta_corona}$ $\\Omega$m')398ax2.set_xlabel('Resistivity $\\eta$ ($\\Omega$·m)', fontsize=12)399ax2.set_ylabel('Reconnection time (s)', fontsize=12)400ax2.set_title('Reconnection Timescale vs Resistivity', fontsize=13)401ax2.legend(fontsize=10)402ax2.grid(True, alpha=0.3, which='both')403404plt.tight_layout()405plt.savefig('mhd_magnetic_reconnection.pdf', dpi=150, bbox_inches='tight')406plt.close()407\end{pycode}408409\begin{figure}[H]410\centering411\includegraphics[width=0.98\textwidth]{mhd_magnetic_reconnection.pdf}412\caption{Sweet-Parker magnetic reconnection rate (left) scales as $v_{\text{in}}/v_A \sim S^{-1/2}$ where Lundquist number $S = \mu_0 L v_A / \eta$ quantifies the ratio of resistive diffusion time to Alfvén transit time. Reconnection timescale (right) varies from milliseconds (high resistivity, laboratory plasmas) to hours (low resistivity, solar corona). For solar corona parameters ($B = 100$ G, $n = 10^{15}$ m$^{-3}$, $L = 10^4$ km, $\eta = 10^{-2}$ $\Omega$m), we find $S = \py{f'{computed_results["lundquist_number"]:.1e}'}$ and reconnection time $t = \py{f'{computed_results["reconnection_time"]:.1f}'}$ s. Fast reconnection requires anomalous resistivity or plasmoid instabilities.}413\end{figure}414415\section{MHD Equilibrium: Force Balance}416417MHD equilibrium requires force balance $\nabla p = \mathbf{j} \times \mathbf{B}$ where the pressure gradient is balanced by the Lorentz force. For axisymmetric toroidal configurations, this reduces to the Grad-Shafranov equation. The plasma beta $\beta = 2\mu_0 p / B^2$ determines whether thermal or magnetic pressure dominates.418419\begin{pycode}420# Plasma equilibrium: pressure balance profiles421def plasma_pressure_profile(r, r_minor, pressure_peak, alpha=2.0):422"""Parabolic pressure profile p(r) = p_0 (1 - (r/a)^alpha)."""423profile = pressure_peak * (1 - (r/r_minor)**alpha)424return np.maximum(profile, 0)425426def magnetic_field_profile(r, r_minor, B_axis, q_profile_param=1.5):427"""428Magnetic field profile assuming circular cross-section.429B increases slightly off-axis due to toroidal compression.430"""431B = B_axis * (1 + 0.1 * (r/r_minor)**2)432return B433434# Tokamak-like parameters435r_radial = np.linspace(0, 0.5, 200) # meters (0 to minor radius)436a_minor = 0.5 # m437B_axis_tokamak = 5.0 # Tesla on axis438p_0 = 5e5 # Pascal (5 bar peak pressure)439440# Profiles441pressure_profile = plasma_pressure_profile(r_radial, a_minor, p_0, alpha=2.5)442B_profile = magnetic_field_profile(r_radial, a_minor, B_axis_tokamak)443magnetic_pressure_profile = B_profile**2 / (2 * mu_0)444beta_profile = 2 * mu_0 * pressure_profile / B_profile**2445446# Safety factor q(r) profile (increases toward edge)447q_profile = 1.0 + 2.5 * (r_radial / a_minor)**2448449# Store central beta450computed_results['central_beta'] = beta_profile[0] * 100 # percent451452fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(14, 12))453454# Pressure profiles455ax1.plot(r_radial, pressure_profile/1e5, 'r-', linewidth=2.5, label='Thermal pressure')456ax1.plot(r_radial, magnetic_pressure_profile/1e5, 'b-', linewidth=2.5,457label='Magnetic pressure')458ax1.set_xlabel('Radius $r$ (m)', fontsize=12)459ax1.set_ylabel('Pressure (bar)', fontsize=12)460ax1.set_title('Pressure Balance', fontsize=13)461ax1.legend(fontsize=11)462ax1.grid(True, alpha=0.3)463464# Beta profile465ax2.plot(r_radial, beta_profile * 100, 'g-', linewidth=2.5)466ax2.axhline(1.0, color='gray', linestyle='--', linewidth=1.5, label='$\\beta = 1\\%$')467ax2.set_xlabel('Radius $r$ (m)', fontsize=12)468ax2.set_ylabel('Plasma beta $\\beta$ (\\%)', fontsize=12)469ax2.set_title('Beta Profile', fontsize=13)470ax2.legend(fontsize=11)471ax2.grid(True, alpha=0.3)472473# Magnetic field474ax3.plot(r_radial, B_profile, 'b-', linewidth=2.5)475ax3.set_xlabel('Radius $r$ (m)', fontsize=12)476ax3.set_ylabel('Magnetic field $B$ (T)', fontsize=12)477ax3.set_title('Magnetic Field Strength', fontsize=13)478ax3.grid(True, alpha=0.3)479480# Safety factor q(r)481ax4.plot(r_radial, q_profile, 'm-', linewidth=2.5)482ax4.axhline(1.0, color='gray', linestyle='--', linewidth=1.5, label='$q = 1$')483ax4.axhline(2.0, color='gray', linestyle=':', linewidth=1.5, label='$q = 2$')484ax4.set_xlabel('Radius $r$ (m)', fontsize=12)485ax4.set_ylabel('Safety factor $q$', fontsize=12)486ax4.set_title('Safety Factor Profile', fontsize=13)487ax4.legend(fontsize=11)488ax4.grid(True, alpha=0.3)489490plt.tight_layout()491plt.savefig('mhd_equilibrium_profiles.pdf', dpi=150, bbox_inches='tight')492plt.close()493\end{pycode}494495\begin{figure}[H]496\centering497\includegraphics[width=0.98\textwidth]{mhd_equilibrium_profiles.pdf}498\caption{MHD equilibrium profiles for a tokamak-like configuration showing thermal vs magnetic pressure balance (top left), plasma beta $\beta = 2\mu_0 p/B^2$ (top right), toroidal magnetic field strength (bottom left), and safety factor $q(r)$ (bottom right). Parameters: $a = 0.5$ m, $B_0 = 5$ T, peak pressure $p_0 = 5$ bar. Central beta is $\beta_0 = \py{f'{computed_results["central_beta"]:.2f}'}$\%. Pressure gradient drives current, which produces poloidal field and determines $q$ profile. Rational surfaces at $q = 1, 2, 3$ are susceptible to tearing modes. Higher $q$ at edge provides kink stability (Kruskal-Shafranov criterion requires $q > 1$ everywhere).}499\end{figure}500501\section{Results Summary}502503\begin{pycode}504results = [505['Alfvén velocity $v_A$', f"{computed_results['alfven_velocity']:.0f} km/s"],506['Sound speed $c_s$', f"{computed_results['sound_speed']:.0f} km/s"],507['Plasma beta $\\beta$', f"{computed_results['plasma_beta']:.3f}"],508['Kink growth time', f"{computed_results['kink_growth_time']:.1f} $\\mu$s"],509['Kink wavelength', f"{computed_results['kink_wavelength']:.1f} cm"],510['Lundquist number $S$', f"{computed_results['lundquist_number']:.2e}"],511['Reconnection rate', f"{computed_results['reconnection_rate']:.2e}"],512['Reconnection time', f"{computed_results['reconnection_time']:.1f} s"],513['Central beta (tokamak)', f"{computed_results['central_beta']:.2f}\\%"],514]515516print(r'\begin{table}[H]')517print(r'\centering')518print(r'\caption{Computed MHD Parameters}')519print(r'\begin{tabular}{@{}lc@{}}')520print(r'\toprule')521print(r'Parameter & Value \\')522print(r'\midrule')523for row in results:524print(f"{row[0]} & {row[1]} \\\\")525print(r'\bottomrule')526print(r'\end{tabular}')527print(r'\end{table}')528\end{pycode}529530\section{Conclusions}531532This computational study demonstrates fundamental magnetohydrodynamic processes governing plasma confinement, wave propagation, and magnetic energy release. For fusion-relevant parameters ($B = 2$ T, $n = 10^{20}$ m$^{-3}$, $T = 1$ keV), we computed Alfvén velocity $v_A = \py{int(computed_results['alfven_velocity'])}$ km/s and sound speed $c_s = \py{int(computed_results['sound_speed'])}$ km/s, yielding plasma beta $\beta = \py{f"{computed_results['plasma_beta']:.3f}"}$ where magnetic pressure dominates. The MHD dispersion relation reveals three wave modes: fast magnetosonic waves propagating at velocities up to 1200 km/s perpendicular to the field, shear Alfvén waves at 1100 km/s along field lines, and slow magnetosonic waves below 400 km/s.533534Stability analysis for a cylindrical Z-pinch ($a = 5$ cm, $B_\theta = 0.5$ T) shows kink instability growth time $\tau_{\text{kink}} = \py{f"{computed_results['kink_growth_time']:.1f}"}$ $\mu$s at wavelength $\lambda = \py{f"{computed_results['kink_wavelength']:.1f}"}$ cm, requiring rapid feedback control or conducting wall stabilization. The Kruskal-Shafranov criterion $q > 1$ sets a fundamental limit on sustainable current. For tokamak equilibria with $q(0) \sim 1$ and $q(a) \sim 3.5$, rational surfaces at $q = 2, 3$ are susceptible to tearing modes that degrade confinement.535536Magnetic reconnection in solar corona conditions ($B = 100$ G, $n = 10^{15}$ m$^{-3}$, $L = 10^4$ km) yields Lundquist number $S = \py{f"{computed_results['lundquist_number']:.1e}"}$ and Sweet-Parker reconnection time $t = \py{f"{computed_results['reconnection_time']:.1f}"}$ s. This reconnection rate $v_{\text{in}}/v_A = \py{f"{computed_results['reconnection_rate']:.2e}"}$ is too slow to explain observed solar flare timescales, indicating the necessity of fast reconnection mechanisms involving plasmoid instabilities or anomalous resistivity. Understanding these MHD processes is essential for magnetic fusion energy, space weather prediction, and astrophysical plasma dynamics.537538\end{document}539540541