Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Add new mms tests to test the temporally scaled equations against the…
Browse files Browse the repository at this point in the history
… originallsolutions.
  • Loading branch information
micahjohnson150 committed Jul 1, 2014
1 parent 35616ba commit 5655951
Show file tree
Hide file tree
Showing 20 changed files with 584 additions and 38 deletions.
9 changes: 8 additions & 1 deletion include/kernels/MassTransportSourceMMS.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

// MOOSE includes
#include "Kernel.h"
//Pika Includes
#include "PropertyUserObjectInterface.h"

// Forward declarations
class MassTransportSourceMMS;
Expand All @@ -28,7 +30,10 @@ InputParameters validParams<MassTransportSourceMMS>();
* A kernel for adding forcing function for the MMS tests of the mass
* transport equation, Eq. (35)
*/
class MassTransportSourceMMS : public Kernel
class MassTransportSourceMMS :
public Kernel,
PropertyUserObjectInterface

{
public:

Expand All @@ -46,6 +51,8 @@ class MassTransportSourceMMS : public Kernel
const MaterialProperty<Real> & _D_v;
const VariableValue & _phi;
bool _use_dphi_dt;
bool _use_scale;
const Real & _xi;

};

Expand Down
2 changes: 2 additions & 0 deletions include/kernels/PhaseEvolutionSourceMMS.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class PhaseEvolutionSourceMMS :
const bool & _use_potential_transition;
const VariableValue & _T;
const VariableValue & _u;
const bool & _use_scale;
const Real & _xi;

};

Expand Down
1 change: 1 addition & 0 deletions include/kernels/PhaseTransition.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ class PhaseTransition :
MaterialProperty<Real> & _lambda;

MaterialProperty<Real> & _s_eq;

};
#endif // PHASETRANSITION_H
19 changes: 13 additions & 6 deletions include/kernels/PikaScaledMatDiffusion.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef PIKASCALEDMATDIFFUSION_H
#define PIKASCALEDMATDIFFUSION_H
#ifndef MATDIFFUSION_H
#define MATDIFFUSION_H

#include "MatDiffusion.h"
#include "Diffusion.h"
#include "Material.h"
#include "PropertyUserObjectInterface.h"

//Forward Declarations
Expand All @@ -11,8 +12,8 @@ template<>
InputParameters validParams<PikaScaledMatDiffusion>();

class PikaScaledMatDiffusion :
public MatDiffusion,
public PropertyUserObjectInterface
public Diffusion,
PropertyUserObjectInterface
{
public:
PikaScaledMatDiffusion(const std::string & name, InputParameters parameters);
Expand All @@ -21,6 +22,12 @@ class PikaScaledMatDiffusion :
virtual Real computeQpResidual();
virtual Real computeQpJacobian();

private:
std::string _D_name;

MaterialProperty<Real> & _D;

const Real & _xi;
};

#endif // PIKASCALEDMATDIFFUSION_H
#endif //MATDIFFUSION_H
35 changes: 35 additions & 0 deletions include/kernels/ScaledPhaseTransition.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef SCALEDPHASETRANSITION_H
#define SCALEPHASETRANSITION_H

// modules/phase_field includes
#include "ACBulk.h"

#include "PropertyUserObjectInterface.h"
//Forward Declarations
class ScaledPhaseTransition;

template<>
InputParameters validParams<ScaledPhaseTransition>();

class ScaledPhaseTransition :
public ACBulk,
public PropertyUserObjectInterface
{
public:

ScaledPhaseTransition(const std::string & name, InputParameters parameters);

protected:
virtual Real computeDFDOP(PFFunctionType type);

private:
VariableValue & _s;

MaterialProperty<Real> & _lambda;

MaterialProperty<Real> & _s_eq;

const Real & _xi;

};
#endif // SCALEDPHASETRANSITION_H
2 changes: 2 additions & 0 deletions src/base/PikaApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "DoubleWellPotentialMMS.h"
#include "PikaScaledTimeDerivative.h"
#include "PikaScaledMatDiffusion.h"
#include "ScaledPhaseTransition.h"

// AuxKernels
#include "ErrorFunctionAux.h"
Expand Down Expand Up @@ -102,6 +103,7 @@ PikaApp::registerObjects(Factory & factory)
registerKernel(DoubleWellPotentialMMS);
registerKernel(PikaScaledTimeDerivative);
registerKernel(PikaScaledMatDiffusion);
registerKernel(ScaledPhaseTransition);

// InitialConditions
registerInitialCondition(ChemicalPotentialIC);
Expand Down
2 changes: 1 addition & 1 deletion src/kernels/HeatEquationSourceMMS.C
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ InputParameters validParams<HeatEquationSourceMMS>()
params.addParam<std::string>("latent_heat_name", "latent_heat", "The name of the material property that contains the latent heat coefficient for sublimation (L_sg)");
params.addRequiredCoupledVar("phase_variable", "Phase-field variable, phi");
params.addParam<bool>("use_dphi_dt", true, "Include the dphi_dt portion of the forcing function");
params.addParam<bool>("use_time_scaling", true, "Temporally scale this term");
params.addParam<bool>("use_time_scaling", false, "Temporally scale the forcing term");
return params;
}

Expand Down
24 changes: 20 additions & 4 deletions src/kernels/MassTransportSourceMMS.C
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ InputParameters validParams<MassTransportSourceMMS>()
params.addParam<std::string>("diffusion_coefficient_name", "diffusion_coefficient", "The name of the phase dependent material property that contains the water vapor diffusion coefficient (D_v)");
params.addRequiredCoupledVar("phi", "Phase-field variable, phi");
params.addParam<bool>("use_dphi_dt", true, "Include the dphi_dt portion of the forcing function");
params.addParam<bool>("use_time_scaling", false, "Temporally scale this term");

return params;
}

MassTransportSourceMMS::MassTransportSourceMMS(const std::string & name, InputParameters parameters) :
Kernel(name, parameters),
PropertyUserObjectInterface(name,parameters),
_D_v(getMaterialProperty<Real>(getParam<std::string>("diffusion_coefficient_name"))),
_phi(coupledValue("phi")),
_use_dphi_dt(getParam<bool>("use_dphi_dt"))
_use_dphi_dt(getParam<bool>("use_dphi_dt")),
_use_scale(getParam<bool>("use_time_scaling")),
_xi(_property_uo.getParam<Real>("temporal_scaling"))
{
}

Expand All @@ -30,10 +35,21 @@ MassTransportSourceMMS::computeQpResidual()
Real Pi = libMesh::pi;
Real phi = _phi[_qp];

Real f =
8.0*pow(pi, 2)*D*t*sin(2.0*pi*x)*cos(2.0*pi*y) + sin(2.0*pi*x)*cos(2.0*pi*y);
Real f,term1,term2,term3;
term1 = sin(2.0*pi*x)*cos(2.0*pi*y);
term2 = 8.0*pow(pi, 2.0)*D*t*sin(2.0*pi*x)*cos(2.0*pi*y);
term3 = 0.5*x*y;

if (_use_scale)
{
term2=_xi*term2;
term3=_xi*term3;
}

f=term1+term2;

if (_use_dphi_dt)
f += 0.5*x*y;
f+=term3;

return -_test[_i][_qp] * f;
}
20 changes: 15 additions & 5 deletions src/kernels/PhaseEvolutionSourceMMS.C
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ InputParameters validParams<PhaseEvolutionSourceMMS>()
params.addParam<bool>("use_potential_transition",false, "Include term proportional to lambda in Eq.(33)");
params.addRequiredCoupledVar("temperature","temperature specifying vapor density, T) ");
params.addRequiredCoupledVar("chemical_potential","vapor concentration, u) ");
params.addParam<bool>("use_time_scaling", false, "Temporally scale the forcing term");
return params;
}

Expand All @@ -19,8 +20,9 @@ PhaseEvolutionSourceMMS::PhaseEvolutionSourceMMS(const std::string & name, Input
_lambda(getMaterialProperty<Real>("lambda")),
_use_potential_transition(getParam<bool>("use_potential_transition")),
_T(coupledValue("temperature")),
_u(coupledValue("chemical_potential"))

_u(coupledValue("chemical_potential")),
_use_scale(getParam<bool>("use_time_scaling")),
_xi(_property_uo.getParam<Real>("temporal_scaling"))

{
}
Expand All @@ -36,11 +38,19 @@ PhaseEvolutionSourceMMS::computeQpResidual()
Real w = _w[_qp];
Real lambda = _lambda[_qp];
Real u_eq =_property_uo.equilibriumConcentration( _T[_qp]);
Real f =

Real terms123 =
-4*t*pow(w, 2.0) - t*(pow(x - 0.5, 2) + pow(y - 0.5, 2) - 0.125) + tau*(pow(x - 0.5, 2) + pow(y - 0.5, 2) - 0.125) + pow(t*(pow(x - 0.5, 2) + pow(y - 0.5, 2) - 0.125), 3.0);

Real term4 = -lambda*(_u[_qp] - u_eq)*pow(-pow(t, 2)*pow(pow(x - 0.5, 2) + pow(y - 0.5, 2) - 0.125, 2) + 1.0, 2.0);

if (_use_scale)
term4 = _xi*term4;

Real f = terms123;

if(_use_potential_transition)
f+=
-lambda*(_u[_qp] - u_eq)*pow(-pow(t, 2)*pow(pow(x - 0.5, 2) + pow(y - 0.5, 2) - 0.125, 2) + 1.0, 2.0);
f+=term4;

return -_test[_i][_qp] * f;
}
6 changes: 2 additions & 4 deletions src/kernels/PhaseTransition.C
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ PhaseTransition::computeDFDOP(PFFunctionType type)
switch (type)
{
case Residual:
return -(_lambda[_qp]) * (_s[_qp] - _s_eq[_qp]/(_property_uo.temporalScale())) * (1.0 - _u[_qp]*_u[_qp])*(1.0 - _u[_qp]*_u[_qp]);
// return -(_lambda[_qp]) * (_s[_qp] - _s_eq[_qp]) * (1.0 - _u[_qp]*_u[_qp])*(1.0 - _u[_qp]*_u[_qp]);
return -(_lambda[_qp]) * (_s[_qp] - _s_eq[_qp]) * (1.0 - _u[_qp]*_u[_qp])*(1.0 - _u[_qp]*_u[_qp]);

case Jacobian:
return 4.0 * _lambda[_qp] * _u[_qp] * (-_u[_qp]*_u[_qp]+1.0) * (_s[_qp] - (_s_eq[_qp])/(_property_uo.temporalScale()));
// return 4.0 * _lambda[_qp] * _u[_qp] * (-_u[_qp]*_u[_qp]+1.0) * (_s[_qp] - (_s_eq[_qp]));
return 4.0 * _lambda[_qp] * _u[_qp] * (-_u[_qp]*_u[_qp]+1.0) * (_s[_qp] - (_s_eq[_qp]));
}
}
15 changes: 10 additions & 5 deletions src/kernels/PikaScaledMatDiffusion.C
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@
template<>
InputParameters validParams<PikaScaledMatDiffusion>()
{
InputParameters params = validParams<MatDiffusion>();
InputParameters params = validParams<Diffusion>();
params.addParam<std::string>("diffusivity", "D", "The name of the diffusivity");
return params;
}

PikaScaledMatDiffusion::PikaScaledMatDiffusion(const std::string & name, InputParameters parameters) :
MatDiffusion(name, parameters),
PropertyUserObjectInterface(name,parameters)
Diffusion(name, parameters),
PropertyUserObjectInterface(name, parameters),
_D_name(getParam<std::string>("diffusivity")),
_D(getMaterialProperty<Real>(_D_name)),
_xi(_property_uo.getParam<Real>("temporal_scaling"))
{}

Real
PikaScaledMatDiffusion::computeQpResidual()
{
return (_property_uo.temporalScale()) * MatDiffusion::computeQpResidual();
return _xi*_D[_qp] * _grad_test[_i][_qp] * _grad_u[_qp];
}

Real
PikaScaledMatDiffusion::computeQpJacobian()
{
return (_property_uo.temporalScale()) * MatDiffusion::computeQpJacobian();
return _xi* _D[_qp] * _grad_test[_i][_qp] * _grad_phi[_j][_qp];
}
35 changes: 35 additions & 0 deletions src/kernels/ScaledPhaseTransition.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "ScaledPhaseTransition.h"
#include "AirProperties.h"

template<>
InputParameters validParams<ScaledPhaseTransition>()
{
InputParameters params = validParams<ACBulk>();
params.addRequiredCoupledVar("chemical_potential", "The chemical potential variable to couple");
params.addParam<std::string>("lambda", "lambda", "The name of the material property containing the definition of lambda");
params.addParam<std::string>("equilibrium_concentration", "equilibrium_concentration", "The name of the material property containing the equilibrium concentration");
return params;
}

ScaledPhaseTransition::ScaledPhaseTransition(const std::string & name, InputParameters parameters) :
ACBulk(name, parameters),
PropertyUserObjectInterface(name, parameters),
_s(coupledValue("chemical_potential")),
_lambda(getMaterialProperty<Real>(getParam<std::string>("lambda"))),
_s_eq(getMaterialProperty<Real>(getParam<std::string>("equilibrium_concentration"))),
_xi(_property_uo.getParam<Real>("temporal_scaling"))
{
}

Real
ScaledPhaseTransition::computeDFDOP(PFFunctionType type)
{
switch (type)
{
case Residual:
return -(_lambda[_qp]*_xi) * (_s[_qp] - _s_eq[_qp]) * (1.0 - _u[_qp]*_u[_qp])*(1.0 - _u[_qp]*_u[_qp]);

case Jacobian:
return 4.0 * _xi * _lambda[_qp] * _u[_qp] * (-_u[_qp]*_u[_qp]+1.0) * (_s[_qp] - (_s_eq[_qp]));
}
}
20 changes: 10 additions & 10 deletions src/materials/PhaseFieldProperties.C
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,27 @@ PhaseFieldProperties::computeQpProperties()
/// @todo{This needs to be computed}
_interface_velocity[_qp] = 1e-9; // [m/s]

//_capillary_length[_qp] =(rho_vs/rho_i[_qp])*(gamma * std::pow(a, 3.) ) / (k * _property_uo.referenceTemp());
_capillary_length[_qp] =_d_o/_xi;
// _capillary_length[_qp] =(1.3e-9);
// _capillary_length[_qp] =(rho_vs/(rho_i[_qp]*_xi)) * (gamma * std::pow(a, 3.) ) / (k * _property_uo.referenceTemp());
// _capillary_length[_qp] =_d_o/_xi;
_capillary_length[_qp] =(1.3e-9);
// std::cout<<"d_o = " <<_capillary_length[_qp]<<std::endl;

//_beta[_qp] = (1./alpha) * (rho_i[_qp]/rho_vs)* std::sqrt((2.*libMesh::pi*m) / (k * _property_uo.referenceTemp()));
_beta[_qp]=_interface_kinetic_coefficient/_xi;
//_beta[_qp] = (5.5e5);
//_beta[_qp] = (1./(alpha * _xi)) * std::sqrt((2.*libMesh::pi*m) / (k * _property_uo.referenceTemp()));
// _beta[_qp]=_interface_kinetic_coefficient/_xi;
_beta[_qp] = (5.5e5);
//std::cout<<"beta = "<<_beta[_qp]<<std::endl;

_lambda[_qp] = (_xi*_a1 * w / _capillary_length[_qp]);
//_lambda[_qp] = (_a1 * w / _capillary_length[_qp]);
//_lambda[_qp] = (_xi*_a1 * w / _capillary_length[_qp]);
_lambda[_qp] = (_a1 * w / _capillary_length[_qp]);
//std::cout<<"lambda = "<<_lambda[_qp]<<std::endl;

_tau[_qp] = (_beta[_qp] * w * _lambda[_qp]) / _a1;

_conductivity[_qp] = ki[_qp] * (1. + _phase[_qp]) / 2. + ka[_qp] * (1. - _phase[_qp]) / 2.;
_conductivity[_qp] = (ki[_qp] * (1. + _phase[_qp]) / 2. + ka[_qp] * (1. - _phase[_qp]) / 2.);

_heat_capacity[_qp] = ci[_qp] * (1. + _phase[_qp]) / 2. + ca[_qp] * (1. - _phase[_qp]) / 2.;

_diffusion_coefficient[_qp] = dv[_qp] * (1. - _phase[_qp]) / 2.;
_diffusion_coefficient[_qp] = (dv[_qp] * (1. - _phase[_qp]) / 2.);

_interface_thickness_squared[_qp] = w*w;

Expand Down
Loading

0 comments on commit 5655951

Please sign in to comment.