```{r, include = FALSE, eval =F , echo = F}
source("rosmose-local.R", local = knitr::knit_global())
```

# Heat pump superstructure 2 levels{-}

Before anything, we define the supestructure as heat pump and provide a name for the ET. 

```{rosmose}
! OSMOSE SUPERSTRUCTURE HEATPUMP heatpump_ss
```


Low-grade residual heat is produced in practically any existing industrial process that converts high quality energy (e.g. fuels and electricity) into other value-added products. Exothermic reactions and dissipative devices are responsible for producing more or less amount of waste heat. Industry has traditionally regarded this thermal waste as an undesirable side-product of the main production activity and it has devised means to collect and reject the excess low-temperature heat to the environment, provided that internal heat recovery is not further applicable. Clearly, this approach entails larger process inefficiencies and worsened environmental impact. To tackle these issues, waste heat can be upgraded using a specialized equipment called heat pump, whose working principle is similar to that of a refrigeration cycle. 

To this end, heat pumps also use working fluids called refrigerants that can absorb heat by evaporating in a heat exchanger at low temperature in order to supply that heat at a higher temperature (i.e. "pump heat up"). When the evaporated fluids are recompressed, the temperature significantly increase, thus facilitating the heat exchange with other process streams in a condensation heat exchanger. The capacity of these fluids to achieve lower temperatures is due to the Joule-Thomson effect, by which certain fluids exhibit a rapid cooling accompanied by partial vaporization when throttled or expanded through a valve, a capillar tube or an expander. In this regard, a typical heat pump cycle requires different components, namely an evaporator, a compressor, a condenser and an expansion device. The main electricity input is the compressor power consumption, which in turn depends on the isoentropic efficiency and other compressor design details.


```{r, out.width='30%', fig.align='center', fig.cap='Heat pump unit structure', echo = F}
knitr::include_graphics('model/HeatpumpSS/heatpump.svg')
```

Although some transcritical heat pump cycles can be implemented, the minimum evaporator `Evap_Tin` and maximum condenser temperatures `Cond_Tin` are typically limited by the freezing and critical temperatures of the fluid employed. Moreover, since for pure substances in the subcritical two-phase region, both temperature and pressure properties are not independent, the selection of the temperature also fixes the operating pressure. On the one hand, in order to avoid air leakage into the evaporator, the lowest cycle pressure is preferably set slightly above the ambient pressure. On the other hand, the maximum pressure (and temperature) is chosen to enable the heat exchange at high temperatures relevant to the process units. In practice, other structural constraints and fluid properties influence the selection of the refrigerants, as well as the operating conditions and the materials used in the heat pump components. In order to avoid a heat pump misplacement, low-grade waste heat must be only shifted from below to above the pinch: if placed below the pinch, it increases the cooling requirement, and if placed above, it behaves as a simple electricity dissipation device (i.e. no heat pumping beneficial effect).

Other financial parameters are summarized in the following chunk of code, whereas the commentaries provide further details on the meaning and relevance of each term. For each industrial application, some parameters, such as the temperature levels of the heat pump model, should clearly be adapted.


Since a heat pump is a thermal cycle, the actual coefficient of performance (COP) is limited by the theoretical Carnot COP (`= T_{cond}/(T_{cond}-T_{evap})`), which is only a function of the temperatures, and not of the substance. In practice, this ideal COP is virtually impossible to achieve, but it can be approached by reducing the technology inefficiencies. Commercially, the ratio between `COP_{actual}` and `COP_{Carnot}` is around 0.45-0.55, which can be used as an heuristic correction factor to estimate the actual performance. Based on the previous parameters, it is possible to calcualte the total power demand for the reference heat pumping capacity `W_heatpump` and the corresponding evaporation heat absorption `Evap_Qmax`. Finally, the annualization factor can be determined based on the assumed life time of the energy technology and the interest rate adopted to calculate the annualized investment cost.



**Fluid list**

Define the fluids list from which Osmose can choose the fluid during the optimization process. Use one of the following list: R141b, R123, n-Butane, IsoButane, Ammonia, R12, R134a, n-Propane, R22, R1234yf, Propylene, R115, R32, Ethane, CarbonDioxide, R13, Ethylene, Methane.



```{rosmose}
: OSMOSE FLUIDS heatpump_ss

|Fluid        |
|:------------|
|Ethylene     |
|Methane      |
|water        |
```

|R141b        |
|R123         |
|IsoButane    |
|Ammonia      |
|R12          |
|R134a        |
|n-Propane    |
|R1234yf      |
|Propylene    |
|R32          |
|Ethane       |
|CarbonDioxide|
|R13          |
|R245fa       |
|R1233zd(E)   |
|R1234ze(Z)   |
|R365MFC      |

Still debbuging some problematic fluids: n-Butane, R22, R115


**Temperatures table**

Define the temperature related parameters as rows.

Temperatures [C]: Evaporation and condensation temperatures in descending order, as many temperatures as desired

SuperheatDT [C]: Superheating temperature difference corresponding to the temperature level

SupercoolingDT [C]: Supercooling temperature difference corresponding to the temperature level

DT [C]: Minimum temperature difference contribution corresponding to the temperature level


```{rosmose}
: OSMOSE TEMPERATURES heatpump_ss

|Parameter    |T1   |T2   |Unit |Comment                                  |
|:------------|:----|:----|:----|:----------------------------------------|
|Temperatures |70   |30   | C   |Evaporation and condensation temperatures|
|SuperheatDT  |2    |2    | C   |Superheating temperature difference      |
|SubcoolingDT |2    |2    | C   |Minimum temperature difference contrib   |
|CompressorDT |2    |2    | C   |Superheating temperature difference      |
|DT           |2    |2    | C   |Minimum temperature difference (dTmin/2) |
|MixForceUse  |1    |0    | -   |Sensible heat contained                  |
```


**Layer type and supercriticality**

Define the layer of electricity and the possibility to have supercritical fluid states.

```{rosmose}
: OSMOSE LAYER heatpump_ss

|Balance_type     |LayerOfElec  |Supercritical|
|:----------------|:------------|:------------|
|ResourceBalance  |ELEC         | no          |
```



**Parameters of the Compressors**

Define the sizing and economic parameters of the compressor (Inv2 is REQUIRED, all the other three are OPTIONAL).

Fmin: Minimum load factor [-]

Fmax: Maximum load factor [-]

Inv1: Fixed cost coefficient [Eur/y]

Inv2: Variable cost coefficient [Eur/kW/y]


```{rosmose}
: OSMOSE COMPRESSORS_PARAMS1 heatpump_ss

|Fmin |Fmax |Inv1  |Inv2  |
|:----|:----|:-----|:-----|
|0    |100  |0     |300   |
```

The following parameters can be set by default or changed by experts to help convergence (OPTIONAL).

Define the quantity of compressors allowed per fluid, per model and per cluster. Define the efficiency of the compressor. Define the following bounds:

- size: min and max size of compressor [kW], note the difference with the Fmin/Fmax, as this defines the bounds of compressor for design

- pressure: min and max pressure levels [bar]

- ratio: min and max pressure ratio [-]


```{rosmose}
: OSMOSE COMPRESSORS_QUANTITY heatpump_ss

|Per_fluid |Per_model |Per_cluster |
|:---------|:---------|:-----------|
|4         |4         |4           |
```

```{rosmose}
: OSMOSE COMPRESSORS_EFFICIENCY heatpump_ss

|Efficiency|
|:---------|
|0.8       |
```

```{rosmose}
: OSMOSE COMPRESSORS_SIZING heatpump_ss

|Param   |Min     |Max     |Unit| Comment          |
|:-------|:-------|:-------|:---|:-----------------|
|size    | 7      |500     |kW	|Compressor size   |
|pressure| 0.5    | 20     |bar |Range cost linear |
|ratio   | 1.2    | 7      |-   |Pressure ratio    |
```


```{rosmose}
! OSMOSE COMPRESSORS_SELECTION heatpump_ss

select >> 0 [-] # Activate selection
linearize >> {10,100} [kW] # Linearize cost between this range
f_corr >> 1 [-] # Cost corr factor
ctype >> {1,2,5} [-] # Type of compressor: {1-liquid_ring, 2-mono_screw, 3-twin_screw, 4-scroll, 5-vane, 6-lobe, 7-centrifugal, 8-axial, 9-crankshaft, 10-barrel, 11-diaphragm, 12-gas_lub}
mstages >> 0 [-] # Apply max number of stages per casing: 1-yes, 0-no
```



**Parameters of the Heat Exchangers**

Define the sizing and economic parameters of the heat exchangers (OPTIONAL)

Fmin: Minimum load factor [-]

Fmax: Maximum load factor [-]

Inv1: Fixed cost coefficient [Eur/y]

Inv2: Variable cost coefficient [Eur/kW/y]



```{rosmose}
: OSMOSE HEX_PARAMS1 heatpump_ss

|Component  |Fmin  |Fmax  |Inv1  |Inv2  |
|:----------|:-----|:-----|:-----|:-----|
|Evaporator |0     |100   |     0|     0|
|Condenser  |0     |100   |     0|     0|
```



The following parameters can be set by default or changed by experts to help convergence (OPTIONAL)

The area of the evaporator and condenser can be estimated as: cost = a * Area ^ b (used only to avoid too many small HEX units, not used in costing as Inv1 and Inv2), with area of the evaporator or condenser in [m2]

```{rosmose}
: OSMOSE HEX_PARAMS2 heatpump_ss

|Param    |Value   |Unit   | Comment                                                  |
|:--------|:-------|:------|:---------------------------------------------------------|
|U        | 1      | W/m2K | Heat transfer coefficient                                |
|dT       | 10     | K     | Minimum temperature difference                           |
|a        | 500    | Euro  | Cost multiplication coefficient                          |
|b        | 0.8    | -     | Cost power coefficient                                   |
|Min      | 100    | kW    | Minimum size of heat exchangers                          |
|Max      | 1000   | kW    | Maximum size of heat exchangers                          |
|force    | 0      | -     | Binary {0,1} to force the sizing of HEX                  |
|DSH      | 0.2    | -     | Percent use of desuperheating % of a condensation level  |
```



**Parameters of the Valves**

Define the bounds of the valves pressure drop, dp: differential pressure [bard] (OPTIONAL)

Min: Minimum absolute pressure drop (different from Fmin concept) [bard]

Max: Maximum absolute pressure drop (different from Fmax concept) [bard]

```{rosmose}
: OSMOSE VALVES_PARAMS heatpump_ss

|Min  |Max  |Unit |Comment              |
|:----|:----|:----|:--------------------|
|0.5  |20   |bard |differential pressure|
```


**Parameters of the Vessels**

Define the maximum and maximum multiplication factors of vessel units (OPTIONAL).

Fmin [-]: Minimum load factor

Fmax [-]: Maximum load factor

```{rosmose}
: OSMOSE VESSELS_PARAMS heatpump_ss

|Vessel |Fmin    |Fmax    |Comment      |
|:------|:-------|:-------|:------------|
|FlaD   |0       |100     |Flash Drum   |
|MixS   |0       |100     |Mix separator|
|DSHQ   |0       |100     |Desuperheater|
```



**References**

[1] Arpagaus, C., Bless, F., Uhlmann, M., Schiffmann, J., Bertsch, S. (2018). "High temperature heat pumps: Market overview, state of the art, research status, refrigerants, and application potentials." Energy 152: 985-1010.

[2] Florez-orrego et al, 2023, Techno-economic and environmental analysis of high temperature heat pumps integration into industrial processes: the ammonia plant and pulp mill cases, Sustainable Energy Technologies and Assessments
Volume 60, December 2023, 103560