The basic Phase types merely implement mass balances.

The model user should not normally handle low-level objects such as the basic phase types, but rather use them within more complex objects such as stream and reactions.

However you can operate on them as shown in this tutorial.

The simplest things you can do with phases objects are sum them and print them.

Start from the Hello world tutorial, and perform these steps:

  1. in the #include section, include the header file PhaseIdeal:

    #include <libpf/phases/PhaseIdeal.h>
    
  2. in the main function, remove the "Hello, world !" statement and replace it as follows:

  3. define water and nitrogen as components:

    components.addcomp(new purecomps::water);
    components.addcomp(new purecomps::N2);
    
  4. add the actual stream manipulation:

    PhaseIdeal<PhaseType::vapor> feed1;
    PhaseIdeal<PhaseType::vapor> feed2;
    feed2.ndot.set(100.0, "kmol/h");
    feed2.clearcomposition(MassBalanceMode::Nx);
    feed2.x[0].set(1.0);
    
    feed1.calculate();
    diagnostic(0, "The first feed:" << feed1)
    feed2.calculate();
    diagnostic(0, "The second feed:" << feed2)
    
    PhaseIdeal<PhaseType::vapor> product = feed1 + feed2;
    diagnostic(0, "The resulting product:" << product)
    

Note that the composition of feed1 is not specified: it will remain at its default value, i.e. equimolar.

The energy- and volumetric-properties rho, v, h, H, s, S and g for the feeds will not be calculated and stick to their default values because the phase object does only the mass and energy balance and does not compute any property (that is the job of the Stream classes).

The properties (i.e., h, H, s, S and g) for the product will be calculated from those of feed1 and feed2 according to the mass and energy balance.

This is the expected output:

LIBPF is correctly activated for site com.example_1.0 on this computer.
main * Entered
* ****************** LIBPF 01.00.2193 [2015/06/07 15:28:37] ******************
* (C) Copyright 2004-2015 Paolo Greppi simevo s.r.l.
* ****************************************************************************
* All rights reserved; do not distribute without permission.
* ****************************************************************************

main * The first feed:{
  "fullTag": "",
  "type": "PhaseIdeal<vapor>",
  "id": 0,
  "parent": 0,
  "I": {
    "nCalculations": "0"
  },
  "Q": {
    "AMW": "23.0144 kmol^-1 kg",
    "Cp": "232.6 kmol^-1 m^2 kg K^-1 s^-2",
    "H": "1 kmol^-1 m^2 kg s^-2",
    "S": "0 kmol^-1 m^2 kg K^-1 s^-2",
    "cp": "4186.8 m^2 K^-1 s^-2",
    "fraction": "1 ",
    "g": "0 m^2 s^-2",
    "h": "18 m^2 s^-2",
    "mdot": "3.55160493827 kg s^-1",
    "mdotcomps[0]": "1.39006944444 kg s^-1",
    "mdotcomps[1]": "2.16153549383 kg s^-1",
    "ndot": "0.154320987654 kmol s^-1",
    "ndotcomps[0]": "0.0771604938272 kmol s^-1",
    "ndotcomps[1]": "0.0771604938272 kmol s^-1",
    "rho": "1000 m^-3 kg",
    "s": "0 m^2 K^-1 s^-2",
    "v": "0.018 kmol^-1 m^3",
    "vdot": "0.00355160493827 m^3 s^-1",
    "w[0]": "0.391391911151 ",
    "w[1]": "0.608608088849 ",
    "x[0]": "0.5 ",
    "x[1]": "0.5 "
  },
  "SV": {
    "errors": [],
    "warnings": []
  }
}
main * The second feed:{
  "fullTag": "",
  "type": "PhaseIdeal<vapor>",
  "id": 0,
  "parent": 0,
  "I": {
    "nCalculations": "0"
  },
  "Q": {
    "AMW": "18.0153 kmol^-1 kg",
    "Cp": "232.6 kmol^-1 m^2 kg K^-1 s^-2",
    "H": "1 kmol^-1 m^2 kg s^-2",
    "S": "0 kmol^-1 m^2 kg K^-1 s^-2",
    "cp": "4186.8 m^2 K^-1 s^-2",
    "fraction": "1 ",
    "g": "0 m^2 s^-2",
    "h": "18 m^2 s^-2",
    "mdot": "0.500425 kg s^-1",
    "mdotcomps[0]": "0.500425 kg s^-1",
    "mdotcomps[1]": "0 kg s^-1",
    "ndot": "0.0277777777778 kmol s^-1",
    "ndotcomps[0]": "0.0277777777778 kmol s^-1",
    "ndotcomps[1]": "0 kmol s^-1",
    "rho": "1000 m^-3 kg",
    "s": "0 m^2 K^-1 s^-2",
    "v": "0.018 kmol^-1 m^3",
    "vdot": "0.000500425 m^3 s^-1",
    "w[0]": "1 ",
    "w[1]": "0 ",
    "x[0]": "1 ",
    "x[1]": "0 "
  },
  "SV": {
    "errors": [],
    "warnings": []
  }
}
main * The resulting product:{
  "fullTag": "",
  "type": "PhaseIdeal<vapor>",
  "id": 0,
  "parent": 0,
  "I": {
    "nCalculations": "0"
  },
  "Q": {
    "AMW": "22.2518254237 kmol^-1 kg",
    "Cp": "232.6 kmol^-1 m^2 kg K^-1 s^-2",
    "H": "1 kmol^-1 m^2 kg s^-2",
    "S": "0 kmol^-1 m^2 kg K^-1 s^-2",
    "cp": "4186.8 m^2 K^-1 s^-2",
    "fraction": "1 ",
    "g": "0 m^2 s^-2",
    "h": "0.0449401332681 m^2 s^-2",
    "mdot": "4.05202993827 kg s^-1",
    "mdotcomps[0]": "1.89049444444 kg s^-1",
    "mdotcomps[1]": "2.16153549383 kg s^-1",
    "ndot": "0.182098765432 kmol s^-1",
    "ndotcomps[0]": "0.104938271605 kmol s^-1",
    "ndotcomps[1]": "0.0771604938272 kmol s^-1",
    "rho": "1000 m^-3 kg",
    "s": "0 m^2 K^-1 s^-2",
    "v": "0.018 kmol^-1 m^3",
    "vdot": "0.00405202993827 m^3 s^-1",
    "w[0]": "0.466554905379 ",
    "w[1]": "0.533445094621 ",
    "x[0]": "0.576271186441 ",
    "x[1]": "0.423728813559 "
  },
  "SV": {
    "errors": [],
    "warnings": []
  }
}

How to get on

  1. check the phases chapter in the LIBPF™ SDK Classes overview

  2. Proceed to the stream manipulation tutorial