N体問題パッケージ

基本的な計算の流れは以下になります。serial プログラムを参考に利用してください。
ちなみに、加速度算出のための式は以下

ma = GmM/|r|^2 * r
m  :点1質量
M  :点2質量
G  :万有引力定数
a  :点1の加速度ベクトル
r  :点1と2を結んだ方向ベクトル
|r|:二点間の距離 
  1. 点データを読み込む
  2. 加速度計算をする(各点の位置情報が必要)
  3. 速度計算をする(各点の加速度情報が必要)
  4. 位置計算をする(各店の速度情報が必要)
  5. 2に戻る
  6. 規定ステップ繰り返したらデータを書き出して終了する

与えられる問題は以下の情報で構成されます

state_t st
問題の情報を収めた構造体
typedef struct state{
	int nplots;  // 点の総数
	int delta_t; // 1ステップで経過する時間
	int xmax;    // すべての点の横方向の最大値、右端
	int ymax;    // すべての点の縦方向の最大値、下端
	int xmin;    // すべての点の横方向の最小値、左端
	int ymin;    // すべての点の縦方向の最小値、上端
	float gc;    // この問題で利用する万有引力定数
	int cutoff;  // カットオフ距離 (第4回までは使わない)
	float msum;  // 点の質量の総和 (普通は使わない)
} state_t;
point_t plot
点の情報
typedef struct point{
	float x;     // 点の x 座標
	float y;     // 点の y 座標
	float vx;    // 点の x 方向速度
	float vy;    // 点の y 方向速度
	float m;     // 点の質量
} point_t;

パッケージ構成(2007/01/10現在)

- nbody
  +- nbody
  |  +- nbody-api.c
  |  +- mt19937ar.c
  |  +- nbody.h
  |  +- mt19937ar.h
  |  +- Makefile
  |
  +- problem
  |  +- problem.c
  |  +- Makefile
  |
  +- serial
  |  +- nbody.c
  |  +- Makefile
  |
  +- mpi_poor
  |  +- nbody.c
  |  +- Makefile
  |
  +- spe_poor
     +- nbody.c
     +- Makefile

準備

使い方

libnbody.a (nbody 内)

init_plots_map(char* filename, state_t *st, point_t **plots)
ファイルからデータをplots に読み込む
point_t *plots;
state_t st;
init_plots_map("filename", &st, &plots);
(plots[i].x とか plots[i].y とかでつかえる)
write_plots_map(char* filename, state_t *st, point_t *plots)
ファイルにデータを書き込む
point_t *plots;
state_t st;
(plots のデータ読みこみと計算後)
write_plots_map("filename", &st, plots);
print_plols_map(point_t *plots, state_t st, int px, int py)
plots のデータを縮小して視覚的に見せてくれる(っぽい)
point_t *plots;
state_t st;
(plots のデータ読みこみと計算後)
print_plots_map(plots, st, 64, 32); //(横, 縦) = (64文字*32文字) のマップを表示
dump_plots_map(point_t *plots, state_t st)
plots のデータをすべて並べて出力
point_t *plots;
state_t st;
(plots のデータ読みこみと計算後)
dump_plots_map(plots, st);
fini_plots_map(point_t *plots)
plots に割り当てたメモリ領域を開放したりする。init_plots_map を使ったときはプログラムの最後に必ず呼ぶこと
point_t *plots;
state_t st;
(plots のデータ読みこみと計算後)
fini_plots_map(plots);

problem (problem 内)

serial (serial 内)


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS