Skip to content

Commit 3d91876

Browse files
authored
Merge pull request #30 from keniley1/master
Adding kernels for electron-impact reactions under the Townsend formulation
2 parents f750d60 + 0b9c77f commit 3d91876

14 files changed

+885
-61
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//* This file is part of Zapdos, an open-source
2+
//* application for the simulation of plasmas
3+
//* https://github.com/shannon-lab/zapdos
4+
//*
5+
//* Zapdos is powered by the MOOSE Framework
6+
//* https://www.mooseframework.org
7+
//*
8+
//* Licensed under LGPL 2.1, please see LICENSE for details
9+
//* https://www.gnu.org/licenses/lgpl-2.1.html
10+
11+
#ifndef ELECTRONENERGYTERMELASTICTOWNSEND_H
12+
#define ELECTRONENERGYTERMELASTICTOWNSEND_H
13+
14+
#include "Kernel.h"
15+
16+
class ElectronEnergyTermElasticTownsend;
17+
18+
template <>
19+
InputParameters validParams<ElectronEnergyTermElasticTownsend>();
20+
21+
class ElectronEnergyTermElasticTownsend : public Kernel
22+
{
23+
public:
24+
ElectronEnergyTermElasticTownsend(const InputParameters & parameters);
25+
virtual ~ElectronEnergyTermElasticTownsend();
26+
27+
protected:
28+
virtual Real computeQpResidual();
29+
virtual Real computeQpJacobian();
30+
virtual Real computeQpOffDiagJacobian(unsigned int jvar);
31+
32+
Real _r_units;
33+
std::string _reaction_coeff_name;
34+
const MaterialProperty<Real> & _diffem;
35+
const MaterialProperty<Real> & _muem;
36+
const MaterialProperty<Real> & _alpha;
37+
const MaterialProperty<Real> & _d_iz_d_actual_mean_en;
38+
const MaterialProperty<Real> & _d_muem_d_actual_mean_en;
39+
const MaterialProperty<Real> & _d_diffem_d_actual_mean_en;
40+
// const MaterialProperty<Real> & _massem;
41+
const MaterialProperty<Real> & _massGas;
42+
const MaterialProperty<Real> & _d_el_d_actual_mean_en;
43+
44+
const VariableGradient & _grad_potential;
45+
const VariableValue & _em;
46+
const VariableGradient & _grad_em;
47+
unsigned int _potential_id;
48+
unsigned int _em_id;
49+
Real _massem;
50+
};
51+
52+
#endif /* ELECTRONENERGYLOSSFROMELASTIC_H */
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/****************************************************************/
2+
/* DO NOT MODIFY THIS HEADER */
3+
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
4+
/* */
5+
/* (c) 2010 Battelle Energy Alliance, LLC */
6+
/* ALL RIGHTS RESERVED */
7+
/* */
8+
/* Prepared by Battelle Energy Alliance, LLC */
9+
/* Under Contract No. DE-AC07-05ID14517 */
10+
/* With the U. S. Department of Energy */
11+
/* */
12+
/* See COPYRIGHT for full restrictions */
13+
/****************************************************************/
14+
15+
#ifndef ELECTRONENERGYTERMTOWNSEND_H
16+
#define ELECTRONENERGYTERMTOWNSEND_H
17+
18+
#include "Kernel.h"
19+
20+
class ElectronEnergyTermTownsend;
21+
22+
template <>
23+
InputParameters validParams<ElectronEnergyTermTownsend>();
24+
25+
class ElectronEnergyTermTownsend : public Kernel
26+
{
27+
public:
28+
ElectronEnergyTermTownsend(const InputParameters & parameters);
29+
virtual ~ElectronEnergyTermTownsend();
30+
31+
protected:
32+
virtual Real computeQpResidual();
33+
virtual Real computeQpJacobian();
34+
virtual Real computeQpOffDiagJacobian(unsigned int jvar);
35+
36+
Real _r_units;
37+
38+
bool _elastic;
39+
Real _threshold_energy;
40+
const MaterialProperty<Real> & _elastic_energy;
41+
const MaterialProperty<Real> & _diffem;
42+
const MaterialProperty<Real> & _muem;
43+
const MaterialProperty<Real> & _alpha;
44+
const MaterialProperty<Real> & _d_iz_d_actual_mean_en;
45+
const MaterialProperty<Real> & _d_muem_d_actual_mean_en;
46+
const MaterialProperty<Real> & _d_diffem_d_actual_mean_en;
47+
48+
const VariableGradient & _grad_potential;
49+
const VariableValue & _em;
50+
const VariableGradient & _grad_em;
51+
unsigned int _potential_id;
52+
unsigned int _em_id;
53+
54+
Real _energy_change;
55+
};
56+
57+
#endif /* ELECTRONENERGYTERMTOWNSEND_H */
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/****************************************************************/
2+
/* DO NOT MODIFY THIS HEADER */
3+
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
4+
/* */
5+
/* (c) 2010 Battelle Energy Alliance, LLC */
6+
/* ALL RIGHTS RESERVED */
7+
/* */
8+
/* Prepared by Battelle Energy Alliance, LLC */
9+
/* Under Contract No. DE-AC07-05ID14517 */
10+
/* With the U. S. Department of Energy */
11+
/* */
12+
/* See COPYRIGHT for full restrictions */
13+
/****************************************************************/
14+
15+
#ifndef ELECTRONIMPACTREACTIONPRODUCT_H
16+
#define ELECTRONIMPACTREACTIONPRODUCT_H
17+
18+
#include "Kernel.h"
19+
20+
class ElectronImpactReactionProduct;
21+
22+
template <>
23+
InputParameters validParams<ElectronImpactReactionProduct>();
24+
25+
class ElectronImpactReactionProduct : public Kernel
26+
{
27+
public:
28+
ElectronImpactReactionProduct(const InputParameters & parameters);
29+
virtual ~ElectronImpactReactionProduct();
30+
31+
protected:
32+
virtual Real computeQpResidual();
33+
virtual Real computeQpJacobian();
34+
virtual Real computeQpOffDiagJacobian(unsigned int jvar);
35+
36+
Real _r_units;
37+
std::string _reaction_coeff_name;
38+
std::string _reaction_name;
39+
40+
const MaterialProperty<Real> & _diffem;
41+
const MaterialProperty<Real> & _muem;
42+
const MaterialProperty<Real> & _alpha;
43+
const MaterialProperty<Real> & _d_iz_d_actual_mean_en;
44+
const MaterialProperty<Real> & _d_muem_d_actual_mean_en;
45+
const MaterialProperty<Real> & _d_diffem_d_actual_mean_en;
46+
47+
const VariableValue & _mean_en;
48+
const VariableGradient & _grad_potential;
49+
const VariableValue & _em;
50+
const VariableGradient & _grad_em;
51+
unsigned int _mean_en_id;
52+
unsigned int _potential_id;
53+
unsigned int _em_id;
54+
};
55+
56+
#endif /* ELECTRONIMPACTREACTIONPRODUCT_H */
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/****************************************************************/
2+
/* DO NOT MODIFY THIS HEADER */
3+
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
4+
/* */
5+
/* (c) 2010 Battelle Energy Alliance, LLC */
6+
/* ALL RIGHTS RESERVED */
7+
/* */
8+
/* Prepared by Battelle Energy Alliance, LLC */
9+
/* Under Contract No. DE-AC07-05ID14517 */
10+
/* With the U. S. Department of Energy */
11+
/* */
12+
/* See COPYRIGHT for full restrictions */
13+
/****************************************************************/
14+
15+
#ifndef ELECTRONIMPACTREACTIONREACTANT_H
16+
#define ELECTRONIMPACTREACTIONREACTANT_H
17+
18+
#include "Kernel.h"
19+
20+
class ElectronImpactReactionReactant;
21+
22+
template <>
23+
InputParameters validParams<ElectronImpactReactionReactant>();
24+
25+
class ElectronImpactReactionReactant : public Kernel
26+
{
27+
public:
28+
ElectronImpactReactionReactant(const InputParameters & parameters);
29+
virtual ~ElectronImpactReactionReactant();
30+
31+
protected:
32+
virtual Real computeQpResidual();
33+
virtual Real computeQpJacobian();
34+
virtual Real computeQpOffDiagJacobian(unsigned int jvar);
35+
36+
Real _r_units;
37+
std::string _reaction_coeff_name;
38+
std::string _reaction_name;
39+
40+
const MaterialProperty<Real> & _diffem;
41+
const MaterialProperty<Real> & _muem;
42+
const MaterialProperty<Real> & _alpha;
43+
const MaterialProperty<Real> & _d_iz_d_actual_mean_en;
44+
const MaterialProperty<Real> & _d_muem_d_actual_mean_en;
45+
const MaterialProperty<Real> & _d_diffem_d_actual_mean_en;
46+
47+
const VariableValue & _mean_en;
48+
const VariableGradient & _grad_potential;
49+
const VariableValue & _em;
50+
const VariableGradient & _grad_em;
51+
unsigned int _mean_en_id;
52+
unsigned int _potential_id;
53+
unsigned int _em_id;
54+
};
55+
56+
#endif /* ELECTRONIMPACTREACTIONREACTANT_H */

include/kernels/ElectronReactantSecondOrderLog.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,5 @@ class ElectronReactantSecondOrderLog : public Kernel
4444
const MaterialProperty<Real> & _n_gas;
4545
Real _stoichiometric_coeff;
4646
bool _v_eq_electron;
47-
4847
};
4948
#endif // ELECTRONREACTANTSECONDORDERLOG_H

include/materials/EEDFRateConstantTownsend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class EEDFRateConstantTownsend : public Material
4343
MaterialProperty<unsigned int> & _d_alpha_d_var_id;
4444
MaterialProperty<bool> & _target_coupled;
4545
bool _is_target_aux;
46-
const MaterialProperty<Real> & _n_gas;
46+
// const MaterialProperty<Real> & _n_gas;
4747
const MaterialProperty<Real> & _massIncident;
4848
const MaterialProperty<Real> & _massTarget;
4949

src/actions/AddZapdosReactions.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ AddZapdosReactions::act()
552552
InputParameters params = _factory.getValidParams(reactant_kernel_name);
553553
params.set<NonlinearVariableName>("variable") = _species[j];
554554
params.set<Real>("coefficient") = _species_count[i][j];
555-
// std::cout << getParam<std::vector<SubdomainName>>("block")[0] << ", " << _species_count[i][j] << std::endl;
556-
// mooseError("TESTING");
555+
// std::cout << getParam<std::vector<SubdomainName>>("block")[0] << ", " <<
556+
// _species_count[i][j] << std::endl; mooseError("TESTING");
557557
params.set<std::string>("reaction") = _reaction[i];
558558
if (find_other || find_aux)
559559
{
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
//* This file is part of CRANE, an open-source
2+
//* application for the simulation of plasmas
3+
//* https://github.com/lcpp-org/crane
4+
//*
5+
//* CRANE is powered by the MOOSE Framework
6+
//* https://www.mooseframework.org
7+
//*
8+
//* Licensed under LGPL 2.1, please see LICENSE for details
9+
//* https://www.gnu.org/licenses/lgpl-2.1.html
10+
11+
#include "ElectronEnergyTermElasticTownsend.h"
12+
13+
registerMooseObject("CraneApp", ElectronEnergyTermElasticTownsend);
14+
15+
template <>
16+
InputParameters
17+
validParams<ElectronEnergyTermElasticTownsend>()
18+
{
19+
InputParameters params = validParams<Kernel>();
20+
params.addRequiredCoupledVar("potential", "The potential.");
21+
params.addRequiredCoupledVar("electron_species", "The electron density.");
22+
params.addRequiredCoupledVar("target_species", "The target species variable.");
23+
params.addRequiredParam<std::string>("reaction",
24+
"Stores the name of the reaction (townsend) coefficient, "
25+
"unique to each individual reaction.");
26+
params.addRequiredParam<Real>("position_units", "Units of position.");
27+
return params;
28+
}
29+
30+
ElectronEnergyTermElasticTownsend::ElectronEnergyTermElasticTownsend(
31+
const InputParameters & parameters)
32+
: Kernel(parameters),
33+
_r_units(1. / getParam<Real>("position_units")),
34+
_diffem(getMaterialProperty<Real>("diffem")),
35+
_muem(getMaterialProperty<Real>("muem")),
36+
_alpha(getMaterialProperty<Real>("alpha_" + getParam<std::string>("reaction"))),
37+
_d_iz_d_actual_mean_en(getMaterialProperty<Real>("d_iz_d_actual_mean_en")),
38+
_d_muem_d_actual_mean_en(getMaterialProperty<Real>("d_muem_d_actual_mean_en")),
39+
_d_diffem_d_actual_mean_en(getMaterialProperty<Real>("d_diffem_d_actual_mean_en")),
40+
// _massem(getMaterialProperty<Real>("mass" + (*getVar("electron_species",0)).name())),
41+
_massGas(getMaterialProperty<Real>("mass" + (*getVar("target_species", 0)).name())),
42+
_d_el_d_actual_mean_en(getMaterialProperty<Real>("d_el_d_actual_mean_en")),
43+
_grad_potential(coupledGradient("potential")),
44+
_em(coupledValue("electron_species")),
45+
_grad_em(coupledGradient("electron_species")),
46+
_potential_id(coupled("potential")),
47+
_em_id(coupled("electron_species"))
48+
{
49+
_massem = 9.11e-31;
50+
}
51+
52+
ElectronEnergyTermElasticTownsend::~ElectronEnergyTermElasticTownsend() {}
53+
54+
Real
55+
ElectronEnergyTermElasticTownsend::computeQpResidual()
56+
{
57+
Real electron_flux_mag = (-_muem[_qp] * -_grad_potential[_qp] * _r_units * std::exp(_em[_qp]) -
58+
_diffem[_qp] * std::exp(_em[_qp]) * _grad_em[_qp] * _r_units)
59+
.norm();
60+
Real Eel = -3.0 * _massem / _massGas[_qp] * 2.0 / 3 * std::exp(_u[_qp] - _em[_qp]);
61+
Real el_term = _alpha[_qp] * electron_flux_mag * Eel;
62+
63+
return -_test[_i][_qp] * el_term;
64+
}
65+
66+
Real
67+
ElectronEnergyTermElasticTownsend::computeQpJacobian()
68+
{
69+
Real d_actual_mean_en_d_mean_en = std::exp(_u[_qp] - _em[_qp]) * _phi[_j][_qp];
70+
Real d_el_d_mean_en = _d_el_d_actual_mean_en[_qp] * d_actual_mean_en_d_mean_en;
71+
Real d_muem_d_mean_en = _d_muem_d_actual_mean_en[_qp] * d_actual_mean_en_d_mean_en;
72+
Real d_diffem_d_mean_en = _d_diffem_d_actual_mean_en[_qp] * d_actual_mean_en_d_mean_en;
73+
74+
RealVectorValue electron_flux =
75+
-_muem[_qp] * -_grad_potential[_qp] * _r_units * std::exp(_em[_qp]) -
76+
_diffem[_qp] * std::exp(_em[_qp]) * _grad_em[_qp] * _r_units;
77+
RealVectorValue d_electron_flux_d_mean_en =
78+
-d_muem_d_mean_en * -_grad_potential[_qp] * _r_units * std::exp(_em[_qp]) -
79+
d_diffem_d_mean_en * std::exp(_em[_qp]) * _grad_em[_qp] * _r_units;
80+
Real electron_flux_mag = electron_flux.norm();
81+
Real d_electron_flux_mag_d_mean_en = electron_flux * d_electron_flux_d_mean_en /
82+
(electron_flux_mag + std::numeric_limits<double>::epsilon());
83+
84+
Real Eel = -3.0 * _massem / _massGas[_qp] * 2.0 / 3 * std::exp(_u[_qp] - _em[_qp]);
85+
Real d_Eel_d_mean_en =
86+
-3.0 * _massem / _massGas[_qp] * 2.0 / 3 * std::exp(_u[_qp] - _em[_qp]) * _phi[_j][_qp];
87+
Real d_el_term_d_mean_en =
88+
(electron_flux_mag * d_el_d_mean_en + _alpha[_qp] * d_electron_flux_mag_d_mean_en) * Eel +
89+
electron_flux_mag * _alpha[_qp] * d_Eel_d_mean_en;
90+
91+
return -_test[_i][_qp] * d_el_term_d_mean_en;
92+
}
93+
94+
Real
95+
ElectronEnergyTermElasticTownsend::computeQpOffDiagJacobian(unsigned int jvar)
96+
{
97+
Real d_actual_mean_en_d_em = -std::exp(_u[_qp] - _em[_qp]) * _phi[_j][_qp];
98+
Real d_el_d_em = _d_el_d_actual_mean_en[_qp] * d_actual_mean_en_d_em;
99+
Real d_muem_d_em = _d_muem_d_actual_mean_en[_qp] * d_actual_mean_en_d_em;
100+
Real d_diffem_d_em = _d_diffem_d_actual_mean_en[_qp] * d_actual_mean_en_d_em;
101+
102+
RealVectorValue electron_flux =
103+
-_muem[_qp] * -_grad_potential[_qp] * _r_units * std::exp(_em[_qp]) -
104+
_diffem[_qp] * std::exp(_em[_qp]) * _grad_em[_qp] * _r_units;
105+
RealVectorValue d_electron_flux_d_potential =
106+
-_muem[_qp] * -_grad_phi[_j][_qp] * _r_units * std::exp(_em[_qp]);
107+
RealVectorValue d_electron_flux_d_em =
108+
-d_muem_d_em * -_grad_potential[_qp] * _r_units * std::exp(_em[_qp]) -
109+
_muem[_qp] * -_grad_potential[_qp] * _r_units * std::exp(_em[_qp]) * _phi[_j][_qp] -
110+
d_diffem_d_em * std::exp(_em[_qp]) * _grad_em[_qp] * _r_units -
111+
_diffem[_qp] * std::exp(_em[_qp]) * _phi[_j][_qp] * _grad_em[_qp] * _r_units -
112+
_diffem[_qp] * std::exp(_em[_qp]) * _grad_phi[_j][_qp] * _r_units;
113+
Real electron_flux_mag = electron_flux.norm();
114+
Real d_electron_flux_mag_d_potential =
115+
electron_flux * d_electron_flux_d_potential /
116+
(electron_flux_mag + std::numeric_limits<double>::epsilon());
117+
Real d_electron_flux_mag_d_em = electron_flux * d_electron_flux_d_em /
118+
(electron_flux_mag + std::numeric_limits<double>::epsilon());
119+
120+
Real Eel = -3.0 * _massem / _massGas[_qp] * 2.0 / 3 * std::exp(_u[_qp] - _em[_qp]);
121+
Real d_Eel_d_em =
122+
-3.0 * _massem / _massGas[_qp] * 2.0 / 3 * std::exp(_u[_qp] - _em[_qp]) * -_phi[_j][_qp];
123+
Real d_Eel_d_potential = 0.0;
124+
Real d_el_term_d_em =
125+
(electron_flux_mag * d_el_d_em + _alpha[_qp] * d_electron_flux_mag_d_em) * Eel +
126+
electron_flux_mag * _alpha[_qp] * d_Eel_d_em;
127+
Real d_el_term_d_potential = (_alpha[_qp] * d_electron_flux_mag_d_potential) * Eel +
128+
electron_flux_mag * _alpha[_qp] * d_Eel_d_potential;
129+
130+
if (jvar == _potential_id)
131+
return -_test[_i][_qp] * d_el_term_d_potential;
132+
133+
else if (jvar == _em_id)
134+
return -_test[_i][_qp] * d_el_term_d_em;
135+
136+
else
137+
return 0.0;
138+
}

0 commit comments

Comments
 (0)