# Slicing global last_state_vector_y in CADET corresponding to each unit operation

I am trying to understand how the global_last_state_vector_y is defined and stored in CADET, in order to slice the “last_state” vector corresponding to each unit operation.
According to CADET documentation, the length of LAST_STATE_Y is equal to NDOF (number of degrees of freedom)/2NDOF and NDOF is defined as follows:
NDOF = Column bulk DOFs: nCol * nComp + Particle DOFs: nCol * nParType particles each having nComp (liquid phase) + sum boundStates (solid phase) DOFs in each shell; there are nParCell shells for each particle type + Flux DOFs: nCol * nComp * nParType (as many as column bulk DOFs) + Inlet DOFs: nComp
So, for example if I have a single component system, which is modelled with 75 axial (NCOL) and 20 radial (nParType) cells, then using the above formula results in NDOF = 3151 but when I checked the length of LAST_STATE_Y in CADET output file then it was equal to 3155. It means there are 4 extra terms, then I further looked into the source code and in ModelSymtemImpl.cpp a following function related to calculation of NDOF is defined as:

unsigned int ModelSystem::numDofs() const CADET_NOEXCEPT
{
return _dofOffset.back() + numCouplingDOF();
}


One of the term in the return argument of this function is numCouplingDOF() and I am not sure what information this term carries and maybe these are the missing 4 terms I am not able to calculate. Can anyone please help me out in understanding how these terms are stored in the global last_state vector so that I can identify them for each unit operation?

Dear Jazib,

There are generally two levels to consider here: System level and unit operation level.

The system state vector (global state vector) consists of the individual state vector slices of its unit operations. At the end, we have additional DOFs that are used to connect the unit operations with each other. The number of connection DOFs is given by

\sum_{k=1}^{n_{\mathrm{units}}} n_{\mathrm{inlet\, ports}, k} \, n_{\mathrm{comp}, k}.

The state vector slice of each unit operation starts with dedicated inlet DOFs that are used to receive the inlet signal from the model system. The inlet data is then mapped to the actual inlet of the unit. The remaining structure of the unit slice is determined by the unit operation. The system does not need to know how this structure looks like. It only needs to know where the outlet DOFs are located.

The inlet DOFs are overwritten during consistent initialization of the model system. Thus, it may suffice to save only the actual state vector slice (i.e., the black part on the right side in the picture).

The ModelSystem class conveniently holds offsets to the beginning of the slices in the global state vector: _dofOffset contains the required offsets and, at the end, an additional offset to the beginning of the connection DOFs. The size of the inlet DOFs of unit k is given by

n_{\mathrm{inlet\, ports}, k} \, n_{\mathrm{comp}, k}.
1 Like