bem_app_config_runtime Module

app_config からメッシュ・粒子群を構築する実行時変換モジュール。


Uses

  • module~~bem_app_config_runtime~~UsesGraph module~bem_app_config_runtime bem_app_config_runtime ieee_arithmetic ieee_arithmetic module~bem_app_config_runtime->ieee_arithmetic module~bem_app_config_types bem_app_config_types module~bem_app_config_runtime->module~bem_app_config_types module~bem_config_helpers bem_config_helpers module~bem_app_config_runtime->module~bem_config_helpers module~bem_field bem_field module~bem_app_config_runtime->module~bem_field module~bem_importers bem_importers module~bem_app_config_runtime->module~bem_importers module~bem_injection bem_injection module~bem_app_config_runtime->module~bem_injection module~bem_kinds bem_kinds module~bem_app_config_runtime->module~bem_kinds module~bem_mesh bem_mesh module~bem_app_config_runtime->module~bem_mesh module~bem_mpi bem_mpi module~bem_app_config_runtime->module~bem_mpi module~bem_particles bem_particles module~bem_app_config_runtime->module~bem_particles module~bem_sheath_injection_model bem_sheath_injection_model module~bem_app_config_runtime->module~bem_sheath_injection_model module~bem_string_utils bem_string_utils module~bem_app_config_runtime->module~bem_string_utils module~bem_templates bem_templates module~bem_app_config_runtime->module~bem_templates module~bem_types bem_types module~bem_app_config_runtime->module~bem_types module~bem_app_config_types->module~bem_kinds module~bem_app_config_types->module~bem_types module~bem_config_helpers->module~bem_app_config_types module~bem_config_helpers->module~bem_kinds module~bem_config_helpers->module~bem_string_utils module~bem_field->module~bem_kinds module~bem_field->module~bem_types module~bem_constants bem_constants module~bem_field->module~bem_constants module~bem_importers->module~bem_kinds module~bem_importers->module~bem_mesh module~bem_importers->module~bem_types module~bem_injection->module~bem_kinds module~bem_injection->module~bem_particles module~bem_injection->module~bem_string_utils module~bem_injection->module~bem_types module~bem_boundary bem_boundary module~bem_injection->module~bem_boundary module~bem_collision bem_collision module~bem_injection->module~bem_collision module~bem_injection->module~bem_constants iso_fortran_env iso_fortran_env module~bem_kinds->iso_fortran_env module~bem_mesh->module~bem_kinds module~bem_mesh->module~bem_string_utils module~bem_mesh->module~bem_types module~bem_mpi->module~bem_kinds module~bem_particles->module~bem_kinds module~bem_particles->module~bem_types module~bem_sheath_runtime bem_sheath_runtime module~bem_sheath_injection_model->module~bem_sheath_runtime module~bem_templates->module~bem_kinds module~bem_templates->module~bem_mesh module~bem_templates->module~bem_types module~bem_types->module~bem_kinds module~bem_boundary->module~bem_kinds module~bem_boundary->module~bem_types module~bem_collision->module~bem_kinds module~bem_collision->module~bem_string_utils module~bem_collision->module~bem_types module~bem_constants->module~bem_kinds module~bem_sheath_runtime->module~bem_app_config_types module~bem_sheath_runtime->module~bem_config_helpers module~bem_sheath_runtime->module~bem_kinds module~bem_sheath_runtime->module~bem_string_utils module~bem_sheath_runtime->module~bem_types module~bem_sheath_runtime->module~bem_constants module~bem_sheath_model_core bem_sheath_model_core module~bem_sheath_runtime->module~bem_sheath_model_core module~bem_sheath_model_core->ieee_arithmetic module~bem_sheath_model_core->module~bem_injection module~bem_sheath_model_core->module~bem_kinds module~bem_sheath_model_core->module~bem_string_utils module~bem_sheath_model_core->module~bem_constants

Used by

  • module~~bem_app_config_runtime~~UsedByGraph module~bem_app_config_runtime bem_app_config_runtime module~bem_app_config bem_app_config module~bem_app_config->module~bem_app_config_runtime module~bem_simulator bem_simulator module~bem_simulator->module~bem_app_config program~main main program~main->module~bem_app_config program~main->module~bem_simulator module~bem_simulator_io bem_simulator_io module~bem_simulator_io->module~bem_simulator module~bem_simulator_loop bem_simulator_loop module~bem_simulator_loop->module~bem_simulator module~bem_simulator_stats bem_simulator_stats module~bem_simulator_stats->module~bem_simulator

Functions

public pure function species_number_density_m3(spec) result(number_density_m3)

粒子種設定から実効密度[m^-3]を返す。

Arguments

Type IntentOptional Attributes Name
type(particle_species_spec), intent(in) :: spec

粒子種設定。

Return Value real(kind=dp)

public pure function species_temperature_k(spec) result(temperature_k)

粒子種設定から実効温度[K]を返す。

Arguments

Type IntentOptional Attributes Name
type(particle_species_spec), intent(in) :: spec

粒子種設定。

Return Value real(kind=dp)


Subroutines

public subroutine build_mesh_from_config(cfg, mesh)

mesh_mode と OBJ ファイル有無に応じてメッシュ生成方法を選ぶ。

Arguments

Type IntentOptional Attributes Name
type(app_config), intent(in) :: cfg

メッシュ入力設定を含むアプリ設定。

type(mesh_type), intent(out) :: mesh

構築した三角形メッシュ。

public subroutine apply_obj_transform(mesh, scale, rotation_deg, offset)

OBJ メッシュの全頂点にスケール→回転→平行移動を適用し再初期化する。 変換順序: v_new = R(rotation) * (v_old * scale) + offset 回転は度単位で x→y→z の順に外因性 (extrinsic) 回転を適用する。

Arguments

Type IntentOptional Attributes Name
type(mesh_type), intent(inout) :: mesh

変換対象の三角形メッシュ。

real(kind=dp), intent(in) :: scale

一様スケーリング係数。

real(kind=dp), intent(in) :: rotation_deg(3)
real(kind=dp), intent(in) :: offset(3)

public subroutine init_particles_from_config(cfg, pcls)

設定全体ぶんの粒子群を生成し、SoA へ詰める。 粒子種ごとに乱数サンプルした後、種ごとに rank を揃えて interleave する。

Arguments

Type IntentOptional Attributes Name
type(app_config), intent(in) :: cfg

粒子種設定を含むアプリ設定。

type(particles_soa), intent(out) :: pcls

生成した全粒子群。

public subroutine seed_particles_from_config(cfg, mpi_rank, mpi_size, mpi)

バッチ生成前に乱数シードだけを初期化する。

Arguments

Type IntentOptional Attributes Name
type(app_config), intent(in) :: cfg

乱数シード値 sim.rng_seed を含むアプリ設定。

integer(kind=i32), intent(in), optional :: mpi_rank
integer(kind=i32), intent(in), optional :: mpi_size
type(mpi_context), intent(in), optional :: mpi

public subroutine init_particle_batch_from_config(cfg, batch_idx, pcls, state, mesh, photo_emission_dq, mpi_rank, mpi_size, mpi)

指定バッチ番号に対応する粒子バッチを生成する。

Arguments

Type IntentOptional Attributes Name
type(app_config), intent(in) :: cfg

粒子種とシミュレーション条件を含むアプリ設定。

integer(kind=i32), intent(in) :: batch_idx

生成対象のバッチ番号(1始まり)。

type(particles_soa), intent(out) :: pcls

生成したバッチ粒子群。

type(injection_state), intent(inout), optional :: state

reservoir_face 注入の残差状態(必要時のみ)。

type(mesh_type), intent(in), optional :: mesh

現在バッチ開始時点の電荷分布メッシュ(電位補正時に必要)。

real(kind=dp), intent(out), optional :: photo_emission_dq(:)
integer(kind=i32), intent(in), optional :: mpi_rank
integer(kind=i32), intent(in), optional :: mpi_size
type(mpi_context), intent(in), optional :: mpi

public subroutine sample_species_state(sim, spec, n, x, v, barrier_normal_energy, vmin_normal, apply_barrier_energy_shift, temperature_k_override, drift_velocity_override)

1粒子種ぶんの位置・速度サンプルをまとめて生成する。

Arguments

Type IntentOptional Attributes Name
type(sim_config), intent(in) :: sim

ボックス境界・バッチ時間などのシミュレーション設定。

type(particle_species_spec), intent(in) :: spec

1粒子種の注入設定。

integer(kind=i32), intent(in) :: n

生成粒子数。

real(kind=dp), intent(out) :: x(:,:)
real(kind=dp), intent(out) :: v(:,:)
real(kind=dp), intent(in), optional :: barrier_normal_energy

reservoir_face 法線方向のエネルギー障壁 2 q Δφ / m [m^2/s^2]。

real(kind=dp), intent(in), optional :: vmin_normal

reservoir_face 法線速度の下限 [m/s]。

logical, intent(in), optional :: apply_barrier_energy_shift

reservoir_face 法線速度へ障壁エネルギー変換を適用するか。

real(kind=dp), intent(in), optional :: temperature_k_override
real(kind=dp), intent(in), optional :: drift_velocity_override(3)

public subroutine sample_photo_species_state(sim, spec, mesh, n_rays, x, v, w, n_emit, emit_elem_idx, global_rays_per_batch, emit_current_density_override, normal_drift_speed_override, vmin_normal)

photo_raycast 粒子種のレイキャスト放出を実行する。

Arguments

Type IntentOptional Attributes Name
type(sim_config), intent(in) :: sim

シミュレーション設定。

type(particle_species_spec), intent(in) :: spec

photo_raycast 粒子種設定。

type(mesh_type), intent(in) :: mesh

交差判定に使う現在メッシュ。

integer(kind=i32), intent(in) :: n_rays

バッチで発射するレイ本数。

real(kind=dp), intent(out) :: x(:,:)
real(kind=dp), intent(out) :: v(:,:)
real(kind=dp), intent(out) :: w(:)
integer(kind=i32), intent(out) :: n_emit

実際に放出された粒子数。

integer(kind=i32), intent(out), optional :: emit_elem_idx(:)
integer(kind=i32), intent(in), optional :: global_rays_per_batch
real(kind=dp), intent(in), optional :: emit_current_density_override

放出電流密度の上書き値 [A/m^2]。

real(kind=dp), intent(in), optional :: normal_drift_speed_override

放出法線ドリフトの上書き値 [m/s]。

real(kind=dp), intent(in), optional :: vmin_normal

放出法線速度の下限 [m/s]。

public subroutine compute_macro_particles_for_species(sim, spec, residual, count, vmin_normal, batch_duration_scale, number_density_override, w_particle_override, temperature_k_override, drift_velocity_override)

reservoir_face 用に、物理流量と残差から今バッチのマクロ粒子数を決める。

Arguments

Type IntentOptional Attributes Name
type(sim_config), intent(in) :: sim

ボックス境界・バッチ時間などのシミュレーション設定。

type(particle_species_spec), intent(in) :: spec

reservoir_face 粒子種設定。

real(kind=dp), intent(inout) :: residual

前バッチから繰り越した端数。

integer(kind=i32), intent(out) :: count

今バッチで生成するマクロ粒子数。

real(kind=dp), intent(in), optional :: vmin_normal

法線速度の下限 [m/s](省略時は 0)。

real(kind=dp), intent(in), optional :: batch_duration_scale
real(kind=dp), intent(in), optional :: number_density_override

数密度の上書き値 [1/m^3]。

real(kind=dp), intent(in), optional :: w_particle_override

マクロ粒子重みの上書き値。

real(kind=dp), intent(in), optional :: temperature_k_override

温度の上書き値 [K]。

real(kind=dp), intent(in), optional :: drift_velocity_override(3)

public subroutine resolve_reservoir_target_weight(sim, spec, number_density_m3, vmin_normal, temperature_k, drift_velocity, target_macro_particles_per_batch, w_particle)

reservoir_face の target 個数からシース補正込み重みを解決する。

Arguments

Type IntentOptional Attributes Name
type(sim_config), intent(in) :: sim

シミュレーション設定。

type(particle_species_spec), intent(in) :: spec

reservoir_face 粒子種設定。

real(kind=dp), intent(in) :: number_density_m3

実効数密度 [1/m^3]。

real(kind=dp), intent(in) :: vmin_normal

実効数密度 [1/m^3]。 法線速度の下限 [m/s]。

real(kind=dp), intent(in) :: temperature_k

実効数密度 [1/m^3]。 法線速度の下限 [m/s]。 実効温度 [K]。

real(kind=dp), intent(in) :: drift_velocity(3)

実効数密度 [1/m^3]。 法線速度の下限 [m/s]。 実効温度 [K]。

integer(kind=i32), intent(in) :: target_macro_particles_per_batch

目標マクロ粒子数。

real(kind=dp), intent(out) :: w_particle

解決したマクロ粒子重み。

public subroutine apply_normal_speed_override(drift_velocity, inward_normal, normal_speed, drift_velocity_out)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: drift_velocity(3)
real(kind=dp), intent(in) :: inward_normal(3)
real(kind=dp), intent(in) :: normal_speed
real(kind=dp), intent(out) :: drift_velocity_out(3)

