Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions include/components/Coaxial1PhaseBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "Component.h"
#include "InputParameters.h"

class Coaxial1PhaseBase : public Component {
public:
Coaxial1PhaseBase(const InputParameters &params) : Component(params) {}

protected:
// Create constant function based on scalar value
FunctionName CreateFunctionFromValue(const std::string &suffix,
const Real value);

// Function that copies parameters depending on whether the
// local parameter or global parameter is specified
template <typename T>
inline void CopyParamFromParamWithGlobal(const std::string dst_name,
const std::string src_name,
const std::string global_src_name,
InputParameters &dst_params);
};
17 changes: 17 additions & 0 deletions include/components/CoaxialElbow1Phase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include "Coaxial1PhaseBase.h"

class CoaxialElbow1Phase : public Coaxial1PhaseBase {
public:
static InputParameters validParams();

CoaxialElbow1Phase(const InputParameters &params);

protected:
// Add elbow geometry and form loss for inner pipe
void AddElbowInner();

// Add elbow geometry and form loss for outer annulus
void AddElbowOuter();
};
10 changes: 4 additions & 6 deletions include/components/CoaxialPipe1Phase.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include <Component1D.h>
#pragma once

#include <Coaxial1PhaseBase.h>
#include <FlowChannel1Phase.h>
#include <InputParameters.h>

class CoaxialPipe1Phase : public Component {
class CoaxialPipe1Phase : public Coaxial1PhaseBase {
public:
static InputParameters validParams();

Expand All @@ -25,8 +27,4 @@ class CoaxialPipe1Phase : public Component {
void AddHeatTransferConnection(const std::string &flow_channel,
const std::string &hs,
const std::string &hs_side, const Real radius);

// Create constant function based on scalar value
FunctionName CreateFunctionFromValue(const std::string &suffix,
const Real value);
};
18 changes: 18 additions & 0 deletions include/userobjects/ADElbow0D1PhaseUserObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include "ADVolumeJunction1PhaseUserObject.h"
#include "InputParameters.h"

class ADElbow0D1PhaseUserObject : public ADVolumeJunction1PhaseUserObject {
public:
static InputParameters validParams();

ADElbow0D1PhaseUserObject(const InputParameters &params);

protected:
void computeFluxesAndResiduals(const unsigned int &c) override;

const Real &_r_curv;

const Real &_d_h;
};
25 changes: 25 additions & 0 deletions src/components/Coaxial1PhaseBase.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "Coaxial1PhaseBase.h"

FunctionName
Coaxial1PhaseBase::CreateFunctionFromValue(const std::string &suffix,
const Real value) {
auto func_params = _factory.getValidParams("ConstantFunction");
func_params.set<Real>("value") = value;

auto func_name = name() + "_" + suffix;
getTHMProblem().addFunction("ConstantFunction", func_name, func_params);
return func_name;
}

template <typename T>
void Coaxial1PhaseBase::CopyParamFromParamWithGlobal(
const std::string dst_name, const std::string src_name,
const std::string global_src_name, InputParameters &dst_params) {

if (!isParamSetByUser(src_name) && !isParamSetByUser(global_src_name))
mooseError("Either ", src_name, " or ", global_src_name, " must be set.");

dst_params.set<T>(dst_name) = (isParamSetByUser(src_name))
? getParam<T>(src_name)
: getParam<T>(global_src_name);
}
199 changes: 199 additions & 0 deletions src/components/CoaxialElbow1Phase.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
#include "CoaxialElbow1Phase.h"
#include "CoaxialPipe1Phase.h"
#include "InputParameters.h"
#include "Registry.h"
#include <cmath>
#include <cstdio>

registerMooseObject("ProteusApp", CoaxialElbow1Phase);

namespace {
// Compute momentum loss per unit length using Handbook of Hydraulic Resistance
// p. 195
Real getElbowKPrime(const Real &R_c, const Real &D_h) {
const Real length = 0.5 * pi * R_c;
Real k;
if (R_c / D_h > 1.)
k = 0.21 / sqrt(R_c / D_h);
else
k = 0.21 / pow(R_c / D_h, 2.5);

return k / length;
}
} // namespace

InputParameters CoaxialElbow1Phase::validParams() {

InputParameters params = CoaxialPipe1Phase::validParams();
params.addRequiredParam<Real>("radius", "Radius of the pipe [m]");
params.addRequiredParam<Real>("start_angle",
"Angle at which the pipe starts [degrees]");
params.addRequiredParam<Real>("end_angle",
"Angle at which the pipe ends [degrees]");

// Suppress length. Also need to set it to something, because it is required
// in the parent class
params.set<std::vector<Real>>("length") = {0.0};
params.suppressParameter<std::vector<Real>>("length");

// Momentum losses provided by minor loss formula
params.suppressParameter<std::vector<std::string>>("inner_closures");
params.suppressParameter<std::vector<std::string>>("outer_closures");
params.suppressParameter<std::vector<std::string>>("closures");
// f set to zero
params.suppressParameter<FunctionName>("inner_f");
params.suppressParameter<FunctionName>("outer_f");
params.suppressParameter<FunctionName>("f");

params.addClassDescription("Bent pipe for 1-phase coaxial flow");

return params;
}

CoaxialElbow1Phase::CoaxialElbow1Phase(const InputParameters &params)
: Coaxial1PhaseBase(params) {

auto start_angle = getParam<Real>("start_angle");
auto end_angle = getParam<Real>("end_angle");

// This component is for 90 degree bends
if (!MooseUtils::relativeFuzzyEqual(abs(start_angle - end_angle), 90.))
mooseError("Difference between start and end angles should be 90 degrees.");

// Closure has been removed as a parameter to be specified but we must specify
// it
auto closure_params = _factory.getValidParams("Closures1PhaseSimple");
closure_params.set<THMProblem *>("_thm_problem") = &getTHMProblem();
closure_params.set<Logger *>("_logger") = &(getTHMProblem().log());
getTHMProblem().addClosures("Closures1PhaseSimple", name() + "_closure",
closure_params);

AddElbowInner();
AddElbowOuter();
}

void CoaxialElbow1Phase::AddElbowInner() {

const std::string component_name = name() + "/inner";
Real radius = getParam<Real>("tube_inner_radius");
const Real d_h = 2 * radius;

// Add elbow geometry for inner pipe and pipe information
{
const std::string class_name = "ElbowPipe1Phase";
auto pipe_params = _factory.getValidParams(class_name);
pipe_params.set<THMProblem *>("_thm_problem") = &getTHMProblem();

CopyParamFromParamWithGlobal<UserObjectName>("fp", "inner_fp", "fp",
pipe_params);

pipe_params.set<std::vector<std::string>>("closures") = {name() +
"_closure"};
pipe_params.set<FunctionName>("f") = CreateFunctionFromValue("inner_f", 0.);

passParameter<std::vector<unsigned int>>("n_elems", pipe_params);
passParameter<Point>("position", pipe_params);
passParameter<RealVectorValue>("orientation", pipe_params);

auto area = pi * radius * radius;
pipe_params.set<FunctionName>("A") =
CreateFunctionFromValue("inner_area", area);

pipe_params.set<FunctionName>("D_h") =
CreateFunctionFromValue("inner_dh", d_h);

CopyParamFromParamWithGlobal<FunctionName>("initial_T", "inner_initial_T",
"initial_T", pipe_params);
CopyParamFromParamWithGlobal<FunctionName>("initial_p", "inner_initial_p",
"initial_p", pipe_params);
CopyParamFromParamWithGlobal<FunctionName>(
"initial_vel", "inner_initial_vel", "initial_vel", pipe_params);

passParameter<Real>("radius", pipe_params);
passParameter<Real>("start_angle", pipe_params);
passParameter<Real>("end_angle", pipe_params);

getTHMProblem().addComponent(class_name, component_name, pipe_params);
}

// Add form loss from Handbook of Hydraulic Resistance p. 195
{
const std::string class_name = "FormLossFromFunction1Phase";
auto loss_params = _factory.getValidParams(class_name);
loss_params.set<THMProblem *>("_thm_problem") = &getTHMProblem();
loss_params.set<std::string>("flow_channel") = component_name;

const Real r_c = getParam<Real>("radius");

loss_params.set<FunctionName>("K_prime") =
CreateFunctionFromValue("inner_k_prime", getElbowKPrime(r_c, d_h));

getTHMProblem().addComponent(class_name, component_name + "_loss",
loss_params);
}
}

void CoaxialElbow1Phase::AddElbowOuter() {

Real tube_radius = getParam<Real>("tube_inner_radius");
auto tube_widths = getParam<std::vector<Real>>("tube_widths");
Real inner_radius =
tube_radius + std::accumulate(tube_widths.begin(), tube_widths.end(), 0.);
Real outer_radius = getParam<Real>("shell_inner_radius");
const Real d_h = 2 * (outer_radius - inner_radius);

// Add elbow geometry for outer annulus
const std::string component_name = name() + "/outer";
{
const std::string class_name = "ElbowPipe1Phase";
auto pipe_params = _factory.getValidParams(class_name);
pipe_params.set<THMProblem *>("_thm_problem") = &getTHMProblem();

CopyParamFromParamWithGlobal<UserObjectName>("fp", "outer_fp", "fp",
pipe_params);

pipe_params.set<std::vector<std::string>>("closures") = {name() +
"_closure"};
pipe_params.set<FunctionName>("f") = CreateFunctionFromValue("outer_f", 0.);

passParameter<std::vector<unsigned int>>("n_elems", pipe_params);
passParameter<Point>("position", pipe_params);
passParameter<RealVectorValue>("orientation", pipe_params);

auto area =
pi * (outer_radius * outer_radius - inner_radius * inner_radius);
pipe_params.set<FunctionName>("A") =
CreateFunctionFromValue("outer_area", area);

pipe_params.set<FunctionName>("D_h") =
CreateFunctionFromValue("outer_dh", d_h);

CopyParamFromParamWithGlobal<FunctionName>("initial_T", "outer_initial_T",
"initial_T", pipe_params);
CopyParamFromParamWithGlobal<FunctionName>("initial_p", "outer_initial_p",
"initial_p", pipe_params);
CopyParamFromParamWithGlobal<FunctionName>(
"initial_vel", "outer_initial_vel", "initial_vel", pipe_params);

passParameter<Real>("radius", pipe_params);
passParameter<Real>("start_angle", pipe_params);
passParameter<Real>("end_angle", pipe_params);

getTHMProblem().addComponent(class_name, component_name, pipe_params);
}

{
const std::string class_name = "FormLossFromFunction1Phase";
auto loss_params = _factory.getValidParams(class_name);
loss_params.set<THMProblem *>("_thm_problem") = &getTHMProblem();
loss_params.set<std::string>("flow_channel") = component_name;

auto r_c = getParam<Real>("radius");

loss_params.set<FunctionName>("K_prime") =
CreateFunctionFromValue("outer_k_prime", getElbowKPrime(r_c, d_h));

getTHMProblem().addComponent(class_name, component_name + "_loss",
loss_params);
}
}
Loading
Loading