1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

pyTDGLを動かすための環境構築メモ:Python 3.12で動かない問題の解消方法

Last updated at Posted at 2025-11-15

はじめに

Time-Dependent Ginzburg–Landau (TDGL) 方程式を数値的に扱う必要があり、Python 実装である pyTDGL を利用してみました。
ただし、公式の Quickstart Notebook が最後に更新されたのは 2024年4月 で、現在(2025年)とは Python バージョン環境が大きく異なります。

実際に触ってみると、

  • Python のバージョン依存が強い
  • pip install がそのままでは通らない
  • Google Colab では Python のダウングレードが困難

といった環境構築の“つまずきポイント”がいくつかありました。

この記事では、ローカル環境Google Colab の両方で、
実際に pyTDGL を動かすまでに必要だった手順と注意点を紹介します。

環境構築

pyTDGL のインストールでハマるポイント

公式のインストールガイド では Python 3.12 もサポート対象に見えますが、
pip でインストールできるパッケージ版(PyPI 配布版)は 3.12 非対応 のようです。

実際に conda で Python 3.12 の環境を作り、そのまま pip install tdgl を実行すると、
次のようなエラーになります。

ERROR: Ignored the following versions that require a different python version:
0.0.1 Requires-Python >=3.8,<3.11
0.1.0 Requires-Python >=3.8,<3.11
0.1.1 Requires-Python >=3.8,<3.11
0.2.1 Requires-Python >=3.8,<3.11
0.3.0 Requires-Python >=3.8,<3.12
0.3.1 Requires-Python >=3.8,<3.12
0.4.0 Requires-Python >=3.8,<3.12
0.5.0 Requires-Python >=3.8,<3.12
0.5.1 Requires-Python >=3.8,<3.12
0.6.0 Requires-Python >=3.8,<3.12
0.6.1 Requires-Python >=3.8,<3.12
0.7.0 Requires-Python >=3.8,<3.12
0.7.1 Requires-Python >=3.8,<3.12
0.8.0 Requires-Python >=3.8,<3.12
0.8.1 Requires-Python >=3.8,<3.12
0.8.2 Requires-Python >=3.8,<3.12
0.8.3 Requires-Python >=3.8,<3.12

ERROR: Could not find a version that satisfies the requirement tdgl
ERROR: No matching distribution found for tdgl

ローカル環境でのセットアップ例

公式の Google Colab 用 Quickstart を確認すると、ページ最下部の環境情報から Python 3.10 系 が使用されていることが分かります。

つまり、

  • 開発チームが実際に 3.10 上で Notebook を検証している
  • 公式サンプルが動作する “既知の安定環境” が 3.10
  • pip 版 pyTDGL も 3.8〜3.11 に対応している

という理由より、ローカルでも Python 3.10 を選ぶのが最も安全 だと思います。

実際に 筆者のローカル環境(macOS Apple Silicon)では、
conda を使って 3.10 の環境を作るとそのまま動作しました。

conda create -n tdgl python=3.10
conda activate tdgl

pip install tdgl
pip install jupyterlab

Google Colab での注意点

Google Colab は 2025年11月現在 Python 3.12 系がデフォルトで、
この Python バージョンを任意の 3.10 にダウングレードする方法も調べて試しましたが、Colab では現実的には非常に難しいと思います(技術的に完全に不可能というわけではないと思いますが)。

そのため、

  • Colab の標準環境(Python 3.12)では pip install tdgl が通らない
    → pip 版 pyTDGL が Python 3.12 非対応のため

という制約があります。

ただし、公式の Quickstart でも使われているように、
GitHub から直接インストールする方法であれば問題なく動作しました。

# Automatically install tdgl from GitHub only if running in Google Colab
if "google.colab" in str(get_ipython()):
    %pip install --quiet git+https://github.com/loganbvh/py-tdgl.git
    !apt install ffmpeg

実際に Quickstart を最後まで実行し、正常動作を確認しています。

参考として、実際に動かした Colab ノートブックはこちらです:

※ 動画生成を ON にすると 20〜30 分かかります。
軽く試すだけなら MAKE_ANIMATIONS = False を推奨します。

pyTDGL の簡単な紹介

pyTDGL は、超伝導薄膜の Time-Dependent Ginzburg–Landau (TDGL) 方程式を
2 次元で数値的に解くための Python パッケージです。

扱える主な物理量は次の通りです:

  • 超伝導秩序変数 $\psi = |\psi|e^{i\theta}$
  • 電位 $\mu(r,t)$
  • シート電流密度 $K_s + K_n$
  • ボルテックスの生成・移動・消滅
  • フラックソイドの計算

デバイス形状はポリゴンで柔軟に定義でき、穴あき構造などの複雑な形状も扱えます。

また、薄膜近似に基づく 2 次元モデルを
有限体積法(finite volume method)で非構造メッシュ上に離散化して解く仕組みが採用されています。

詳しい数理背景については、公式ドキュメントをご参照ください:

まとめ

  • PyPI 版 pyTDGL は Python 3.12 に非対応(3.8〜3.11 のみ対応)
  • 公式 Quickstart Notebook が使用している Python 3.10 が最も安定
  • ローカル環境では conda で Python 3.10 を作成するのが確実
  • Google Colab では Python のダウングレードが現実的に困難
    → pip install は不可(3.12 非対応)
    GitHub からの直接インストールで動作を確認
  • 公式 Quickstart(最終更新 2024 年)と同じコードが、2025 年時点でも問題なく実行可能

環境構築は何かと手間がかかりますが、この記事がこれから pyTDGL を触る方の少しでも助けになれば幸いです。

参考文献

pyTDGL is described in detail in the following paper:

pyTDGL: Time-dependent Ginzburg-Landau in Python, Computer Physics Communications 291, 108799 (2023), DOI: 10.1016/j.cpc.2023.108799.

The accepted version of the paper can also be found on arXiv: arXiv:2302.03812.

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?