app_config から粒子源計画と粒子バッチを構築する実行時変換。
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=i32), | public, | parameter | :: | slot_kind_none | = | 0_i32 |
slot の種別。 |
| integer(kind=i32), | public, | parameter | :: | slot_kind_volume | = | 1_i32 | |
| integer(kind=i32), | public, | parameter | :: | slot_kind_photo_ray | = | 2_i32 | |
| integer(kind=i32), | public, | parameter | :: | slot_kind_reservoir_face | = | 3_i32 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(app_config), | intent(in) | :: | cfg | |||
| integer(kind=i32), | intent(in) | :: | batch_idx | |||
| type(batch_injection_layout_type), | intent(out) | :: | layout | |||
| type(injection_state), | intent(inout), | optional | :: | state | ||
| type(mesh_type), | intent(in), | optional | :: | mesh | ||
| integer(kind=i32), | intent(in), | optional | :: | mpi_rank | ||
| integer(kind=i32), | intent(in), | optional | :: | mpi_size | ||
| type(mpi_context), | intent(in), | optional | :: | mpi | ||
| type(electrostatic_snapshot_type), | intent(inout), | optional | :: | snapshot | ||
| type(particle_source_plan_type), | intent(in) | :: | source_plan |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(app_config), | intent(in) | :: | cfg | |||
| type(batch_injection_layout_type), | intent(in) | :: | layout | |||
| integer(kind=i32), | intent(in) | :: | slot | |||
| type(mesh_type), | intent(in), | optional | :: | mesh | ||
| real(kind=dp), | intent(out) | :: | x(3) | |||
| real(kind=dp), | intent(out) | :: | v(3) | |||
| real(kind=dp), | intent(out) | :: | w | |||
| real(kind=dp), | intent(out) | :: | q | |||
| real(kind=dp), | intent(out) | :: | m | |||
| integer(kind=i32), | intent(out) | :: | species_idx | |||
| integer(kind=i32), | intent(out) | :: | source_element | |||
| logical, | intent(out) | :: | emitted | |||
| integer(kind=i32), | intent(out) | :: | collision_status | |||
| integer(kind=i32), | intent(out) | :: | bounce_count |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(app_config), | intent(in) | :: | cfg | |||
| integer(kind=i32), | intent(in) | :: | batch_idx | |||
| type(particles_soa), | intent(out) | :: | pcls | |||
| type(injection_state), | intent(inout), | optional | :: | state | ||
| 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 | ||
| type(photo_ray_failure_type), | intent(out), | optional | :: | photo_failure |
不完全な photo collision query(省略時は停止)。 |
|
| type(electrostatic_snapshot_type), | intent(inout), | optional | :: | snapshot | ||
| type(particle_source_plan_type), | intent(in) | :: | source_plan | |||
| real(kind=dp), | intent(out), | optional | :: | photo_emission_dq_by_species(:,:) | ||
| integer(kind=i32), | intent(out), | optional, | allocatable | :: | slot_ids(:) |
各粒子の global slot 番号(粒子追跡の境界・二次電子乱数の鍵に使う)。 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(app_config), | intent(in) | :: | cfg | |||
| type(particle_species_spec), | intent(in) | :: | spec | |||
| real(kind=dp), | intent(out) | :: | vmin_normal | |||
| real(kind=dp), | intent(out) | :: | barrier_normal | |||
| type(mesh_type), | intent(in), | optional | :: | mesh | ||
| type(electrostatic_snapshot_type), | intent(inout), | optional | :: | snapshot | ||
| logical, | intent(in), | optional | :: | warn_face_variation | ||
| real(kind=dp), | intent(inout), | optional | :: | face_potential(4) |
面の電位統計 (平均, 標準偏差, 最小, 最大) [V] の cache。 |
|
| logical, | intent(inout), | optional | :: | face_potential_ready |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(app_config), | intent(in) | :: | cfg | |||
| type(particle_species_spec), | intent(in) | :: | spec | |||
| real(kind=dp), | intent(in) | :: | reservoir_potential_v | |||
| real(kind=dp), | intent(in) | :: | access_potential_v | |||
| real(kind=dp), | intent(out) | :: | vmin_normal | |||
| real(kind=dp), | intent(out) | :: | barrier_normal | |||
| type(mesh_type), | intent(in), | optional | :: | mesh | ||
| type(electrostatic_snapshot_type), | intent(inout), | optional | :: | snapshot | ||
| logical, | intent(in), | optional | :: | warn_face_variation | ||
| real(kind=dp), | intent(inout), | optional | :: | face_potential(4) |
面の電位統計 (平均, 標準偏差, 最小, 最大) [V] の cache。 |
|
| logical, | intent(inout), | optional | :: | face_potential_ready |
1 バッチの注入 layout。全 rank で同じ global 粒子数と面ごとの速度補正を持ち、
static の rank 分割と shared の slot pool の両方がこれを基に粒子を作る。
segment は species 順に source(volume_seed または photo ray)、次に面 1..6 の reservoir が並ぶ。
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| logical, | public | :: | ready | = | .false. | ||
| integer(kind=i32), | public | :: | batch_idx | = | 0_i32 | ||
| integer(kind=i32), | public | :: | nspecies | = | 0_i32 | ||
| integer(kind=i32), | public, | allocatable | :: | source_kind(:) | |||
| integer(kind=i32), | public, | allocatable | :: | source_global_count(:) | |||
| integer(kind=i32), | public, | allocatable | :: | boundary_global_count(:,:) | |||
| real(kind=dp), | public, | allocatable | :: | boundary_vmin(:,:) | |||
| real(kind=dp), | public, | allocatable | :: | boundary_barrier(:,:) | |||
| real(kind=dp), | public, | allocatable | :: | weight(:) | |||
| real(kind=dp), | public, | allocatable | :: | temperature_k(:) | |||
| real(kind=dp), | public, | allocatable | :: | drift_velocity(:,:) | |||
| real(kind=dp), | public, | allocatable | :: | photo_emit_current_density(:) | |||
| real(kind=dp), | public, | allocatable | :: | photo_normal_drift_speed(:) | |||
| real(kind=dp), | public, | allocatable | :: | photo_ray_weight(:) |
1 本の ray が当たったときのマクロ粒子重み(全 rank 合計の ray 数で分担)。 |
||
| integer(kind=i32), | public | :: | nsegments | = | 0_i32 | ||
| integer(kind=i32), | public | :: | total_slots | = | 0_i32 | ||
| integer(kind=i32), | public, | allocatable | :: | segment_species(:) | |||
| integer(kind=i32), | public, | allocatable | :: | segment_kind(:) | |||
| integer(kind=i32), | public, | allocatable | :: | segment_face(:) | |||
| integer(kind=i32), | public, | allocatable | :: | segment_begin(:) | |||
| integer(kind=i32), | public, | allocatable | :: | segment_end(:) | |||
| integer(kind=i32), | public | :: | nbands | = | 0_i32 |
slot は segment を round-robin に回って並ぶ(segment 内 index k の周回で、長さが k 以上の segment を順に取る)。
取り合う順に種が混ざり、static の round-robin 組み立てと同じ処理順になる。slot ごとの表は持たず、
segment 長の相異なる値ごとの帯で |
|
| integer(kind=i32), | public, | allocatable | :: | band_length(:) | |||
| integer(kind=i32), | public, | allocatable | :: | band_last_slot(:) |
帯 b の最後の global slot( |
| procedure, public :: locate_slot => locate_batch_slot |
source plan がこの rank/size と mpi 引数の有無で構築されたかを返す。 rank、size、mpi 引数の有無はそれぞれ独立に一致する必要がある。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(particle_source_plan_type), | intent(in) | :: | plan |
|
||
| integer(kind=i32), | intent(in) | :: | local_rank |
今回解決した rank 番号。 |
||
| integer(kind=i32), | intent(in) | :: | n_ranks |
今回解決した rank 番号。 今回解決した rank 数。 |
||
| logical, | intent(in) | :: | mpi_argument_present |
今回 |
speciesに外部 reservoir 流入を指定したbox面があるかを返す。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(particle_species_spec), | intent(in) | :: | spec |
global slot から (segment, segment 内 index) を求める。O(nsegments) で、slot ごとの表を持たない。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(batch_injection_layout_type), | intent(in) | :: | self | |||
| integer(kind=i32), | intent(in) | :: | slot |
|
||
| integer(kind=i32), | intent(out) | :: | segment |
slot が属する segment。 |
||
| integer(kind=i32), | intent(out) | :: | local_index |
slot が属する segment。 segment 内の 1 始まり index。 |
バッチ生成前に乱数シードだけを初期化する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(app_config), | intent(in) | :: | cfg |
乱数シード値 |
||
| integer(kind=i32), | intent(in), | optional | :: | mpi_rank | ||
| integer(kind=i32), | intent(in), | optional | :: | mpi_size | ||
| type(mpi_context), | intent(in), | optional | :: | mpi |
設定とMPI配置だけに依存する粒子 source の導出値を構築する。 乱数、残差、mesh/snapshot依存の障壁は扱わず、run中に不変な値だけを保持する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(app_config), | intent(in) | :: | cfg | |||
| type(particle_source_plan_type), | intent(out) | :: | plan | |||
| integer(kind=i32), | intent(in), | optional | :: | mpi_rank | ||
| integer(kind=i32), | intent(in), | optional | :: | mpi_size | ||
| type(mpi_context), | intent(in), | optional | :: | mpi | ||
| logical, | intent(in), | optional | :: | kinetic_inflow_active(:) | ||
| real(kind=dp), | intent(in), | optional | :: | kinetic_reservoir_potential_v(:) | ||
| real(kind=dp), | intent(in), | optional | :: | kinetic_access_potential_v(:) | ||
| integer(kind=i32), | intent(in), | optional | :: | kinetic_inflow_face(:) | ||
| logical, | intent(in), | optional | :: | number_flux_override_active(:) | ||
| real(kind=dp), | intent(in), | optional | :: | number_flux_override_m2_s(:) | ||
| real(kind=dp), | intent(in), | optional | :: | kinetic_reservoir_density_m3(:) |
流入写像の面だけで使う貯留部密度。0以下の要素は species 設定の密度を使う。 |
外部 closure の kinetic 写像(有効フラグ・貯留部/access 電位・面・貯留部密度)を検査して plan へ写す。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(particle_source_plan_type), | intent(inout) | :: | plan | |||
| integer(kind=i32), | intent(in) | :: | nspecies | |||
| logical, | intent(in), | optional | :: | kinetic_inflow_active(:) | ||
| real(kind=dp), | intent(in), | optional | :: | kinetic_reservoir_potential_v(:) | ||
| real(kind=dp), | intent(in), | optional | :: | kinetic_access_potential_v(:) | ||
| integer(kind=i32), | intent(in), | optional | :: | kinetic_inflow_face(:) | ||
| real(kind=dp), | intent(in), | optional | :: | kinetic_reservoir_density_m3(:) |
外部 closure の number-flux override の有効フラグを検査して plan へ写す(flux 値は種の解決時に使う)。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(particle_source_plan_type), | intent(inout) | :: | plan | |||
| integer(kind=i32), | intent(in) | :: | nspecies | |||
| logical, | intent(in), | optional | :: | number_flux_override_active(:) | ||
| real(kind=dp), | intent(in), | optional | :: | number_flux_override_m2_s(:) |
box 全面の境界流入をサンプリングする面座標を構築する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(sim_config), | intent(in) | :: | sim | |||
| type(particle_species_spec), | intent(in) | :: | source_spec | |||
| integer(kind=i32), | intent(in) | :: | face | |||
| type(particle_species_spec), | intent(out) | :: | inflow_spec |
境界流入用に、物理流量と残差から今バッチのマクロ粒子数を決める。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(sim_config), | intent(in) | :: | sim |
ボックス境界・バッチ時間などのシミュレーション設定。 |
||
| type(particle_species_spec), | intent(in) | :: | spec |
境界流入面の粒子種設定。 |
||
| 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 | :: | 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) | ||
| real(kind=dp), | intent(in), | optional | :: | particle_flux_override |
粒子数 flux の上書き値 [1/m^2/s]。 |
|
| logical, | intent(in), | optional | :: | use_particle_flux_override |
併存対応のため mpi_context と rank/size の両方を受け、最終的なrank/sizeを解決する。
| Type | Intent | Optional | 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 |