3#include "../afivo/src/cpp_macros.h"
83 integer,
parameter,
public ::
i_rho = 1
85 integer,
parameter,
public ::
i_mom(ndim) = [2]
87 integer,
parameter,
public ::
i_mom(ndim) = [2, 3]
89 integer,
parameter,
public ::
i_mom(ndim) = [2, 3, 4]
91 integer,
parameter,
public ::
i_e =
i_mom(ndim) + 1
105 type(af_t),
intent(inout) :: tree
106 type(cfg_t),
intent(inout) :: cfg
110 "Whether the gas dynamics are simulated")
124 call af_add_cc_variable(tree,
"M", ix=
i_gas_dens)
129 call af_add_fc_variable(tree,
"flux", ix=
gas_fluxes(n))
131 if (tree%coord_t == af_cyl .and. n ==
i_mom(1))
then
132 call af_set_cc_methods(tree,
gas_vars(n), bc_radial_momentum)
134 call af_set_cc_methods(tree,
gas_vars(n), af_bc_neumann_zero)
148 call af_add_cc_variable(tree,
"M", ix=
i_gas_dens)
154 "The gas pressure (bar)")
156 "The gas temperature (Kelvin)")
159 "Gas mean molecular weight (kg), for gas dynamics")
161 "Joule heating efficiency (between 0.0 and 1.0)")
163 "Fraction of gas heating that occurs via V-T relaxation")
164 call cfg_add_get(cfg,
"gas%vt_relaxation_time",
gas_vt_time, &
165 "Vibration-Translation relaxation time")
167 "Factor for the EHD force term (should be 1 by default)")
178 call cfg_add(cfg,
"gas%components", [
"N2",
"O2"], &
179 "Gas component names", .true.)
180 call cfg_add(cfg,
"gas%fractions", [0.8_dp, 0.2_dp], &
181 "Gas component fractions", .true.)
183 call cfg_get_size(cfg,
"gas%components", n)
193 error stop
"gas%fractions has negative value"
195 error stop
"gas%fractions not normalized"
203 s_prev, w_prev, s_out, i_step, n_steps)
204 use m_af_flux_schemes
206 type(af_t),
intent(inout) :: tree
207 real(dp),
intent(in) :: dt
208 real(dp),
intent(in) :: dt_stiff
209 real(dp),
intent(inout) :: dt_lim
210 real(dp),
intent(in) :: time
211 integer,
intent(in) :: s_deriv
212 integer,
intent(in) :: n_prev
213 integer,
intent(in) :: s_prev(n_prev)
214 real(dp),
intent(in) :: w_prev(n_prev)
215 integer,
intent(in) :: s_out
216 integer,
intent(in) :: i_step
217 integer,
intent(in) :: n_steps
218 real(dp) :: dt_dummy(0)
221 gas_fluxes, dt_lim, max_wavespeed, get_fluxes, &
222 flux_dummy_modify, flux_dummy_line_modify, to_primitive, &
223 to_conservative, af_limiter_vanleer_t)
224 if (tree%coord_t == af_cyl)
then
227 add_geometric_source, 0, dt_dummy)
231 flux_dummy_source, 0, dt_dummy)
237 subroutine add_geometric_source(box, dt, n_vars, i_cc, s_deriv, s_out, &
239 type(box_t),
intent(inout) :: box
240 real(dp),
intent(in) :: dt
241 integer,
intent(in) :: n_vars
242 integer,
intent(in) :: i_cc(n_vars)
243 integer,
intent(in) :: s_deriv
244 integer,
intent(in) :: s_out
245 logical,
intent(in) :: mask(dtimes(box%n_cell))
246 integer,
intent(in) :: n_dt
247 real(dp),
intent(inout) :: dt_lim(n_dt)
250 real(dp) :: pressure(dtimes(box%n_cell))
251 real(dp) :: inv_radius
255 pressure = get_pressure(box, s_deriv)
258 inv_radius = 1/af_cyl_radius_cc(box, i)
260 box%cc(i, 1:nc, i_cc(
i_mom(1))+s_out) = &
261 box%cc(i, 1:nc, i_cc(
i_mom(1))+s_out) + dt * &
262 pressure(i, :) * inv_radius
266 end subroutine add_geometric_source
269 pure function get_pressure(box, s_in)
result(pressure)
270 type(box_t),
intent(in) :: box
271 integer,
intent(in) :: s_in
272 real(dp) :: pressure(dtimes(box%n_cell))
277 box%cc(dtimes(1:nc),
gas_vars(
i_e)+s_in) - 0.5_dp * &
278 sum(box%cc(dtimes(1:nc),
gas_vars(
i_mom)+s_in)**2, dim=ndim+1) / &
280 end function get_pressure
285 character(len=*),
intent(in) :: name
292 subroutine to_primitive(n_values, n_vars, u)
293 integer,
intent(in) :: n_values, n_vars
294 real(dp),
intent(inout) :: u(n_values, n_vars)
302 0.5_dp*u(:,
i_rho)* sum(u(:,
i_mom(:))**2, dim=2))
303 end subroutine to_primitive
305 subroutine to_conservative(n_values, n_vars, u)
306 integer,
intent(in) :: n_values, n_vars
307 real(dp),
intent(inout) :: u(n_values, n_vars)
308 real(dp) :: kin_en(n_values)
313 kin_en = 0.5_dp * u(:,
i_rho) * sum(u(:,
i_mom(:))**2, dim=2)
317 u(:,
i_e) = u(:,
i_e) * inv_fac + kin_en
323 end subroutine to_conservative
325 subroutine max_wavespeed(n_values, n_var, flux_dim, u, w)
326 integer,
intent(in) :: n_values
327 integer,
intent(in) :: n_var
328 integer,
intent(in) :: flux_dim
329 real(dp),
intent(in) :: u(n_values, n_var)
330 real(dp),
intent(out) :: w(n_values)
331 real(dp) :: sound_speeds(n_values)
334 w = sound_speeds + abs(u(:,
i_mom(flux_dim)))
335 end subroutine max_wavespeed
337 subroutine get_fluxes(n_values, n_var, flux_dim, u, flux, box, line_ix, s_deriv)
338 integer,
intent(in) :: n_values
339 integer,
intent(in) :: n_var
340 integer,
intent(in) :: flux_dim
341 real(dp),
intent(in) :: u(n_values, n_var)
342 real(dp),
intent(out) :: flux(n_values, n_var)
343 type(box_t),
intent(in) :: box
344 integer,
intent(in) :: line_ix(ndim-1)
345 integer,
intent(in) :: s_deriv
346 real(dp) :: e(n_values), inv_fac
362 flux(:,
i_mom(flux_dim)) = flux(:,
i_mom(flux_dim)) + u(:,
i_e)
366 e = u(:,
i_e) * inv_fac + 0.5_dp * u(:,
i_rho) * &
367 sum(u(:,
i_mom(:))**2, dim=2)
370 flux(:,
i_e) = u(:,
i_mom(flux_dim)) * (e + u(:,
i_e))
372 end subroutine get_fluxes
375 subroutine bc_radial_momentum(box, nb, iv, coords, bc_val, bc_type)
376 type(box_t),
intent(in) :: box
377 integer,
intent(in) :: nb
378 integer,
intent(in) :: iv
379 real(dp),
intent(in) :: coords(ndim, box%n_cell**(ndim-1))
380 real(dp),
intent(out) :: bc_val(box%n_cell**(ndim-1))
381 integer,
intent(out) :: bc_type
383 if (nb == af_neighb_lowx)
then
386 bc_type = af_bc_dirichlet
389 bc_type = af_bc_neumann
392 end subroutine bc_radial_momentum
Module to set the time step.
integer, public, protected time_integrator
Which time integrator is used.
Module that stores parameters related to the gas.
character(len=comp_len), dimension(:), allocatable, public, protected gas_components
real(dp), public, protected gas_molecular_weight
real(dp), public, protected gas_euler_gamma
subroutine, public gas_forward_euler(tree, dt, dt_stiff, dt_lim, time, s_deriv, n_prev, s_prev, w_prev, s_out, i_step, n_steps)
A forward-Euler method for the Euler equations.
integer, dimension(n_vars_euler+1), public, protected gas_prim_vars
elemental integer function, public gas_index(name)
Find index of a gas component, return -1 if not found.
real(dp), dimension(:), allocatable, public, protected gas_fractions
logical, public, protected gas_dynamics
Whether the gas dynamics are simulated.
integer, public, protected i_gas_dens
real(dp), public, protected gas_temperature
integer, dimension(ndim), parameter, public i_mom
real(dp), public, protected gas_heating_efficiency
integer, dimension(n_vars_euler), public, protected gas_fluxes
real(dp), parameter, public townsend_to_si
real(dp), parameter, public si_to_townsend
real(dp), public, protected gas_pressure
real(dp), dimension(:), allocatable, public, protected gas_densities
integer, dimension(n_vars_euler), public, protected gas_vars
real(dp), public, protected gas_fraction_slow_heating
integer, parameter, public i_e
logical, public, protected gas_constant_density
Whether the gas has a constant density.
integer, public, protected i_vibration_energy
integer, parameter, public i_rho
real(dp), public, protected gas_vt_time
Vibration-Translation relaxation time (s)
character(len=name_len), dimension(n_vars_euler), public, protected gas_var_names
integer, parameter, public n_vars_euler
real(dp), public, protected gas_ehd_factor
subroutine, public gas_initialize(tree, cfg)
Initialize this module.
real(dp), public, protected gas_number_density
real(dp), public, protected gas_inverse_number_density
Module that contains physical and numerical constants.
real(dp), parameter uc_boltzmann_const
real(dp), parameter uc_atomic_mass
This module contains all the methods that users can customize.
procedure(gas_dens_func), pointer user_gas_density
To set a user-defined gas number density.