Coverage for tcvx21/grillix_post/observables/heat_flux_m.py: 100%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2Routines to calculate the heat flux profile and lambda_q
3"""
6def electron_parallel_heat_conduction(electron_temp, electron_temp_parallel_gradient, norm):
7 """
8 Electron parallel heat conduction to the boundaries
9 Equivalent to
10 3.16 * density * electron_temp / (nu_ee * electron_mass) * parallel_grad(Te)
11 with nu_ee the electron-electron collision rate
12 """
14 value = -norm.chipar_e \
15 * electron_temp ** 2.5 \
16 * electron_temp_parallel_gradient
18 return value.assign_attrs(norm=(norm.n0 * norm.c_s0 * norm.Te0).to('MW/m^2'))
21def ion_parallel_heat_conduction(ion_temp, ion_temp_parallel_gradient, norm):
22 """
23 Ion parallel heat conduction to the boundaries
24 Equivalent to
25 3.9 * density * ion_temp / (nu_ee * ion_mass) * parallel_grad(Ti)
26 with nu_ee the ion-ion collision rate
27 """
29 value = -norm.chipar_i \
30 * ion_temp ** 2.5 \
31 * ion_temp_parallel_gradient
33 return value.assign_attrs(norm=(norm.n0 * norm.c_s0 * norm.Ti0).to('MW/m^2'))
36def electron_parallel_velocity(ion_velocity, current, density, norm):
37 """
38 Electron velocity parallel to the field
39 """
41 return ion_velocity - current / (norm.Z * density)
44def electron_parallel_heat_convection(density, electron_temp, ion_velocity, current, norm):
45 """
46 Electron parallel heat flux to the boundaries due to electron advection
47 5/2 density * electron_velocity * electron_temp
48 """
50 vpar = electron_parallel_velocity(ion_velocity, current, density, norm)
52 return (2.5 * density * electron_temp * vpar).assign_attrs(
53 norm=(norm.n0 * norm.c_s0 * norm.Te0).to('MW/m^2'))
56def ion_parallel_heat_convection(density, ion_temp, ion_velocity, norm):
57 """
58 Ion parallel heat flux to the boundaries due to ion advection
59 5/2 density * ion_velocity * ion_temp
60 """
62 return (2.5 * density * ion_temp * ion_velocity).assign_attrs(
63 norm=(norm.n0 * norm.c_s0 * norm.Ti0).to('MW/m^2'))
66def exb_effective_parallel_heat_convection(density, temperature, effective_parallel_exb_velocity, norm):
67 """
68 The effective parallel heat convection due to the ExB velocity (computed as the poloidal ExB component multiplied
69 by the inverse magnetic field pitch)
70 """
71 return (2.5 * density * temperature * effective_parallel_exb_velocity).assign_attrs(
72 norm=(norm.n0 * norm.c_s0 * temperature.norm).to('MW/m^2'))
75def total_parallel_electron_heat_flux(density, electron_temp, electron_temp_parallel_gradient, ion_velocity,
76 current, effective_parallel_exb_velocity, norm):
77 """
78 Sum of the conductive and convective components of the electron parallel heat flux to the boundaries
79 """
80 return electron_parallel_heat_conduction(electron_temp, electron_temp_parallel_gradient, norm) \
81 + electron_parallel_heat_convection(density, electron_temp, ion_velocity, current, norm) \
82 + exb_effective_parallel_heat_convection(density, electron_temp, effective_parallel_exb_velocity, norm)
85def total_parallel_ion_heat_flux(density, ion_temp, ion_temp_parallel_gradient, ion_velocity,
86 effective_parallel_exb_velocity, norm):
87 """
88 Sum of the conductive and convective components of the ion parallel heat flux to the boundaries
89 """
90 return ion_parallel_heat_conduction(ion_temp, ion_temp_parallel_gradient, norm) \
91 + ion_parallel_heat_convection(density, ion_temp, ion_velocity, norm) \
92 + exb_effective_parallel_heat_convection(density, ion_temp, effective_parallel_exb_velocity, norm)
95def total_parallel_heat_flux(density, electron_temp, electron_temp_parallel_gradient,
96 ion_temp, ion_temp_parallel_gradient,
97 ion_velocity, current, effective_parallel_exb_velocity, norm):
98 """
99 Total heat flux -- sum of the electron and ion heat fluxes
100 """
101 electron_heat_flux = total_parallel_electron_heat_flux(density, electron_temp, electron_temp_parallel_gradient,
102 ion_velocity, current, effective_parallel_exb_velocity, norm)
103 ion_heat_flux = total_parallel_ion_heat_flux(density, ion_temp, ion_temp_parallel_gradient, ion_velocity,
104 effective_parallel_exb_velocity, norm)
106 return electron_heat_flux + ion_heat_flux