Proportion of a compartment's mass which originates from another compartment System & Objective
I have the following open system (mass flow) with 2 compartments $A$ and $B$ and constant flow rates $a,b,\alpha,\beta,\gamma,\delta$.


I would like an expression for "the proportion of $A(t)$ at time $t$ which originated from $B(t)$", denoted $A_B(t)$.

We can assume originally no mass in $A$ came from $B$ -- i.e. $A_B(t=0) = 0$.
Approach
I assume the proportion could be expressed as a fraction,
$$ A_B(t) = \frac{N(t)}{D(t)} $$
where the denominator is simply the current mass in $A$, $D(t) = A(t)$; and the numerator $N(t)$ is the absolute mass currently in $A$ which originated from $B$.
I'm struggling to derive an expression for $N(t)$.
I defined the cumulative mass which enters $A$ from $B$ as
$$ T_{A_B}(t) = \int_{0}^{t} b B(\tau) d\tau $$
but we also need an expression for the cumulative mass which exits $A$ after entering from $B$, denoted $E_{A_B}(t)$. I would then define $N(t) = T_{A_B}(t) - E_{A_B}(t)$.
I had three approaches to defining $E_{A_B}(t)$... is any correct?
Cumulative Exit Attempt 1:
\begin{equation}
\begin{aligned}
E_{A_B}(t) &= \int_{0}^{t} (\alpha + a) T_{A_B}(\tau) d\tau \\
&= \int_{0}^{t} (\alpha + a) \left(\int_{0}^{\tau} b B(s) ds \right) d\tau
\end{aligned}
\end{equation}
But this double integral seems wrong and would blow up for large $t$.
Cumulative Exit Attempt 2:
\begin{equation}
E_{A_B}(t) = \int_{0}^{t} (\alpha + a) b B(\tau) d\tau
\end{equation}
But this doesn't seem right either, as the exit only depends on the current value of $B(t)$.
Cumulative Exit Attempt 3:
\begin{equation}
E_{A_B}(t) = \int_{0}^{t} (\alpha + a) A(\tau) A_B(\tau) d\tau
\end{equation}
But this would result in recursive definition of $A_B(t)$, and I'm not sure how I could rearrange to isolate $A_B(t)$ from the the LHS and the RHS integral.

Overall, is this a reasonable approach? Any ideas how to derive either $E_{A_B}(t)$, or $A_B(t)$ by another approach altogether? I feel like I should be using Laplace.
Thanks,
 A: I'm unsure if my answer does what you want, but the way I see it, we can write the total amount $N(t) = A_B(t) \cdot A(t)$ as a differential equation:
$$
\dot{N}(t) = b B(t) - (a + \alpha) N(t)
$$
This corresponds to your case 3.
We will also need the differential equation for $A(t)$:
$$
\dot{A}(t) = b B(t) + \gamma - (a + \alpha) A(t)
$$
Hence, to have $A_B(t)$ we would need to compute the quotient between these two quantities:
$$
A_B(t) = \frac{N(t)}{A(t)}
$$
Note that, in order for the system to be complete, you will also need the differential equation for $B(t)$
$$
\dot{B}(t) = a A(t) + \delta - (b + \beta) B(t) 
$$
A: There are just a couple of remarks to the @Ertxiem's answer, which I believe is correct.


*

*We implicitely assume that any particle that enters the compartment $B$ immediately acquires the property to be of type $B$. Otherwise, we would need to trace particles from $A$ and $B$ separately and sort out the situations when a particle $x$ leaves $A$, enters $B$ and then reenters $A$ and so on...

*You can simplify the computations if you subtract the DE for $N$ from the DE for $A$ to get 
$$\frac{d}{dt}(A-N)=\gamma-(a+\alpha)(A-N),$$
with the initial condition $A(0)-A_B(0)$. This DE can be solved independently of others.

