# spc_blackbox_mem_solvent Subroutine

## public subroutine spc_blackbox_mem_solvent(me, state, bcBuffer, globBC, levelDesc, tree, nSize, iLevel, sim_time, neigh, layout, fieldProp, varPos, nScalars, varSys, derVarPos, physics, iField, mixture)

This routine computes mole diffusion flux of the solvent at the membrance using black box model and then mass density at the membrane boundary from mole diffusion flux. Then equilibrium is set at the boundary which is computed from mass density and velocity

Black box model: \n - for solvent mole diffusion flux: $J^m_s (x^m,t) = \frac{t^m_s(x^m,t)}{F} i^m(x^m,t) + LW(IS^l(x^m,t)-IS^r(x^m,t))$

$J^m_s$ - mole diffusion flux of solvent through the membrane $t^m_k$ - transference number of solvent on the membrane (selective membrane property) $F$ - Faraday constant $LW$ - osmotic solvent transport coefficient $IS^l$ and $IS^r$ are ionic strength of electrolyte solution at the left and right side of membrance $IS^l(x^m,t)=\frac{1}{2}\sum^n_{k=1} z^2_k c^m_k(x^m,t)$ $c^m_k = \rho^m_k/m_k$ - molar concentration $i^m(x^m,t) = n^l_x_1 \cdot i^l(x,t) = - n^r_x_1 \cdot i^r(x,t)$ - orthogonal projection of the current density at the left $i^l$ and right $i^r$ side of the membrance. The normal vectors $n^l_1$ and $n^r_1$ point into the membrane surface $i(x,t) = F \sum_{j=1}^{n} z_j J^e_j(x,t)$ - local current density [A/m^3] $J^e_k = c^e_k(v^e_k - v)$ - mole diffusion flux of ion in the electrolyte In black box model: mixture averaged velocity at the membrane is assumed to be zero

This subroutine's interface must match the abstract interface definition boundaryRoutine in bc/mus_bc_header_module.f90 in order to be callable via fnct function pointer.

### Arguments

TypeIntentOptionalAttributesName
class(boundary_type) :: me

global boundary type

real(kind=rk), intent(inout) :: state(:)

Current state vector of iLevel

real(kind=rk), intent(in) :: bcBuffer(:)

state values of boundary elements of all fields of iLevel

type(glob_boundary_type), intent(in) :: globBC

scheme global boundary type

type(tem_levelDesc_type), intent(in) :: levelDesc

iLevel descriptor

type(treelmesh_type), intent(in) :: tree

Treelm Mesh

integer, intent(in) :: nSize

size of state array ( in terms of elements )

integer, intent(in) :: iLevel

the level On which this boundary was invoked

type(tem_time_type), intent(in) :: sim_time

global time information

integer, intent(in) :: neigh(:)

connectivity array corresponding to state vector

type(mus_scheme_layout_type), intent(in) :: layout

stencil layout information

type(mus_field_prop_type), intent(in) :: fieldProp

fluid parameters and properties

integer, intent(in) :: varPos(:)

pointer to field variable in the state vector

integer, intent(in) :: nScalars

number of Scalars in the scheme var system

type(tem_varSys_type), intent(in) :: varSys

scheme variable system

type(mus_derVarPos_type), intent(in) :: derVarPos

position of derived quantities in varsys

type(mus_physics_type), intent(in) :: physics

scheme global boundary type

integer, intent(in) :: iField

current field

type(mus_mixture_type), intent(in) :: mixture

mixture info

## Variables

TypeVisibilityAttributesNameInitial
real(kind=rk), private :: fTmp_all(layout%fStencil%QQ*varSys%nStateVars)
real(kind=rk), private :: mass_dens(varSys%nStateVars)
real(kind=rk), private :: num_dens(varSys%nStateVars)
integer, private :: iElem
integer, private :: iDir
integer, private :: iFieldLoc
integer, private :: nFields
integer, private :: pos
integer, private :: bndNormalDir
integer, private :: QQ
real(kind=rk), private :: molWeight(varSys%nStateVars)
real(kind=rk), private :: chargeNr(varSys%nStateVars)
real(kind=rk), private, dimension(3, varSys%nStateVars):: molar_flux
real(kind=rk), private, dimension(3, varSys%nStateVars):: vel
real(kind=rk), private, dimension(3, varSys%nStateVars):: momentum
real(kind=rk), private :: loc_curr_dens(3)
real(kind=rk), private :: mem_curr_dens
real(kind=rk), private :: mem_molar_flux
real(kind=rk), private :: molefrac(3)
real(kind=rk), private :: mem_mass_flux
real(kind=rk), private :: elec_mass_flux(3)
real(kind=rk), private :: tot_NumDens
real(kind=rk), private :: tot_MassDens
real(kind=rk), private :: first_moments(3,varSys%nStateVars)
real(kind=rk), private :: molWeightInv(varSys%nStateVars)
real(kind=rk), private :: phi(varSys%nStateVars)
real(kind=rk), private :: resi_coeff(varSys%nStateVars,varSys%nStateVars)
real(kind=rk), private :: paramBInv
real(kind=rk), private :: omega_fac
type(mus_varSys_data_type), private, pointer:: fPtr
integer, private :: posInBuffer
integer, private :: posInState