Particle-motion simulations in rotating frames related to the Magnetorotational Instability (MRI).
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.
MRI_epicyclic.py- Full simulation of MRI epicyclic motionMRI_toy.py- Simplified two-mass spring modelrunge1.py- Python port of runge1.pro
runge1.pro- IDL implementation of the MRI motionrunge.pro- Simplified two-body IDL implementation
Simulator that solves the full equations of motion for single-particle MRI epicyclic motion.
- 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)
dx/dt = u
dy/dt = v
du/dt = 2Ωv + (2Ω²q - s)x
dv/dt = -2Ωu - sy
Ω = 1.0: Angular velocityq = 1.5: Shear parameter (Keplerian disk)s = 1.0: Spring constant (magnetic restoring force)distance_threshold = 3.0: Instability threshold
- Filename:
MRI_epicyclic_omega1.0_q1.5_s1.0.gif
Simulator that interprets the simplified equations as a two-body spring problem and visualizes it similarly to runge.pro.
- 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
dx/dt = u
dy/dt = v
du/dt = 2v + (3 - s)x (coefficient 3 is a simplified tidal term)
dv/dt = -2u - sy
- From relative coordinates (x, y) to particle positions:
- Mass 1 (red):
(x/2, y/2) - Mass 2 (blue):
(-x/2, -y/2)
- Mass 1 (red):
Ω = 1.0: Angular velocity (normalized)q = 1.5: Shear parameter (simplified as coefficient 3)s = 6.0: Spring constantdistance_threshold = 3.0: Separation threshold
- Filename:
MRI_toy_omega1.0_q1.5_s6.0.gif
pip install numpy matplotlib scipy# Full MRI epicyclic motion
python MRI_epicyclic.py
# Simplified two-body spring model
python MRI_toy.py- Toggle animation creation
- Toggle GIF saving
- Output directory:
anim/
- Particle orbit as seen from the lab frame
- Gray circle: reference orbit (radius r₀)
- Particle trajectory and current position
- Particle motion in the rotating frame
- Background: effective potential contours (jet colormap)
- Origin: rotation center (blue point)
- White/pale lines: particle trajectory
- Bird's-eye view of the effective potential surface
- Particle trajectory on the surface (white line)
- Current position (red point)
s < 2Ω²q(MRI_epicyclic) ors < 3(MRI_toy): unstable (MRI present)s = 2Ω²qors = 3: criticals > 2Ω²qors > 3: stable
q = 1.5: Keplerian disk (angular velocity ∝ r^(-3/2))q = 2.0: Near solid-body rotations = 0: Pure tidal instabilitys > 0: Magnetic stabilization
- Arises in differentially rotating disks with weak magnetic fields
- Primary driver of angular momentum transport
- Contributes to turbulence in accretion disks
- Oscillatory motion from small deviations off a circular orbit
- Fundamental mode in rotating frames
- Basis for linear MRI analysis
- Long integrations can accumulate numerical error
- Simulations stop automatically under unstable parameters
- Animation generation can take time
MIT License
- 2024: Ported and extended from IDL to Python
- Added stability monitoring
- Implemented 3D visualization
============================================================
磁気回転不安定性(Magnetorotational Instability: MRI)に関連する回転座標系での粒子運動シミュレーション
このリポジトリは、回転座標系における粒子運動を数値シミュレーションし、可視化するPythonコードを提供します。特に、降着円盤などで重要な役割を果たす磁気回転不安定性(MRI)のダイナミクスを理解するための教育的なツールとして開発されました。
MRI_epicyclic.py- MRIエピサイクリック運動の完全なシミュレーションMRI_toy.py- 簡略化された2体バネ系モデルrunge1.py- runge1.proのPython移植版
runge1.pro- MRI運動のIDL実装runge.pro- 簡略化された2体系のIDL実装
単一粒子の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
簡略化された運動方程式を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(赤):
Ω = 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/ディレクトリ
- 実験室系から見た粒子の軌道
- 灰色の円: 基準軌道(半径r₀)
- 粒子の軌跡と現在位置
- 回転座標系での粒子運動
- 背景: 有効ポテンシャルの等高線(jetカラーマップ)
- 原点: 回転中心(青点)
- 白/薄色の線: 粒子の軌跡
- 有効ポテンシャル曲面の鳥瞰図
- ポテンシャル上での粒子軌跡(白線)
- 現在位置(赤点)
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の線形解析の基礎
- 長時間積分では数値誤差が蓄積する可能性があります
- 不安定なパラメータでは自動的に計算が停止します
- アニメーション生成には時間がかかる場合があります
MIT License
- 2024年: IDLからPythonへの移植と機能拡張
- 安定性監視機能の追加
- 3D可視化の実装