BEACH (BEM + Accumulated CHarge): BEM surface-charging + test-particle prototype (insulator mode) with hybrid E-field and Boris pusher.
Project description
BEACH(BEM + Accumulated CHarge)
BEACH は、BEM(境界要素法)ベースの表面帯電 + テスト粒子追跡シミュレータです。
計算本体は Fortran(fpm 管理)、Python は後処理・可視化を担当します。
v0.x の主対象は insulator accumulation(絶縁体への電荷蓄積) です。
推奨ワークフロー
通常利用では、pip install beach-bem で導入して beach を実行する運用を推奨します。
pip install -e や make は、開発に参加する場合の手順として扱います。
1. 利用者向けセットアップ
1.1 前提ツール
make --version
gfortran --version
fpm --version
python --version
1.2 PyPI から一括インストール(推奨)
python -m pip install -U pip setuptools wheel
python -m pip install beach-bem
開発版を直接試したい場合は、Git URL からも導入できます。
python -m pip install "git+https://github.com/Nkzono99/BEACH.git"
このインストールでは、ビルド時に make install が実行され、Python 側と Fortran 実行バイナリ(beach)が同時に導入されます。
ユーザーインストール時は ~/.local/bin に入るため、必要なら PATH を追加してください。
pip 経由のビルドでは既定で INSTALL_PROFILE=auto を使います。必要なら INSTALL_PROFILE=camphor などを環境変数で上書きできます。
auto 失敗時は既定で generic へフォールバックします。無効化したい場合は BEACH_PIP_FALLBACK_GENERIC=0 を指定してください。
export PATH="$HOME/.local/bin:$PATH"
2. 実行
2.1 推奨: beach コマンド
beach examples/beach.toml
引数なしの場合は、カレントディレクトリの beach.toml を自動読込します。
2.2 出力確認
ls outputs/latest
beachx inspect outputs/latest
主な出力:
summary.txtcharges.csvmesh_triangles.csvcharge_history.csv(history_stride > 0のとき)
2.3 可視化
beachx inspect outputs/latest \
--save-bar outputs/latest/charges_bar.png \
--save-mesh outputs/latest/charges_mesh.png
beachx animate outputs/latest \
--quantity charge \
--save-gif outputs/latest/charge_history.gif \
--total-frames 200
beachx slices outputs/latest \
--grid-n 200 \
--vmin -20 --vmax 20 \
--save outputs/latest/potential_slices.png
beachx coulomb outputs/latest \
--component z \
--save outputs/latest/coulomb_force_z.png
beachx mobility outputs/latest \
--density-kg-m3 2500 \
--mu-static 0.4 \
--save-csv outputs/latest/mobility_summary.csv
beachx coulomb は、beach.toml の mesh.templates が見つかれば object の kind と順序をそこから読み取り、既定では全 object を target 軸に並べて行列を描きます。特定 kind だけに絞りたいときは --target-kinds sphere のように指定できます。
beachx mobility は、既定で plane を support とみなし、それ以外の object について合力・合トルクと lift_ratio / slide_ratio / roll_ratio を CSV に書き出します。質量由来の指標は --density-kg-m3 と beach.toml の幾何情報が必要です。
旧 alias の beach-inspect / beach-animate-history / beach-plot-coulomb-force-matrix /
beach-plot-potential-slices なども当面は使えますが、今後は beachx ... を推奨します。
Python から mesh source ごとの面積重み付き箱ひげ図を作る例:
from beach import Beach
run = Beach("outputs/latest")
# 電荷 [C] の面積重み付き箱ひげ図(mesh sourceごと)
fig_q, ax_q = run.plot_mesh_source_boxplot(
quantity="charge",
step=-1, # 最新 history。None なら charges.csv を使う
showfliers=False,
)
fig_q.savefig("outputs/latest/charge_box_by_source.png", dpi=150)
# ポテンシャル [V] の面積重み付き箱ひげ図(mesh sourceごと)
fig_phi, ax_phi = run.plot_mesh_source_boxplot(
quantity="potential",
softening=0.0,
self_term="area_equivalent",
)
fig_phi.savefig("outputs/latest/potential_box_by_source.png", dpi=150)
# object ごとの Coulomb 力行列(beach.toml があれば plane/sphere などを自動ラベル化)
fig_f, ax_f = run.plot_coulomb_force_matrix(
component="z",
)
fig_f.savefig("outputs/latest/coulomb_force_z.png", dpi=150)
# 移動可能性の簡易評価(既定では plane 以外を対象)
mobility = run.analyze_coulomb_mobility(
density_kg_m3=2500.0,
mu_static=0.4,
)
for record in mobility.records:
print(record.label, record.lift_ratio, record.slide_ratio, record.roll_ratio)
3. 運用でよく使うコマンド
3.1 負荷見積もり
beachx workload examples/beach.toml --threads 8
3.2 再開実行
[output]
dir = "outputs/latest"
resume = true
同じ output.dir で beach を再実行すると続きから計算します。
4. 開発に携わる場合
ローカル開発では、Python と Fortran を分けて運用するのが便利です。
4.1 Python 側(編集可能インストール)
python -m pip install -U pip setuptools wheel
python -m pip install -e . --no-build-isolation
4.2 Fortran 実行系(make)
make
make のデフォルトターゲットは install で、BUILD_PROFILE=auto(ホスト自動判定)を使います。
必要に応じて明示指定できます。
make install-generic
make install-camphor
4.3 fpm 直接実行(開発向け)
fpm run --profile release --flag "-fopenmp" -- examples/beach.toml
MPI + OpenMP(USE_MPI 有効化):
FPM_FC=mpiifort \
fpm run --profile release --flag "-fpp -DUSE_MPI -qopenmp" \
--runner "mpirun -n 4" -- examples/beach.toml
4.4 テスト
pytest -q
fpm test
4.5 Fortran 整形
Fortran の *.f90 / *.F90 は fprettify -i 2 を標準 formatter とします。
生成バックアップの *.i90 は整形対象外です。
ローカルで hook を有効にするには:
python -m pip install pre-commit
make install-hooks
手動整形と CI 相当の確認:
make fmt-fortran
make fmt-check-fortran
GitHub Actions でも同じ pre-commit 設定を --all-files で実行し、整形漏れを検知します。
5. プロジェクト構成
src/,app/: Fortran 本体tests/fortran/: Fortran テストbeach/: Python 後処理ライブラリtests/python/: Python テストexamples/: 設定例・補助スクリプトdocs/: 運用ドキュメントSPEC.md: 現行 Fortran 実装仕様
6. ドキュメント案内
- Fortran 実行フロー:
docs/fortran_workflow.md beach.toml仕様:docs/fortran_parameter_file.md- Coulomb FMM コア仕様:
docs/fortran_fmm_core.md - 実装仕様(source of truth):
SPEC.md - 設定サンプル:
examples/beach.toml
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file beach_bem-0.7.1.tar.gz.
File metadata
- Download URL: beach_bem-0.7.1.tar.gz
- Upload date:
- Size: 214.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e328292d24ca0bf61af3322168249e72676d12236a24de904d1ab9d9020c29f0
|
|
| MD5 |
dffb2bd0638f413bab5a57b4674ff755
|
|
| BLAKE2b-256 |
0196f049c0641cd233ba1747fc321dd578b90d6c660104daf49fa1503745c8fb
|
Provenance
The following attestation bundles were made for beach_bem-0.7.1.tar.gz:
Publisher:
publish-pypi.yml on Nkzono99/BEACH
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
beach_bem-0.7.1.tar.gz -
Subject digest:
e328292d24ca0bf61af3322168249e72676d12236a24de904d1ab9d9020c29f0 - Sigstore transparency entry: 1147956030
- Sigstore integration time:
-
Permalink:
Nkzono99/BEACH@981e605a6bca0d0b0b49d374b580debdfcf5545e -
Branch / Tag:
refs/tags/v0.7.1 - Owner: https://github.com/Nkzono99
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@981e605a6bca0d0b0b49d374b580debdfcf5545e -
Trigger Event:
release
-
Statement type: