svZeroDSolver
Loading...
Searching...
No Matches
Junction Class Reference

Junction. More...

#include <Junction.h>

Inheritance diagram for Junction:
[legend]

Public Member Functions

 Junction (int id, Model *model)
 Construct a new Junction object.
 
void setup_dofs (DOFHandler &dofhandler)
 Set up the degrees of freedom (DOF) of the block.
 
void update_constant (SparseSystem &system, std::vector< double > &parameters)
 Update the constant contributions of the element in a sparse system.
 
void update_gradient (Eigen::SparseMatrix< double > &jacobian, Eigen::Matrix< double, Eigen::Dynamic, 1 > &residual, Eigen::Matrix< double, Eigen::Dynamic, 1 > &alpha, std::vector< double > &y, std::vector< double > &dy)
 Set the gradient of the block contributions with respect to the parameters.
 
- Public Member Functions inherited from Block
 Block (int id, Model *model, BlockType block_type, BlockClass block_class, std::vector< std::pair< std::string, InputParameter > > input_params)
 Construct a new Block object.
 
 ~Block ()
 Destroy the Block object.
 
 Block (const Block &)=delete
 Copy the Block object.
 
std::string get_name ()
 Get the name of the block.
 
void update_vessel_type (VesselType type)
 Update vessel type of the block.
 
void setup_params_ (const std::vector< int > &param_ids)
 Setup parameter IDs for the block.
 
void setup_dofs_ (DOFHandler &dofhandler, int num_equations, const std::list< std::string > &internal_var_names)
 Set up the degrees of freedom (DOF) of the block.
 
virtual void setup_model_dependent_params ()
 Setup parameters that depend on the model.
 
virtual void setup_initial_state_dependent_params (State initial_state, std::vector< double > &parameters)
 Setup parameters that depend on the initial state.
 
virtual void update_time (SparseSystem &system, std::vector< double > &parameters)
 Update the time-dependent contributions of the element in a sparse system.
 
virtual void update_solution (SparseSystem &system, std::vector< double > &parameters, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &y, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &dy)
 Update the solution-dependent contributions of the element in a sparse system.
 
virtual void post_solve (Eigen::Matrix< double, Eigen::Dynamic, 1 > &y)
 Modify the solution after solving it.
 
virtual TripletsContributions get_num_triplets ()
 Get number of triplets of element.
 

Public Attributes

TripletsContributions num_triplets {0, 0, 0}
 Number of triplets of element.
 
int num_inlets
 Number of inlets to the block.
 
int num_outlets
 Number of outlets from the block.
 
- Public Attributes inherited from Block
const int id
 Global ID of the block.
 
const Modelmodel
 The model to which the block belongs.
 
const BlockType block_type
 Type of this block.
 
const BlockClass block_class
 Class of this block.
 
VesselType vessel_type = VesselType::neither
 Vessel type of this block.
 
const std::vector< std::pair< std::string, InputParameter > > input_params
 Map from name to input parameter.
 
std::vector< Node * > inlet_nodes
 Inlet nodes.
 
std::vector< Node * > outlet_nodes
 Outlet nodes.
 
bool steady = false
 Toggle steady behavior.
 
bool input_params_list = false
 Are input parameters given as a list?
 
std::vector< int > global_param_ids
 Global IDs for the block parameters.
 
std::vector< int > global_var_ids
 Global variable indices of the local element contributions.
 
std::vector< int > global_eqn_ids
 Global equation indices of the local element contributions.
 
TripletsContributions num_triplets
 Number of triplets of element.
 

Static Public Attributes

static const BlockType block_type
 Type of this block.
 
static const BlockClass block_class
 Class of this block.
 
static const std::vector< InputParameterinput_params
 List of input parameter names.
 

Detailed Description

Junction.

Models a junction with arbitrary inlets and outlets. Across all inlets and outlets of the junction, mass is conserved and pressure is continuous.

Inlets and outlets can be specified in two ways. Either using inlet_vessels and outlet_vessels keys in the JSON file, with the corresponding lists specifying vessel IDs, or using inlet_blocks and outlet_blocks keys, with the corresponding lists specifying the names of blocks as strings.

\[
\begin{circuitikz}
\draw node[left] {$Q_{in}$} [-latex] (0,0) -- (0.8,0);
\draw (1,0) node[anchor=south]{$P_{in}$} to [short, *-*] (3.0,0);
\draw (3,0) node[anchor=south]{} to [short, -*] (4.5,1.0);
\draw (4.3,1.1) node[anchor=south] {$P_{out,1}$};
\draw (3,0) node[anchor=south]{} to [short, -*] (4.5,-1.0);
\draw (4.3,-1.1) node[anchor=north] {$P_{out,2}$};
\draw [-latex] (4.65,1.1) -- (5.25,1.5) node[right] {$Q_{out,1}$};
\draw [-latex] (4.65,-1.1) -- (5.25,-1.5) node[right] {$Q_{out,2}$};
\end{circuitikz}
\]

Governing equations

\[
\sum_{i}^{n_{inlets}} Q_{in, i}=\sum_{j}^{n_{outlets}} Q_{out, j}
\]

\[
P_{i}=P_{j} \quad \mathrm{with} \quad i \neq j
\]

Local contributions

\[
\mathbf{y}^{e}=\left[\begin{array}{llllllllll}P_{in, 1}^{e} & Q_{in, 1}^{e} &
\dots & P_{in, i}^{e} & Q_{in, i}^{e} & P_{out, 1}^{e} & Q_{out, 1}^{e} &
\dots & P_{out, i}^{e} & Q_{out, i}^{e}\end{array}\right] \]

Mass conservation

\[
\mathbf{F}^{e}_1 = \left[\begin{array}{llllllllll}0 & 1 & 0 & 1 & \dots & 0 &
-1 & 0 & -1 & \dots\end{array}\right] \]

Due to the pressure continuity, we can write for all independent pressure pairs:

\[ \mathbf{F}^{e}_{2,...,n} = \left[\begin{array}{lllll}\dots &
\underbrace{1}_{P_i} & \dots & \underbrace{1}_{P_j} & \dots\end{array}\right]
\quad \mathrm{with} \quad i \neq j \]

Internal variables

This block has no internal variables.

Constructor & Destructor Documentation

◆ Junction()

Junction::Junction ( int id,
Model * model )
inline

Construct a new Junction object.

Parameters
idGlobal ID of the block
modelThe model to which the block belongs

Member Function Documentation

◆ setup_dofs()

void Junction::setup_dofs ( DOFHandler & dofhandler)
virtual

Set up the degrees of freedom (DOF) of the block.

Set global_var_ids and global_eqn_ids of the element based on the number of equations and the number of internal variables of the element.

Parameters
dofhandlerDegree-of-freedom handler to register variables and equations at

Reimplemented from Block.

◆ update_constant()

void Junction::update_constant ( SparseSystem & system,
std::vector< double > & parameters )
virtual

Update the constant contributions of the element in a sparse system.

Parameters
systemSystem to update contributions at
parametersParameters of the model

Reimplemented from Block.

◆ update_gradient()

void Junction::update_gradient ( Eigen::SparseMatrix< double > & jacobian,
Eigen::Matrix< double, Eigen::Dynamic, 1 > & residual,
Eigen::Matrix< double, Eigen::Dynamic, 1 > & alpha,
std::vector< double > & y,
std::vector< double > & dy )
virtual

Set the gradient of the block contributions with respect to the parameters.

Parameters
jacobianJacobian with respect to the parameters
alphaCurrent parameter vector
residualResidual with respect to the parameters
yCurrent solution
dyTime-derivative of the current solution

Reimplemented from Block.

Member Data Documentation

◆ block_class

const BlockClass Junction::block_class
static

Class of this block.

◆ block_type

const BlockType Junction::block_type
static

Type of this block.

◆ input_params

const std::vector<InputParameter> Junction::input_params
static

List of input parameter names.

◆ num_inlets

int Junction::num_inlets

Number of inlets to the block.

◆ num_outlets

int Junction::num_outlets

Number of outlets from the block.

◆ num_triplets

TripletsContributions Junction::num_triplets {0, 0, 0}

Number of triplets of element.

Number of triplets that the element contributes to the global system (relevant for sparse memory reservation)


The documentation for this class was generated from the following files: