The PPP MixF routine has two shortcomings in my opinion. First, the mixed stream replaces one of the input streams. Thus, the routine can't be used directly to simulate a mixing tee. Second, it can't mix more than two streams at a time. Thus, it can't simulate a header with multiple input streams.
The MixF routine also continues with the "reverse" order for streams, a feature discussed in the previous post. In MixF, the first stream listed for mixing becomes the outlet stream. The second stream listed is another inlet stream. So the order in MixF is (in/out,in). I prefer (in,out).
The routine below fixes those shortcomings and preferences.
The following image shows how the mix function is used. The streams to be mixed may be specified directly in the argument list, or by using a named vector of the stream numbers.
This routine can accommodate as many inlet streams as needed, and they are retained in the archive, along with the new outlet stream (70 in the example above). It may look like the mixed temperature is the only result. However, the mixed stream is also created in the PPP archive.
A good feature about the PPP MixF routine
The mix routine in PPP mixes based on component identification, not position in the stream vector. Thus, a stream in the PPP archive can be initialized with just the components needed if desired and they can be in any order. The MixF routine starts with the component list for the first stream (it appears to me) and then adds new components from the second stream to the bottom of the list in the new, mixed stream. My mix routine retains this feature because it uses the PPP MixF routine as its core function.