3#include "../afivo/src/cpp_macros.h"
25 type(af_t),
intent(in) :: tree
26 integer,
intent(in) :: iv
27 real(dp),
intent(in) :: threshold
28 integer,
intent(in) :: n_max
29 real(dp),
intent(inout) :: coord_val(ndim+1, n_max)
30 integer,
intent(out) :: n_found
32 integer :: ijk, nc, n, lvl, id
33 real(dp) :: val, neighbs(2*ndim)
39 do lvl = 1, tree%highest_lvl
41 do n = 1,
size(tree%lvls(lvl)%leaves)
42 id = tree%lvls(lvl)%leaves(n)
44 associate(cc => tree%boxes(id)%cc)
48 neighbs = [cc(i-1, iv), cc(i+1, iv)]
50 neighbs = [cc(i-1, j, iv), cc(i+1, j, iv), &
51 cc(i, j-1, iv), cc(i, j+1, iv)]
53 neighbs = [cc(i-1, j, k, iv), cc(i+1, j, k, iv), &
54 cc(i, j-1, k, iv), cc(i, j+1, k, iv), &
55 cc(i, j, k-1, iv), cc(i, j, k+1, iv)]
59 if (val > threshold .and. all(val >= neighbs) &
60 .and. any(val > neighbs))
then
64 if (n_found <= n_max)
then
65 coord_val(ndim+1, n_found) = val
66 coord_val(1:ndim, n_found) = af_r_cc(tree%boxes(id), [ijk])
82 type(af_t),
intent(in) :: tree
83 integer,
intent(in) :: iv
85 real(dp),
intent(in) :: threshold
87 real(dp),
intent(in) :: limits(2)
89 real(dp),
intent(out) :: z_minmax(2)
91 call af_reduction_vec(tree, box_minmax_z, reduce_minmax, &
98 function box_minmax_z(box, n_vals)
result(vec)
99 type(box_t),
intent(in) :: box
100 integer,
intent(in) :: n_vals
101 real(dp) :: vec(n_vals)
103 integer :: i, j, n, nc, ix(ndim)
113 above = box%cc(n, iv) > threshold
115 above = maxval(box%cc(1:nc, n, iv)) > threshold
117 above = maxval(box%cc(1:nc, 1:nc, n, iv)) > threshold
125 vec = [1e100_dp, -1e100_dp]
138 end function box_minmax_z
141 function reduce_minmax(vec_1, vec_2, n_vals)
result(vec)
142 integer,
intent(in) :: n_vals
143 real(dp),
intent(in) :: vec_1(n_vals), vec_2(n_vals)
144 real(dp) :: vec(n_vals)
145 vec(1) = min(vec_1(1), vec_2(1))
146 vec(2) = max(vec_1(2), vec_2(2))
147 end function reduce_minmax
154 type(af_t),
intent(in) :: tree
155 integer,
intent(in) :: iv
156 real(dp),
intent(in) :: r0(ndim)
157 real(dp),
intent(in) :: r1(ndim)
158 real(dp),
intent(out) :: max_value
159 type(af_loc_t),
intent(out) :: loc
161 call af_reduction_loc(tree, iv, box_max_region, reduce_max, &
162 -1e100_dp, max_value, loc)
166 subroutine box_max_region(box, iv, val, ix)
167 type(box_t),
intent(in) :: box
168 integer,
intent(in) :: iv
169 real(dp),
intent(out) :: val
170 integer,
intent(out) :: ix(ndim)
172 real(dp) :: r_max(ndim)
175 r_max = box%r_min + box%n_cell * box%dr
177 if (any(box%r_min > r1) .or. any(r_max < r0))
then
181 ix = maxloc(box%cc(dtimes(1:nc), iv))
182 val = box%cc(dindex(ix), iv)
184 end subroutine box_max_region
189 type(af_t),
intent(in) :: tree
190 integer,
intent(in) :: ivs(:)
191 real(dp),
intent(out) :: max_value
192 type(af_loc_t),
intent(out) :: loc
194 call af_reduction_loc(tree, -1, box_max_product, reduce_max, &
195 -1e100_dp, max_value, loc)
199 subroutine box_max_product(box, iv, val, ix)
200 type(box_t),
intent(in) :: box
201 integer,
intent(in) :: iv
202 real(dp),
intent(out) :: val
203 integer,
intent(out) :: ix(ndim)
207 ix = maxloc(product(box%cc(dtimes(1:nc), ivs), dim=ndim+1))
208 val = product(box%cc(dindex(ix), ivs))
209 end subroutine box_max_product
213 real(dp) function reduce_max(a, b)
214 real(dp),
intent(in) :: a, b
215 reduce_max = max(a, b)
216 end function reduce_max
227 type(af_t),
intent(in) :: tree
228 real(dp),
intent(in) :: rmax
229 real(dp),
intent(in) :: z
230 real(dp),
intent(out) :: elec_dens
231 real(dp),
intent(out) :: charge_dens
232 real(dp),
intent(out) :: current_dens
234 real(dp) :: ne_fld_rhs(3), mu, td, r, dr, n_inv
235 real(dp) :: ne, fld, ez, rhs, fld_vec(ndim)
236 real(dp) :: d_elec_dens, d_charge_dens, d_current_dens
238 integer :: id_guess, i, m
241 error stop
"analysis_get_cross error: need cylindrical coordinates"
243 error stop
"analysis_get_cross error: need constant gas density"
248 current_dens = 0.0_dp
254 r = i * rmax / (m + 1)
256 ne_fld_rhs = af_interp1(tree, [r, z], &
258 if (.not. success) error stop
"unsuccessful af_interp1"
261 fld_vec = af_interp1_fc(tree, [r, z],
electric_fld, success, id_guess)
262 if (.not. success) error stop
"unsuccessful af_interp1_fc"
271 d_elec_dens = ne * 2.0_dp *
uc_pi * r * dr
276 elec_dens = elec_dens + d_elec_dens
277 charge_dens = charge_dens + d_charge_dens
278 current_dens = current_dens + d_current_dens
Module with routines to help analyze simulations.
subroutine, public analysis_max_var_region(tree, iv, r0, r1, max_value, loc)
Find maximal value for boxes that are (at least partially) in the rectangle from r0 to r1.
subroutine, public analysis_get_cross(tree, rmax, z, elec_dens, charge_dens, current_dens)
Get integrated quantities of an axisymmetric streamer at a z-coordinate.
subroutine, public analysis_max_var_product(tree, ivs, max_value, loc)
subroutine, public analysis_zmin_zmax_threshold(tree, iv, threshold, limits, z_minmax)
Find minimum and maximum z coordinate where a variable exceeds a threshold.
subroutine, public analysis_get_maxima(tree, iv, threshold, n_max, coord_val, n_found)
Find at most n_max maxima of a variable. Maxima are determined by looking at the direct neighbors.
Module for handling chemical reactions.
Module that stores parameters related to the gas.
real(dp), parameter, public si_to_townsend
logical, public, protected gas_constant_density
Whether the gas has a constant density.
real(dp), public, protected gas_number_density
This module contains several pre-defined variables like:
logical, public, protected st_cylindrical
Whether cylindrical coordinates are used.
integer, public, protected i_electron
Index of electron density.
integer, public, protected electric_fld
Index of electric field vector.
integer, public, protected i_rhs
Index of source term Poisson.
integer, public, protected i_electric_fld
Index of electric field norm.
Module that provides routines for reading in arbritrary transport data.
type(lt_t), public, protected td_tbl
integer, parameter, public td_mobility
Electron mobility.
Module that contains physical and numerical constants.
real(dp), parameter uc_elem_charge
real(dp), parameter uc_pi
real(dp), parameter uc_eps0
real(dp), parameter uc_elec_charge