public subroutine reservoir_face_velocity_correction(sim, spec, vmin_normal, barrier_normal, mesh)

reservoir_face 注入に対する法線速度補正パラメータを計算する。

Arguments

Type IntentOptional Attributes Name
type(sim_config), intent(in) :: sim

シミュレーション設定。

type(particle_species_spec), intent(in) :: spec

reservoir_face 粒子種設定。

real(kind=dp), intent(out) :: vmin_normal

無限遠法線速度の下限 [m/s]。

real(kind=dp), intent(out) :: barrier_normal

法線エネルギー障壁 2 q Δφ / m [m^2/s^2]。

type(mesh_type), intent(in), optional :: mesh

現在バッチ開始時点の電荷分布メッシュ(補正時に必要)。

public subroutine compute_face_average_potential(mesh, sim, spec, phi_face)

reservoir_face 開口面の平均電位を N x N 格子平均で評価する。

Arguments

Type IntentOptional Attributes Name
type(mesh_type), intent(in) :: mesh

現在バッチ開始時点の電荷分布メッシュ。

type(sim_config), intent(in) :: sim

シミュレーション設定。

type(particle_species_spec), intent(in) :: spec

reservoir_face 粒子種設定。

real(kind=dp), intent(out) :: phi_face

注入開口面の平均電位 [V]。

public subroutine resolve_face_sampling_geometry(box_min, box_max, inject_face, axis_n, axis_t1, axis_t2, boundary_value, inward_normal)

注入面名から法線軸・接線軸・境界値・内向き法線を返す。

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: box_min(3)
real(kind=dp), intent(in) :: box_max(3)
character(len=*), intent(in) :: inject_face

注入面識別子。

integer, intent(out) :: axis_n

法線軸インデックス(1:x, 2:y, 3:z)。

integer, intent(out) :: axis_t1

法線軸インデックス(1:x, 2:y, 3:z)。 第1接線軸インデックス。

integer, intent(out) :: axis_t2

法線軸インデックス(1:x, 2:y, 3:z)。 第1接線軸インデックス。 第2接線軸インデックス。

real(kind=dp), intent(out) :: boundary_value

注入面の境界座標値 [m]。

real(kind=dp), intent(out) :: inward_normal(3)

public subroutine resolve_parallel_rank_size(local_rank, n_ranks, mpi_rank, mpi_size, mpi, caller_name)

併存対応のため mpi_context と rank/size の両方を受け、最終的なrank/sizeを解決する。

Arguments

Type IntentOptional Attributes Name
integer(kind=i32), intent(out) :: local_rank
integer(kind=i32), intent(out) :: n_ranks
integer(kind=i32), intent(in), optional :: mpi_rank
integer(kind=i32), intent(in), optional :: mpi_size
type(mpi_context), intent(in), optional :: mpi
character(len=*), intent(in) :: caller_name

public subroutine build_template_mesh(cfg, mesh)

有効なテンプレートを連結し、1つのメッシュへまとめる。

Arguments

Type IntentOptional Attributes Name
type(app_config), intent(in) :: cfg

テンプレート設定を含むアプリ設定。

type(mesh_type), intent(out) :: mesh

連結後の三角形メッシュ。

public subroutine build_one_template(spec, mesh)

テンプレート種別に応じて形状生成ルーチンへディスパッチする。

Arguments

Type IntentOptional Attributes Name
type(template_spec), intent(in) :: spec

1テンプレート分の形状設定。

type(mesh_type), intent(out) :: mesh

生成したテンプレートメッシュ。

public subroutine append_triangles(v0, v1, v2, add_v0, add_v1, add_v2)

既存三角形配列へ追加分を連結し、再確保後の配列へ差し替える。

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout), allocatable :: v0(:,:)
real(kind=dp), intent(inout), allocatable :: v1(:,:)
real(kind=dp), intent(inout), allocatable :: v2(:,:)
real(kind=dp), intent(in) :: add_v0(:,:)
real(kind=dp), intent(in) :: add_v1(:,:)
real(kind=dp), intent(in) :: add_v2(:,:)

public subroutine append_mesh_ids(mesh_ids, add_ids)

既存の要素メッシュID配列へ追加分を連結する。

Arguments

Type IntentOptional Attributes Name
integer(kind=i32), intent(inout), allocatable :: mesh_ids(:)
integer(kind=i32), intent(in) :: add_ids(:)