Skip to content

Commit ba6fbfb

Browse files
committed
Adding comsol BCs
1 parent cf5a295 commit ba6fbfb

10 files changed

+608
-0
lines changed

include/bcs/ADComsolElectronBC.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
#pragma once
12+
13+
#include "ADIntegratedBC.h"
14+
15+
// Forward Declarations
16+
class ADComsolElectronBC;
17+
18+
declareADValidParams(ADComsolElectronBC);
19+
20+
class ADComsolElectronBC : public ADIntegratedBC
21+
{
22+
public:
23+
static InputParameters validParams();
24+
ADComsolElectronBC(const InputParameters & parameters);
25+
26+
protected:
27+
virtual ADReal computeQpResidual() override;
28+
29+
Real _r_units;
30+
Real _r;
31+
32+
// Coupled variables
33+
34+
const ADVariableGradient & _grad_potential;
35+
const ADVariableValue & _mean_en;
36+
37+
const ADMaterialProperty<Real> & _muem;
38+
const MaterialProperty<Real> & _massem;
39+
const MaterialProperty<Real> & _e;
40+
41+
Real _a;
42+
ADReal _v_thermal;
43+
44+
};

include/bcs/ADComsolEnergyBC.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
#pragma once
12+
13+
#include "ADIntegratedBC.h"
14+
15+
// Forward Declarations
16+
class ADComsolEnergyBC;
17+
18+
declareADValidParams(ADComsolEnergyBC);
19+
20+
class ADComsolEnergyBC : public ADIntegratedBC
21+
{
22+
public:
23+
static InputParameters validParams();
24+
ADComsolEnergyBC(const InputParameters & parameters);
25+
26+
protected:
27+
virtual ADReal computeQpResidual() override;
28+
29+
Real _r_units;
30+
Real _r;
31+
32+
const ADVariableGradient & _grad_potential;
33+
const ADVariableValue & _em;
34+
35+
const MaterialProperty<Real> & _massem;
36+
const MaterialProperty<Real> & _e;
37+
38+
ADReal _v_thermal;
39+
40+
};

include/bcs/ADComsolIonBC.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
#pragma once
12+
13+
#include "ADIntegratedBC.h"
14+
15+
// Forward Declarations
16+
class ADComsolIonBC;
17+
18+
declareADValidParams(ADComsolIonBC);
19+
20+
class ADComsolIonBC : public ADIntegratedBC
21+
{
22+
public:
23+
static InputParameters validParams();
24+
ADComsolIonBC(const InputParameters & parameters);
25+
26+
protected:
27+
virtual ADReal computeQpResidual() override;
28+
29+
Real _r_units;
30+
Real _r;
31+
32+
// Coupled variables
33+
34+
const ADVariableGradient & _grad_potential;
35+
36+
const ADMaterialProperty<Real> & _mu;
37+
const MaterialProperty<Real> & _e;
38+
const MaterialProperty<Real> & _sgn;
39+
const MaterialProperty<Real> & _kb;
40+
const ADMaterialProperty<Real> & _T;
41+
const MaterialProperty<Real> & _mass;
42+
43+
Real _a;
44+
45+
ADReal _v_thermal;
46+
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
#pragma once
12+
13+
#include "ADIntegratedBC.h"
14+
15+
// Forward Declarations
16+
class ADComsolSecondaryElectronBC;
17+
18+
declareADValidParams(ADComsolSecondaryElectronBC);
19+
20+
class ADComsolSecondaryElectronBC : public ADIntegratedBC
21+
{
22+
public:
23+
static InputParameters validParams();
24+
ADComsolSecondaryElectronBC(const InputParameters & parameters);
25+
26+
protected:
27+
virtual ADReal computeQpResidual() override;
28+
29+
Real _r_units;
30+
Real _r;
31+
Real _r_ion;
32+
const MaterialProperty<Real> & _kb;
33+
34+
// Coupled variables
35+
36+
const ADVariableGradient & _grad_potential;
37+
const ADVariableValue & _mean_en;
38+
std::vector<const ADVariableValue *> _ip;
39+
std::vector<const ADVariableGradient *> _grad_ip;
40+
41+
const ADMaterialProperty<Real> & _muem;
42+
const MaterialProperty<Real> & _massem;
43+
const MaterialProperty<Real> & _e;
44+
std::vector<const MaterialProperty<Real> *> _sgnip;
45+
std::vector<const ADMaterialProperty<Real> *> _muip;
46+
std::vector<const ADMaterialProperty<Real> *> _Tip;
47+
std::vector<const MaterialProperty<Real> *> _massip;
48+
const MaterialProperty<Real> & _se_coeff;
49+
50+
Real _b;
51+
ADReal _ion_flux;
52+
53+
unsigned int _num_ions;
54+
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
#pragma once
12+
13+
#include "ADIntegratedBC.h"
14+
15+
// Forward Declarations
16+
class ADComsolSecondaryElectronEnergyBC;
17+
18+
declareADValidParams(ADComsolSecondaryElectronEnergyBC);
19+
20+
class ADComsolSecondaryElectronEnergyBC : public ADIntegratedBC
21+
{
22+
public:
23+
static InputParameters validParams();
24+
ADComsolSecondaryElectronEnergyBC(const InputParameters & parameters);
25+
26+
protected:
27+
virtual ADReal computeQpResidual() override;
28+
29+
Real _r_units;
30+
Real _r;
31+
Real _r_ion;
32+
const MaterialProperty<Real> & _kb;
33+
34+
// Coupled variables
35+
36+
const ADVariableGradient & _grad_potential;
37+
const ADVariableValue & _em;
38+
std::vector<const ADVariableValue *> _ip;
39+
std::vector<const ADVariableGradient *> _grad_ip;
40+
41+
const MaterialProperty<Real> & _massem;
42+
const MaterialProperty<Real> & _e;
43+
std::vector<const MaterialProperty<Real> *> _sgnip;
44+
std::vector<const ADMaterialProperty<Real> *> _muip;
45+
std::vector<const ADMaterialProperty<Real> *> _Tip;
46+
std::vector<const MaterialProperty<Real> *> _massip;
47+
const MaterialProperty<Real> & _se_coeff;
48+
const MaterialProperty<Real> & _se_energy;
49+
50+
Real _b;
51+
ADReal _ion_flux;
52+
53+
unsigned int _num_ions;
54+
};

src/bcs/ADComsolElectronBC.C

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
#include "ADComsolElectronBC.h"
12+
13+
registerADMooseObject("ZapdosApp", ADComsolElectronBC);
14+
15+
defineADLegacyParams(ADComsolElectronBC);
16+
17+
InputParameters
18+
ADComsolElectronBC::validParams()
19+
{
20+
InputParameters params = ADIntegratedBC::validParams();
21+
params.addRequiredParam<Real>("r", "The reflection coefficient");
22+
params.addRequiredCoupledVar("potential", "The electric potential");
23+
params.addRequiredCoupledVar("mean_en", "The mean energy.");
24+
params.addRequiredParam<Real>("position_units", "Units of position.");
25+
params.addClassDescription("Kinetic electron boundary condition"
26+
"(Based on DOI:https://doi.org/10.1103/PhysRevE.62.1452)");
27+
return params;
28+
}
29+
30+
ADComsolElectronBC::ADComsolElectronBC(const InputParameters & parameters)
31+
: ADIntegratedBC(parameters),
32+
_r_units(1. / getParam<Real>("position_units")),
33+
_r(getParam<Real>("r")),
34+
35+
// Coupled Variables
36+
_grad_potential(adCoupledGradient("potential")),
37+
_mean_en(adCoupledValue("mean_en")),
38+
39+
_muem(getADMaterialProperty<Real>("muem")),
40+
_massem(getMaterialProperty<Real>("massem")),
41+
_e(getMaterialProperty<Real>("e"))
42+
{
43+
_a = 0.0;
44+
_v_thermal = 0.0;
45+
}
46+
47+
ADReal
48+
ADComsolElectronBC::computeQpResidual()
49+
{
50+
_v_thermal =
51+
std::sqrt(8 * _e[_qp] * 2.0 / 3 * std::exp(_mean_en[_qp] - _u[_qp]) / (M_PI * _massem[_qp]));
52+
53+
return _test[_i][_qp] * _r_units * (1. - _r) / (1. + _r) * (0.5 * _v_thermal * std::exp(_u[_qp]));
54+
}

src/bcs/ADComsolEnergyBC.C

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
#include "ADComsolEnergyBC.h"
12+
13+
registerADMooseObject("ZapdosApp", ADComsolEnergyBC);
14+
15+
defineADLegacyParams(ADComsolEnergyBC);
16+
17+
InputParameters
18+
ADComsolEnergyBC::validParams()
19+
{
20+
InputParameters params = ADIntegratedBC::validParams();
21+
params.addRequiredParam<Real>("r", "The reflection coefficient");
22+
params.addRequiredCoupledVar("potential", "The electric potential");
23+
params.addRequiredCoupledVar("em", "The electron density.");
24+
params.addRequiredParam<Real>("position_units", "Units of position.");
25+
return params;
26+
}
27+
28+
ADComsolEnergyBC::ADComsolEnergyBC(const InputParameters & parameters)
29+
: ADIntegratedBC(parameters),
30+
_r_units(1. / getParam<Real>("position_units")),
31+
_r(getParam<Real>("r")),
32+
33+
// Coupled Variables
34+
_grad_potential(adCoupledGradient("potential")),
35+
_em(adCoupledValue("em")),
36+
37+
_massem(getMaterialProperty<Real>("massem")),
38+
_e(getMaterialProperty<Real>("e"))
39+
{
40+
_v_thermal = 0.0;
41+
}
42+
43+
ADReal
44+
ADComsolEnergyBC::computeQpResidual()
45+
{
46+
_v_thermal =
47+
std::sqrt(8 * _e[_qp] * 2.0 / 3 * std::exp(_u[_qp] - _em[_qp]) / (M_PI * _massem[_qp]));
48+
49+
return _test[_i][_qp] * _r_units * (1. - _r) / (1. + _r) * 5. / 6. * _v_thermal *
50+
std::exp(_u[_qp]);
51+
}

0 commit comments

Comments
 (0)