Skip to content

Commit

Permalink
Finished spliting growth variables into groups #11
Browse files Browse the repository at this point in the history
  • Loading branch information
tophmatthews committed Feb 19, 2015
1 parent 90ac41e commit c47f028
Show file tree
Hide file tree
Showing 12 changed files with 343 additions and 31 deletions.
10 changes: 6 additions & 4 deletions include/kernels/SinkGrowth.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ class SinkGrowth : public Kernel
Real calcLosses();
Real calcGains();

std::vector<Real> _atoms;
std::vector<VariableValue *> _c;
std::vector<Real> _avgsize;
std::vector<Real> _maxsize;
std::vector<Real> _jumpsize;
VariableValue & _temp;

int _g;
int _G;
int _N_nuc;

MaterialProperty<Real> & _atomic_diffusivity;

int _G;
std::vector<VariableValue *> _c;

};
#endif //SINKGROWTH_H
29 changes: 16 additions & 13 deletions src/actions/ClustersActionBase.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "ClustersActionBase.h"

#include "BuckUtils.h"

template<>
InputParameters validParams<ClustersActionBase>()
{
Expand Down Expand Up @@ -29,18 +31,21 @@ ClustersActionBase::ClustersActionBase(const std::string & name, InputParameters
void
ClustersActionBase::setup()
{
if ( _G < _N_max )
mooseError("From ClustersActionBase: G must be equal to or greater than N_max.");
// if ( _G < _N_max )
// mooseError("From ClustersActionBase: G must be equal to or greater than N_max.");
if ( _N_nuc > _N_max )
mooseError("From ClustersActionBase: N_max must be equal to or greater than N_nuc.");

varNamesFromG( _vars, _var_name_base, _G);
avgSizeFromGroup( _atoms, _G, getParam<Real>("N_max"), getParam<int>("N_nuc"), getParam<bool>("log") );

Buck::iterateAndDisplay("vars", _vars);
Buck::iterateAndDisplay("atoms", _atoms);
}


void
ClustersActionBase::avgSizeFromGroup(std::vector<Real> & avgs, const Real G, const Real N_max, const int N_nuc, const bool log)
ClustersActionBase::avgSizeFromGroup(std::vector<Real> & sizes, const Real G, const Real N_max, const int N_nuc, const bool log)
{
// Determines maximum cluster size for a given group.
// G = Max number of groups
Expand All @@ -49,8 +54,6 @@ ClustersActionBase::avgSizeFromGroup(std::vector<Real> & avgs, const Real G, con

// First setup nucleation clusters, which consist of N_nuc groups with one atom each

std::vector<Real> sizes;

for ( int g=1; g<N_nuc+1; ++g )
sizes.push_back(g);

Expand All @@ -62,7 +65,7 @@ ClustersActionBase::avgSizeFromGroup(std::vector<Real> & avgs, const Real G, con
b = N_nuc;
m = (N_max - N_nuc) / (G - N_nuc);

for ( int g=N_nuc; g<G+1; ++g )
for ( int g=N_nuc; g<G; ++g )
sizes.push_back( b + m * (g-N_nuc+1) );
}
else
Expand All @@ -71,16 +74,16 @@ ClustersActionBase::avgSizeFromGroup(std::vector<Real> & avgs, const Real G, con
b = N_nuc - 1;
m = std::log10(N_max - N_nuc +1) / (G - N_nuc);

for ( int g=N_nuc; g<G+1; ++g )
for ( int g=N_nuc; g<G; ++g )
sizes.push_back( b+ std::pow( 10, m * (g-N_nuc+1) ) );
}

avgs.push_back(1.0);
for ( int g=0; g<N_max-1; ++g )
{
Real tempavg = 0.5*sizes[g] + 0.5*sizes[g+1];
avgs.push_back( ceil(tempavg) );
}
// avgs.push_back(1.0);
// for ( int g=0; g<N_max-1; ++g )
// {
// Real tempavg = 0.5*sizes[g] + 0.5*sizes[g+1];
// avgs.push_back( ceil(tempavg) );
// }
}


Expand Down
2 changes: 1 addition & 1 deletion src/actions/GrowthKernelsAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ GrowthKernelsAction::act()
InputParameters p = _factory.getValidParams("SinkGrowth");
p.set<NonlinearVariableName>("variable") = var_name;
p.set<std::vector<VariableName> >("coupled_conc") = _vars;
p.set<std::vector<Real> >("coupled_conc_atoms") = _atoms;
p.set<std::vector<Real> >("coupled_maxsize") = _atoms;
p.set<int>("N_nuc") = _N_nuc;

p.addCoupledVar("temp", "");
Expand Down
47 changes: 35 additions & 12 deletions src/kernels/SinkGrowth.C
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "SinkGrowth.h"

// #include "MooseException.h"
#include "MaterialXeBubble.h"
#include "BuckUtils.h"

template<>
InputParameters validParams<SinkGrowth>()
{
InputParameters params = validParams<Kernel>();

params.addRequiredCoupledVar("coupled_conc", "List of coupled concentration variables.");
params.addRequiredParam<std::vector<Real> >("coupled_conc_atoms", "List of coupled concentration variables.");
params.addRequiredParam<std::vector<Real> >("coupled_maxsize", "List of coupled concentration variables.");
params.addRequiredCoupledVar("temp", "Coupled Temperature");
params.addRequiredParam<int>("g", "Group number");
params.addRequiredParam<int>("N_nuc", "Largest cluster size in nucleation model");
Expand All @@ -19,7 +19,7 @@ InputParameters validParams<SinkGrowth>()

SinkGrowth::SinkGrowth(const std::string & name, InputParameters parameters)
:Kernel(name,parameters),
_atoms(getParam<std::vector<Real> >("coupled_conc_atoms")),
_maxsize(getParam<std::vector<Real> >("coupled_maxsize")),
_temp(coupledValue("temp")),
_g(getParam<int>("g") - 1),
_N_nuc(getParam<int>("N_nuc")),
Expand All @@ -29,11 +29,33 @@ SinkGrowth::SinkGrowth(const std::string & name, InputParameters parameters)
{
_G = coupledComponents("coupled_conc");

if ( _maxsize.size() != _G )
mooseError("In SinkGrowth: coupled_conc and coupled_maxsize must be the same size!");

for ( int i=0; i<_G; ++i )
{
if ( _maxsize[i] <= _N_nuc )
_avgsize.push_back(_maxsize[i]);
else
_avgsize.push_back( ( _maxsize[i] + _maxsize[i-1] + 1.0 ) /2.0 );
}

for ( int i=0; i<_G-1; ++i )
{
if ( _maxsize[i] < _N_nuc )
_jumpsize.push_back(0);
else if ( _maxsize[i] == _N_nuc )
_jumpsize.push_back( _maxsize[i+1]*0.5 - _maxsize[i]*0.5 + 0.5 );
else
_jumpsize.push_back( 0.5*_maxsize[i+1] - 0.5*_maxsize[i-1] );
}

for ( int i=0; i<_G; ++i)
_c.push_back( &coupledValue("coupled_conc", i) );

if ( _atoms.size() != _c.size() )
mooseError("In SinkGrowth: coupled_conc.size() != coupled_conc_atoms.size()");
// Buck::iterateAndDisplay("avg", _avgsize);
// Buck::iterateAndDisplay("max", _maxsize);
// Buck::iterateAndDisplay("jumpsize", _jumpsize);
}

Real
Expand All @@ -48,7 +70,7 @@ SinkGrowth::computeQpResidual()
Real gains(0);

losses = calcLosses();
if ( _atoms[_g] > _N_nuc )
if ( _avgsize[_g] > _N_nuc )
gains = calcGains();

return -( gains - losses * _u[_qp] ) * _test[_i][_qp];
Expand Down Expand Up @@ -80,19 +102,20 @@ SinkGrowth::calcLosses()
{
for ( int i=1; i<_G-1; ++i ) // iterate through clusters, except for largest size
{
if ( _atoms[i] >= _N_nuc )
if ( _avgsize[i] >= _N_nuc ) // don't allow losses from nucleation model bubbles, except for N_nuc concentration
{
radius = 1.0e9 * MaterialXeBubble::VDW_MtoR( _atoms[i], _temp[_qp], sigma );
losses += KoverR * radius * (*_c[i])[_qp]; // *_u[_qp] below
radius = 1.0e9 * MaterialXeBubble::VDW_MtoR( _avgsize[i], _temp[_qp], sigma );
losses += KoverR * radius * (*_c[i])[_qp] * _jumpsize[i]; // *_u[_qp] below
// std::cout << "i: " << i << " size: " << _avgsize[i] << " width: " << _width[i] << " width/2: " << ceil(_width[i]/2) << std::endl;
}
}
}
else // if bubble
{
// Losses due to this cluster absorbing atoms
if ( _g < _G-1 && _atoms[_g] >= _N_nuc ) // make sure it's not the largest bubble size
if ( _g < _G-1 && _avgsize[_g] >= _N_nuc ) // make sure it's not the largest bubble size
{
radius = 1.0e9 * MaterialXeBubble::VDW_MtoR( _atoms[_g], _temp[_qp], sigma );
radius = 1.0e9 * MaterialXeBubble::VDW_MtoR( _avgsize[_g], _temp[_qp], sigma );
losses += KoverR * radius * (*_c[0])[_qp]; // *_u[_qp] below
}
}
Expand All @@ -110,7 +133,7 @@ SinkGrowth::calcGains()

Real KoverR = 4.0 * M_PI * _atomic_diffusivity[_qp]; // reaction co-efficient divided by radius

radius = 1.0e9 * MaterialXeBubble::VDW_MtoR( _atoms[_g-1], _temp[_qp], sigma );
radius = 1.0e9 * MaterialXeBubble::VDW_MtoR( _avgsize[_g-1], _temp[_qp], sigma );
gain = KoverR * radius * (*_c[0])[_qp] * (*_c[_g-1])[_qp];

return gain;
Expand Down
Binary file added tests/clustersaction_growth/gold/spacedout_out.e
Binary file not shown.
125 changes: 125 additions & 0 deletions tests/clustersaction_growth/spacedout.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Test for SinkGrowth action.
# Sum should always be 400
#
# This should be exactly the same as tests/sinkgrowth/spacedout.i
#
# +----------------+----------------+----------------+----------------+----------------+----------------+----------------+
# | time | c1_conc | c2_conc | c3_conc | c4_conc | c5_conc | sum |
# +----------------+----------------+----------------+----------------+----------------+----------------+----------------+
# | 1.000000e+02 | 9.908314e-01 | 0.000000e+00 | 9.957639e-01 | 4.214605e-03 | 2.147220e-05 | 4.000000e+00 |
# | 2.000000e+02 | 9.816081e-01 | 0.000000e+00 | 9.915849e-01 | 8.351485e-03 | 6.362455e-05 | 4.000000e+00 |
# | 3.000000e+02 | 9.723358e-01 | 0.000000e+00 | 9.874625e-01 | 1.241178e-02 | 1.256786e-04 | 4.000000e+00 |
# | 4.000000e+02 | 9.630203e-01 | 0.000000e+00 | 9.833965e-01 | 1.639663e-02 | 2.068700e-04 | 4.000000e+00 |
# | 5.000000e+02 | 9.536671e-01 | 0.000000e+00 | 9.793864e-01 | 2.030718e-02 | 3.064487e-04 | 4.000000e+00 |
# | 6.000000e+02 | 9.442816e-01 | 0.000000e+00 | 9.754317e-01 | 2.414458e-02 | 4.236794e-04 | 4.000000e+00 |
# | 7.000000e+02 | 9.348690e-01 | 0.000000e+00 | 9.715322e-01 | 2.790998e-02 | 5.578416e-04 | 4.000000e+00 |
# | 8.000000e+02 | 9.254344e-01 | 0.000000e+00 | 9.676872e-01 | 3.160452e-02 | 7.082301e-04 | 4.000000e+00 |
# | 9.000000e+02 | 9.159826e-01 | 0.000000e+00 | 9.638965e-01 | 3.522935e-02 | 8.741551e-04 | 4.000000e+00 |
# | 1.000000e+03 | 9.065184e-01 | 0.000000e+00 | 9.601595e-01 | 3.878560e-02 | 1.054942e-03 | 4.000000e+00 |
# +----------------+----------------+----------------+----------------+----------------+----------------+----------------+

[GlobalParams]
N_max = 20
G = 5
log = true
N_nuc = 3
temp = temp
[]


[Mesh]
type = GeneratedMesh
dim = 1
[]


[Clusters]
[./Growth]
[../]
[]


[ICs]
[./c3_ic]
type = ConstantIC
variable = c3
value = 1
[../]
[./c1_ic]
type = ConstantIC
variable = c1
value = 1
[../]
[]


[AuxVariables]
[./temp]
order = CONSTANT
family = MONOMIAL
[../]
[]


[AuxKernels]
[./temp_aux]
type = ConstantAux
variable = temp
value = 1000
[../]
[]


[Materials]
[./c1_diff]
type = AtomicDiffusionCoef
model = 1
factor = 1
block = 0
[../]
[]


[Executioner]
type = Transient

solve_type = PJFNK

num_steps = 10
dt = 100
[]


[Postprocessors]
[./c1_conc]
type = ElementIntegralVariablePostprocessor
variable = c1
[../]
[./c2_conc]
type = ElementIntegralVariablePostprocessor
variable = c2
[../]
[./c3_conc]
type = ElementIntegralVariablePostprocessor
variable = c3
[../]
[./c4_conc]
type = ElementIntegralVariablePostprocessor
variable = c4
[../]
[./c5_conc]
type = ElementIntegralVariablePostprocessor
variable = c5
[../]
[./sum]
type = SumOfPostprocessors
postprocessors = 'c1_conc c2_conc c3_conc c4_conc c5_conc'
factors = '1 2 3 5.12132 13.62132'
[../]
[]

[Outputs]
console = true
exodus = true
interval = 1
[]
5 changes: 5 additions & 0 deletions tests/clustersaction_growth/tests
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@
input = '3species.i'
exodiff = '3species_out.e'
[../]
[./spacedout]
type = 'Exodiff'
input = 'spacedout.i'
exodiff = 'spacedout_out.e'
[../]
[]
2 changes: 1 addition & 1 deletion tests/sinkgrowth/3species.i
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

[GlobalParams]
coupled_conc = 'c1 c5 c6'
coupled_conc_atoms = '1 5 6'
coupled_maxsize = '1 5 6'
N_nuc = 5
temp = 1000
[]
Expand Down
Binary file modified tests/sinkgrowth/gold/3species_out.e
Binary file not shown.
Binary file added tests/sinkgrowth/gold/spacedout_out.e
Binary file not shown.
Loading

0 comments on commit c47f028

Please sign in to comment.