Skip to content

nombac/MRI_basics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MRI_basics

English Version

Particle-motion simulations in rotating frames related to the Magnetorotational Instability (MRI).

Overview

This repository provides Python code to numerically simulate and visualize particle motion in a rotating frame. It is intended as an educational tool to explore the dynamics of the MRI, which is central to accretion-disk physics.

File List

Python implementations

  • MRI_epicyclic.py - Full simulation of MRI epicyclic motion
  • MRI_toy.py - Simplified two-mass spring model
  • runge1.py - Python port of runge1.pro

IDL originals

  • runge1.pro - IDL implementation of the MRI motion
  • runge.pro - Simplified two-body IDL implementation

MRI_epicyclic.py

Overview

Simulator that solves the full equations of motion for single-particle MRI epicyclic motion.

Features

  • Exact equations of motion in a rotating frame
  • Three visualizations (LAB FRAME, ROT FRAME, 3D effective potential)
  • Multiple high-accuracy integrators:
    • Runge-Kutta-Gill (4th order)
    • DOP853 (8th-order Dormand-Prince)
    • RK45, Radau, LSODA
  • Automatic instability detection (monitoring distance from the ROT FRAME origin)

Equations of motion

dx/dt = u
dy/dt = v
du/dt = 2Ωv + (2Ω²q - s)x
dv/dt = -2Ωu - sy

Physical parameters

  • Ω = 1.0: Angular velocity
  • q = 1.5: Shear parameter (Keplerian disk)
  • s = 1.0: Spring constant (magnetic restoring force)
  • distance_threshold = 3.0: Instability threshold

Example output

  • Filename: MRI_epicyclic_omega1.0_q1.5_s1.0.gif

MRI_toy.py

Overview

Simulator that interprets the simplified equations as a two-body spring problem and visualizes it similarly to runge.pro.

Features

  • Solves the same differential equations in relative coordinates
  • Splits the solution into two masses (red and blue) for display
  • Visualizes two-body motion in the center-of-mass frame
  • Monitors separation for stability checks

Simplified equations of motion

dx/dt = u
dy/dt = v
du/dt = 2v + (3 - s)x  (coefficient 3 is a simplified tidal term)
dv/dt = -2u - sy

Coordinate transform

  • From relative coordinates (x, y) to particle positions:
    • Mass 1 (red): (x/2, y/2)
    • Mass 2 (blue): (-x/2, -y/2)

Physical parameters

  • Ω = 1.0: Angular velocity (normalized)
  • q = 1.5: Shear parameter (simplified as coefficient 3)
  • s = 6.0: Spring constant
  • distance_threshold = 3.0: Separation threshold

Example output

  • Filename: MRI_toy_omega1.0_q1.5_s6.0.gif

Usage

Required libraries

pip install numpy matplotlib scipy

Run

# Full MRI epicyclic motion
python MRI_epicyclic.py

# Simplified two-body spring model
python MRI_toy.py

Interactive options

  • Toggle animation creation
  • Toggle GIF saving
  • Output directory: anim/

Visualization Notes

LAB FRAME (inertial frame)

  • Particle orbit as seen from the lab frame
  • Gray circle: reference orbit (radius r₀)
  • Particle trajectory and current position

ROT FRAME (rotating frame)

  • Particle motion in the rotating frame
  • Background: effective potential contours (jet colormap)
  • Origin: rotation center (blue point)
  • White/pale lines: particle trajectory

3D Effective Potential (MRI_epicyclic only)

  • Bird's-eye view of the effective potential surface
  • Particle trajectory on the surface (white line)
  • Current position (red point)

Parameter Tuning Guide

Stability conditions

  • s < 2Ω²q (MRI_epicyclic) or s < 3 (MRI_toy): unstable (MRI present)
  • s = 2Ω²q or s = 3: critical
  • s > 2Ω²q or s > 3: stable

Typical parameter values

  • q = 1.5: Keplerian disk (angular velocity ∝ r^(-3/2))
  • q = 2.0: Near solid-body rotation
  • s = 0: Pure tidal instability
  • s > 0: Magnetic stabilization

Physical Background

Magnetorotational Instability (MRI)

  • Arises in differentially rotating disks with weak magnetic fields
  • Primary driver of angular momentum transport
  • Contributes to turbulence in accretion disks

Epicyclic motion

  • Oscillatory motion from small deviations off a circular orbit
  • Fundamental mode in rotating frames
  • Basis for linear MRI analysis

Notes

  • Long integrations can accumulate numerical error
  • Simulations stop automatically under unstable parameters
  • Animation generation can take time

License

MIT License

Changelog

  • 2024: Ported and extended from IDL to Python
  • Added stability monitoring
  • Implemented 3D visualization

============================================================

日本語版

磁気回転不安定性(Magnetorotational Instability: MRI)に関連する回転座標系での粒子運動シミュレーション

概要

このリポジトリは、回転座標系における粒子運動を数値シミュレーションし、可視化するPythonコードを提供します。特に、降着円盤などで重要な役割を果たす磁気回転不安定性(MRI)のダイナミクスを理解するための教育的なツールとして開発されました。

ファイル一覧

Python実装

  • MRI_epicyclic.py - MRIエピサイクリック運動の完全なシミュレーション
  • MRI_toy.py - 簡略化された2体バネ系モデル
  • runge1.py - runge1.proのPython移植版

IDLオリジナル

  • runge1.pro - MRI運動のIDL実装
  • runge.pro - 簡略化された2体系のIDL実装

MRI_epicyclic.py

概要

単一粒子のMRIエピサイクリック運動を完全な運動方程式で解くシミュレーター

特徴

  • 回転座標系での厳密な運動方程式
  • 3種類の可視化(LAB FRAME、ROT FRAME、3D有効ポテンシャル)
  • 複数の高精度数値積分法に対応
    • ルンゲ・クッタ・ジル法(4次)
    • DOP853(8次Dormand-Prince法)
    • RK45、Radau、LSODA
  • 不安定性の自動検出(ROT FRAME原点からの距離監視)

運動方程式

dx/dt = u
dy/dt = v
du/dt = 2Ωv + (2Ω²q - s)x
dv/dt = -2Ωu - sy

物理パラメータ

  • Ω = 1.0: 回転角速度
  • q = 1.5: 質量比パラメータ(ケプラー円盤に対応)
  • s = 1.0: バネ係数(磁場による復元力)
  • distance_threshold = 3.0: 安定性判定の閾値

出力例

  • ファイル名: MRI_epicyclic_omega1.0_q1.5_s1.0.gif

MRI_toy.py

概要

簡略化された運動方程式を2体問題として解釈し、runge.proと同様の可視化を行うシミュレーター

特徴

  • 同じ微分方程式を相対座標として解く
  • 解を2つの質点(赤と青)に分解して表示
  • 質量中心座標系での2体運動を可視化
  • 2体間距離の監視による安定性チェック

運動方程式(簡略化版)

dx/dt = u
dy/dt = v
du/dt = 2v + (3 - s)x  (係数3は潮汐力の簡略化)
dv/dt = -2u - sy

座標変換

  • 相対座標 (x, y) から各質点位置へ:
    • 質点1(赤): (x/2, y/2)
    • 質点2(青): (-x/2, -y/2)

物理パラメータ

  • Ω = 1.0: 回転角速度(正規化済み)
  • q = 1.5: 質量比パラメータ(係数3として簡略化)
  • s = 6.0: バネ係数
  • distance_threshold = 3.0: 2体間距離の閾値

出力例

  • ファイル名: MRI_toy_omega1.0_q1.5_s6.0.gif

使用方法

必要なライブラリ

pip install numpy matplotlib scipy

実行方法

# MRIエピサイクリック運動(完全版)
python MRI_epicyclic.py

# 2体バネ系モデル(簡略版)
python MRI_toy.py

対話的オプション

  • アニメーション作成の選択
  • GIFファイル保存の選択
  • 保存先: anim/ ディレクトリ

可視化の説明

LAB FRAME(慣性系)

  • 実験室系から見た粒子の軌道
  • 灰色の円: 基準軌道(半径r₀)
  • 粒子の軌跡と現在位置

ROT FRAME(回転座標系)

  • 回転座標系での粒子運動
  • 背景: 有効ポテンシャルの等高線(jetカラーマップ)
  • 原点: 回転中心(青点)
  • 白/薄色の線: 粒子の軌跡

3D Effective Potential(MRI_epicyclicのみ)

  • 有効ポテンシャル曲面の鳥瞰図
  • ポテンシャル上での粒子軌跡(白線)
  • 現在位置(赤点)

パラメータ調整ガイド

安定性の条件

  • s < 2Ω²q (MRI_epicyclic) または s < 3 (MRI_toy): 不安定(MRI発生)
  • s = 2Ω²q または s = 3: 臨界状態
  • s > 2Ω²q または s > 3: 安定

典型的なパラメータ値

  • q = 1.5: ケプラー円盤(r^(-3/2)の角速度分布)
  • q = 2.0: 剛体回転に近い状態
  • s = 0: 純粋な潮汐不安定性
  • s > 0: 磁場による安定化効果

物理的背景

磁気回転不安定性(MRI)

  • 弱い磁場を持つ差動回転円盤で発生
  • 角運動量輸送の主要メカニズム
  • 降着円盤の乱流生成に寄与

エピサイクリック運動

  • 円軌道からのずれに対する振動運動
  • 回転座標系での基本的な運動モード
  • MRIの線形解析の基礎

注意事項

  • 長時間積分では数値誤差が蓄積する可能性があります
  • 不安定なパラメータでは自動的に計算が停止します
  • アニメーション生成には時間がかかる場合があります

ライセンス

MIT License

更新履歴

  • 2024年: IDLからPythonへの移植と機能拡張
  • 安定性監視機能の追加
  • 3D可視化の実装

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages