Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "ElectromagneticHeatingMaterial.h" 11 : #include "FormulationEnums.h" 12 : 13 : registerMooseObject("HeatTransferApp", ElectromagneticHeatingMaterial); 14 : 15 : InputParameters 16 381 : ElectromagneticHeatingMaterial::validParams() 17 : { 18 381 : InputParameters params = ADMaterial::validParams(); 19 381 : params.addClassDescription( 20 : "Material class used to provide the electric field as a material property and computes the " 21 : "residual contributions for electromagnetic/electrostatic heating objects."); 22 762 : params.addCoupledVar( 23 : "electric_field", 24 : "The electric field vector or electrostatic potential scalar to produce the field."); 25 762 : params.addCoupledVar( 26 : "complex_electric_field", 27 : "The complex component of the electric field vector for the time-harmonic formulation."); 28 762 : params.addParam<std::string>("electric_field_material_name", 29 : "electric_field", 30 : "User-specified material property name for the field."); 31 762 : params.addParam<std::string>("electric_field_heating_name", 32 : "electric_field_heating", 33 : "User-specified material property name for the Joule heating."); 34 762 : params.addParam<Real>("heating_scaling", 1.0, "Coefficient to multiply by heating term."); 35 762 : params.addParam<MaterialPropertyName>( 36 : "electrical_conductivity", 37 : "electrical_conductivity", 38 : "Material property providing electrical conductivity of the material."); 39 762 : MooseEnum formulation("time frequency", "time"); 40 762 : MooseEnum solver("electrostatic electromagnetic", "electrostatic"); 41 762 : params.addParam<MooseEnum>( 42 : "formulation", 43 : formulation, 44 : "The domain formulation of the Joule heating, time or frequency (default = time)."); 45 762 : params.addParam<MooseEnum>( 46 : "solver", solver, "Electrostatic or electromagnetic field solver (default = electrostatic)."); 47 381 : return params; 48 381 : } 49 : 50 297 : ElectromagneticHeatingMaterial::ElectromagneticHeatingMaterial(const InputParameters & parameters) 51 : : ADMaterial(parameters), 52 297 : _electric_field_var(*getFieldVar("electric_field", 0)), 53 297 : _is_vector(_electric_field_var.isVector()), 54 297 : _efield(_is_vector ? adCoupledVectorValue("electric_field") : _ad_grad_zero), 55 297 : _efield_complex(_is_vector ? adCoupledVectorValue("complex_electric_field") : _ad_grad_zero), 56 297 : _grad_potential(_is_vector ? _ad_grad_zero : adCoupledGradient("electric_field")), 57 297 : _electric_field( 58 594 : declareADProperty<RealVectorValue>(getParam<std::string>("electric_field_material_name"))), 59 297 : _electric_field_complex(declareADProperty<RealVectorValue>( 60 594 : getParam<std::string>("electric_field_material_name") + "_complex")), 61 297 : _electric_field_heating( 62 594 : declareADProperty<Real>(getParam<std::string>("electric_field_heating_name"))), 63 594 : _heating_scaling(getParam<Real>("heating_scaling")), 64 594 : _elec_cond(getADMaterialProperty<Real>("electrical_conductivity")), 65 594 : _formulation(getParam<MooseEnum>("formulation")), 66 891 : _solver(getParam<MooseEnum>("solver")) 67 : { 68 297 : if ((_formulation == ElectromagneticFormulation::FREQUENCY) && 69 0 : (_solver == ElectromagneticFormulation::ELECTROSTATIC)) 70 : { 71 0 : mooseError("The frequency domain is selected, but the solver type is electrostatic! Please " 72 : "check input file."); 73 : } 74 : 75 297 : if ((_solver == ElectromagneticFormulation::ELECTROMAGNETIC) && !_is_vector) 76 : { 77 0 : mooseError("The solver type is electromagnetic, but only a scalar potential is provided! " 78 : "Please check input file."); 79 : } 80 : 81 297 : if ((_formulation == ElectromagneticFormulation::FREQUENCY) && !_is_vector) 82 : { 83 0 : mooseError("The frequency domain is selected, but only a scalar potential is provided! " 84 : "Please check input file."); 85 : } 86 297 : } 87 : 88 : void 89 799200 : ElectromagneticHeatingMaterial::computeQpProperties() 90 : { 91 799200 : computeFieldValue(); 92 799200 : computeJouleHeating(); 93 799200 : } 94 : 95 : void 96 799200 : ElectromagneticHeatingMaterial::computeFieldValue() 97 : { 98 799200 : if (_solver == ElectromagneticFormulation::ELECTROSTATIC) 99 1598400 : _electric_field[_qp] = -_grad_potential[_qp]; 100 : else 101 0 : _electric_field[_qp] = _efield[_qp]; 102 : 103 799200 : if (_formulation == ElectromagneticFormulation::FREQUENCY) 104 0 : _electric_field_complex[_qp] = _efield_complex[_qp]; 105 799200 : } 106 : 107 : void 108 799200 : ElectromagneticHeatingMaterial::computeJouleHeating() 109 : { 110 799200 : if (_formulation == ElectromagneticFormulation::FREQUENCY) 111 0 : _electric_field_heating[_qp] = _heating_scaling * 0.5 * _elec_cond[_qp] * 112 0 : (_electric_field[_qp] * _electric_field[_qp] + 113 0 : _electric_field_complex[_qp] * _electric_field_complex[_qp]); 114 : else 115 799200 : _electric_field_heating[_qp] = 116 1598400 : _heating_scaling * _elec_cond[_qp] * _electric_field[_qp] * _electric_field[_qp]; 117 799200 : }