## Pressure Model

### Pressure Calculation and Assumptions

The `PressureModel`

class in the provided Python code is responsible for estimating and updating the pressures involved in Tangential Flow Filtration (TFF) based on the current pump flow rates and pinch valve position. This section explains the calculation and assumptions made in the pressure modeling process.

### Pressure Estimation

The class includes several methods to calculate the pressures at different stages of the TFF process, namely P1 (feed pressure), P2 (retentate pressure), and P3 (permeate pressure). These calculations consider the flow rates, pinch valve position, and pressure drops between different sections of the TFF system.

`calc_delta_p_feed_retentate(R1)`

This method calculates the pressure drop between the feed and retentate using the flow rate (R1) in the pass-through leg of the TFF filter. The calculation assumes a relationship where the pressure drop is inversely proportional to the square of the Cv value of the retentate leg of the TFF filter.

The equation is given by:

```
ΔP_feed_retentate = 1 / ((Cv * 0.865 / R1)^2)
```

where ΔP_feed_retentate is the pressure drop between feed and retentate, Cv is the Cv value of the retentate leg of the TFF filter.

`calc_pv_cv(PV)`

This method calculates the Cv (flow coefficient) of the pinch valve based on its position (PV). The calculation uses a non-linear expression that decreases as the pinch valve position increases, following a relationship of (percent open)^-2 with an onset position of 0.3 (30%).

The equation is given by:

```
Cv =
if PV < 0.3 {
100 - (1 / (PV^2))
} else {
100
}
```

where Cv is the Cv of the pinch valve, and PV is the pinch valve position.

`calc_delta_p_retentate(R1, PV)`

This method calculates the pressure drop between the retentate and permeate based on the flow rate (R1) and pinch valve position (PV). The calculation assumes a relationship similar to `calc_delta_p_feed_retentate()`

, where the pressure drop is inversely proportional to the square of the Cv value obtained from `calc_pv_cv()`

.

The equation is given by:

```
ΔP_retentate_permeate = 1 / ((Cv * 0.865 / R1)^2)
```

where ΔP_retentate_permeate is the pressure drop between retentate and permeate, Cv is the Cv of the pinch valve obtained from `calc_pv_cv()`

, and R1 is the flow rate in the pass-through leg of the TFF filter.

`calc_p1(R1, PV, P2)`

This method calculates the P1 pressure based on the flow rate (R1), pinch valve position (PV), and the P2 pressure. The calculation adds the pressure drop obtained from `calc_delta_p_retentate()`

to the P2 pressure.

The equation is given by:

```
P1 = P2 + ΔP_retentate_permeate
```

where P1 is the feed pressure, P2 is the retentate pressure, and ΔP_retentate_permeate is the pressure drop between retentate and permeate.

#### Pressure Update

The `calc_pressures()`

method is responsible for updating the pressures in the TFF system using the model equations. It calls the aforementioned methods to calculate P1, P2, and P3 based on the available data (flow rates, pinch valve position) and limits the pressures to a maximum value of 50.

The updated pressures are then set as simulated values for the corresponding devices in the Aqueduct system, ensuring that the simulated TFF process reflects the calculated pressures.

It's important to note that the provided code represents a simplified model for estimating the pressures in the TFF process. The calculations and assumptions made in the model may not capture all the intricacies of the real TFF system and should be further refined and validated based on the specific requirements and characteristics of the actual TFF process.